babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /** Defines that the ressource is not delayed*/
  4092. static readonly DELAYLOADSTATE_NONE: number;
  4093. /** Defines that the ressource was successfully delay loaded */
  4094. static readonly DELAYLOADSTATE_LOADED: number;
  4095. /** Defines that the ressource is currently delay loading */
  4096. static readonly DELAYLOADSTATE_LOADING: number;
  4097. /** Defines that the ressource is delayed and has not started loading */
  4098. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4100. static readonly NEVER: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4102. static readonly ALWAYS: number;
  4103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4104. static readonly LESS: number;
  4105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4106. static readonly EQUAL: number;
  4107. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4108. static readonly LEQUAL: number;
  4109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4110. static readonly GREATER: number;
  4111. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4112. static readonly GEQUAL: number;
  4113. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4114. static readonly NOTEQUAL: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be kept */
  4116. static readonly KEEP: number;
  4117. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4118. static readonly REPLACE: number;
  4119. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4120. static readonly INCR: number;
  4121. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4122. static readonly DECR: number;
  4123. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4124. static readonly INVERT: number;
  4125. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4126. static readonly INCR_WRAP: number;
  4127. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4128. static readonly DECR_WRAP: number;
  4129. /** Texture is not repeating outside of 0..1 UVs */
  4130. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4131. /** Texture is repeating outside of 0..1 UVs */
  4132. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4133. /** Texture is repeating and mirrored */
  4134. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4135. /** ALPHA */
  4136. static readonly TEXTUREFORMAT_ALPHA: number;
  4137. /** LUMINANCE */
  4138. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4139. /** LUMINANCE_ALPHA */
  4140. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4141. /** RGB */
  4142. static readonly TEXTUREFORMAT_RGB: number;
  4143. /** RGBA */
  4144. static readonly TEXTUREFORMAT_RGBA: number;
  4145. /** RED */
  4146. static readonly TEXTUREFORMAT_RED: number;
  4147. /** RED (2nd reference) */
  4148. static readonly TEXTUREFORMAT_R: number;
  4149. /** RG */
  4150. static readonly TEXTUREFORMAT_RG: number;
  4151. /** RED_INTEGER */
  4152. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4153. /** RED_INTEGER (2nd reference) */
  4154. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4155. /** RG_INTEGER */
  4156. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4157. /** RGB_INTEGER */
  4158. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4159. /** RGBA_INTEGER */
  4160. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4161. /** UNSIGNED_BYTE */
  4162. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4163. /** UNSIGNED_BYTE (2nd reference) */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4165. /** FLOAT */
  4166. static readonly TEXTURETYPE_FLOAT: number;
  4167. /** HALF_FLOAT */
  4168. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4169. /** BYTE */
  4170. static readonly TEXTURETYPE_BYTE: number;
  4171. /** SHORT */
  4172. static readonly TEXTURETYPE_SHORT: number;
  4173. /** UNSIGNED_SHORT */
  4174. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4175. /** INT */
  4176. static readonly TEXTURETYPE_INT: number;
  4177. /** UNSIGNED_INT */
  4178. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4179. /** UNSIGNED_SHORT_4_4_4_4 */
  4180. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4181. /** UNSIGNED_SHORT_5_5_5_1 */
  4182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4183. /** UNSIGNED_SHORT_5_6_5 */
  4184. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4185. /** UNSIGNED_INT_2_10_10_10_REV */
  4186. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4187. /** UNSIGNED_INT_24_8 */
  4188. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4189. /** UNSIGNED_INT_10F_11F_11F_REV */
  4190. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4191. /** UNSIGNED_INT_5_9_9_9_REV */
  4192. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4193. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4194. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4195. /** nearest is mag = nearest and min = nearest and mip = linear */
  4196. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4198. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4199. /** Trilinear is mag = linear and min = linear and mip = linear */
  4200. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4201. /** nearest is mag = nearest and min = nearest and mip = linear */
  4202. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4204. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4205. /** Trilinear is mag = linear and min = linear and mip = linear */
  4206. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4207. /** mag = nearest and min = nearest and mip = nearest */
  4208. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4209. /** mag = nearest and min = linear and mip = nearest */
  4210. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4211. /** mag = nearest and min = linear and mip = linear */
  4212. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4213. /** mag = nearest and min = linear and mip = none */
  4214. static readonly TEXTURE_NEAREST_LINEAR: number;
  4215. /** mag = nearest and min = nearest and mip = none */
  4216. static readonly TEXTURE_NEAREST_NEAREST: number;
  4217. /** mag = linear and min = nearest and mip = nearest */
  4218. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4219. /** mag = linear and min = nearest and mip = linear */
  4220. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4221. /** mag = linear and min = linear and mip = none */
  4222. static readonly TEXTURE_LINEAR_LINEAR: number;
  4223. /** mag = linear and min = nearest and mip = none */
  4224. static readonly TEXTURE_LINEAR_NEAREST: number;
  4225. /** Explicit coordinates mode */
  4226. static readonly TEXTURE_EXPLICIT_MODE: number;
  4227. /** Spherical coordinates mode */
  4228. static readonly TEXTURE_SPHERICAL_MODE: number;
  4229. /** Planar coordinates mode */
  4230. static readonly TEXTURE_PLANAR_MODE: number;
  4231. /** Cubic coordinates mode */
  4232. static readonly TEXTURE_CUBIC_MODE: number;
  4233. /** Projection coordinates mode */
  4234. static readonly TEXTURE_PROJECTION_MODE: number;
  4235. /** Skybox coordinates mode */
  4236. static readonly TEXTURE_SKYBOX_MODE: number;
  4237. /** Inverse Cubic coordinates mode */
  4238. static readonly TEXTURE_INVCUBIC_MODE: number;
  4239. /** Equirectangular coordinates mode */
  4240. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4241. /** Equirectangular Fixed coordinates mode */
  4242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4243. /** Equirectangular Fixed Mirrored coordinates mode */
  4244. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4245. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4246. static readonly SCALEMODE_FLOOR: number;
  4247. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4248. static readonly SCALEMODE_NEAREST: number;
  4249. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4250. static readonly SCALEMODE_CEILING: number;
  4251. /**
  4252. * The dirty texture flag value
  4253. */
  4254. static readonly MATERIAL_TextureDirtyFlag: number;
  4255. /**
  4256. * The dirty light flag value
  4257. */
  4258. static readonly MATERIAL_LightDirtyFlag: number;
  4259. /**
  4260. * The dirty fresnel flag value
  4261. */
  4262. static readonly MATERIAL_FresnelDirtyFlag: number;
  4263. /**
  4264. * The dirty attribute flag value
  4265. */
  4266. static readonly MATERIAL_AttributesDirtyFlag: number;
  4267. /**
  4268. * The dirty misc flag value
  4269. */
  4270. static readonly MATERIAL_MiscDirtyFlag: number;
  4271. /**
  4272. * The all dirty flag value
  4273. */
  4274. static readonly MATERIAL_AllDirtyFlag: number;
  4275. /**
  4276. * Returns the triangle fill mode
  4277. */
  4278. static readonly MATERIAL_TriangleFillMode: number;
  4279. /**
  4280. * Returns the wireframe mode
  4281. */
  4282. static readonly MATERIAL_WireFrameFillMode: number;
  4283. /**
  4284. * Returns the point fill mode
  4285. */
  4286. static readonly MATERIAL_PointFillMode: number;
  4287. /**
  4288. * Returns the point list draw mode
  4289. */
  4290. static readonly MATERIAL_PointListDrawMode: number;
  4291. /**
  4292. * Returns the line list draw mode
  4293. */
  4294. static readonly MATERIAL_LineListDrawMode: number;
  4295. /**
  4296. * Returns the line loop draw mode
  4297. */
  4298. static readonly MATERIAL_LineLoopDrawMode: number;
  4299. /**
  4300. * Returns the line strip draw mode
  4301. */
  4302. static readonly MATERIAL_LineStripDrawMode: number;
  4303. /**
  4304. * Returns the triangle strip draw mode
  4305. */
  4306. static readonly MATERIAL_TriangleStripDrawMode: number;
  4307. /**
  4308. * Returns the triangle fan draw mode
  4309. */
  4310. static readonly MATERIAL_TriangleFanDrawMode: number;
  4311. /**
  4312. * Stores the clock-wise side orientation
  4313. */
  4314. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4315. /**
  4316. * Stores the counter clock-wise side orientation
  4317. */
  4318. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4319. /**
  4320. * Nothing
  4321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4322. */
  4323. static readonly ACTION_NothingTrigger: number;
  4324. /**
  4325. * On pick
  4326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4327. */
  4328. static readonly ACTION_OnPickTrigger: number;
  4329. /**
  4330. * On left pick
  4331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4332. */
  4333. static readonly ACTION_OnLeftPickTrigger: number;
  4334. /**
  4335. * On right pick
  4336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4337. */
  4338. static readonly ACTION_OnRightPickTrigger: number;
  4339. /**
  4340. * On center pick
  4341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4342. */
  4343. static readonly ACTION_OnCenterPickTrigger: number;
  4344. /**
  4345. * On pick down
  4346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4347. */
  4348. static readonly ACTION_OnPickDownTrigger: number;
  4349. /**
  4350. * On double pick
  4351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4352. */
  4353. static readonly ACTION_OnDoublePickTrigger: number;
  4354. /**
  4355. * On pick up
  4356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4357. */
  4358. static readonly ACTION_OnPickUpTrigger: number;
  4359. /**
  4360. * On pick out.
  4361. * This trigger will only be raised if you also declared a OnPickDown
  4362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4363. */
  4364. static readonly ACTION_OnPickOutTrigger: number;
  4365. /**
  4366. * On long press
  4367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4368. */
  4369. static readonly ACTION_OnLongPressTrigger: number;
  4370. /**
  4371. * On pointer over
  4372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4373. */
  4374. static readonly ACTION_OnPointerOverTrigger: number;
  4375. /**
  4376. * On pointer out
  4377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4378. */
  4379. static readonly ACTION_OnPointerOutTrigger: number;
  4380. /**
  4381. * On every frame
  4382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4383. */
  4384. static readonly ACTION_OnEveryFrameTrigger: number;
  4385. /**
  4386. * On intersection enter
  4387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4388. */
  4389. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4390. /**
  4391. * On intersection exit
  4392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4393. */
  4394. static readonly ACTION_OnIntersectionExitTrigger: number;
  4395. /**
  4396. * On key down
  4397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4398. */
  4399. static readonly ACTION_OnKeyDownTrigger: number;
  4400. /**
  4401. * On key up
  4402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4403. */
  4404. static readonly ACTION_OnKeyUpTrigger: number;
  4405. /**
  4406. * Billboard mode will only apply to Y axis
  4407. */
  4408. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4409. /**
  4410. * Billboard mode will apply to all axes
  4411. */
  4412. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4413. /**
  4414. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4415. */
  4416. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4417. /**
  4418. * Gets or sets base Assets URL
  4419. */
  4420. static PARTICLES_BaseAssetsUrl: string;
  4421. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4422. * Test order :
  4423. * Is the bounding sphere outside the frustum ?
  4424. * If not, are the bounding box vertices outside the frustum ?
  4425. * It not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4428. /** Culling strategy : Bounding Sphere Only.
  4429. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4430. * It's also less accurate than the standard because some not visible objects can still be selected.
  4431. * Test : is the bounding sphere outside the frustum ?
  4432. * If not, then the cullable object is in the frustum.
  4433. */
  4434. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4435. /** Culling strategy : Optimistic Inclusion.
  4436. * This in an inclusion test first, then the standard exclusion test.
  4437. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4438. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4439. * Anyway, it's as accurate as the standard strategy.
  4440. * Test :
  4441. * Is the cullable object bounding sphere center in the frustum ?
  4442. * If not, apply the default culling strategy.
  4443. */
  4444. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4445. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4446. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4447. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4448. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4449. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4450. * Test :
  4451. * Is the cullable object bounding sphere center in the frustum ?
  4452. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4453. */
  4454. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4455. /**
  4456. * No logging while loading
  4457. */
  4458. static readonly SCENELOADER_NO_LOGGING: number;
  4459. /**
  4460. * Minimal logging while loading
  4461. */
  4462. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4463. /**
  4464. * Summary logging while loading
  4465. */
  4466. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4467. /**
  4468. * Detailled logging while loading
  4469. */
  4470. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4471. }
  4472. }
  4473. declare module "babylonjs/Engines/IPipelineContext" {
  4474. /**
  4475. * Class used to store and describe the pipeline context associated with an effect
  4476. */
  4477. export interface IPipelineContext {
  4478. /**
  4479. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4480. */
  4481. isAsync: boolean;
  4482. /**
  4483. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4484. */
  4485. isReady: boolean;
  4486. /** @hidden */
  4487. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4488. }
  4489. }
  4490. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4491. /** @hidden */
  4492. export interface IShaderProcessor {
  4493. attributeProcessor?: (attribute: string) => string;
  4494. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4495. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4496. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4497. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4498. lineProcessor?: (line: string, isFragment: boolean) => string;
  4499. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4500. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4501. }
  4502. }
  4503. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4504. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4505. /** @hidden */
  4506. export interface ProcessingOptions {
  4507. defines: string[];
  4508. indexParameters: any;
  4509. isFragment: boolean;
  4510. shouldUseHighPrecisionShader: boolean;
  4511. supportsUniformBuffers: boolean;
  4512. shadersRepository: string;
  4513. includesShadersStore: {
  4514. [key: string]: string;
  4515. };
  4516. processor?: IShaderProcessor;
  4517. version: string;
  4518. platformName: string;
  4519. lookForClosingBracketForUniformBuffer?: boolean;
  4520. }
  4521. }
  4522. declare module "babylonjs/Misc/stringTools" {
  4523. /**
  4524. * Helper to manipulate strings
  4525. */
  4526. export class StringTools {
  4527. /**
  4528. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static EndsWith(str: string, suffix: string): boolean;
  4534. /**
  4535. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4536. * @param str Source string
  4537. * @param suffix Suffix to search for in the source string
  4538. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4539. */
  4540. static StartsWith(str: string, suffix: string): boolean;
  4541. }
  4542. }
  4543. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4544. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4545. /** @hidden */
  4546. export class ShaderCodeNode {
  4547. line: string;
  4548. children: ShaderCodeNode[];
  4549. additionalDefineKey?: string;
  4550. additionalDefineValue?: string;
  4551. isValid(preprocessors: {
  4552. [key: string]: string;
  4553. }): boolean;
  4554. process(preprocessors: {
  4555. [key: string]: string;
  4556. }, options: ProcessingOptions): string;
  4557. }
  4558. }
  4559. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4560. /** @hidden */
  4561. export class ShaderCodeCursor {
  4562. private _lines;
  4563. lineIndex: number;
  4564. readonly currentLine: string;
  4565. readonly canRead: boolean;
  4566. lines: string[];
  4567. }
  4568. }
  4569. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4570. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4571. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4572. /** @hidden */
  4573. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4574. process(preprocessors: {
  4575. [key: string]: string;
  4576. }, options: ProcessingOptions): string;
  4577. }
  4578. }
  4579. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4580. /** @hidden */
  4581. export class ShaderDefineExpression {
  4582. isTrue(preprocessors: {
  4583. [key: string]: string;
  4584. }): boolean;
  4585. }
  4586. }
  4587. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4588. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4589. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4590. /** @hidden */
  4591. export class ShaderCodeTestNode extends ShaderCodeNode {
  4592. testExpression: ShaderDefineExpression;
  4593. isValid(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4602. define: string;
  4603. not: boolean;
  4604. constructor(define: string, not?: boolean);
  4605. isTrue(preprocessors: {
  4606. [key: string]: string;
  4607. }): boolean;
  4608. }
  4609. }
  4610. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4611. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4612. /** @hidden */
  4613. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4614. leftOperand: ShaderDefineExpression;
  4615. rightOperand: ShaderDefineExpression;
  4616. isTrue(preprocessors: {
  4617. [key: string]: string;
  4618. }): boolean;
  4619. }
  4620. }
  4621. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4622. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4623. /** @hidden */
  4624. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4625. leftOperand: ShaderDefineExpression;
  4626. rightOperand: ShaderDefineExpression;
  4627. isTrue(preprocessors: {
  4628. [key: string]: string;
  4629. }): boolean;
  4630. }
  4631. }
  4632. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4633. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4634. /** @hidden */
  4635. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4636. define: string;
  4637. operand: string;
  4638. testValue: string;
  4639. constructor(define: string, operand: string, testValue: string);
  4640. isTrue(preprocessors: {
  4641. [key: string]: string;
  4642. }): boolean;
  4643. }
  4644. }
  4645. declare module "babylonjs/Misc/loadFileError" {
  4646. import { WebRequest } from "babylonjs/Misc/webRequest";
  4647. /**
  4648. * @ignore
  4649. * Application error to support additional information when loading a file
  4650. */
  4651. export class LoadFileError extends Error {
  4652. /** defines the optional web request */
  4653. request?: WebRequest | undefined;
  4654. private static _setPrototypeOf;
  4655. /**
  4656. * Creates a new LoadFileError
  4657. * @param message defines the message of the error
  4658. * @param request defines the optional web request
  4659. */
  4660. constructor(message: string,
  4661. /** defines the optional web request */
  4662. request?: WebRequest | undefined);
  4663. }
  4664. }
  4665. declare module "babylonjs/Offline/IOfflineProvider" {
  4666. /**
  4667. * Class used to enable access to offline support
  4668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4669. */
  4670. export interface IOfflineProvider {
  4671. /**
  4672. * Gets a boolean indicating if scene must be saved in the database
  4673. */
  4674. enableSceneOffline: boolean;
  4675. /**
  4676. * Gets a boolean indicating if textures must be saved in the database
  4677. */
  4678. enableTexturesOffline: boolean;
  4679. /**
  4680. * Open the offline support and make it available
  4681. * @param successCallback defines the callback to call on success
  4682. * @param errorCallback defines the callback to call on error
  4683. */
  4684. open(successCallback: () => void, errorCallback: () => void): void;
  4685. /**
  4686. * Loads an image from the offline support
  4687. * @param url defines the url to load from
  4688. * @param image defines the target DOM image
  4689. */
  4690. loadImage(url: string, image: HTMLImageElement): void;
  4691. /**
  4692. * Loads a file from offline support
  4693. * @param url defines the URL to load from
  4694. * @param sceneLoaded defines a callback to call on success
  4695. * @param progressCallBack defines a callback to call when progress changed
  4696. * @param errorCallback defines a callback to call on error
  4697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4698. */
  4699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4700. }
  4701. }
  4702. declare module "babylonjs/Misc/filesInputStore" {
  4703. /**
  4704. * Class used to help managing file picking and drag'n'drop
  4705. * File Storage
  4706. */
  4707. export class FilesInputStore {
  4708. /**
  4709. * List of files ready to be loaded
  4710. */
  4711. static FilesToLoad: {
  4712. [key: string]: File;
  4713. };
  4714. }
  4715. }
  4716. declare module "babylonjs/Misc/retryStrategy" {
  4717. import { WebRequest } from "babylonjs/Misc/webRequest";
  4718. /**
  4719. * Class used to define a retry strategy when error happens while loading assets
  4720. */
  4721. export class RetryStrategy {
  4722. /**
  4723. * Function used to defines an exponential back off strategy
  4724. * @param maxRetries defines the maximum number of retries (3 by default)
  4725. * @param baseInterval defines the interval between retries
  4726. * @returns the strategy function to use
  4727. */
  4728. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4729. }
  4730. }
  4731. declare module "babylonjs/Misc/fileTools" {
  4732. import { WebRequest } from "babylonjs/Misc/webRequest";
  4733. import { Nullable } from "babylonjs/types";
  4734. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4735. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4736. /**
  4737. * @hidden
  4738. */
  4739. export class FileTools {
  4740. /**
  4741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4742. */
  4743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4744. /**
  4745. * Gets or sets the base URL to use to load assets
  4746. */
  4747. static BaseUrl: string;
  4748. /**
  4749. * Default behaviour for cors in the application.
  4750. * It can be a string if the expected behavior is identical in the entire app.
  4751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4752. */
  4753. static CorsBehavior: string | ((url: string | string[]) => string);
  4754. /**
  4755. * Gets or sets a function used to pre-process url before using them to load assets
  4756. */
  4757. static PreprocessUrl: (url: string) => string;
  4758. /**
  4759. * Removes unwanted characters from an url
  4760. * @param url defines the url to clean
  4761. * @returns the cleaned url
  4762. */
  4763. private static _CleanUrl;
  4764. /**
  4765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4766. * @param url define the url we are trying
  4767. * @param element define the dom element where to configure the cors policy
  4768. */
  4769. static SetCorsBehavior(url: string | string[], element: {
  4770. crossOrigin: string | null;
  4771. }): void;
  4772. /**
  4773. * Loads an image as an HTMLImageElement.
  4774. * @param input url string, ArrayBuffer, or Blob to load
  4775. * @param onLoad callback called when the image successfully loads
  4776. * @param onError callback called when the image fails to load
  4777. * @param offlineProvider offline provider for caching
  4778. * @returns the HTMLImageElement of the loaded image
  4779. */
  4780. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4781. /**
  4782. * Loads a file
  4783. * @param fileToLoad defines the file to load
  4784. * @param callback defines the callback to call when data is loaded
  4785. * @param progressCallBack defines the callback to call during loading process
  4786. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4787. * @returns a file request object
  4788. */
  4789. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4790. /**
  4791. * Loads a file
  4792. * @param url url string, ArrayBuffer, or Blob to load
  4793. * @param onSuccess callback called when the file successfully loads
  4794. * @param onProgress callback called while file is loading (if the server supports this mode)
  4795. * @param offlineProvider defines the offline provider for caching
  4796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4797. * @param onError callback called when the file fails to load
  4798. * @returns a file request object
  4799. */
  4800. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4801. /**
  4802. * Checks if the loaded document was accessed via `file:`-Protocol.
  4803. * @returns boolean
  4804. */
  4805. static IsFileURL(): boolean;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4809. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4810. /** @hidden */
  4811. export class ShaderProcessor {
  4812. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4813. private static _ProcessPrecision;
  4814. private static _ExtractOperation;
  4815. private static _BuildSubExpression;
  4816. private static _BuildExpression;
  4817. private static _MoveCursorWithinIf;
  4818. private static _MoveCursor;
  4819. private static _EvaluatePreProcessors;
  4820. private static _PreparePreProcessors;
  4821. private static _ProcessShaderConversion;
  4822. private static _ProcessIncludes;
  4823. }
  4824. }
  4825. declare module "babylonjs/Maths/math.color" {
  4826. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4827. /**
  4828. * Class used to hold a RBG color
  4829. */
  4830. export class Color3 {
  4831. /**
  4832. * Defines the red component (between 0 and 1, default is 0)
  4833. */
  4834. r: number;
  4835. /**
  4836. * Defines the green component (between 0 and 1, default is 0)
  4837. */
  4838. g: number;
  4839. /**
  4840. * Defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. b: number;
  4843. /**
  4844. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4845. * @param r defines the red component (between 0 and 1, default is 0)
  4846. * @param g defines the green component (between 0 and 1, default is 0)
  4847. * @param b defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. constructor(
  4850. /**
  4851. * Defines the red component (between 0 and 1, default is 0)
  4852. */
  4853. r?: number,
  4854. /**
  4855. * Defines the green component (between 0 and 1, default is 0)
  4856. */
  4857. g?: number,
  4858. /**
  4859. * Defines the blue component (between 0 and 1, default is 0)
  4860. */
  4861. b?: number);
  4862. /**
  4863. * Creates a string with the Color3 current values
  4864. * @returns the string representation of the Color3 object
  4865. */
  4866. toString(): string;
  4867. /**
  4868. * Returns the string "Color3"
  4869. * @returns "Color3"
  4870. */
  4871. getClassName(): string;
  4872. /**
  4873. * Compute the Color3 hash code
  4874. * @returns an unique number that can be used to hash Color3 objects
  4875. */
  4876. getHashCode(): number;
  4877. /**
  4878. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4879. * @param array defines the array where to store the r,g,b components
  4880. * @param index defines an optional index in the target array to define where to start storing values
  4881. * @returns the current Color3 object
  4882. */
  4883. toArray(array: FloatArray, index?: number): Color3;
  4884. /**
  4885. * Returns a new Color4 object from the current Color3 and the given alpha
  4886. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4887. * @returns a new Color4 object
  4888. */
  4889. toColor4(alpha?: number): Color4;
  4890. /**
  4891. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4892. * @returns the new array
  4893. */
  4894. asArray(): number[];
  4895. /**
  4896. * Returns the luminance value
  4897. * @returns a float value
  4898. */
  4899. toLuminance(): number;
  4900. /**
  4901. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4902. * @param otherColor defines the second operand
  4903. * @returns the new Color3 object
  4904. */
  4905. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4906. /**
  4907. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4908. * @param otherColor defines the second operand
  4909. * @param result defines the Color3 object where to store the result
  4910. * @returns the current Color3
  4911. */
  4912. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4913. /**
  4914. * Determines equality between Color3 objects
  4915. * @param otherColor defines the second operand
  4916. * @returns true if the rgb values are equal to the given ones
  4917. */
  4918. equals(otherColor: DeepImmutable<Color3>): boolean;
  4919. /**
  4920. * Determines equality between the current Color3 object and a set of r,b,g values
  4921. * @param r defines the red component to check
  4922. * @param g defines the green component to check
  4923. * @param b defines the blue component to check
  4924. * @returns true if the rgb values are equal to the given ones
  4925. */
  4926. equalsFloats(r: number, g: number, b: number): boolean;
  4927. /**
  4928. * Multiplies in place each rgb value by scale
  4929. * @param scale defines the scaling factor
  4930. * @returns the updated Color3
  4931. */
  4932. scale(scale: number): Color3;
  4933. /**
  4934. * Multiplies the rgb values by scale and stores the result into "result"
  4935. * @param scale defines the scaling factor
  4936. * @param result defines the Color3 object where to store the result
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Scale the current Color3 values by a factor and add the result to a given Color3
  4942. * @param scale defines the scale factor
  4943. * @param result defines color to store the result into
  4944. * @returns the unmodified current Color3
  4945. */
  4946. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4947. /**
  4948. * Clamps the rgb values by the min and max values and stores the result into "result"
  4949. * @param min defines minimum clamping value (default is 0)
  4950. * @param max defines maximum clamping value (default is 1)
  4951. * @param result defines color to store the result into
  4952. * @returns the original Color3
  4953. */
  4954. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4955. /**
  4956. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4957. * @param otherColor defines the second operand
  4958. * @returns the new Color3
  4959. */
  4960. add(otherColor: DeepImmutable<Color3>): Color3;
  4961. /**
  4962. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4963. * @param otherColor defines the second operand
  4964. * @param result defines Color3 object to store the result into
  4965. * @returns the unmodified current Color3
  4966. */
  4967. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4968. /**
  4969. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4970. * @param otherColor defines the second operand
  4971. * @returns the new Color3
  4972. */
  4973. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4974. /**
  4975. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4976. * @param otherColor defines the second operand
  4977. * @param result defines Color3 object to store the result into
  4978. * @returns the unmodified current Color3
  4979. */
  4980. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4981. /**
  4982. * Copy the current object
  4983. * @returns a new Color3 copied the current one
  4984. */
  4985. clone(): Color3;
  4986. /**
  4987. * Copies the rgb values from the source in the current Color3
  4988. * @param source defines the source Color3 object
  4989. * @returns the updated Color3 object
  4990. */
  4991. copyFrom(source: DeepImmutable<Color3>): Color3;
  4992. /**
  4993. * Updates the Color3 rgb values from the given floats
  4994. * @param r defines the red component to read from
  4995. * @param g defines the green component to read from
  4996. * @param b defines the blue component to read from
  4997. * @returns the current Color3 object
  4998. */
  4999. copyFromFloats(r: number, g: number, b: number): Color3;
  5000. /**
  5001. * Updates the Color3 rgb values from the given floats
  5002. * @param r defines the red component to read from
  5003. * @param g defines the green component to read from
  5004. * @param b defines the blue component to read from
  5005. * @returns the current Color3 object
  5006. */
  5007. set(r: number, g: number, b: number): Color3;
  5008. /**
  5009. * Compute the Color3 hexadecimal code as a string
  5010. * @returns a string containing the hexadecimal representation of the Color3 object
  5011. */
  5012. toHexString(): string;
  5013. /**
  5014. * Computes a new Color3 converted from the current one to linear space
  5015. * @returns a new Color3 object
  5016. */
  5017. toLinearSpace(): Color3;
  5018. /**
  5019. * Converts current color in rgb space to HSV values
  5020. * @returns a new color3 representing the HSV values
  5021. */
  5022. toHSV(): Color3;
  5023. /**
  5024. * Converts current color in rgb space to HSV values
  5025. * @param result defines the Color3 where to store the HSV values
  5026. */
  5027. toHSVToRef(result: Color3): void;
  5028. /**
  5029. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5030. * @param convertedColor defines the Color3 object where to store the linear space version
  5031. * @returns the unmodified Color3
  5032. */
  5033. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5034. /**
  5035. * Computes a new Color3 converted from the current one to gamma space
  5036. * @returns a new Color3 object
  5037. */
  5038. toGammaSpace(): Color3;
  5039. /**
  5040. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5041. * @param convertedColor defines the Color3 object where to store the gamma space version
  5042. * @returns the unmodified Color3
  5043. */
  5044. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5045. private static _BlackReadOnly;
  5046. /**
  5047. * Convert Hue, saturation and value to a Color3 (RGB)
  5048. * @param hue defines the hue
  5049. * @param saturation defines the saturation
  5050. * @param value defines the value
  5051. * @param result defines the Color3 where to store the RGB values
  5052. */
  5053. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5054. /**
  5055. * Creates a new Color3 from the string containing valid hexadecimal values
  5056. * @param hex defines a string containing valid hexadecimal values
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromHexString(hex: string): Color3;
  5060. /**
  5061. * Creates a new Color3 from the starting index of the given array
  5062. * @param array defines the source array
  5063. * @param offset defines an offset in the source array
  5064. * @returns a new Color3 object
  5065. */
  5066. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5067. /**
  5068. * Creates a new Color3 from integer values (< 256)
  5069. * @param r defines the red component to read from (value between 0 and 255)
  5070. * @param g defines the green component to read from (value between 0 and 255)
  5071. * @param b defines the blue component to read from (value between 0 and 255)
  5072. * @returns a new Color3 object
  5073. */
  5074. static FromInts(r: number, g: number, b: number): Color3;
  5075. /**
  5076. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5077. * @param start defines the start Color3 value
  5078. * @param end defines the end Color3 value
  5079. * @param amount defines the gradient value between start and end
  5080. * @returns a new Color3 object
  5081. */
  5082. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5083. /**
  5084. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5085. * @param left defines the start value
  5086. * @param right defines the end value
  5087. * @param amount defines the gradient factor
  5088. * @param result defines the Color3 object where to store the result
  5089. */
  5090. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5091. /**
  5092. * Returns a Color3 value containing a red color
  5093. * @returns a new Color3 object
  5094. */
  5095. static Red(): Color3;
  5096. /**
  5097. * Returns a Color3 value containing a green color
  5098. * @returns a new Color3 object
  5099. */
  5100. static Green(): Color3;
  5101. /**
  5102. * Returns a Color3 value containing a blue color
  5103. * @returns a new Color3 object
  5104. */
  5105. static Blue(): Color3;
  5106. /**
  5107. * Returns a Color3 value containing a black color
  5108. * @returns a new Color3 object
  5109. */
  5110. static Black(): Color3;
  5111. /**
  5112. * Gets a Color3 value containing a black color that must not be updated
  5113. */
  5114. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5115. /**
  5116. * Returns a Color3 value containing a white color
  5117. * @returns a new Color3 object
  5118. */
  5119. static White(): Color3;
  5120. /**
  5121. * Returns a Color3 value containing a purple color
  5122. * @returns a new Color3 object
  5123. */
  5124. static Purple(): Color3;
  5125. /**
  5126. * Returns a Color3 value containing a magenta color
  5127. * @returns a new Color3 object
  5128. */
  5129. static Magenta(): Color3;
  5130. /**
  5131. * Returns a Color3 value containing a yellow color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Yellow(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a gray color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Gray(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a teal color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Teal(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a random color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Random(): Color3;
  5150. }
  5151. /**
  5152. * Class used to hold a RBGA color
  5153. */
  5154. export class Color4 {
  5155. /**
  5156. * Defines the red component (between 0 and 1, default is 0)
  5157. */
  5158. r: number;
  5159. /**
  5160. * Defines the green component (between 0 and 1, default is 0)
  5161. */
  5162. g: number;
  5163. /**
  5164. * Defines the blue component (between 0 and 1, default is 0)
  5165. */
  5166. b: number;
  5167. /**
  5168. * Defines the alpha component (between 0 and 1, default is 1)
  5169. */
  5170. a: number;
  5171. /**
  5172. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5173. * @param r defines the red component (between 0 and 1, default is 0)
  5174. * @param g defines the green component (between 0 and 1, default is 0)
  5175. * @param b defines the blue component (between 0 and 1, default is 0)
  5176. * @param a defines the alpha component (between 0 and 1, default is 1)
  5177. */
  5178. constructor(
  5179. /**
  5180. * Defines the red component (between 0 and 1, default is 0)
  5181. */
  5182. r?: number,
  5183. /**
  5184. * Defines the green component (between 0 and 1, default is 0)
  5185. */
  5186. g?: number,
  5187. /**
  5188. * Defines the blue component (between 0 and 1, default is 0)
  5189. */
  5190. b?: number,
  5191. /**
  5192. * Defines the alpha component (between 0 and 1, default is 1)
  5193. */
  5194. a?: number);
  5195. /**
  5196. * Adds in place the given Color4 values to the current Color4 object
  5197. * @param right defines the second operand
  5198. * @returns the current updated Color4 object
  5199. */
  5200. addInPlace(right: DeepImmutable<Color4>): Color4;
  5201. /**
  5202. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5203. * @returns the new array
  5204. */
  5205. asArray(): number[];
  5206. /**
  5207. * Stores from the starting index in the given array the Color4 successive values
  5208. * @param array defines the array where to store the r,g,b components
  5209. * @param index defines an optional index in the target array to define where to start storing values
  5210. * @returns the current Color4 object
  5211. */
  5212. toArray(array: number[], index?: number): Color4;
  5213. /**
  5214. * Determines equality between Color4 objects
  5215. * @param otherColor defines the second operand
  5216. * @returns true if the rgba values are equal to the given ones
  5217. */
  5218. equals(otherColor: DeepImmutable<Color4>): boolean;
  5219. /**
  5220. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5221. * @param right defines the second operand
  5222. * @returns a new Color4 object
  5223. */
  5224. add(right: DeepImmutable<Color4>): Color4;
  5225. /**
  5226. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5227. * @param right defines the second operand
  5228. * @returns a new Color4 object
  5229. */
  5230. subtract(right: DeepImmutable<Color4>): Color4;
  5231. /**
  5232. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5233. * @param right defines the second operand
  5234. * @param result defines the Color4 object where to store the result
  5235. * @returns the current Color4 object
  5236. */
  5237. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5238. /**
  5239. * Creates a new Color4 with the current Color4 values multiplied by scale
  5240. * @param scale defines the scaling factor to apply
  5241. * @returns a new Color4 object
  5242. */
  5243. scale(scale: number): Color4;
  5244. /**
  5245. * Multiplies the current Color4 values by scale and stores the result in "result"
  5246. * @param scale defines the scaling factor to apply
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the current unmodified Color4
  5249. */
  5250. scaleToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Scale the current Color4 values by a factor and add the result to a given Color4
  5253. * @param scale defines the scale factor
  5254. * @param result defines the Color4 object where to store the result
  5255. * @returns the unmodified current Color4
  5256. */
  5257. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5258. /**
  5259. * Clamps the rgb values by the min and max values and stores the result into "result"
  5260. * @param min defines minimum clamping value (default is 0)
  5261. * @param max defines maximum clamping value (default is 1)
  5262. * @param result defines color to store the result into.
  5263. * @returns the cuurent Color4
  5264. */
  5265. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5266. /**
  5267. * Multipy an Color4 value by another and return a new Color4 object
  5268. * @param color defines the Color4 value to multiply by
  5269. * @returns a new Color4 object
  5270. */
  5271. multiply(color: Color4): Color4;
  5272. /**
  5273. * Multipy a Color4 value by another and push the result in a reference value
  5274. * @param color defines the Color4 value to multiply by
  5275. * @param result defines the Color4 to fill the result in
  5276. * @returns the result Color4
  5277. */
  5278. multiplyToRef(color: Color4, result: Color4): Color4;
  5279. /**
  5280. * Creates a string with the Color4 current values
  5281. * @returns the string representation of the Color4 object
  5282. */
  5283. toString(): string;
  5284. /**
  5285. * Returns the string "Color4"
  5286. * @returns "Color4"
  5287. */
  5288. getClassName(): string;
  5289. /**
  5290. * Compute the Color4 hash code
  5291. * @returns an unique number that can be used to hash Color4 objects
  5292. */
  5293. getHashCode(): number;
  5294. /**
  5295. * Creates a new Color4 copied from the current one
  5296. * @returns a new Color4 object
  5297. */
  5298. clone(): Color4;
  5299. /**
  5300. * Copies the given Color4 values into the current one
  5301. * @param source defines the source Color4 object
  5302. * @returns the current updated Color4 object
  5303. */
  5304. copyFrom(source: Color4): Color4;
  5305. /**
  5306. * Copies the given float values into the current one
  5307. * @param r defines the red component to read from
  5308. * @param g defines the green component to read from
  5309. * @param b defines the blue component to read from
  5310. * @param a defines the alpha component to read from
  5311. * @returns the current updated Color4 object
  5312. */
  5313. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5314. /**
  5315. * Copies the given float values into the current one
  5316. * @param r defines the red component to read from
  5317. * @param g defines the green component to read from
  5318. * @param b defines the blue component to read from
  5319. * @param a defines the alpha component to read from
  5320. * @returns the current updated Color4 object
  5321. */
  5322. set(r: number, g: number, b: number, a: number): Color4;
  5323. /**
  5324. * Compute the Color4 hexadecimal code as a string
  5325. * @returns a string containing the hexadecimal representation of the Color4 object
  5326. */
  5327. toHexString(): string;
  5328. /**
  5329. * Computes a new Color4 converted from the current one to linear space
  5330. * @returns a new Color4 object
  5331. */
  5332. toLinearSpace(): Color4;
  5333. /**
  5334. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5335. * @param convertedColor defines the Color4 object where to store the linear space version
  5336. * @returns the unmodified Color4
  5337. */
  5338. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5339. /**
  5340. * Computes a new Color4 converted from the current one to gamma space
  5341. * @returns a new Color4 object
  5342. */
  5343. toGammaSpace(): Color4;
  5344. /**
  5345. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5346. * @param convertedColor defines the Color4 object where to store the gamma space version
  5347. * @returns the unmodified Color4
  5348. */
  5349. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5350. /**
  5351. * Creates a new Color4 from the string containing valid hexadecimal values
  5352. * @param hex defines a string containing valid hexadecimal values
  5353. * @returns a new Color4 object
  5354. */
  5355. static FromHexString(hex: string): Color4;
  5356. /**
  5357. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5358. * @param left defines the start value
  5359. * @param right defines the end value
  5360. * @param amount defines the gradient factor
  5361. * @returns a new Color4 object
  5362. */
  5363. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5364. /**
  5365. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5366. * @param left defines the start value
  5367. * @param right defines the end value
  5368. * @param amount defines the gradient factor
  5369. * @param result defines the Color4 object where to store data
  5370. */
  5371. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5372. /**
  5373. * Creates a new Color4 from a Color3 and an alpha value
  5374. * @param color3 defines the source Color3 to read from
  5375. * @param alpha defines the alpha component (1.0 by default)
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5379. /**
  5380. * Creates a new Color4 from the starting index element of the given array
  5381. * @param array defines the source array to read from
  5382. * @param offset defines the offset in the source array
  5383. * @returns a new Color4 object
  5384. */
  5385. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5386. /**
  5387. * Creates a new Color3 from integer values (< 256)
  5388. * @param r defines the red component to read from (value between 0 and 255)
  5389. * @param g defines the green component to read from (value between 0 and 255)
  5390. * @param b defines the blue component to read from (value between 0 and 255)
  5391. * @param a defines the alpha component to read from (value between 0 and 255)
  5392. * @returns a new Color3 object
  5393. */
  5394. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5395. /**
  5396. * Check the content of a given array and convert it to an array containing RGBA data
  5397. * If the original array was already containing count * 4 values then it is returned directly
  5398. * @param colors defines the array to check
  5399. * @param count defines the number of RGBA data to expect
  5400. * @returns an array containing count * 4 values (RGBA)
  5401. */
  5402. static CheckColors4(colors: number[], count: number): number[];
  5403. }
  5404. /**
  5405. * @hidden
  5406. */
  5407. export class TmpColors {
  5408. static Color3: Color3[];
  5409. static Color4: Color4[];
  5410. }
  5411. }
  5412. declare module "babylonjs/Maths/sphericalPolynomial" {
  5413. import { Vector3 } from "babylonjs/Maths/math.vector";
  5414. import { Color3 } from "babylonjs/Maths/math.color";
  5415. /**
  5416. * Class representing spherical harmonics coefficients to the 3rd degree
  5417. */
  5418. export class SphericalHarmonics {
  5419. /**
  5420. * Defines whether or not the harmonics have been prescaled for rendering.
  5421. */
  5422. preScaled: boolean;
  5423. /**
  5424. * The l0,0 coefficients of the spherical harmonics
  5425. */
  5426. l00: Vector3;
  5427. /**
  5428. * The l1,-1 coefficients of the spherical harmonics
  5429. */
  5430. l1_1: Vector3;
  5431. /**
  5432. * The l1,0 coefficients of the spherical harmonics
  5433. */
  5434. l10: Vector3;
  5435. /**
  5436. * The l1,1 coefficients of the spherical harmonics
  5437. */
  5438. l11: Vector3;
  5439. /**
  5440. * The l2,-2 coefficients of the spherical harmonics
  5441. */
  5442. l2_2: Vector3;
  5443. /**
  5444. * The l2,-1 coefficients of the spherical harmonics
  5445. */
  5446. l2_1: Vector3;
  5447. /**
  5448. * The l2,0 coefficients of the spherical harmonics
  5449. */
  5450. l20: Vector3;
  5451. /**
  5452. * The l2,1 coefficients of the spherical harmonics
  5453. */
  5454. l21: Vector3;
  5455. /**
  5456. * The l2,2 coefficients of the spherical harmonics
  5457. */
  5458. l22: Vector3;
  5459. /**
  5460. * Adds a light to the spherical harmonics
  5461. * @param direction the direction of the light
  5462. * @param color the color of the light
  5463. * @param deltaSolidAngle the delta solid angle of the light
  5464. */
  5465. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5466. /**
  5467. * Scales the spherical harmonics by the given amount
  5468. * @param scale the amount to scale
  5469. */
  5470. scaleInPlace(scale: number): void;
  5471. /**
  5472. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5473. *
  5474. * ```
  5475. * E_lm = A_l * L_lm
  5476. * ```
  5477. *
  5478. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5479. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5480. * the scaling factors are given in equation 9.
  5481. */
  5482. convertIncidentRadianceToIrradiance(): void;
  5483. /**
  5484. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5485. *
  5486. * ```
  5487. * L = (1/pi) * E * rho
  5488. * ```
  5489. *
  5490. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5491. */
  5492. convertIrradianceToLambertianRadiance(): void;
  5493. /**
  5494. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5495. * required operations at run time.
  5496. *
  5497. * This is simply done by scaling back the SH with Ylm constants parameter.
  5498. * The trigonometric part being applied by the shader at run time.
  5499. */
  5500. preScaleForRendering(): void;
  5501. /**
  5502. * Constructs a spherical harmonics from an array.
  5503. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5504. * @returns the spherical harmonics
  5505. */
  5506. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5507. /**
  5508. * Gets the spherical harmonics from polynomial
  5509. * @param polynomial the spherical polynomial
  5510. * @returns the spherical harmonics
  5511. */
  5512. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5513. }
  5514. /**
  5515. * Class representing spherical polynomial coefficients to the 3rd degree
  5516. */
  5517. export class SphericalPolynomial {
  5518. private _harmonics;
  5519. /**
  5520. * The spherical harmonics used to create the polynomials.
  5521. */
  5522. readonly preScaledHarmonics: SphericalHarmonics;
  5523. /**
  5524. * The x coefficients of the spherical polynomial
  5525. */
  5526. x: Vector3;
  5527. /**
  5528. * The y coefficients of the spherical polynomial
  5529. */
  5530. y: Vector3;
  5531. /**
  5532. * The z coefficients of the spherical polynomial
  5533. */
  5534. z: Vector3;
  5535. /**
  5536. * The xx coefficients of the spherical polynomial
  5537. */
  5538. xx: Vector3;
  5539. /**
  5540. * The yy coefficients of the spherical polynomial
  5541. */
  5542. yy: Vector3;
  5543. /**
  5544. * The zz coefficients of the spherical polynomial
  5545. */
  5546. zz: Vector3;
  5547. /**
  5548. * The xy coefficients of the spherical polynomial
  5549. */
  5550. xy: Vector3;
  5551. /**
  5552. * The yz coefficients of the spherical polynomial
  5553. */
  5554. yz: Vector3;
  5555. /**
  5556. * The zx coefficients of the spherical polynomial
  5557. */
  5558. zx: Vector3;
  5559. /**
  5560. * Adds an ambient color to the spherical polynomial
  5561. * @param color the color to add
  5562. */
  5563. addAmbient(color: Color3): void;
  5564. /**
  5565. * Scales the spherical polynomial by the given amount
  5566. * @param scale the amount to scale
  5567. */
  5568. scaleInPlace(scale: number): void;
  5569. /**
  5570. * Gets the spherical polynomial from harmonics
  5571. * @param harmonics the spherical harmonics
  5572. * @returns the spherical polynomial
  5573. */
  5574. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5575. /**
  5576. * Constructs a spherical polynomial from an array.
  5577. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5578. * @returns the spherical polynomial
  5579. */
  5580. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5581. }
  5582. }
  5583. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5584. /**
  5585. * Define options used to create a render target texture
  5586. */
  5587. export class RenderTargetCreationOptions {
  5588. /**
  5589. * Specifies is mipmaps must be generated
  5590. */
  5591. generateMipMaps?: boolean;
  5592. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5593. generateDepthBuffer?: boolean;
  5594. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5595. generateStencilBuffer?: boolean;
  5596. /** Defines texture type (int by default) */
  5597. type?: number;
  5598. /** Defines sampling mode (trilinear by default) */
  5599. samplingMode?: number;
  5600. /** Defines format (RGBA by default) */
  5601. format?: number;
  5602. }
  5603. }
  5604. declare module "babylonjs/States/alphaCullingState" {
  5605. /**
  5606. * @hidden
  5607. **/
  5608. export class _AlphaState {
  5609. private _isAlphaBlendDirty;
  5610. private _isBlendFunctionParametersDirty;
  5611. private _isBlendEquationParametersDirty;
  5612. private _isBlendConstantsDirty;
  5613. private _alphaBlend;
  5614. private _blendFunctionParameters;
  5615. private _blendEquationParameters;
  5616. private _blendConstants;
  5617. /**
  5618. * Initializes the state.
  5619. */
  5620. constructor();
  5621. readonly isDirty: boolean;
  5622. alphaBlend: boolean;
  5623. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5624. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5625. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5626. reset(): void;
  5627. apply(gl: WebGLRenderingContext): void;
  5628. }
  5629. }
  5630. declare module "babylonjs/States/depthCullingState" {
  5631. import { Nullable } from "babylonjs/types";
  5632. /**
  5633. * @hidden
  5634. **/
  5635. export class _DepthCullingState {
  5636. private _isDepthTestDirty;
  5637. private _isDepthMaskDirty;
  5638. private _isDepthFuncDirty;
  5639. private _isCullFaceDirty;
  5640. private _isCullDirty;
  5641. private _isZOffsetDirty;
  5642. private _isFrontFaceDirty;
  5643. private _depthTest;
  5644. private _depthMask;
  5645. private _depthFunc;
  5646. private _cull;
  5647. private _cullFace;
  5648. private _zOffset;
  5649. private _frontFace;
  5650. /**
  5651. * Initializes the state.
  5652. */
  5653. constructor();
  5654. readonly isDirty: boolean;
  5655. zOffset: number;
  5656. cullFace: Nullable<number>;
  5657. cull: Nullable<boolean>;
  5658. depthFunc: Nullable<number>;
  5659. depthMask: boolean;
  5660. depthTest: boolean;
  5661. frontFace: Nullable<number>;
  5662. reset(): void;
  5663. apply(gl: WebGLRenderingContext): void;
  5664. }
  5665. }
  5666. declare module "babylonjs/States/stencilState" {
  5667. /**
  5668. * @hidden
  5669. **/
  5670. export class _StencilState {
  5671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5672. static readonly ALWAYS: number;
  5673. /** Passed to stencilOperation to specify that stencil value must be kept */
  5674. static readonly KEEP: number;
  5675. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5676. static readonly REPLACE: number;
  5677. private _isStencilTestDirty;
  5678. private _isStencilMaskDirty;
  5679. private _isStencilFuncDirty;
  5680. private _isStencilOpDirty;
  5681. private _stencilTest;
  5682. private _stencilMask;
  5683. private _stencilFunc;
  5684. private _stencilFuncRef;
  5685. private _stencilFuncMask;
  5686. private _stencilOpStencilFail;
  5687. private _stencilOpDepthFail;
  5688. private _stencilOpStencilDepthPass;
  5689. readonly isDirty: boolean;
  5690. stencilFunc: number;
  5691. stencilFuncRef: number;
  5692. stencilFuncMask: number;
  5693. stencilOpStencilFail: number;
  5694. stencilOpDepthFail: number;
  5695. stencilOpStencilDepthPass: number;
  5696. stencilMask: number;
  5697. stencilTest: boolean;
  5698. constructor();
  5699. reset(): void;
  5700. apply(gl: WebGLRenderingContext): void;
  5701. }
  5702. }
  5703. declare module "babylonjs/States/index" {
  5704. export * from "babylonjs/States/alphaCullingState";
  5705. export * from "babylonjs/States/depthCullingState";
  5706. export * from "babylonjs/States/stencilState";
  5707. }
  5708. declare module "babylonjs/Instrumentation/timeToken" {
  5709. import { Nullable } from "babylonjs/types";
  5710. /**
  5711. * @hidden
  5712. **/
  5713. export class _TimeToken {
  5714. _startTimeQuery: Nullable<WebGLQuery>;
  5715. _endTimeQuery: Nullable<WebGLQuery>;
  5716. _timeElapsedQuery: Nullable<WebGLQuery>;
  5717. _timeElapsedQueryEnded: boolean;
  5718. }
  5719. }
  5720. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5721. /**
  5722. * Class used to evalaute queries containing `and` and `or` operators
  5723. */
  5724. export class AndOrNotEvaluator {
  5725. /**
  5726. * Evaluate a query
  5727. * @param query defines the query to evaluate
  5728. * @param evaluateCallback defines the callback used to filter result
  5729. * @returns true if the query matches
  5730. */
  5731. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5732. private static _HandleParenthesisContent;
  5733. private static _SimplifyNegation;
  5734. }
  5735. }
  5736. declare module "babylonjs/Misc/tags" {
  5737. /**
  5738. * Class used to store custom tags
  5739. */
  5740. export class Tags {
  5741. /**
  5742. * Adds support for tags on the given object
  5743. * @param obj defines the object to use
  5744. */
  5745. static EnableFor(obj: any): void;
  5746. /**
  5747. * Removes tags support
  5748. * @param obj defines the object to use
  5749. */
  5750. static DisableFor(obj: any): void;
  5751. /**
  5752. * Gets a boolean indicating if the given object has tags
  5753. * @param obj defines the object to use
  5754. * @returns a boolean
  5755. */
  5756. static HasTags(obj: any): boolean;
  5757. /**
  5758. * Gets the tags available on a given object
  5759. * @param obj defines the object to use
  5760. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5761. * @returns the tags
  5762. */
  5763. static GetTags(obj: any, asString?: boolean): any;
  5764. /**
  5765. * Adds tags to an object
  5766. * @param obj defines the object to use
  5767. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5768. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5769. */
  5770. static AddTagsTo(obj: any, tagsString: string): void;
  5771. /**
  5772. * @hidden
  5773. */
  5774. static _AddTagTo(obj: any, tag: string): void;
  5775. /**
  5776. * Removes specific tags from a specific object
  5777. * @param obj defines the object to use
  5778. * @param tagsString defines the tags to remove
  5779. */
  5780. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5781. /**
  5782. * @hidden
  5783. */
  5784. static _RemoveTagFrom(obj: any, tag: string): void;
  5785. /**
  5786. * Defines if tags hosted on an object match a given query
  5787. * @param obj defines the object to use
  5788. * @param tagsQuery defines the tag query
  5789. * @returns a boolean
  5790. */
  5791. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5792. }
  5793. }
  5794. declare module "babylonjs/Maths/math.path" {
  5795. import { DeepImmutable, Nullable } from "babylonjs/types";
  5796. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5797. /**
  5798. * Defines potential orientation for back face culling
  5799. */
  5800. export enum Orientation {
  5801. /**
  5802. * Clockwise
  5803. */
  5804. CW = 0,
  5805. /** Counter clockwise */
  5806. CCW = 1
  5807. }
  5808. /** Class used to represent a Bezier curve */
  5809. export class BezierCurve {
  5810. /**
  5811. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5812. * @param t defines the time
  5813. * @param x1 defines the left coordinate on X axis
  5814. * @param y1 defines the left coordinate on Y axis
  5815. * @param x2 defines the right coordinate on X axis
  5816. * @param y2 defines the right coordinate on Y axis
  5817. * @returns the interpolated value
  5818. */
  5819. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5820. }
  5821. /**
  5822. * Defines angle representation
  5823. */
  5824. export class Angle {
  5825. private _radians;
  5826. /**
  5827. * Creates an Angle object of "radians" radians (float).
  5828. * @param radians the angle in radians
  5829. */
  5830. constructor(radians: number);
  5831. /**
  5832. * Get value in degrees
  5833. * @returns the Angle value in degrees (float)
  5834. */
  5835. degrees(): number;
  5836. /**
  5837. * Get value in radians
  5838. * @returns the Angle value in radians (float)
  5839. */
  5840. radians(): number;
  5841. /**
  5842. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5843. * @param a defines first vector
  5844. * @param b defines second vector
  5845. * @returns a new Angle
  5846. */
  5847. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5848. /**
  5849. * Gets a new Angle object from the given float in radians
  5850. * @param radians defines the angle value in radians
  5851. * @returns a new Angle
  5852. */
  5853. static FromRadians(radians: number): Angle;
  5854. /**
  5855. * Gets a new Angle object from the given float in degrees
  5856. * @param degrees defines the angle value in degrees
  5857. * @returns a new Angle
  5858. */
  5859. static FromDegrees(degrees: number): Angle;
  5860. }
  5861. /**
  5862. * This represents an arc in a 2d space.
  5863. */
  5864. export class Arc2 {
  5865. /** Defines the start point of the arc */
  5866. startPoint: Vector2;
  5867. /** Defines the mid point of the arc */
  5868. midPoint: Vector2;
  5869. /** Defines the end point of the arc */
  5870. endPoint: Vector2;
  5871. /**
  5872. * Defines the center point of the arc.
  5873. */
  5874. centerPoint: Vector2;
  5875. /**
  5876. * Defines the radius of the arc.
  5877. */
  5878. radius: number;
  5879. /**
  5880. * Defines the angle of the arc (from mid point to end point).
  5881. */
  5882. angle: Angle;
  5883. /**
  5884. * Defines the start angle of the arc (from start point to middle point).
  5885. */
  5886. startAngle: Angle;
  5887. /**
  5888. * Defines the orientation of the arc (clock wise/counter clock wise).
  5889. */
  5890. orientation: Orientation;
  5891. /**
  5892. * Creates an Arc object from the three given points : start, middle and end.
  5893. * @param startPoint Defines the start point of the arc
  5894. * @param midPoint Defines the midlle point of the arc
  5895. * @param endPoint Defines the end point of the arc
  5896. */
  5897. constructor(
  5898. /** Defines the start point of the arc */
  5899. startPoint: Vector2,
  5900. /** Defines the mid point of the arc */
  5901. midPoint: Vector2,
  5902. /** Defines the end point of the arc */
  5903. endPoint: Vector2);
  5904. }
  5905. /**
  5906. * Represents a 2D path made up of multiple 2D points
  5907. */
  5908. export class Path2 {
  5909. private _points;
  5910. private _length;
  5911. /**
  5912. * If the path start and end point are the same
  5913. */
  5914. closed: boolean;
  5915. /**
  5916. * Creates a Path2 object from the starting 2D coordinates x and y.
  5917. * @param x the starting points x value
  5918. * @param y the starting points y value
  5919. */
  5920. constructor(x: number, y: number);
  5921. /**
  5922. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5923. * @param x the added points x value
  5924. * @param y the added points y value
  5925. * @returns the updated Path2.
  5926. */
  5927. addLineTo(x: number, y: number): Path2;
  5928. /**
  5929. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5930. * @param midX middle point x value
  5931. * @param midY middle point y value
  5932. * @param endX end point x value
  5933. * @param endY end point y value
  5934. * @param numberOfSegments (default: 36)
  5935. * @returns the updated Path2.
  5936. */
  5937. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5938. /**
  5939. * Closes the Path2.
  5940. * @returns the Path2.
  5941. */
  5942. close(): Path2;
  5943. /**
  5944. * Gets the sum of the distance between each sequential point in the path
  5945. * @returns the Path2 total length (float).
  5946. */
  5947. length(): number;
  5948. /**
  5949. * Gets the points which construct the path
  5950. * @returns the Path2 internal array of points.
  5951. */
  5952. getPoints(): Vector2[];
  5953. /**
  5954. * Retreives the point at the distance aways from the starting point
  5955. * @param normalizedLengthPosition the length along the path to retreive the point from
  5956. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5957. */
  5958. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5959. /**
  5960. * Creates a new path starting from an x and y position
  5961. * @param x starting x value
  5962. * @param y starting y value
  5963. * @returns a new Path2 starting at the coordinates (x, y).
  5964. */
  5965. static StartingAt(x: number, y: number): Path2;
  5966. }
  5967. /**
  5968. * Represents a 3D path made up of multiple 3D points
  5969. */
  5970. export class Path3D {
  5971. /**
  5972. * an array of Vector3, the curve axis of the Path3D
  5973. */
  5974. path: Vector3[];
  5975. private _curve;
  5976. private _distances;
  5977. private _tangents;
  5978. private _normals;
  5979. private _binormals;
  5980. private _raw;
  5981. /**
  5982. * new Path3D(path, normal, raw)
  5983. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5984. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5985. * @param path an array of Vector3, the curve axis of the Path3D
  5986. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5987. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5988. */
  5989. constructor(
  5990. /**
  5991. * an array of Vector3, the curve axis of the Path3D
  5992. */
  5993. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5994. /**
  5995. * Returns the Path3D array of successive Vector3 designing its curve.
  5996. * @returns the Path3D array of successive Vector3 designing its curve.
  5997. */
  5998. getCurve(): Vector3[];
  5999. /**
  6000. * Returns an array populated with tangent vectors on each Path3D curve point.
  6001. * @returns an array populated with tangent vectors on each Path3D curve point.
  6002. */
  6003. getTangents(): Vector3[];
  6004. /**
  6005. * Returns an array populated with normal vectors on each Path3D curve point.
  6006. * @returns an array populated with normal vectors on each Path3D curve point.
  6007. */
  6008. getNormals(): Vector3[];
  6009. /**
  6010. * Returns an array populated with binormal vectors on each Path3D curve point.
  6011. * @returns an array populated with binormal vectors on each Path3D curve point.
  6012. */
  6013. getBinormals(): Vector3[];
  6014. /**
  6015. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6016. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6017. */
  6018. getDistances(): number[];
  6019. /**
  6020. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6021. * @param path path which all values are copied into the curves points
  6022. * @param firstNormal which should be projected onto the curve
  6023. * @returns the same object updated.
  6024. */
  6025. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6026. private _compute;
  6027. private _getFirstNonNullVector;
  6028. private _getLastNonNullVector;
  6029. private _normalVector;
  6030. }
  6031. /**
  6032. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6033. * A Curve3 is designed from a series of successive Vector3.
  6034. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6035. */
  6036. export class Curve3 {
  6037. private _points;
  6038. private _length;
  6039. /**
  6040. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6041. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6042. * @param v1 (Vector3) the control point
  6043. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6044. * @param nbPoints (integer) the wanted number of points in the curve
  6045. * @returns the created Curve3
  6046. */
  6047. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6048. /**
  6049. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6050. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6051. * @param v1 (Vector3) the first control point
  6052. * @param v2 (Vector3) the second control point
  6053. * @param v3 (Vector3) the end point of the Cubic Bezier
  6054. * @param nbPoints (integer) the wanted number of points in the curve
  6055. * @returns the created Curve3
  6056. */
  6057. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6058. /**
  6059. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6060. * @param p1 (Vector3) the origin point of the Hermite Spline
  6061. * @param t1 (Vector3) the tangent vector at the origin point
  6062. * @param p2 (Vector3) the end point of the Hermite Spline
  6063. * @param t2 (Vector3) the tangent vector at the end point
  6064. * @param nbPoints (integer) the wanted number of points in the curve
  6065. * @returns the created Curve3
  6066. */
  6067. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6068. /**
  6069. * Returns a Curve3 object along a CatmullRom Spline curve :
  6070. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6071. * @param nbPoints (integer) the wanted number of points between each curve control points
  6072. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6073. * @returns the created Curve3
  6074. */
  6075. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6076. /**
  6077. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6078. * A Curve3 is designed from a series of successive Vector3.
  6079. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6080. * @param points points which make up the curve
  6081. */
  6082. constructor(points: Vector3[]);
  6083. /**
  6084. * @returns the Curve3 stored array of successive Vector3
  6085. */
  6086. getPoints(): Vector3[];
  6087. /**
  6088. * @returns the computed length (float) of the curve.
  6089. */
  6090. length(): number;
  6091. /**
  6092. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6093. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6094. * curveA and curveB keep unchanged.
  6095. * @param curve the curve to continue from this curve
  6096. * @returns the newly constructed curve
  6097. */
  6098. continue(curve: DeepImmutable<Curve3>): Curve3;
  6099. private _computeLength;
  6100. }
  6101. }
  6102. declare module "babylonjs/Animations/easing" {
  6103. /**
  6104. * This represents the main contract an easing function should follow.
  6105. * Easing functions are used throughout the animation system.
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export interface IEasingFunction {
  6109. /**
  6110. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6111. * of the easing function.
  6112. * The link below provides some of the most common examples of easing functions.
  6113. * @see https://easings.net/
  6114. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6115. * @returns the corresponding value on the curve defined by the easing function
  6116. */
  6117. ease(gradient: number): number;
  6118. }
  6119. /**
  6120. * Base class used for every default easing function.
  6121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6122. */
  6123. export class EasingFunction implements IEasingFunction {
  6124. /**
  6125. * Interpolation follows the mathematical formula associated with the easing function.
  6126. */
  6127. static readonly EASINGMODE_EASEIN: number;
  6128. /**
  6129. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6130. */
  6131. static readonly EASINGMODE_EASEOUT: number;
  6132. /**
  6133. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6134. */
  6135. static readonly EASINGMODE_EASEINOUT: number;
  6136. private _easingMode;
  6137. /**
  6138. * Sets the easing mode of the current function.
  6139. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6140. */
  6141. setEasingMode(easingMode: number): void;
  6142. /**
  6143. * Gets the current easing mode.
  6144. * @returns the easing mode
  6145. */
  6146. getEasingMode(): number;
  6147. /**
  6148. * @hidden
  6149. */
  6150. easeInCore(gradient: number): number;
  6151. /**
  6152. * Given an input gradient between 0 and 1, this returns the corresponding value
  6153. * of the easing function.
  6154. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6155. * @returns the corresponding value on the curve defined by the easing function
  6156. */
  6157. ease(gradient: number): number;
  6158. }
  6159. /**
  6160. * Easing function with a circle shape (see link below).
  6161. * @see https://easings.net/#easeInCirc
  6162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6163. */
  6164. export class CircleEase extends EasingFunction implements IEasingFunction {
  6165. /** @hidden */
  6166. easeInCore(gradient: number): number;
  6167. }
  6168. /**
  6169. * Easing function with a ease back shape (see link below).
  6170. * @see https://easings.net/#easeInBack
  6171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6172. */
  6173. export class BackEase extends EasingFunction implements IEasingFunction {
  6174. /** Defines the amplitude of the function */
  6175. amplitude: number;
  6176. /**
  6177. * Instantiates a back ease easing
  6178. * @see https://easings.net/#easeInBack
  6179. * @param amplitude Defines the amplitude of the function
  6180. */
  6181. constructor(
  6182. /** Defines the amplitude of the function */
  6183. amplitude?: number);
  6184. /** @hidden */
  6185. easeInCore(gradient: number): number;
  6186. }
  6187. /**
  6188. * Easing function with a bouncing shape (see link below).
  6189. * @see https://easings.net/#easeInBounce
  6190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6191. */
  6192. export class BounceEase extends EasingFunction implements IEasingFunction {
  6193. /** Defines the number of bounces */
  6194. bounces: number;
  6195. /** Defines the amplitude of the bounce */
  6196. bounciness: number;
  6197. /**
  6198. * Instantiates a bounce easing
  6199. * @see https://easings.net/#easeInBounce
  6200. * @param bounces Defines the number of bounces
  6201. * @param bounciness Defines the amplitude of the bounce
  6202. */
  6203. constructor(
  6204. /** Defines the number of bounces */
  6205. bounces?: number,
  6206. /** Defines the amplitude of the bounce */
  6207. bounciness?: number);
  6208. /** @hidden */
  6209. easeInCore(gradient: number): number;
  6210. }
  6211. /**
  6212. * Easing function with a power of 3 shape (see link below).
  6213. * @see https://easings.net/#easeInCubic
  6214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6215. */
  6216. export class CubicEase extends EasingFunction implements IEasingFunction {
  6217. /** @hidden */
  6218. easeInCore(gradient: number): number;
  6219. }
  6220. /**
  6221. * Easing function with an elastic shape (see link below).
  6222. * @see https://easings.net/#easeInElastic
  6223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6224. */
  6225. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6226. /** Defines the number of oscillations*/
  6227. oscillations: number;
  6228. /** Defines the amplitude of the oscillations*/
  6229. springiness: number;
  6230. /**
  6231. * Instantiates an elastic easing function
  6232. * @see https://easings.net/#easeInElastic
  6233. * @param oscillations Defines the number of oscillations
  6234. * @param springiness Defines the amplitude of the oscillations
  6235. */
  6236. constructor(
  6237. /** Defines the number of oscillations*/
  6238. oscillations?: number,
  6239. /** Defines the amplitude of the oscillations*/
  6240. springiness?: number);
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with an exponential shape (see link below).
  6246. * @see https://easings.net/#easeInExpo
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6250. /** Defines the exponent of the function */
  6251. exponent: number;
  6252. /**
  6253. * Instantiates an exponential easing function
  6254. * @see https://easings.net/#easeInExpo
  6255. * @param exponent Defines the exponent of the function
  6256. */
  6257. constructor(
  6258. /** Defines the exponent of the function */
  6259. exponent?: number);
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a power shape (see link below).
  6265. * @see https://easings.net/#easeInQuad
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class PowerEase extends EasingFunction implements IEasingFunction {
  6269. /** Defines the power of the function */
  6270. power: number;
  6271. /**
  6272. * Instantiates an power base easing function
  6273. * @see https://easings.net/#easeInQuad
  6274. * @param power Defines the power of the function
  6275. */
  6276. constructor(
  6277. /** Defines the power of the function */
  6278. power?: number);
  6279. /** @hidden */
  6280. easeInCore(gradient: number): number;
  6281. }
  6282. /**
  6283. * Easing function with a power of 2 shape (see link below).
  6284. * @see https://easings.net/#easeInQuad
  6285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6286. */
  6287. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6288. /** @hidden */
  6289. easeInCore(gradient: number): number;
  6290. }
  6291. /**
  6292. * Easing function with a power of 4 shape (see link below).
  6293. * @see https://easings.net/#easeInQuart
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6297. /** @hidden */
  6298. easeInCore(gradient: number): number;
  6299. }
  6300. /**
  6301. * Easing function with a power of 5 shape (see link below).
  6302. * @see https://easings.net/#easeInQuint
  6303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6304. */
  6305. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6306. /** @hidden */
  6307. easeInCore(gradient: number): number;
  6308. }
  6309. /**
  6310. * Easing function with a sin shape (see link below).
  6311. * @see https://easings.net/#easeInSine
  6312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6313. */
  6314. export class SineEase extends EasingFunction implements IEasingFunction {
  6315. /** @hidden */
  6316. easeInCore(gradient: number): number;
  6317. }
  6318. /**
  6319. * Easing function with a bezier shape (see link below).
  6320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6322. */
  6323. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6324. /** Defines the x component of the start tangent in the bezier curve */
  6325. x1: number;
  6326. /** Defines the y component of the start tangent in the bezier curve */
  6327. y1: number;
  6328. /** Defines the x component of the end tangent in the bezier curve */
  6329. x2: number;
  6330. /** Defines the y component of the end tangent in the bezier curve */
  6331. y2: number;
  6332. /**
  6333. * Instantiates a bezier function
  6334. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6335. * @param x1 Defines the x component of the start tangent in the bezier curve
  6336. * @param y1 Defines the y component of the start tangent in the bezier curve
  6337. * @param x2 Defines the x component of the end tangent in the bezier curve
  6338. * @param y2 Defines the y component of the end tangent in the bezier curve
  6339. */
  6340. constructor(
  6341. /** Defines the x component of the start tangent in the bezier curve */
  6342. x1?: number,
  6343. /** Defines the y component of the start tangent in the bezier curve */
  6344. y1?: number,
  6345. /** Defines the x component of the end tangent in the bezier curve */
  6346. x2?: number,
  6347. /** Defines the y component of the end tangent in the bezier curve */
  6348. y2?: number);
  6349. /** @hidden */
  6350. easeInCore(gradient: number): number;
  6351. }
  6352. }
  6353. declare module "babylonjs/Animations/animationKey" {
  6354. /**
  6355. * Defines an interface which represents an animation key frame
  6356. */
  6357. export interface IAnimationKey {
  6358. /**
  6359. * Frame of the key frame
  6360. */
  6361. frame: number;
  6362. /**
  6363. * Value at the specifies key frame
  6364. */
  6365. value: any;
  6366. /**
  6367. * The input tangent for the cubic hermite spline
  6368. */
  6369. inTangent?: any;
  6370. /**
  6371. * The output tangent for the cubic hermite spline
  6372. */
  6373. outTangent?: any;
  6374. /**
  6375. * The animation interpolation type
  6376. */
  6377. interpolation?: AnimationKeyInterpolation;
  6378. }
  6379. /**
  6380. * Enum for the animation key frame interpolation type
  6381. */
  6382. export enum AnimationKeyInterpolation {
  6383. /**
  6384. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6385. */
  6386. STEP = 1
  6387. }
  6388. }
  6389. declare module "babylonjs/Animations/animationRange" {
  6390. /**
  6391. * Represents the range of an animation
  6392. */
  6393. export class AnimationRange {
  6394. /**The name of the animation range**/
  6395. name: string;
  6396. /**The starting frame of the animation */
  6397. from: number;
  6398. /**The ending frame of the animation*/
  6399. to: number;
  6400. /**
  6401. * Initializes the range of an animation
  6402. * @param name The name of the animation range
  6403. * @param from The starting frame of the animation
  6404. * @param to The ending frame of the animation
  6405. */
  6406. constructor(
  6407. /**The name of the animation range**/
  6408. name: string,
  6409. /**The starting frame of the animation */
  6410. from: number,
  6411. /**The ending frame of the animation*/
  6412. to: number);
  6413. /**
  6414. * Makes a copy of the animation range
  6415. * @returns A copy of the animation range
  6416. */
  6417. clone(): AnimationRange;
  6418. }
  6419. }
  6420. declare module "babylonjs/Animations/animationEvent" {
  6421. /**
  6422. * Composed of a frame, and an action function
  6423. */
  6424. export class AnimationEvent {
  6425. /** The frame for which the event is triggered **/
  6426. frame: number;
  6427. /** The event to perform when triggered **/
  6428. action: (currentFrame: number) => void;
  6429. /** Specifies if the event should be triggered only once**/
  6430. onlyOnce?: boolean | undefined;
  6431. /**
  6432. * Specifies if the animation event is done
  6433. */
  6434. isDone: boolean;
  6435. /**
  6436. * Initializes the animation event
  6437. * @param frame The frame for which the event is triggered
  6438. * @param action The event to perform when triggered
  6439. * @param onlyOnce Specifies if the event should be triggered only once
  6440. */
  6441. constructor(
  6442. /** The frame for which the event is triggered **/
  6443. frame: number,
  6444. /** The event to perform when triggered **/
  6445. action: (currentFrame: number) => void,
  6446. /** Specifies if the event should be triggered only once**/
  6447. onlyOnce?: boolean | undefined);
  6448. /** @hidden */
  6449. _clone(): AnimationEvent;
  6450. }
  6451. }
  6452. declare module "babylonjs/Behaviors/behavior" {
  6453. import { Nullable } from "babylonjs/types";
  6454. /**
  6455. * Interface used to define a behavior
  6456. */
  6457. export interface Behavior<T> {
  6458. /** gets or sets behavior's name */
  6459. name: string;
  6460. /**
  6461. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6462. */
  6463. init(): void;
  6464. /**
  6465. * Called when the behavior is attached to a target
  6466. * @param target defines the target where the behavior is attached to
  6467. */
  6468. attach(target: T): void;
  6469. /**
  6470. * Called when the behavior is detached from its target
  6471. */
  6472. detach(): void;
  6473. }
  6474. /**
  6475. * Interface implemented by classes supporting behaviors
  6476. */
  6477. export interface IBehaviorAware<T> {
  6478. /**
  6479. * Attach a behavior
  6480. * @param behavior defines the behavior to attach
  6481. * @returns the current host
  6482. */
  6483. addBehavior(behavior: Behavior<T>): T;
  6484. /**
  6485. * Remove a behavior from the current object
  6486. * @param behavior defines the behavior to detach
  6487. * @returns the current host
  6488. */
  6489. removeBehavior(behavior: Behavior<T>): T;
  6490. /**
  6491. * Gets a behavior using its name to search
  6492. * @param name defines the name to search
  6493. * @returns the behavior or null if not found
  6494. */
  6495. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6496. }
  6497. }
  6498. declare module "babylonjs/Misc/smartArray" {
  6499. /**
  6500. * Defines an array and its length.
  6501. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6502. */
  6503. export interface ISmartArrayLike<T> {
  6504. /**
  6505. * The data of the array.
  6506. */
  6507. data: Array<T>;
  6508. /**
  6509. * The active length of the array.
  6510. */
  6511. length: number;
  6512. }
  6513. /**
  6514. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6515. */
  6516. export class SmartArray<T> implements ISmartArrayLike<T> {
  6517. /**
  6518. * The full set of data from the array.
  6519. */
  6520. data: Array<T>;
  6521. /**
  6522. * The active length of the array.
  6523. */
  6524. length: number;
  6525. protected _id: number;
  6526. /**
  6527. * Instantiates a Smart Array.
  6528. * @param capacity defines the default capacity of the array.
  6529. */
  6530. constructor(capacity: number);
  6531. /**
  6532. * Pushes a value at the end of the active data.
  6533. * @param value defines the object to push in the array.
  6534. */
  6535. push(value: T): void;
  6536. /**
  6537. * Iterates over the active data and apply the lambda to them.
  6538. * @param func defines the action to apply on each value.
  6539. */
  6540. forEach(func: (content: T) => void): void;
  6541. /**
  6542. * Sorts the full sets of data.
  6543. * @param compareFn defines the comparison function to apply.
  6544. */
  6545. sort(compareFn: (a: T, b: T) => number): void;
  6546. /**
  6547. * Resets the active data to an empty array.
  6548. */
  6549. reset(): void;
  6550. /**
  6551. * Releases all the data from the array as well as the array.
  6552. */
  6553. dispose(): void;
  6554. /**
  6555. * Concats the active data with a given array.
  6556. * @param array defines the data to concatenate with.
  6557. */
  6558. concat(array: any): void;
  6559. /**
  6560. * Returns the position of a value in the active data.
  6561. * @param value defines the value to find the index for
  6562. * @returns the index if found in the active data otherwise -1
  6563. */
  6564. indexOf(value: T): number;
  6565. /**
  6566. * Returns whether an element is part of the active data.
  6567. * @param value defines the value to look for
  6568. * @returns true if found in the active data otherwise false
  6569. */
  6570. contains(value: T): boolean;
  6571. private static _GlobalId;
  6572. }
  6573. /**
  6574. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6575. * The data in this array can only be present once
  6576. */
  6577. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6578. private _duplicateId;
  6579. /**
  6580. * Pushes a value at the end of the active data.
  6581. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6582. * @param value defines the object to push in the array.
  6583. */
  6584. push(value: T): void;
  6585. /**
  6586. * Pushes a value at the end of the active data.
  6587. * If the data is already present, it won t be added again
  6588. * @param value defines the object to push in the array.
  6589. * @returns true if added false if it was already present
  6590. */
  6591. pushNoDuplicate(value: T): boolean;
  6592. /**
  6593. * Resets the active data to an empty array.
  6594. */
  6595. reset(): void;
  6596. /**
  6597. * Concats the active data with a given array.
  6598. * This ensures no dupplicate will be present in the result.
  6599. * @param array defines the data to concatenate with.
  6600. */
  6601. concatWithNoDuplicate(array: any): void;
  6602. }
  6603. }
  6604. declare module "babylonjs/Cameras/cameraInputsManager" {
  6605. import { Nullable } from "babylonjs/types";
  6606. import { Camera } from "babylonjs/Cameras/camera";
  6607. /**
  6608. * @ignore
  6609. * This is a list of all the different input types that are available in the application.
  6610. * Fo instance: ArcRotateCameraGamepadInput...
  6611. */
  6612. export var CameraInputTypes: {};
  6613. /**
  6614. * This is the contract to implement in order to create a new input class.
  6615. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6616. */
  6617. export interface ICameraInput<TCamera extends Camera> {
  6618. /**
  6619. * Defines the camera the input is attached to.
  6620. */
  6621. camera: Nullable<TCamera>;
  6622. /**
  6623. * Gets the class name of the current intput.
  6624. * @returns the class name
  6625. */
  6626. getClassName(): string;
  6627. /**
  6628. * Get the friendly name associated with the input class.
  6629. * @returns the input friendly name
  6630. */
  6631. getSimpleName(): string;
  6632. /**
  6633. * Attach the input controls to a specific dom element to get the input from.
  6634. * @param element Defines the element the controls should be listened from
  6635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6636. */
  6637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6638. /**
  6639. * Detach the current controls from the specified dom element.
  6640. * @param element Defines the element to stop listening the inputs from
  6641. */
  6642. detachControl(element: Nullable<HTMLElement>): void;
  6643. /**
  6644. * Update the current camera state depending on the inputs that have been used this frame.
  6645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6646. */
  6647. checkInputs?: () => void;
  6648. }
  6649. /**
  6650. * Represents a map of input types to input instance or input index to input instance.
  6651. */
  6652. export interface CameraInputsMap<TCamera extends Camera> {
  6653. /**
  6654. * Accessor to the input by input type.
  6655. */
  6656. [name: string]: ICameraInput<TCamera>;
  6657. /**
  6658. * Accessor to the input by input index.
  6659. */
  6660. [idx: number]: ICameraInput<TCamera>;
  6661. }
  6662. /**
  6663. * This represents the input manager used within a camera.
  6664. * It helps dealing with all the different kind of input attached to a camera.
  6665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6666. */
  6667. export class CameraInputsManager<TCamera extends Camera> {
  6668. /**
  6669. * Defines the list of inputs attahed to the camera.
  6670. */
  6671. attached: CameraInputsMap<TCamera>;
  6672. /**
  6673. * Defines the dom element the camera is collecting inputs from.
  6674. * This is null if the controls have not been attached.
  6675. */
  6676. attachedElement: Nullable<HTMLElement>;
  6677. /**
  6678. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6679. */
  6680. noPreventDefault: boolean;
  6681. /**
  6682. * Defined the camera the input manager belongs to.
  6683. */
  6684. camera: TCamera;
  6685. /**
  6686. * Update the current camera state depending on the inputs that have been used this frame.
  6687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6688. */
  6689. checkInputs: () => void;
  6690. /**
  6691. * Instantiate a new Camera Input Manager.
  6692. * @param camera Defines the camera the input manager blongs to
  6693. */
  6694. constructor(camera: TCamera);
  6695. /**
  6696. * Add an input method to a camera
  6697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6698. * @param input camera input method
  6699. */
  6700. add(input: ICameraInput<TCamera>): void;
  6701. /**
  6702. * Remove a specific input method from a camera
  6703. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6704. * @param inputToRemove camera input method
  6705. */
  6706. remove(inputToRemove: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Remove a specific input type from a camera
  6709. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6710. * @param inputType the type of the input to remove
  6711. */
  6712. removeByType(inputType: string): void;
  6713. private _addCheckInputs;
  6714. /**
  6715. * Attach the input controls to the currently attached dom element to listen the events from.
  6716. * @param input Defines the input to attach
  6717. */
  6718. attachInput(input: ICameraInput<TCamera>): void;
  6719. /**
  6720. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6721. * @param element Defines the dom element to collect the events from
  6722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6723. */
  6724. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6725. /**
  6726. * Detach the current manager inputs controls from a specific dom element.
  6727. * @param element Defines the dom element to collect the events from
  6728. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6729. */
  6730. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6731. /**
  6732. * Rebuild the dynamic inputCheck function from the current list of
  6733. * defined inputs in the manager.
  6734. */
  6735. rebuildInputCheck(): void;
  6736. /**
  6737. * Remove all attached input methods from a camera
  6738. */
  6739. clear(): void;
  6740. /**
  6741. * Serialize the current input manager attached to a camera.
  6742. * This ensures than once parsed,
  6743. * the input associated to the camera will be identical to the current ones
  6744. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6745. */
  6746. serialize(serializedCamera: any): void;
  6747. /**
  6748. * Parses an input manager serialized JSON to restore the previous list of inputs
  6749. * and states associated to a camera.
  6750. * @param parsedCamera Defines the JSON to parse
  6751. */
  6752. parse(parsedCamera: any): void;
  6753. }
  6754. }
  6755. declare module "babylonjs/Collisions/intersectionInfo" {
  6756. import { Nullable } from "babylonjs/types";
  6757. /**
  6758. * @hidden
  6759. */
  6760. export class IntersectionInfo {
  6761. bu: Nullable<number>;
  6762. bv: Nullable<number>;
  6763. distance: number;
  6764. faceId: number;
  6765. subMeshId: number;
  6766. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6767. }
  6768. }
  6769. declare module "babylonjs/Maths/math.plane" {
  6770. import { DeepImmutable } from "babylonjs/types";
  6771. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6772. /**
  6773. * Represens a plane by the equation ax + by + cz + d = 0
  6774. */
  6775. export class Plane {
  6776. private static _TmpMatrix;
  6777. /**
  6778. * Normal of the plane (a,b,c)
  6779. */
  6780. normal: Vector3;
  6781. /**
  6782. * d component of the plane
  6783. */
  6784. d: number;
  6785. /**
  6786. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6787. * @param a a component of the plane
  6788. * @param b b component of the plane
  6789. * @param c c component of the plane
  6790. * @param d d component of the plane
  6791. */
  6792. constructor(a: number, b: number, c: number, d: number);
  6793. /**
  6794. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6795. */
  6796. asArray(): number[];
  6797. /**
  6798. * @returns a new plane copied from the current Plane.
  6799. */
  6800. clone(): Plane;
  6801. /**
  6802. * @returns the string "Plane".
  6803. */
  6804. getClassName(): string;
  6805. /**
  6806. * @returns the Plane hash code.
  6807. */
  6808. getHashCode(): number;
  6809. /**
  6810. * Normalize the current Plane in place.
  6811. * @returns the updated Plane.
  6812. */
  6813. normalize(): Plane;
  6814. /**
  6815. * Applies a transformation the plane and returns the result
  6816. * @param transformation the transformation matrix to be applied to the plane
  6817. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6818. */
  6819. transform(transformation: DeepImmutable<Matrix>): Plane;
  6820. /**
  6821. * Calcualtte the dot product between the point and the plane normal
  6822. * @param point point to calculate the dot product with
  6823. * @returns the dot product (float) of the point coordinates and the plane normal.
  6824. */
  6825. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6826. /**
  6827. * Updates the current Plane from the plane defined by the three given points.
  6828. * @param point1 one of the points used to contruct the plane
  6829. * @param point2 one of the points used to contruct the plane
  6830. * @param point3 one of the points used to contruct the plane
  6831. * @returns the updated Plane.
  6832. */
  6833. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6834. /**
  6835. * Checks if the plane is facing a given direction
  6836. * @param direction the direction to check if the plane is facing
  6837. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6838. * @returns True is the vector "direction" is the same side than the plane normal.
  6839. */
  6840. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6841. /**
  6842. * Calculates the distance to a point
  6843. * @param point point to calculate distance to
  6844. * @returns the signed distance (float) from the given point to the Plane.
  6845. */
  6846. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6847. /**
  6848. * Creates a plane from an array
  6849. * @param array the array to create a plane from
  6850. * @returns a new Plane from the given array.
  6851. */
  6852. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6853. /**
  6854. * Creates a plane from three points
  6855. * @param point1 point used to create the plane
  6856. * @param point2 point used to create the plane
  6857. * @param point3 point used to create the plane
  6858. * @returns a new Plane defined by the three given points.
  6859. */
  6860. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6861. /**
  6862. * Creates a plane from an origin point and a normal
  6863. * @param origin origin of the plane to be constructed
  6864. * @param normal normal of the plane to be constructed
  6865. * @returns a new Plane the normal vector to this plane at the given origin point.
  6866. * Note : the vector "normal" is updated because normalized.
  6867. */
  6868. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6869. /**
  6870. * Calculates the distance from a plane and a point
  6871. * @param origin origin of the plane to be constructed
  6872. * @param normal normal of the plane to be constructed
  6873. * @param point point to calculate distance to
  6874. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6875. */
  6876. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { Plane } from "babylonjs/Maths/math.plane";
  6883. /**
  6884. * Class used to store bounding sphere information
  6885. */
  6886. export class BoundingSphere {
  6887. /**
  6888. * Gets the center of the bounding sphere in local space
  6889. */
  6890. readonly center: Vector3;
  6891. /**
  6892. * Radius of the bounding sphere in local space
  6893. */
  6894. radius: number;
  6895. /**
  6896. * Gets the center of the bounding sphere in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Radius of the bounding sphere in world space
  6901. */
  6902. radiusWorld: number;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * Creates a new bounding sphere
  6915. * @param min defines the minimum vector (in local space)
  6916. * @param max defines the maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6920. /**
  6921. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6922. * @param min defines the new minimum vector (in local space)
  6923. * @param max defines the new maximum vector (in local space)
  6924. * @param worldMatrix defines the new world matrix
  6925. */
  6926. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6927. /**
  6928. * Scale the current bounding sphere by applying a scale factor
  6929. * @param factor defines the scale factor to apply
  6930. * @returns the current bounding box
  6931. */
  6932. scale(factor: number): BoundingSphere;
  6933. /**
  6934. * Gets the world matrix of the bounding box
  6935. * @returns a matrix
  6936. */
  6937. getWorldMatrix(): DeepImmutable<Matrix>;
  6938. /** @hidden */
  6939. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6940. /**
  6941. * Tests if the bounding sphere is intersecting the frustum planes
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if there is an intersection
  6944. */
  6945. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if the bounding sphere center is in between the frustum planes.
  6948. * Used for optimistic fast inclusion.
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @returns true if the sphere center is in between the frustum planes
  6951. */
  6952. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. /**
  6954. * Tests if a point is inside the bounding sphere
  6955. * @param point defines the point to test
  6956. * @returns true if the point is inside the bounding sphere
  6957. */
  6958. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6959. /**
  6960. * Checks if two sphere intersct
  6961. * @param sphere0 sphere 0
  6962. * @param sphere1 sphere 1
  6963. * @returns true if the speres intersect
  6964. */
  6965. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6966. }
  6967. }
  6968. declare module "babylonjs/Culling/boundingBox" {
  6969. import { DeepImmutable } from "babylonjs/types";
  6970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6971. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6972. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6973. import { Plane } from "babylonjs/Maths/math.plane";
  6974. /**
  6975. * Class used to store bounding box information
  6976. */
  6977. export class BoundingBox implements ICullable {
  6978. /**
  6979. * Gets the 8 vectors representing the bounding box in local space
  6980. */
  6981. readonly vectors: Vector3[];
  6982. /**
  6983. * Gets the center of the bounding box in local space
  6984. */
  6985. readonly center: Vector3;
  6986. /**
  6987. * Gets the center of the bounding box in world space
  6988. */
  6989. readonly centerWorld: Vector3;
  6990. /**
  6991. * Gets the extend size in local space
  6992. */
  6993. readonly extendSize: Vector3;
  6994. /**
  6995. * Gets the extend size in world space
  6996. */
  6997. readonly extendSizeWorld: Vector3;
  6998. /**
  6999. * Gets the OBB (object bounding box) directions
  7000. */
  7001. readonly directions: Vector3[];
  7002. /**
  7003. * Gets the 8 vectors representing the bounding box in world space
  7004. */
  7005. readonly vectorsWorld: Vector3[];
  7006. /**
  7007. * Gets the minimum vector in world space
  7008. */
  7009. readonly minimumWorld: Vector3;
  7010. /**
  7011. * Gets the maximum vector in world space
  7012. */
  7013. readonly maximumWorld: Vector3;
  7014. /**
  7015. * Gets the minimum vector in local space
  7016. */
  7017. readonly minimum: Vector3;
  7018. /**
  7019. * Gets the maximum vector in local space
  7020. */
  7021. readonly maximum: Vector3;
  7022. private _worldMatrix;
  7023. private static readonly TmpVector3;
  7024. /**
  7025. * @hidden
  7026. */
  7027. _tag: number;
  7028. /**
  7029. * Creates a new bounding box
  7030. * @param min defines the minimum vector (in local space)
  7031. * @param max defines the maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7035. /**
  7036. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7037. * @param min defines the new minimum vector (in local space)
  7038. * @param max defines the new maximum vector (in local space)
  7039. * @param worldMatrix defines the new world matrix
  7040. */
  7041. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Scale the current bounding box by applying a scale factor
  7044. * @param factor defines the scale factor to apply
  7045. * @returns the current bounding box
  7046. */
  7047. scale(factor: number): BoundingBox;
  7048. /**
  7049. * Gets the world matrix of the bounding box
  7050. * @returns a matrix
  7051. */
  7052. getWorldMatrix(): DeepImmutable<Matrix>;
  7053. /** @hidden */
  7054. _update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Tests if the bounding box is intersecting the frustum planes
  7057. * @param frustumPlanes defines the frustum planes to test
  7058. * @returns true if there is an intersection
  7059. */
  7060. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7061. /**
  7062. * Tests if the bounding box is entirely inside the frustum planes
  7063. * @param frustumPlanes defines the frustum planes to test
  7064. * @returns true if there is an inclusion
  7065. */
  7066. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7067. /**
  7068. * Tests if a point is inside the bounding box
  7069. * @param point defines the point to test
  7070. * @returns true if the point is inside the bounding box
  7071. */
  7072. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7073. /**
  7074. * Tests if the bounding box intersects with a bounding sphere
  7075. * @param sphere defines the sphere to test
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7079. /**
  7080. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7081. * @param min defines the min vector to use
  7082. * @param max defines the max vector to use
  7083. * @returns true if there is an intersection
  7084. */
  7085. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7086. /**
  7087. * Tests if two bounding boxes are intersections
  7088. * @param box0 defines the first box to test
  7089. * @param box1 defines the second box to test
  7090. * @returns true if there is an intersection
  7091. */
  7092. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7093. /**
  7094. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7095. * @param minPoint defines the minimum vector of the bounding box
  7096. * @param maxPoint defines the maximum vector of the bounding box
  7097. * @param sphereCenter defines the sphere center
  7098. * @param sphereRadius defines the sphere radius
  7099. * @returns true if there is an intersection
  7100. */
  7101. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an inclusion
  7107. */
  7108. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. /**
  7110. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7111. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7112. * @param frustumPlanes defines the frustum planes to test
  7113. * @return true if there is an intersection
  7114. */
  7115. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. }
  7117. }
  7118. declare module "babylonjs/Collisions/collider" {
  7119. import { Nullable, IndicesArray } from "babylonjs/types";
  7120. import { Vector3 } from "babylonjs/Maths/math.vector";
  7121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7122. import { Plane } from "babylonjs/Maths/math.plane";
  7123. /** @hidden */
  7124. export class Collider {
  7125. /** Define if a collision was found */
  7126. collisionFound: boolean;
  7127. /**
  7128. * Define last intersection point in local space
  7129. */
  7130. intersectionPoint: Vector3;
  7131. /**
  7132. * Define last collided mesh
  7133. */
  7134. collidedMesh: Nullable<AbstractMesh>;
  7135. private _collisionPoint;
  7136. private _planeIntersectionPoint;
  7137. private _tempVector;
  7138. private _tempVector2;
  7139. private _tempVector3;
  7140. private _tempVector4;
  7141. private _edge;
  7142. private _baseToVertex;
  7143. private _destinationPoint;
  7144. private _slidePlaneNormal;
  7145. private _displacementVector;
  7146. /** @hidden */
  7147. _radius: Vector3;
  7148. /** @hidden */
  7149. _retry: number;
  7150. private _velocity;
  7151. private _basePoint;
  7152. private _epsilon;
  7153. /** @hidden */
  7154. _velocityWorldLength: number;
  7155. /** @hidden */
  7156. _basePointWorld: Vector3;
  7157. private _velocityWorld;
  7158. private _normalizedVelocity;
  7159. /** @hidden */
  7160. _initialVelocity: Vector3;
  7161. /** @hidden */
  7162. _initialPosition: Vector3;
  7163. private _nearestDistance;
  7164. private _collisionMask;
  7165. collisionMask: number;
  7166. /**
  7167. * Gets the plane normal used to compute the sliding response (in local space)
  7168. */
  7169. readonly slidePlaneNormal: Vector3;
  7170. /** @hidden */
  7171. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7172. /** @hidden */
  7173. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7174. /** @hidden */
  7175. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7176. /** @hidden */
  7177. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7178. /** @hidden */
  7179. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7180. /** @hidden */
  7181. _getResponse(pos: Vector3, vel: Vector3): void;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingInfo" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7188. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7189. import { Plane } from "babylonjs/Maths/math.plane";
  7190. import { Collider } from "babylonjs/Collisions/collider";
  7191. /**
  7192. * Interface for cullable objects
  7193. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7194. */
  7195. export interface ICullable {
  7196. /**
  7197. * Checks if the object or part of the object is in the frustum
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isInFrustum(frustumPlanes: Plane[]): boolean;
  7202. /**
  7203. * Checks if a cullable object (mesh...) is in the camera frustum
  7204. * Unlike isInFrustum this cheks the full bounding box
  7205. * @param frustumPlanes Camera near/planes
  7206. * @returns true if the object is in frustum otherwise false
  7207. */
  7208. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7209. }
  7210. /**
  7211. * Info for a bounding data of a mesh
  7212. */
  7213. export class BoundingInfo implements ICullable {
  7214. /**
  7215. * Bounding box for the mesh
  7216. */
  7217. readonly boundingBox: BoundingBox;
  7218. /**
  7219. * Bounding sphere for the mesh
  7220. */
  7221. readonly boundingSphere: BoundingSphere;
  7222. private _isLocked;
  7223. private static readonly TmpVector3;
  7224. /**
  7225. * Constructs bounding info
  7226. * @param minimum min vector of the bounding box/sphere
  7227. * @param maximum max vector of the bounding box/sphere
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7231. /**
  7232. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7233. * @param min defines the new minimum vector (in local space)
  7234. * @param max defines the new maximum vector (in local space)
  7235. * @param worldMatrix defines the new world matrix
  7236. */
  7237. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7238. /**
  7239. * min vector of the bounding box/sphere
  7240. */
  7241. readonly minimum: Vector3;
  7242. /**
  7243. * max vector of the bounding box/sphere
  7244. */
  7245. readonly maximum: Vector3;
  7246. /**
  7247. * If the info is locked and won't be updated to avoid perf overhead
  7248. */
  7249. isLocked: boolean;
  7250. /**
  7251. * Updates the bounding sphere and box
  7252. * @param world world matrix to be used to update
  7253. */
  7254. update(world: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7257. * @param center New center of the bounding info
  7258. * @param extend New extend of the bounding info
  7259. * @returns the current bounding info
  7260. */
  7261. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7262. /**
  7263. * Scale the current bounding info by applying a scale factor
  7264. * @param factor defines the scale factor to apply
  7265. * @returns the current bounding info
  7266. */
  7267. scale(factor: number): BoundingInfo;
  7268. /**
  7269. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7270. * @param frustumPlanes defines the frustum to test
  7271. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7272. * @returns true if the bounding info is in the frustum planes
  7273. */
  7274. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7275. /**
  7276. * Gets the world distance between the min and max points of the bounding box
  7277. */
  7278. readonly diagonalLength: number;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7286. /** @hidden */
  7287. _checkCollision(collider: Collider): boolean;
  7288. /**
  7289. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param point the point to check intersection with
  7292. * @returns if the point intersects
  7293. */
  7294. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7295. /**
  7296. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7297. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7298. * @param boundingInfo the bounding info to check intersection with
  7299. * @param precise if the intersection should be done using OBB
  7300. * @returns if the bounding info intersects
  7301. */
  7302. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7303. }
  7304. }
  7305. declare module "babylonjs/Maths/math.functions" {
  7306. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7307. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7308. /**
  7309. * Extracts minimum and maximum values from a list of indexed positions
  7310. * @param positions defines the positions to use
  7311. * @param indices defines the indices to the positions
  7312. * @param indexStart defines the start index
  7313. * @param indexCount defines the end index
  7314. * @param bias defines bias value to add to the result
  7315. * @return minimum and maximum values
  7316. */
  7317. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7318. minimum: Vector3;
  7319. maximum: Vector3;
  7320. };
  7321. /**
  7322. * Extracts minimum and maximum values from a list of positions
  7323. * @param positions defines the positions to use
  7324. * @param start defines the start index in the positions array
  7325. * @param count defines the number of positions to handle
  7326. * @param bias defines bias value to add to the result
  7327. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. }
  7335. declare module "babylonjs/Misc/iInspectable" {
  7336. /**
  7337. * Enum that determines the text-wrapping mode to use.
  7338. */
  7339. export enum InspectableType {
  7340. /**
  7341. * Checkbox for booleans
  7342. */
  7343. Checkbox = 0,
  7344. /**
  7345. * Sliders for numbers
  7346. */
  7347. Slider = 1,
  7348. /**
  7349. * Vector3
  7350. */
  7351. Vector3 = 2,
  7352. /**
  7353. * Quaternions
  7354. */
  7355. Quaternion = 3,
  7356. /**
  7357. * Color3
  7358. */
  7359. Color3 = 4,
  7360. /**
  7361. * String
  7362. */
  7363. String = 5
  7364. }
  7365. /**
  7366. * Interface used to define custom inspectable properties.
  7367. * This interface is used by the inspector to display custom property grids
  7368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7369. */
  7370. export interface IInspectable {
  7371. /**
  7372. * Gets the label to display
  7373. */
  7374. label: string;
  7375. /**
  7376. * Gets the name of the property to edit
  7377. */
  7378. propertyName: string;
  7379. /**
  7380. * Gets the type of the editor to use
  7381. */
  7382. type: InspectableType;
  7383. /**
  7384. * Gets the minimum value of the property when using in "slider" mode
  7385. */
  7386. min?: number;
  7387. /**
  7388. * Gets the maximum value of the property when using in "slider" mode
  7389. */
  7390. max?: number;
  7391. /**
  7392. * Gets the setp to use when using in "slider" mode
  7393. */
  7394. step?: number;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/timingTools" {
  7398. /**
  7399. * Class used to provide helper for timing
  7400. */
  7401. export class TimingTools {
  7402. /**
  7403. * Polyfill for setImmediate
  7404. * @param action defines the action to execute after the current execution block
  7405. */
  7406. static SetImmediate(action: () => void): void;
  7407. }
  7408. }
  7409. declare module "babylonjs/Misc/instantiationTools" {
  7410. /**
  7411. * Class used to enable instatition of objects by class name
  7412. */
  7413. export class InstantiationTools {
  7414. /**
  7415. * Use this object to register external classes like custom textures or material
  7416. * to allow the laoders to instantiate them
  7417. */
  7418. static RegisteredExternalClasses: {
  7419. [key: string]: Object;
  7420. };
  7421. /**
  7422. * Tries to instantiate a new object from a given class name
  7423. * @param className defines the class name to instantiate
  7424. * @returns the new object or null if the system was not able to do the instantiation
  7425. */
  7426. static Instantiate(className: string): any;
  7427. }
  7428. }
  7429. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7430. import { Nullable } from "babylonjs/types";
  7431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7432. /**
  7433. * This represents the required contract to create a new type of texture loader.
  7434. */
  7435. export interface IInternalTextureLoader {
  7436. /**
  7437. * Defines wether the loader supports cascade loading the different faces.
  7438. */
  7439. supportCascades: boolean;
  7440. /**
  7441. * This returns if the loader support the current file information.
  7442. * @param extension defines the file extension of the file being loaded
  7443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7444. * @param fallback defines the fallback internal texture if any
  7445. * @param isBase64 defines whether the texture is encoded as a base64
  7446. * @param isBuffer defines whether the texture data are stored as a buffer
  7447. * @returns true if the loader can load the specified file
  7448. */
  7449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7450. /**
  7451. * Transform the url before loading if required.
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the transformed texture
  7455. */
  7456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7457. /**
  7458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7459. * @param rootUrl the url of the texture
  7460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7461. * @returns the fallback texture
  7462. */
  7463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7464. /**
  7465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7466. * @param data contains the texture data
  7467. * @param texture defines the BabylonJS internal texture
  7468. * @param createPolynomials will be true if polynomials have been requested
  7469. * @param onLoad defines the callback to trigger once the texture is ready
  7470. * @param onError defines the callback to trigger in case of error
  7471. */
  7472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7473. /**
  7474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7475. * @param data contains the texture data
  7476. * @param texture defines the BabylonJS internal texture
  7477. * @param callback defines the method to call once ready to upload
  7478. */
  7479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7480. }
  7481. }
  7482. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7484. import { Nullable } from "babylonjs/types";
  7485. import { Scene } from "babylonjs/scene";
  7486. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7487. module "babylonjs/Engines/engine" {
  7488. interface Engine {
  7489. /**
  7490. * Creates a depth stencil cube texture.
  7491. * This is only available in WebGL 2.
  7492. * @param size The size of face edge in the cube texture.
  7493. * @param options The options defining the cube texture.
  7494. * @returns The cube texture
  7495. */
  7496. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7497. /**
  7498. * Creates a cube texture
  7499. * @param rootUrl defines the url where the files to load is located
  7500. * @param scene defines the current scene
  7501. * @param files defines the list of files to load (1 per face)
  7502. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7503. * @param onLoad defines an optional callback raised when the texture is loaded
  7504. * @param onError defines an optional callback raised if there is an issue to load the texture
  7505. * @param format defines the format of the data
  7506. * @param forcedExtension defines the extension to use to pick the right loader
  7507. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7508. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7509. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7510. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7511. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7512. * @returns the cube texture as an InternalTexture
  7513. */
  7514. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7515. /**
  7516. * Creates a cube texture
  7517. * @param rootUrl defines the url where the files to load is located
  7518. * @param scene defines the current scene
  7519. * @param files defines the list of files to load (1 per face)
  7520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7521. * @param onLoad defines an optional callback raised when the texture is loaded
  7522. * @param onError defines an optional callback raised if there is an issue to load the texture
  7523. * @param format defines the format of the data
  7524. * @param forcedExtension defines the extension to use to pick the right loader
  7525. * @returns the cube texture as an InternalTexture
  7526. */
  7527. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7528. /**
  7529. * Creates a cube texture
  7530. * @param rootUrl defines the url where the files to load is located
  7531. * @param scene defines the current scene
  7532. * @param files defines the list of files to load (1 per face)
  7533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7534. * @param onLoad defines an optional callback raised when the texture is loaded
  7535. * @param onError defines an optional callback raised if there is an issue to load the texture
  7536. * @param format defines the format of the data
  7537. * @param forcedExtension defines the extension to use to pick the right loader
  7538. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7541. * @returns the cube texture as an InternalTexture
  7542. */
  7543. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7544. /** @hidden */
  7545. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7546. /** @hidden */
  7547. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7548. /** @hidden */
  7549. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7550. /** @hidden */
  7551. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7552. }
  7553. }
  7554. }
  7555. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7556. import { Nullable } from "babylonjs/types";
  7557. import { Scene } from "babylonjs/scene";
  7558. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7560. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7561. /**
  7562. * Class for creating a cube texture
  7563. */
  7564. export class CubeTexture extends BaseTexture {
  7565. private _delayedOnLoad;
  7566. /**
  7567. * The url of the texture
  7568. */
  7569. url: string;
  7570. /**
  7571. * Gets or sets the center of the bounding box associated with the cube texture.
  7572. * It must define where the camera used to render the texture was set
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxPosition: Vector3;
  7576. private _boundingBoxSize;
  7577. /**
  7578. * Gets or sets the size of the bounding box associated with the cube texture
  7579. * When defined, the cubemap will switch to local mode
  7580. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7581. * @example https://www.babylonjs-playground.com/#RNASML
  7582. */
  7583. /**
  7584. * Returns the bounding box size
  7585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7586. */
  7587. boundingBoxSize: Vector3;
  7588. protected _rotationY: number;
  7589. /**
  7590. * Sets texture matrix rotation angle around Y axis in radians.
  7591. */
  7592. /**
  7593. * Gets texture matrix rotation angle around Y axis radians.
  7594. */
  7595. rotationY: number;
  7596. /**
  7597. * Are mip maps generated for this texture or not.
  7598. */
  7599. readonly noMipmap: boolean;
  7600. private _noMipmap;
  7601. private _files;
  7602. private _extensions;
  7603. private _textureMatrix;
  7604. private _format;
  7605. private _createPolynomials;
  7606. /** @hidden */
  7607. _prefiltered: boolean;
  7608. /**
  7609. * Creates a cube texture from an array of image urls
  7610. * @param files defines an array of image urls
  7611. * @param scene defines the hosting scene
  7612. * @param noMipmap specifies if mip maps are not used
  7613. * @returns a cube texture
  7614. */
  7615. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7616. /**
  7617. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7618. * @param url defines the url of the prefiltered texture
  7619. * @param scene defines the scene the texture is attached to
  7620. * @param forcedExtension defines the extension of the file if different from the url
  7621. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7622. * @return the prefiltered texture
  7623. */
  7624. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7625. /**
  7626. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7627. * as prefiltered data.
  7628. * @param rootUrl defines the url of the texture or the root name of the six images
  7629. * @param scene defines the scene the texture is attached to
  7630. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7631. * @param noMipmap defines if mipmaps should be created or not
  7632. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7633. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7634. * @param onError defines a callback triggered in case of error during load
  7635. * @param format defines the internal format to use for the texture once loaded
  7636. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7637. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7638. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7641. * @return the cube texture
  7642. */
  7643. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7644. /**
  7645. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7646. */
  7647. readonly isPrefiltered: boolean;
  7648. /**
  7649. * Get the current class name of the texture useful for serialization or dynamic coding.
  7650. * @returns "CubeTexture"
  7651. */
  7652. getClassName(): string;
  7653. /**
  7654. * Update the url (and optional buffer) of this texture if url was null during construction.
  7655. * @param url the url of the texture
  7656. * @param forcedExtension defines the extension to use
  7657. * @param onLoad callback called when the texture is loaded (defaults to null)
  7658. */
  7659. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7660. /**
  7661. * Delays loading of the cube texture
  7662. * @param forcedExtension defines the extension to use
  7663. */
  7664. delayLoad(forcedExtension?: string): void;
  7665. /**
  7666. * Returns the reflection texture matrix
  7667. * @returns the reflection texture matrix
  7668. */
  7669. getReflectionTextureMatrix(): Matrix;
  7670. /**
  7671. * Sets the reflection texture matrix
  7672. * @param value Reflection texture matrix
  7673. */
  7674. setReflectionTextureMatrix(value: Matrix): void;
  7675. /**
  7676. * Parses text to create a cube texture
  7677. * @param parsedTexture define the serialized text to read from
  7678. * @param scene defines the hosting scene
  7679. * @param rootUrl defines the root url of the cube texture
  7680. * @returns a cube texture
  7681. */
  7682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7683. /**
  7684. * Makes a clone, or deep copy, of the cube texture
  7685. * @returns a new cube texture
  7686. */
  7687. clone(): CubeTexture;
  7688. }
  7689. }
  7690. declare module "babylonjs/Materials/materialDefines" {
  7691. /**
  7692. * Manages the defines for the Material
  7693. */
  7694. export class MaterialDefines {
  7695. /** @hidden */
  7696. protected _keys: string[];
  7697. private _isDirty;
  7698. /** @hidden */
  7699. _renderId: number;
  7700. /** @hidden */
  7701. _areLightsDirty: boolean;
  7702. /** @hidden */
  7703. _areLightsDisposed: boolean;
  7704. /** @hidden */
  7705. _areAttributesDirty: boolean;
  7706. /** @hidden */
  7707. _areTexturesDirty: boolean;
  7708. /** @hidden */
  7709. _areFresnelDirty: boolean;
  7710. /** @hidden */
  7711. _areMiscDirty: boolean;
  7712. /** @hidden */
  7713. _areImageProcessingDirty: boolean;
  7714. /** @hidden */
  7715. _normals: boolean;
  7716. /** @hidden */
  7717. _uvs: boolean;
  7718. /** @hidden */
  7719. _needNormals: boolean;
  7720. /** @hidden */
  7721. _needUVs: boolean;
  7722. [id: string]: any;
  7723. /**
  7724. * Specifies if the material needs to be re-calculated
  7725. */
  7726. readonly isDirty: boolean;
  7727. /**
  7728. * Marks the material to indicate that it has been re-calculated
  7729. */
  7730. markAsProcessed(): void;
  7731. /**
  7732. * Marks the material to indicate that it needs to be re-calculated
  7733. */
  7734. markAsUnprocessed(): void;
  7735. /**
  7736. * Marks the material to indicate all of its defines need to be re-calculated
  7737. */
  7738. markAllAsDirty(): void;
  7739. /**
  7740. * Marks the material to indicate that image processing needs to be re-calculated
  7741. */
  7742. markAsImageProcessingDirty(): void;
  7743. /**
  7744. * Marks the material to indicate the lights need to be re-calculated
  7745. * @param disposed Defines whether the light is dirty due to dispose or not
  7746. */
  7747. markAsLightDirty(disposed?: boolean): void;
  7748. /**
  7749. * Marks the attribute state as changed
  7750. */
  7751. markAsAttributesDirty(): void;
  7752. /**
  7753. * Marks the texture state as changed
  7754. */
  7755. markAsTexturesDirty(): void;
  7756. /**
  7757. * Marks the fresnel state as changed
  7758. */
  7759. markAsFresnelDirty(): void;
  7760. /**
  7761. * Marks the misc state as changed
  7762. */
  7763. markAsMiscDirty(): void;
  7764. /**
  7765. * Rebuilds the material defines
  7766. */
  7767. rebuild(): void;
  7768. /**
  7769. * Specifies if two material defines are equal
  7770. * @param other - A material define instance to compare to
  7771. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7772. */
  7773. isEqual(other: MaterialDefines): boolean;
  7774. /**
  7775. * Clones this instance's defines to another instance
  7776. * @param other - material defines to clone values to
  7777. */
  7778. cloneTo(other: MaterialDefines): void;
  7779. /**
  7780. * Resets the material define values
  7781. */
  7782. reset(): void;
  7783. /**
  7784. * Converts the material define values to a string
  7785. * @returns - String of material define information
  7786. */
  7787. toString(): string;
  7788. }
  7789. }
  7790. declare module "babylonjs/Materials/colorCurves" {
  7791. import { Effect } from "babylonjs/Materials/effect";
  7792. /**
  7793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7795. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7797. */
  7798. export class ColorCurves {
  7799. private _dirty;
  7800. private _tempColor;
  7801. private _globalCurve;
  7802. private _highlightsCurve;
  7803. private _midtonesCurve;
  7804. private _shadowsCurve;
  7805. private _positiveCurve;
  7806. private _negativeCurve;
  7807. private _globalHue;
  7808. private _globalDensity;
  7809. private _globalSaturation;
  7810. private _globalExposure;
  7811. /**
  7812. * Gets the global Hue value.
  7813. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7814. */
  7815. /**
  7816. * Sets the global Hue value.
  7817. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7818. */
  7819. globalHue: number;
  7820. /**
  7821. * Gets the global Density value.
  7822. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7823. * Values less than zero provide a filter of opposite hue.
  7824. */
  7825. /**
  7826. * Sets the global Density value.
  7827. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. globalDensity: number;
  7831. /**
  7832. * Gets the global Saturation value.
  7833. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7834. */
  7835. /**
  7836. * Sets the global Saturation value.
  7837. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7838. */
  7839. globalSaturation: number;
  7840. /**
  7841. * Gets the global Exposure value.
  7842. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7843. */
  7844. /**
  7845. * Sets the global Exposure value.
  7846. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7847. */
  7848. globalExposure: number;
  7849. private _highlightsHue;
  7850. private _highlightsDensity;
  7851. private _highlightsSaturation;
  7852. private _highlightsExposure;
  7853. /**
  7854. * Gets the highlights Hue value.
  7855. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7856. */
  7857. /**
  7858. * Sets the highlights Hue value.
  7859. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7860. */
  7861. highlightsHue: number;
  7862. /**
  7863. * Gets the highlights Density value.
  7864. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7865. * Values less than zero provide a filter of opposite hue.
  7866. */
  7867. /**
  7868. * Sets the highlights Density value.
  7869. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7870. * Values less than zero provide a filter of opposite hue.
  7871. */
  7872. highlightsDensity: number;
  7873. /**
  7874. * Gets the highlights Saturation value.
  7875. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7876. */
  7877. /**
  7878. * Sets the highlights Saturation value.
  7879. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7880. */
  7881. highlightsSaturation: number;
  7882. /**
  7883. * Gets the highlights Exposure value.
  7884. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7885. */
  7886. /**
  7887. * Sets the highlights Exposure value.
  7888. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7889. */
  7890. highlightsExposure: number;
  7891. private _midtonesHue;
  7892. private _midtonesDensity;
  7893. private _midtonesSaturation;
  7894. private _midtonesExposure;
  7895. /**
  7896. * Gets the midtones Hue value.
  7897. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7898. */
  7899. /**
  7900. * Sets the midtones Hue value.
  7901. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7902. */
  7903. midtonesHue: number;
  7904. /**
  7905. * Gets the midtones Density value.
  7906. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7907. * Values less than zero provide a filter of opposite hue.
  7908. */
  7909. /**
  7910. * Sets the midtones Density value.
  7911. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7912. * Values less than zero provide a filter of opposite hue.
  7913. */
  7914. midtonesDensity: number;
  7915. /**
  7916. * Gets the midtones Saturation value.
  7917. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7918. */
  7919. /**
  7920. * Sets the midtones Saturation value.
  7921. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7922. */
  7923. midtonesSaturation: number;
  7924. /**
  7925. * Gets the midtones Exposure value.
  7926. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7927. */
  7928. /**
  7929. * Sets the midtones Exposure value.
  7930. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7931. */
  7932. midtonesExposure: number;
  7933. private _shadowsHue;
  7934. private _shadowsDensity;
  7935. private _shadowsSaturation;
  7936. private _shadowsExposure;
  7937. /**
  7938. * Gets the shadows Hue value.
  7939. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7940. */
  7941. /**
  7942. * Sets the shadows Hue value.
  7943. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7944. */
  7945. shadowsHue: number;
  7946. /**
  7947. * Gets the shadows Density value.
  7948. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7949. * Values less than zero provide a filter of opposite hue.
  7950. */
  7951. /**
  7952. * Sets the shadows Density value.
  7953. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7954. * Values less than zero provide a filter of opposite hue.
  7955. */
  7956. shadowsDensity: number;
  7957. /**
  7958. * Gets the shadows Saturation value.
  7959. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7960. */
  7961. /**
  7962. * Sets the shadows Saturation value.
  7963. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7964. */
  7965. shadowsSaturation: number;
  7966. /**
  7967. * Gets the shadows Exposure value.
  7968. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7969. */
  7970. /**
  7971. * Sets the shadows Exposure value.
  7972. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7973. */
  7974. shadowsExposure: number;
  7975. /**
  7976. * Returns the class name
  7977. * @returns The class name
  7978. */
  7979. getClassName(): string;
  7980. /**
  7981. * Binds the color curves to the shader.
  7982. * @param colorCurves The color curve to bind
  7983. * @param effect The effect to bind to
  7984. * @param positiveUniform The positive uniform shader parameter
  7985. * @param neutralUniform The neutral uniform shader parameter
  7986. * @param negativeUniform The negative uniform shader parameter
  7987. */
  7988. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7989. /**
  7990. * Prepare the list of uniforms associated with the ColorCurves effects.
  7991. * @param uniformsList The list of uniforms used in the effect
  7992. */
  7993. static PrepareUniforms(uniformsList: string[]): void;
  7994. /**
  7995. * Returns color grading data based on a hue, density, saturation and exposure value.
  7996. * @param filterHue The hue of the color filter.
  7997. * @param filterDensity The density of the color filter.
  7998. * @param saturation The saturation.
  7999. * @param exposure The exposure.
  8000. * @param result The result data container.
  8001. */
  8002. private getColorGradingDataToRef;
  8003. /**
  8004. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8005. * @param value The input slider value in range [-100,100].
  8006. * @returns Adjusted value.
  8007. */
  8008. private static applyColorGradingSliderNonlinear;
  8009. /**
  8010. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8011. * @param hue The hue (H) input.
  8012. * @param saturation The saturation (S) input.
  8013. * @param brightness The brightness (B) input.
  8014. * @result An RGBA color represented as Vector4.
  8015. */
  8016. private static fromHSBToRef;
  8017. /**
  8018. * Returns a value clamped between min and max
  8019. * @param value The value to clamp
  8020. * @param min The minimum of value
  8021. * @param max The maximum of value
  8022. * @returns The clamped value.
  8023. */
  8024. private static clamp;
  8025. /**
  8026. * Clones the current color curve instance.
  8027. * @return The cloned curves
  8028. */
  8029. clone(): ColorCurves;
  8030. /**
  8031. * Serializes the current color curve instance to a json representation.
  8032. * @return a JSON representation
  8033. */
  8034. serialize(): any;
  8035. /**
  8036. * Parses the color curve from a json representation.
  8037. * @param source the JSON source to parse
  8038. * @return The parsed curves
  8039. */
  8040. static Parse(source: any): ColorCurves;
  8041. }
  8042. }
  8043. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8044. import { Observable } from "babylonjs/Misc/observable";
  8045. import { Nullable } from "babylonjs/types";
  8046. import { Color4 } from "babylonjs/Maths/math.color";
  8047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8048. import { Effect } from "babylonjs/Materials/effect";
  8049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8050. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8051. /**
  8052. * Interface to follow in your material defines to integrate easily the
  8053. * Image proccessing functions.
  8054. * @hidden
  8055. */
  8056. export interface IImageProcessingConfigurationDefines {
  8057. IMAGEPROCESSING: boolean;
  8058. VIGNETTE: boolean;
  8059. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8060. VIGNETTEBLENDMODEOPAQUE: boolean;
  8061. TONEMAPPING: boolean;
  8062. TONEMAPPING_ACES: boolean;
  8063. CONTRAST: boolean;
  8064. EXPOSURE: boolean;
  8065. COLORCURVES: boolean;
  8066. COLORGRADING: boolean;
  8067. COLORGRADING3D: boolean;
  8068. SAMPLER3DGREENDEPTH: boolean;
  8069. SAMPLER3DBGRMAP: boolean;
  8070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8071. }
  8072. /**
  8073. * @hidden
  8074. */
  8075. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8076. IMAGEPROCESSING: boolean;
  8077. VIGNETTE: boolean;
  8078. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8079. VIGNETTEBLENDMODEOPAQUE: boolean;
  8080. TONEMAPPING: boolean;
  8081. TONEMAPPING_ACES: boolean;
  8082. CONTRAST: boolean;
  8083. COLORCURVES: boolean;
  8084. COLORGRADING: boolean;
  8085. COLORGRADING3D: boolean;
  8086. SAMPLER3DGREENDEPTH: boolean;
  8087. SAMPLER3DBGRMAP: boolean;
  8088. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8089. EXPOSURE: boolean;
  8090. constructor();
  8091. }
  8092. /**
  8093. * This groups together the common properties used for image processing either in direct forward pass
  8094. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8095. * or not.
  8096. */
  8097. export class ImageProcessingConfiguration {
  8098. /**
  8099. * Default tone mapping applied in BabylonJS.
  8100. */
  8101. static readonly TONEMAPPING_STANDARD: number;
  8102. /**
  8103. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8104. * to other engines rendering to increase portability.
  8105. */
  8106. static readonly TONEMAPPING_ACES: number;
  8107. /**
  8108. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8109. */
  8110. colorCurves: Nullable<ColorCurves>;
  8111. private _colorCurvesEnabled;
  8112. /**
  8113. * Gets wether the color curves effect is enabled.
  8114. */
  8115. /**
  8116. * Sets wether the color curves effect is enabled.
  8117. */
  8118. colorCurvesEnabled: boolean;
  8119. private _colorGradingTexture;
  8120. /**
  8121. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8122. */
  8123. /**
  8124. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8125. */
  8126. colorGradingTexture: Nullable<BaseTexture>;
  8127. private _colorGradingEnabled;
  8128. /**
  8129. * Gets wether the color grading effect is enabled.
  8130. */
  8131. /**
  8132. * Sets wether the color grading effect is enabled.
  8133. */
  8134. colorGradingEnabled: boolean;
  8135. private _colorGradingWithGreenDepth;
  8136. /**
  8137. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8138. */
  8139. /**
  8140. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8141. */
  8142. colorGradingWithGreenDepth: boolean;
  8143. private _colorGradingBGR;
  8144. /**
  8145. * Gets wether the color grading texture contains BGR values.
  8146. */
  8147. /**
  8148. * Sets wether the color grading texture contains BGR values.
  8149. */
  8150. colorGradingBGR: boolean;
  8151. /** @hidden */
  8152. _exposure: number;
  8153. /**
  8154. * Gets the Exposure used in the effect.
  8155. */
  8156. /**
  8157. * Sets the Exposure used in the effect.
  8158. */
  8159. exposure: number;
  8160. private _toneMappingEnabled;
  8161. /**
  8162. * Gets wether the tone mapping effect is enabled.
  8163. */
  8164. /**
  8165. * Sets wether the tone mapping effect is enabled.
  8166. */
  8167. toneMappingEnabled: boolean;
  8168. private _toneMappingType;
  8169. /**
  8170. * Gets the type of tone mapping effect.
  8171. */
  8172. /**
  8173. * Sets the type of tone mapping effect used in BabylonJS.
  8174. */
  8175. toneMappingType: number;
  8176. protected _contrast: number;
  8177. /**
  8178. * Gets the contrast used in the effect.
  8179. */
  8180. /**
  8181. * Sets the contrast used in the effect.
  8182. */
  8183. contrast: number;
  8184. /**
  8185. * Vignette stretch size.
  8186. */
  8187. vignetteStretch: number;
  8188. /**
  8189. * Vignette centre X Offset.
  8190. */
  8191. vignetteCentreX: number;
  8192. /**
  8193. * Vignette centre Y Offset.
  8194. */
  8195. vignetteCentreY: number;
  8196. /**
  8197. * Vignette weight or intensity of the vignette effect.
  8198. */
  8199. vignetteWeight: number;
  8200. /**
  8201. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8202. * if vignetteEnabled is set to true.
  8203. */
  8204. vignetteColor: Color4;
  8205. /**
  8206. * Camera field of view used by the Vignette effect.
  8207. */
  8208. vignetteCameraFov: number;
  8209. private _vignetteBlendMode;
  8210. /**
  8211. * Gets the vignette blend mode allowing different kind of effect.
  8212. */
  8213. /**
  8214. * Sets the vignette blend mode allowing different kind of effect.
  8215. */
  8216. vignetteBlendMode: number;
  8217. private _vignetteEnabled;
  8218. /**
  8219. * Gets wether the vignette effect is enabled.
  8220. */
  8221. /**
  8222. * Sets wether the vignette effect is enabled.
  8223. */
  8224. vignetteEnabled: boolean;
  8225. private _applyByPostProcess;
  8226. /**
  8227. * Gets wether the image processing is applied through a post process or not.
  8228. */
  8229. /**
  8230. * Sets wether the image processing is applied through a post process or not.
  8231. */
  8232. applyByPostProcess: boolean;
  8233. private _isEnabled;
  8234. /**
  8235. * Gets wether the image processing is enabled or not.
  8236. */
  8237. /**
  8238. * Sets wether the image processing is enabled or not.
  8239. */
  8240. isEnabled: boolean;
  8241. /**
  8242. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8243. */
  8244. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8245. /**
  8246. * Method called each time the image processing information changes requires to recompile the effect.
  8247. */
  8248. protected _updateParameters(): void;
  8249. /**
  8250. * Gets the current class name.
  8251. * @return "ImageProcessingConfiguration"
  8252. */
  8253. getClassName(): string;
  8254. /**
  8255. * Prepare the list of uniforms associated with the Image Processing effects.
  8256. * @param uniforms The list of uniforms used in the effect
  8257. * @param defines the list of defines currently in use
  8258. */
  8259. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8260. /**
  8261. * Prepare the list of samplers associated with the Image Processing effects.
  8262. * @param samplersList The list of uniforms used in the effect
  8263. * @param defines the list of defines currently in use
  8264. */
  8265. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8266. /**
  8267. * Prepare the list of defines associated to the shader.
  8268. * @param defines the list of defines to complete
  8269. * @param forPostProcess Define if we are currently in post process mode or not
  8270. */
  8271. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8272. /**
  8273. * Returns true if all the image processing information are ready.
  8274. * @returns True if ready, otherwise, false
  8275. */
  8276. isReady(): boolean;
  8277. /**
  8278. * Binds the image processing to the shader.
  8279. * @param effect The effect to bind to
  8280. * @param aspectRatio Define the current aspect ratio of the effect
  8281. */
  8282. bind(effect: Effect, aspectRatio?: number): void;
  8283. /**
  8284. * Clones the current image processing instance.
  8285. * @return The cloned image processing
  8286. */
  8287. clone(): ImageProcessingConfiguration;
  8288. /**
  8289. * Serializes the current image processing instance to a json representation.
  8290. * @return a JSON representation
  8291. */
  8292. serialize(): any;
  8293. /**
  8294. * Parses the image processing from a json representation.
  8295. * @param source the JSON source to parse
  8296. * @return The parsed image processing
  8297. */
  8298. static Parse(source: any): ImageProcessingConfiguration;
  8299. private static _VIGNETTEMODE_MULTIPLY;
  8300. private static _VIGNETTEMODE_OPAQUE;
  8301. /**
  8302. * Used to apply the vignette as a mix with the pixel color.
  8303. */
  8304. static readonly VIGNETTEMODE_MULTIPLY: number;
  8305. /**
  8306. * Used to apply the vignette as a replacement of the pixel color.
  8307. */
  8308. static readonly VIGNETTEMODE_OPAQUE: number;
  8309. }
  8310. }
  8311. declare module "babylonjs/Shaders/postprocess.vertex" {
  8312. /** @hidden */
  8313. export var postprocessVertexShader: {
  8314. name: string;
  8315. shader: string;
  8316. };
  8317. }
  8318. declare module "babylonjs/Maths/math.axis" {
  8319. import { Vector3 } from "babylonjs/Maths/math.vector";
  8320. /** Defines supported spaces */
  8321. export enum Space {
  8322. /** Local (object) space */
  8323. LOCAL = 0,
  8324. /** World space */
  8325. WORLD = 1,
  8326. /** Bone space */
  8327. BONE = 2
  8328. }
  8329. /** Defines the 3 main axes */
  8330. export class Axis {
  8331. /** X axis */
  8332. static X: Vector3;
  8333. /** Y axis */
  8334. static Y: Vector3;
  8335. /** Z axis */
  8336. static Z: Vector3;
  8337. }
  8338. }
  8339. declare module "babylonjs/Cameras/targetCamera" {
  8340. import { Nullable } from "babylonjs/types";
  8341. import { Camera } from "babylonjs/Cameras/camera";
  8342. import { Scene } from "babylonjs/scene";
  8343. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8344. /**
  8345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8346. * This is the base of the follow, arc rotate cameras and Free camera
  8347. * @see http://doc.babylonjs.com/features/cameras
  8348. */
  8349. export class TargetCamera extends Camera {
  8350. private static _RigCamTransformMatrix;
  8351. private static _TargetTransformMatrix;
  8352. private static _TargetFocalPoint;
  8353. /**
  8354. * Define the current direction the camera is moving to
  8355. */
  8356. cameraDirection: Vector3;
  8357. /**
  8358. * Define the current rotation the camera is rotating to
  8359. */
  8360. cameraRotation: Vector2;
  8361. /**
  8362. * When set, the up vector of the camera will be updated by the rotation of the camera
  8363. */
  8364. updateUpVectorFromRotation: boolean;
  8365. private _tmpQuaternion;
  8366. /**
  8367. * Define the current rotation of the camera
  8368. */
  8369. rotation: Vector3;
  8370. /**
  8371. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8372. */
  8373. rotationQuaternion: Quaternion;
  8374. /**
  8375. * Define the current speed of the camera
  8376. */
  8377. speed: number;
  8378. /**
  8379. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8380. * around all axis.
  8381. */
  8382. noRotationConstraint: boolean;
  8383. /**
  8384. * Define the current target of the camera as an object or a position.
  8385. */
  8386. lockedTarget: any;
  8387. /** @hidden */
  8388. _currentTarget: Vector3;
  8389. /** @hidden */
  8390. _initialFocalDistance: number;
  8391. /** @hidden */
  8392. _viewMatrix: Matrix;
  8393. /** @hidden */
  8394. _camMatrix: Matrix;
  8395. /** @hidden */
  8396. _cameraTransformMatrix: Matrix;
  8397. /** @hidden */
  8398. _cameraRotationMatrix: Matrix;
  8399. /** @hidden */
  8400. _referencePoint: Vector3;
  8401. /** @hidden */
  8402. _transformedReferencePoint: Vector3;
  8403. protected _globalCurrentTarget: Vector3;
  8404. protected _globalCurrentUpVector: Vector3;
  8405. /** @hidden */
  8406. _reset: () => void;
  8407. private _defaultUp;
  8408. /**
  8409. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8410. * This is the base of the follow, arc rotate cameras and Free camera
  8411. * @see http://doc.babylonjs.com/features/cameras
  8412. * @param name Defines the name of the camera in the scene
  8413. * @param position Defines the start position of the camera in the scene
  8414. * @param scene Defines the scene the camera belongs to
  8415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8416. */
  8417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8418. /**
  8419. * Gets the position in front of the camera at a given distance.
  8420. * @param distance The distance from the camera we want the position to be
  8421. * @returns the position
  8422. */
  8423. getFrontPosition(distance: number): Vector3;
  8424. /** @hidden */
  8425. _getLockedTargetPosition(): Nullable<Vector3>;
  8426. private _storedPosition;
  8427. private _storedRotation;
  8428. private _storedRotationQuaternion;
  8429. /**
  8430. * Store current camera state of the camera (fov, position, rotation, etc..)
  8431. * @returns the camera
  8432. */
  8433. storeState(): Camera;
  8434. /**
  8435. * Restored camera state. You must call storeState() first
  8436. * @returns whether it was successful or not
  8437. * @hidden
  8438. */
  8439. _restoreStateValues(): boolean;
  8440. /** @hidden */
  8441. _initCache(): void;
  8442. /** @hidden */
  8443. _updateCache(ignoreParentClass?: boolean): void;
  8444. /** @hidden */
  8445. _isSynchronizedViewMatrix(): boolean;
  8446. /** @hidden */
  8447. _computeLocalCameraSpeed(): number;
  8448. /**
  8449. * Defines the target the camera should look at.
  8450. * @param target Defines the new target as a Vector or a mesh
  8451. */
  8452. setTarget(target: Vector3): void;
  8453. /**
  8454. * Return the current target position of the camera. This value is expressed in local space.
  8455. * @returns the target position
  8456. */
  8457. getTarget(): Vector3;
  8458. /** @hidden */
  8459. _decideIfNeedsToMove(): boolean;
  8460. /** @hidden */
  8461. _updatePosition(): void;
  8462. /** @hidden */
  8463. _checkInputs(): void;
  8464. protected _updateCameraRotationMatrix(): void;
  8465. /**
  8466. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8467. * @returns the current camera
  8468. */
  8469. private _rotateUpVectorWithCameraRotationMatrix;
  8470. private _cachedRotationZ;
  8471. private _cachedQuaternionRotationZ;
  8472. /** @hidden */
  8473. _getViewMatrix(): Matrix;
  8474. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8475. /**
  8476. * @hidden
  8477. */
  8478. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8479. /**
  8480. * @hidden
  8481. */
  8482. _updateRigCameras(): void;
  8483. private _getRigCamPositionAndTarget;
  8484. /**
  8485. * Gets the current object class name.
  8486. * @return the class name
  8487. */
  8488. getClassName(): string;
  8489. }
  8490. }
  8491. declare module "babylonjs/Events/keyboardEvents" {
  8492. /**
  8493. * Gather the list of keyboard event types as constants.
  8494. */
  8495. export class KeyboardEventTypes {
  8496. /**
  8497. * The keydown event is fired when a key becomes active (pressed).
  8498. */
  8499. static readonly KEYDOWN: number;
  8500. /**
  8501. * The keyup event is fired when a key has been released.
  8502. */
  8503. static readonly KEYUP: number;
  8504. }
  8505. /**
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. */
  8508. export class KeyboardInfo {
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number;
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent;
  8517. /**
  8518. * Instantiates a new keyboard info.
  8519. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8520. * @param type Defines the type of event (KeyboardEventTypes)
  8521. * @param event Defines the related dom event
  8522. */
  8523. constructor(
  8524. /**
  8525. * Defines the type of event (KeyboardEventTypes)
  8526. */
  8527. type: number,
  8528. /**
  8529. * Defines the related dom event
  8530. */
  8531. event: KeyboardEvent);
  8532. }
  8533. /**
  8534. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8535. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8536. */
  8537. export class KeyboardInfoPre extends KeyboardInfo {
  8538. /**
  8539. * Defines the type of event (KeyboardEventTypes)
  8540. */
  8541. type: number;
  8542. /**
  8543. * Defines the related dom event
  8544. */
  8545. event: KeyboardEvent;
  8546. /**
  8547. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8548. */
  8549. skipOnPointerObservable: boolean;
  8550. /**
  8551. * Instantiates a new keyboard pre info.
  8552. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8553. * @param type Defines the type of event (KeyboardEventTypes)
  8554. * @param event Defines the related dom event
  8555. */
  8556. constructor(
  8557. /**
  8558. * Defines the type of event (KeyboardEventTypes)
  8559. */
  8560. type: number,
  8561. /**
  8562. * Defines the related dom event
  8563. */
  8564. event: KeyboardEvent);
  8565. }
  8566. }
  8567. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8570. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8571. /**
  8572. * Manage the keyboard inputs to control the movement of a free camera.
  8573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8574. */
  8575. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8576. /**
  8577. * Defines the camera the input is attached to.
  8578. */
  8579. camera: FreeCamera;
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8582. */
  8583. keysUp: number[];
  8584. /**
  8585. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8586. */
  8587. keysDown: number[];
  8588. /**
  8589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8590. */
  8591. keysLeft: number[];
  8592. /**
  8593. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8594. */
  8595. keysRight: number[];
  8596. private _keys;
  8597. private _onCanvasBlurObserver;
  8598. private _onKeyboardObserver;
  8599. private _engine;
  8600. private _scene;
  8601. /**
  8602. * Attach the input controls to a specific dom element to get the input from.
  8603. * @param element Defines the element the controls should be listened from
  8604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8605. */
  8606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8607. /**
  8608. * Detach the current controls from the specified dom element.
  8609. * @param element Defines the element to stop listening the inputs from
  8610. */
  8611. detachControl(element: Nullable<HTMLElement>): void;
  8612. /**
  8613. * Update the current camera state depending on the inputs that have been used this frame.
  8614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8615. */
  8616. checkInputs(): void;
  8617. /**
  8618. * Gets the class name of the current intput.
  8619. * @returns the class name
  8620. */
  8621. getClassName(): string;
  8622. /** @hidden */
  8623. _onLostFocus(): void;
  8624. /**
  8625. * Get the friendly name associated with the input class.
  8626. * @returns the input friendly name
  8627. */
  8628. getSimpleName(): string;
  8629. }
  8630. }
  8631. declare module "babylonjs/Lights/shadowLight" {
  8632. import { Camera } from "babylonjs/Cameras/camera";
  8633. import { Scene } from "babylonjs/scene";
  8634. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8636. import { Light } from "babylonjs/Lights/light";
  8637. /**
  8638. * Interface describing all the common properties and methods a shadow light needs to implement.
  8639. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8640. * as well as binding the different shadow properties to the effects.
  8641. */
  8642. export interface IShadowLight extends Light {
  8643. /**
  8644. * The light id in the scene (used in scene.findLighById for instance)
  8645. */
  8646. id: string;
  8647. /**
  8648. * The position the shdow will be casted from.
  8649. */
  8650. position: Vector3;
  8651. /**
  8652. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8653. */
  8654. direction: Vector3;
  8655. /**
  8656. * The transformed position. Position of the light in world space taking parenting in account.
  8657. */
  8658. transformedPosition: Vector3;
  8659. /**
  8660. * The transformed direction. Direction of the light in world space taking parenting in account.
  8661. */
  8662. transformedDirection: Vector3;
  8663. /**
  8664. * The friendly name of the light in the scene.
  8665. */
  8666. name: string;
  8667. /**
  8668. * Defines the shadow projection clipping minimum z value.
  8669. */
  8670. shadowMinZ: number;
  8671. /**
  8672. * Defines the shadow projection clipping maximum z value.
  8673. */
  8674. shadowMaxZ: number;
  8675. /**
  8676. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8677. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8678. */
  8679. computeTransformedInformation(): boolean;
  8680. /**
  8681. * Gets the scene the light belongs to.
  8682. * @returns The scene
  8683. */
  8684. getScene(): Scene;
  8685. /**
  8686. * Callback defining a custom Projection Matrix Builder.
  8687. * This can be used to override the default projection matrix computation.
  8688. */
  8689. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8690. /**
  8691. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8692. * @param matrix The materix to updated with the projection information
  8693. * @param viewMatrix The transform matrix of the light
  8694. * @param renderList The list of mesh to render in the map
  8695. * @returns The current light
  8696. */
  8697. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8698. /**
  8699. * Gets the current depth scale used in ESM.
  8700. * @returns The scale
  8701. */
  8702. getDepthScale(): number;
  8703. /**
  8704. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8705. * @returns true if a cube texture needs to be use
  8706. */
  8707. needCube(): boolean;
  8708. /**
  8709. * Detects if the projection matrix requires to be recomputed this frame.
  8710. * @returns true if it requires to be recomputed otherwise, false.
  8711. */
  8712. needProjectionMatrixCompute(): boolean;
  8713. /**
  8714. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8715. */
  8716. forceProjectionMatrixCompute(): void;
  8717. /**
  8718. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8719. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8720. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8721. */
  8722. getShadowDirection(faceIndex?: number): Vector3;
  8723. /**
  8724. * Gets the minZ used for shadow according to both the scene and the light.
  8725. * @param activeCamera The camera we are returning the min for
  8726. * @returns the depth min z
  8727. */
  8728. getDepthMinZ(activeCamera: Camera): number;
  8729. /**
  8730. * Gets the maxZ used for shadow according to both the scene and the light.
  8731. * @param activeCamera The camera we are returning the max for
  8732. * @returns the depth max z
  8733. */
  8734. getDepthMaxZ(activeCamera: Camera): number;
  8735. }
  8736. /**
  8737. * Base implementation IShadowLight
  8738. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8739. */
  8740. export abstract class ShadowLight extends Light implements IShadowLight {
  8741. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8742. protected _position: Vector3;
  8743. protected _setPosition(value: Vector3): void;
  8744. /**
  8745. * Sets the position the shadow will be casted from. Also use as the light position for both
  8746. * point and spot lights.
  8747. */
  8748. /**
  8749. * Sets the position the shadow will be casted from. Also use as the light position for both
  8750. * point and spot lights.
  8751. */
  8752. position: Vector3;
  8753. protected _direction: Vector3;
  8754. protected _setDirection(value: Vector3): void;
  8755. /**
  8756. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8757. * Also use as the light direction on spot and directional lights.
  8758. */
  8759. /**
  8760. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8761. * Also use as the light direction on spot and directional lights.
  8762. */
  8763. direction: Vector3;
  8764. private _shadowMinZ;
  8765. /**
  8766. * Gets the shadow projection clipping minimum z value.
  8767. */
  8768. /**
  8769. * Sets the shadow projection clipping minimum z value.
  8770. */
  8771. shadowMinZ: number;
  8772. private _shadowMaxZ;
  8773. /**
  8774. * Sets the shadow projection clipping maximum z value.
  8775. */
  8776. /**
  8777. * Gets the shadow projection clipping maximum z value.
  8778. */
  8779. shadowMaxZ: number;
  8780. /**
  8781. * Callback defining a custom Projection Matrix Builder.
  8782. * This can be used to override the default projection matrix computation.
  8783. */
  8784. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8785. /**
  8786. * The transformed position. Position of the light in world space taking parenting in account.
  8787. */
  8788. transformedPosition: Vector3;
  8789. /**
  8790. * The transformed direction. Direction of the light in world space taking parenting in account.
  8791. */
  8792. transformedDirection: Vector3;
  8793. private _needProjectionMatrixCompute;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Return the depth scale used for the shadow map.
  8801. * @returns the depth scale.
  8802. */
  8803. getDepthScale(): number;
  8804. /**
  8805. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8808. */
  8809. getShadowDirection(faceIndex?: number): Vector3;
  8810. /**
  8811. * Returns the ShadowLight absolute position in the World.
  8812. * @returns the position vector in world space
  8813. */
  8814. getAbsolutePosition(): Vector3;
  8815. /**
  8816. * Sets the ShadowLight direction toward the passed target.
  8817. * @param target The point to target in local space
  8818. * @returns the updated ShadowLight direction
  8819. */
  8820. setDirectionToTarget(target: Vector3): Vector3;
  8821. /**
  8822. * Returns the light rotation in euler definition.
  8823. * @returns the x y z rotation in local space.
  8824. */
  8825. getRotation(): Vector3;
  8826. /**
  8827. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8828. * @returns true if a cube texture needs to be use
  8829. */
  8830. needCube(): boolean;
  8831. /**
  8832. * Detects if the projection matrix requires to be recomputed this frame.
  8833. * @returns true if it requires to be recomputed otherwise, false.
  8834. */
  8835. needProjectionMatrixCompute(): boolean;
  8836. /**
  8837. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8838. */
  8839. forceProjectionMatrixCompute(): void;
  8840. /** @hidden */
  8841. _initCache(): void;
  8842. /** @hidden */
  8843. _isSynchronized(): boolean;
  8844. /**
  8845. * Computes the world matrix of the node
  8846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8847. * @returns the world matrix
  8848. */
  8849. computeWorldMatrix(force?: boolean): Matrix;
  8850. /**
  8851. * Gets the minZ used for shadow according to both the scene and the light.
  8852. * @param activeCamera The camera we are returning the min for
  8853. * @returns the depth min z
  8854. */
  8855. getDepthMinZ(activeCamera: Camera): number;
  8856. /**
  8857. * Gets the maxZ used for shadow according to both the scene and the light.
  8858. * @param activeCamera The camera we are returning the max for
  8859. * @returns the depth max z
  8860. */
  8861. getDepthMaxZ(activeCamera: Camera): number;
  8862. /**
  8863. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8864. * @param matrix The materix to updated with the projection information
  8865. * @param viewMatrix The transform matrix of the light
  8866. * @param renderList The list of mesh to render in the map
  8867. * @returns The current light
  8868. */
  8869. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8870. }
  8871. }
  8872. declare module "babylonjs/Materials/materialHelper" {
  8873. import { Nullable } from "babylonjs/types";
  8874. import { Scene } from "babylonjs/scene";
  8875. import { Engine } from "babylonjs/Engines/engine";
  8876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8877. import { Light } from "babylonjs/Lights/light";
  8878. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8879. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8882. /**
  8883. * "Static Class" containing the most commonly used helper while dealing with material for
  8884. * rendering purpose.
  8885. *
  8886. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8887. *
  8888. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8889. */
  8890. export class MaterialHelper {
  8891. /**
  8892. * Bind the current view position to an effect.
  8893. * @param effect The effect to be bound
  8894. * @param scene The scene the eyes position is used from
  8895. */
  8896. static BindEyePosition(effect: Effect, scene: Scene): void;
  8897. /**
  8898. * Helps preparing the defines values about the UVs in used in the effect.
  8899. * UVs are shared as much as we can accross channels in the shaders.
  8900. * @param texture The texture we are preparing the UVs for
  8901. * @param defines The defines to update
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8905. /**
  8906. * Binds a texture matrix value to its corrsponding uniform
  8907. * @param texture The texture to bind the matrix for
  8908. * @param uniformBuffer The uniform buffer receivin the data
  8909. * @param key The channel key "diffuse", "specular"... used in the shader
  8910. */
  8911. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8912. /**
  8913. * Gets the current status of the fog (should it be enabled?)
  8914. * @param mesh defines the mesh to evaluate for fog support
  8915. * @param scene defines the hosting scene
  8916. * @returns true if fog must be enabled
  8917. */
  8918. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8919. /**
  8920. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8921. * @param mesh defines the current mesh
  8922. * @param scene defines the current scene
  8923. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8924. * @param pointsCloud defines if point cloud rendering has to be turned on
  8925. * @param fogEnabled defines if fog has to be turned on
  8926. * @param alphaTest defines if alpha testing has to be turned on
  8927. * @param defines defines the current list of defines
  8928. */
  8929. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8930. /**
  8931. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8932. * @param scene defines the current scene
  8933. * @param engine defines the current engine
  8934. * @param defines specifies the list of active defines
  8935. * @param useInstances defines if instances have to be turned on
  8936. * @param useClipPlane defines if clip plane have to be turned on
  8937. */
  8938. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8939. /**
  8940. * Prepares the defines for bones
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. */
  8944. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8945. /**
  8946. * Prepares the defines for morph targets
  8947. * @param mesh The mesh containing the geometry data we will draw
  8948. * @param defines The defines to update
  8949. */
  8950. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8951. /**
  8952. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8953. * @param mesh The mesh containing the geometry data we will draw
  8954. * @param defines The defines to update
  8955. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8956. * @param useBones Precise whether bones should be used or not (override mesh info)
  8957. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8958. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8959. * @returns false if defines are considered not dirty and have not been checked
  8960. */
  8961. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8962. /**
  8963. * Prepares the defines related to multiview
  8964. * @param scene The scene we are intending to draw
  8965. * @param defines The defines to update
  8966. */
  8967. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8968. /**
  8969. * Prepares the defines related to the light information passed in parameter
  8970. * @param scene The scene we are intending to draw
  8971. * @param mesh The mesh the effect is compiling for
  8972. * @param light The light the effect is compiling for
  8973. * @param lightIndex The index of the light
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param state Defines the current state regarding what is needed (normals, etc...)
  8977. */
  8978. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8979. needNormals: boolean;
  8980. needRebuild: boolean;
  8981. shadowEnabled: boolean;
  8982. specularEnabled: boolean;
  8983. lightmapMode: boolean;
  8984. }): void;
  8985. /**
  8986. * Prepares the defines related to the light information passed in parameter
  8987. * @param scene The scene we are intending to draw
  8988. * @param mesh The mesh the effect is compiling for
  8989. * @param defines The defines to update
  8990. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8991. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8992. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8993. * @returns true if normals will be required for the rest of the effect
  8994. */
  8995. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8996. /**
  8997. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8998. * @param lightIndex defines the light index
  8999. * @param uniformsList The uniform list
  9000. * @param samplersList The sampler list
  9001. * @param projectedLightTexture defines if projected texture must be used
  9002. * @param uniformBuffersList defines an optional list of uniform buffers
  9003. */
  9004. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9005. /**
  9006. * Prepares the uniforms and samplers list to be used in the effect
  9007. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9008. * @param samplersList The sampler list
  9009. * @param defines The defines helping in the list generation
  9010. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9011. */
  9012. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9013. /**
  9014. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9015. * @param defines The defines to update while falling back
  9016. * @param fallbacks The authorized effect fallbacks
  9017. * @param maxSimultaneousLights The maximum number of lights allowed
  9018. * @param rank the current rank of the Effect
  9019. * @returns The newly affected rank
  9020. */
  9021. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9022. private static _TmpMorphInfluencers;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param influencers The number of influencers
  9028. */
  9029. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9030. /**
  9031. * Prepares the list of attributes required for morph targets according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the morph targets attributes for
  9034. * @param defines The current Defines of the effect
  9035. */
  9036. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9037. /**
  9038. * Prepares the list of attributes required for bones according to the effect defines.
  9039. * @param attribs The current list of supported attribs
  9040. * @param mesh The mesh to prepare the bones attributes for
  9041. * @param defines The current Defines of the effect
  9042. * @param fallbacks The current efffect fallback strategy
  9043. */
  9044. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9045. /**
  9046. * Check and prepare the list of attributes required for instances according to the effect defines.
  9047. * @param attribs The current list of supported attribs
  9048. * @param defines The current MaterialDefines of the effect
  9049. */
  9050. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9051. /**
  9052. * Add the list of attributes required for instances to the attribs array.
  9053. * @param attribs The current list of supported attribs
  9054. */
  9055. static PushAttributesForInstances(attribs: string[]): void;
  9056. /**
  9057. * Binds the light shadow information to the effect for the given mesh.
  9058. * @param light The light containing the generator
  9059. * @param scene The scene the lights belongs to
  9060. * @param mesh The mesh we are binding the information to render
  9061. * @param lightIndex The light index in the effect used to render the mesh
  9062. * @param effect The effect we are binding the data to
  9063. */
  9064. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9065. /**
  9066. * Binds the light information to the effect.
  9067. * @param light The light containing the generator
  9068. * @param effect The effect we are binding the data to
  9069. * @param lightIndex The light index in the effect used to render
  9070. */
  9071. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param light Light to bind
  9075. * @param lightIndex Light index
  9076. * @param scene The scene where the light belongs to
  9077. * @param mesh The mesh we are binding the information to render
  9078. * @param effect The effect we are binding the data to
  9079. * @param useSpecular Defines if specular is supported
  9080. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9081. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9082. */
  9083. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9084. /**
  9085. * Binds the lights information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param defines The generated defines for the effect
  9090. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9091. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9092. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9093. */
  9094. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9095. private static _tempFogColor;
  9096. /**
  9097. * Binds the fog information from the scene to the effect for the given mesh.
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. * @param linearSpace Defines if the fog effect is applied in linear space
  9102. */
  9103. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9104. /**
  9105. * Binds the bones information from the mesh to the effect.
  9106. * @param mesh The mesh we are binding the information to render
  9107. * @param effect The effect we are binding the data to
  9108. */
  9109. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9110. /**
  9111. * Binds the morph targets information from the mesh to the effect.
  9112. * @param abstractMesh The mesh we are binding the information to render
  9113. * @param effect The effect we are binding the data to
  9114. */
  9115. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9116. /**
  9117. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9118. * @param defines The generated defines used in the effect
  9119. * @param effect The effect we are binding the data to
  9120. * @param scene The scene we are willing to render with logarithmic scale for
  9121. */
  9122. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9123. /**
  9124. * Binds the clip plane information from the scene to the effect.
  9125. * @param scene The scene the clip plane information are extracted from
  9126. * @param effect The effect we are binding the data to
  9127. */
  9128. static BindClipPlane(effect: Effect, scene: Scene): void;
  9129. }
  9130. }
  9131. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9132. /** @hidden */
  9133. export var packingFunctions: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9139. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9182. /** @hidden */
  9183. export var morphTargetsVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9189. /** @hidden */
  9190. export var instancesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9196. /** @hidden */
  9197. export var bonesVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9203. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9206. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9211. /** @hidden */
  9212. export var shadowMapVertexShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9218. /** @hidden */
  9219. export var depthBoxBlurPixelShader: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9225. import { Nullable } from "babylonjs/types";
  9226. import { Scene } from "babylonjs/scene";
  9227. import { Matrix } from "babylonjs/Maths/math.vector";
  9228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9230. import { Mesh } from "babylonjs/Meshes/mesh";
  9231. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9232. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9233. import { Effect } from "babylonjs/Materials/effect";
  9234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9235. import "babylonjs/Shaders/shadowMap.fragment";
  9236. import "babylonjs/Shaders/shadowMap.vertex";
  9237. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9238. import { Observable } from "babylonjs/Misc/observable";
  9239. /**
  9240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9241. */
  9242. export interface ICustomShaderOptions {
  9243. /**
  9244. * Gets or sets the custom shader name to use
  9245. */
  9246. shaderName: string;
  9247. /**
  9248. * The list of attribute names used in the shader
  9249. */
  9250. attributes?: string[];
  9251. /**
  9252. * The list of unifrom names used in the shader
  9253. */
  9254. uniforms?: string[];
  9255. /**
  9256. * The list of sampler names used in the shader
  9257. */
  9258. samplers?: string[];
  9259. /**
  9260. * The list of defines used in the shader
  9261. */
  9262. defines?: string[];
  9263. }
  9264. /**
  9265. * Interface to implement to create a shadow generator compatible with BJS.
  9266. */
  9267. export interface IShadowGenerator {
  9268. /**
  9269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9270. * @returns The render target texture if present otherwise, null
  9271. */
  9272. getShadowMap(): Nullable<RenderTargetTexture>;
  9273. /**
  9274. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9275. * @returns The render target texture if the shadow map is present otherwise, null
  9276. */
  9277. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9278. /**
  9279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9280. * @param subMesh The submesh we want to render in the shadow map
  9281. * @param useInstances Defines wether will draw in the map using instances
  9282. * @returns true if ready otherwise, false
  9283. */
  9284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9285. /**
  9286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9287. * @param defines Defines of the material we want to update
  9288. * @param lightIndex Index of the light in the enabled light list of the material
  9289. */
  9290. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9291. /**
  9292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9293. * defined in the generator but impacting the effect).
  9294. * It implies the unifroms available on the materials are the standard BJS ones.
  9295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9296. * @param effect The effect we are binfing the information for
  9297. */
  9298. bindShadowLight(lightIndex: string, effect: Effect): void;
  9299. /**
  9300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9301. * (eq to shadow prjection matrix * light transform matrix)
  9302. * @returns The transform matrix used to create the shadow map
  9303. */
  9304. getTransformMatrix(): Matrix;
  9305. /**
  9306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9307. * Cube and 2D textures for instance.
  9308. */
  9309. recreateShadowMap(): void;
  9310. /**
  9311. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9312. * @param onCompiled Callback triggered at the and of the effects compilation
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. */
  9315. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9316. useInstances: boolean;
  9317. }>): void;
  9318. /**
  9319. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9320. * @param options Sets of optional options forcing the compilation with different modes
  9321. * @returns A promise that resolves when the compilation completes
  9322. */
  9323. forceCompilationAsync(options?: Partial<{
  9324. useInstances: boolean;
  9325. }>): Promise<void>;
  9326. /**
  9327. * Serializes the shadow generator setup to a json object.
  9328. * @returns The serialized JSON object
  9329. */
  9330. serialize(): any;
  9331. /**
  9332. * Disposes the Shadow map and related Textures and effects.
  9333. */
  9334. dispose(): void;
  9335. }
  9336. /**
  9337. * Default implementation IShadowGenerator.
  9338. * This is the main object responsible of generating shadows in the framework.
  9339. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9340. */
  9341. export class ShadowGenerator implements IShadowGenerator {
  9342. /**
  9343. * Shadow generator mode None: no filtering applied.
  9344. */
  9345. static readonly FILTER_NONE: number;
  9346. /**
  9347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9349. */
  9350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9351. /**
  9352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9354. */
  9355. static readonly FILTER_POISSONSAMPLING: number;
  9356. /**
  9357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9363. * edge artifacts on steep falloff.
  9364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9365. */
  9366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9367. /**
  9368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9369. * edge artifacts on steep falloff.
  9370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9371. */
  9372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9373. /**
  9374. * Shadow generator mode PCF: Percentage Closer Filtering
  9375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9377. */
  9378. static readonly FILTER_PCF: number;
  9379. /**
  9380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9382. * Contact Hardening
  9383. */
  9384. static readonly FILTER_PCSS: number;
  9385. /**
  9386. * Reserved for PCF and PCSS
  9387. * Highest Quality.
  9388. *
  9389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9390. *
  9391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9392. */
  9393. static readonly QUALITY_HIGH: number;
  9394. /**
  9395. * Reserved for PCF and PCSS
  9396. * Good tradeoff for quality/perf cross devices
  9397. *
  9398. * Execute PCF on a 3*3 kernel.
  9399. *
  9400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9401. */
  9402. static readonly QUALITY_MEDIUM: number;
  9403. /**
  9404. * Reserved for PCF and PCSS
  9405. * The lowest quality but the fastest.
  9406. *
  9407. * Execute PCF on a 1*1 kernel.
  9408. *
  9409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9410. */
  9411. static readonly QUALITY_LOW: number;
  9412. /** Gets or sets the custom shader name to use */
  9413. customShaderOptions: ICustomShaderOptions;
  9414. /**
  9415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9416. */
  9417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9418. /**
  9419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9420. */
  9421. onAfterShadowMapRenderObservable: Observable<Effect>;
  9422. /**
  9423. * Observable triggered before a mesh is rendered in the shadow map.
  9424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9425. */
  9426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9427. /**
  9428. * Observable triggered after a mesh is rendered in the shadow map.
  9429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9430. */
  9431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9432. private _bias;
  9433. /**
  9434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9435. */
  9436. /**
  9437. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9438. */
  9439. bias: number;
  9440. private _normalBias;
  9441. /**
  9442. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9443. */
  9444. /**
  9445. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9446. */
  9447. normalBias: number;
  9448. private _blurBoxOffset;
  9449. /**
  9450. * Gets the blur box offset: offset applied during the blur pass.
  9451. * Only useful if useKernelBlur = false
  9452. */
  9453. /**
  9454. * Sets the blur box offset: offset applied during the blur pass.
  9455. * Only useful if useKernelBlur = false
  9456. */
  9457. blurBoxOffset: number;
  9458. private _blurScale;
  9459. /**
  9460. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9461. * 2 means half of the size.
  9462. */
  9463. /**
  9464. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9465. * 2 means half of the size.
  9466. */
  9467. blurScale: number;
  9468. private _blurKernel;
  9469. /**
  9470. * Gets the blur kernel: kernel size of the blur pass.
  9471. * Only useful if useKernelBlur = true
  9472. */
  9473. /**
  9474. * Sets the blur kernel: kernel size of the blur pass.
  9475. * Only useful if useKernelBlur = true
  9476. */
  9477. blurKernel: number;
  9478. private _useKernelBlur;
  9479. /**
  9480. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9481. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9482. */
  9483. /**
  9484. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9485. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9486. */
  9487. useKernelBlur: boolean;
  9488. private _depthScale;
  9489. /**
  9490. * Gets the depth scale used in ESM mode.
  9491. */
  9492. /**
  9493. * Sets the depth scale used in ESM mode.
  9494. * This can override the scale stored on the light.
  9495. */
  9496. depthScale: number;
  9497. private _filter;
  9498. /**
  9499. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9500. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9501. */
  9502. /**
  9503. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9504. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9505. */
  9506. filter: number;
  9507. /**
  9508. * Gets if the current filter is set to Poisson Sampling.
  9509. */
  9510. /**
  9511. * Sets the current filter to Poisson Sampling.
  9512. */
  9513. usePoissonSampling: boolean;
  9514. /**
  9515. * Gets if the current filter is set to ESM.
  9516. */
  9517. /**
  9518. * Sets the current filter is to ESM.
  9519. */
  9520. useExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to filtered ESM.
  9523. */
  9524. /**
  9525. * Gets if the current filter is set to filtered ESM.
  9526. */
  9527. useBlurExponentialShadowMap: boolean;
  9528. /**
  9529. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9530. * exponential to prevent steep falloff artifacts).
  9531. */
  9532. /**
  9533. * Sets the current filter to "close ESM" (using the inverse of the
  9534. * exponential to prevent steep falloff artifacts).
  9535. */
  9536. useCloseExponentialShadowMap: boolean;
  9537. /**
  9538. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9539. * exponential to prevent steep falloff artifacts).
  9540. */
  9541. /**
  9542. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9543. * exponential to prevent steep falloff artifacts).
  9544. */
  9545. useBlurCloseExponentialShadowMap: boolean;
  9546. /**
  9547. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCF" (percentage closer filtering).
  9551. */
  9552. usePercentageCloserFiltering: boolean;
  9553. private _filteringQuality;
  9554. /**
  9555. * Gets the PCF or PCSS Quality.
  9556. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9557. */
  9558. /**
  9559. * Sets the PCF or PCSS Quality.
  9560. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9561. */
  9562. filteringQuality: number;
  9563. /**
  9564. * Gets if the current filter is set to "PCSS" (contact hardening).
  9565. */
  9566. /**
  9567. * Sets the current filter to "PCSS" (contact hardening).
  9568. */
  9569. useContactHardeningShadow: boolean;
  9570. private _contactHardeningLightSizeUVRatio;
  9571. /**
  9572. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9573. * Using a ratio helps keeping shape stability independently of the map size.
  9574. *
  9575. * It does not account for the light projection as it was having too much
  9576. * instability during the light setup or during light position changes.
  9577. *
  9578. * Only valid if useContactHardeningShadow is true.
  9579. */
  9580. /**
  9581. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9582. * Using a ratio helps keeping shape stability independently of the map size.
  9583. *
  9584. * It does not account for the light projection as it was having too much
  9585. * instability during the light setup or during light position changes.
  9586. *
  9587. * Only valid if useContactHardeningShadow is true.
  9588. */
  9589. contactHardeningLightSizeUVRatio: number;
  9590. private _darkness;
  9591. /** Gets or sets the actual darkness of a shadow */
  9592. darkness: number;
  9593. /**
  9594. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9595. * 0 means strongest and 1 would means no shadow.
  9596. * @returns the darkness.
  9597. */
  9598. getDarkness(): number;
  9599. /**
  9600. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9601. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9602. * @returns the shadow generator allowing fluent coding.
  9603. */
  9604. setDarkness(darkness: number): ShadowGenerator;
  9605. private _transparencyShadow;
  9606. /** Gets or sets the ability to have transparent shadow */
  9607. transparencyShadow: boolean;
  9608. /**
  9609. * Sets the ability to have transparent shadow (boolean).
  9610. * @param transparent True if transparent else False
  9611. * @returns the shadow generator allowing fluent coding
  9612. */
  9613. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9614. private _shadowMap;
  9615. private _shadowMap2;
  9616. /**
  9617. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9618. * @returns The render target texture if present otherwise, null
  9619. */
  9620. getShadowMap(): Nullable<RenderTargetTexture>;
  9621. /**
  9622. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9623. * @returns The render target texture if the shadow map is present otherwise, null
  9624. */
  9625. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9626. /**
  9627. * Gets the class name of that object
  9628. * @returns "ShadowGenerator"
  9629. */
  9630. getClassName(): string;
  9631. /**
  9632. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9633. * @param mesh Mesh to add
  9634. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9640. * @param mesh Mesh to remove
  9641. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9642. * @returns the Shadow Generator itself
  9643. */
  9644. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9645. /**
  9646. * Controls the extent to which the shadows fade out at the edge of the frustum
  9647. * Used only by directionals and spots
  9648. */
  9649. frustumEdgeFalloff: number;
  9650. private _light;
  9651. /**
  9652. * Returns the associated light object.
  9653. * @returns the light generating the shadow
  9654. */
  9655. getLight(): IShadowLight;
  9656. /**
  9657. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9658. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9659. * It might on the other hand introduce peter panning.
  9660. */
  9661. forceBackFacesOnly: boolean;
  9662. private _scene;
  9663. private _lightDirection;
  9664. private _effect;
  9665. private _viewMatrix;
  9666. private _projectionMatrix;
  9667. private _transformMatrix;
  9668. private _cachedPosition;
  9669. private _cachedDirection;
  9670. private _cachedDefines;
  9671. private _currentRenderID;
  9672. private _boxBlurPostprocess;
  9673. private _kernelBlurXPostprocess;
  9674. private _kernelBlurYPostprocess;
  9675. private _blurPostProcesses;
  9676. private _mapSize;
  9677. private _currentFaceIndex;
  9678. private _currentFaceIndexCache;
  9679. private _textureType;
  9680. private _defaultTextureMatrix;
  9681. /** @hidden */
  9682. static _SceneComponentInitialization: (scene: Scene) => void;
  9683. /**
  9684. * Creates a ShadowGenerator object.
  9685. * A ShadowGenerator is the required tool to use the shadows.
  9686. * Each light casting shadows needs to use its own ShadowGenerator.
  9687. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9688. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9689. * @param light The light object generating the shadows.
  9690. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9691. */
  9692. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9693. private _initializeGenerator;
  9694. private _initializeShadowMap;
  9695. private _initializeBlurRTTAndPostProcesses;
  9696. private _renderForShadowMap;
  9697. private _renderSubMeshForShadowMap;
  9698. private _applyFilterValues;
  9699. /**
  9700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9701. * @param onCompiled Callback triggered at the and of the effects compilation
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. */
  9704. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9705. useInstances: boolean;
  9706. }>): void;
  9707. /**
  9708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9709. * @param options Sets of optional options forcing the compilation with different modes
  9710. * @returns A promise that resolves when the compilation completes
  9711. */
  9712. forceCompilationAsync(options?: Partial<{
  9713. useInstances: boolean;
  9714. }>): Promise<void>;
  9715. /**
  9716. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9717. * @param subMesh The submesh we want to render in the shadow map
  9718. * @param useInstances Defines wether will draw in the map using instances
  9719. * @returns true if ready otherwise, false
  9720. */
  9721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9722. /**
  9723. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9724. * @param defines Defines of the material we want to update
  9725. * @param lightIndex Index of the light in the enabled light list of the material
  9726. */
  9727. prepareDefines(defines: any, lightIndex: number): void;
  9728. /**
  9729. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9730. * defined in the generator but impacting the effect).
  9731. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9732. * @param effect The effect we are binfing the information for
  9733. */
  9734. bindShadowLight(lightIndex: string, effect: Effect): void;
  9735. /**
  9736. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9737. * (eq to shadow prjection matrix * light transform matrix)
  9738. * @returns The transform matrix used to create the shadow map
  9739. */
  9740. getTransformMatrix(): Matrix;
  9741. /**
  9742. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9743. * Cube and 2D textures for instance.
  9744. */
  9745. recreateShadowMap(): void;
  9746. private _disposeBlurPostProcesses;
  9747. private _disposeRTTandPostProcesses;
  9748. /**
  9749. * Disposes the ShadowGenerator.
  9750. * Returns nothing.
  9751. */
  9752. dispose(): void;
  9753. /**
  9754. * Serializes the shadow generator setup to a json object.
  9755. * @returns The serialized JSON object
  9756. */
  9757. serialize(): any;
  9758. /**
  9759. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9760. * @param parsedShadowGenerator The JSON object to parse
  9761. * @param scene The scene to create the shadow map for
  9762. * @returns The parsed shadow generator
  9763. */
  9764. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9765. }
  9766. }
  9767. declare module "babylonjs/Lights/light" {
  9768. import { Nullable } from "babylonjs/types";
  9769. import { Scene } from "babylonjs/scene";
  9770. import { Vector3 } from "babylonjs/Maths/math.vector";
  9771. import { Color3 } from "babylonjs/Maths/math.color";
  9772. import { Node } from "babylonjs/node";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { Effect } from "babylonjs/Materials/effect";
  9775. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9776. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9777. /**
  9778. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9779. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9780. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9781. */
  9782. export abstract class Light extends Node {
  9783. /**
  9784. * Falloff Default: light is falling off following the material specification:
  9785. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9786. */
  9787. static readonly FALLOFF_DEFAULT: number;
  9788. /**
  9789. * Falloff Physical: light is falling off following the inverse squared distance law.
  9790. */
  9791. static readonly FALLOFF_PHYSICAL: number;
  9792. /**
  9793. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9794. * to enhance interoperability with other engines.
  9795. */
  9796. static readonly FALLOFF_GLTF: number;
  9797. /**
  9798. * Falloff Standard: light is falling off like in the standard material
  9799. * to enhance interoperability with other materials.
  9800. */
  9801. static readonly FALLOFF_STANDARD: number;
  9802. /**
  9803. * If every light affecting the material is in this lightmapMode,
  9804. * material.lightmapTexture adds or multiplies
  9805. * (depends on material.useLightmapAsShadowmap)
  9806. * after every other light calculations.
  9807. */
  9808. static readonly LIGHTMAP_DEFAULT: number;
  9809. /**
  9810. * material.lightmapTexture as only diffuse lighting from this light
  9811. * adds only specular lighting from this light
  9812. * adds dynamic shadows
  9813. */
  9814. static readonly LIGHTMAP_SPECULAR: number;
  9815. /**
  9816. * material.lightmapTexture as only lighting
  9817. * no light calculation from this light
  9818. * only adds dynamic shadows from this light
  9819. */
  9820. static readonly LIGHTMAP_SHADOWSONLY: number;
  9821. /**
  9822. * Each light type uses the default quantity according to its type:
  9823. * point/spot lights use luminous intensity
  9824. * directional lights use illuminance
  9825. */
  9826. static readonly INTENSITYMODE_AUTOMATIC: number;
  9827. /**
  9828. * lumen (lm)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9831. /**
  9832. * candela (lm/sr)
  9833. */
  9834. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9835. /**
  9836. * lux (lm/m^2)
  9837. */
  9838. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9839. /**
  9840. * nit (cd/m^2)
  9841. */
  9842. static readonly INTENSITYMODE_LUMINANCE: number;
  9843. /**
  9844. * Light type const id of the point light.
  9845. */
  9846. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9847. /**
  9848. * Light type const id of the directional light.
  9849. */
  9850. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9851. /**
  9852. * Light type const id of the spot light.
  9853. */
  9854. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9855. /**
  9856. * Light type const id of the hemispheric light.
  9857. */
  9858. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9859. /**
  9860. * Diffuse gives the basic color to an object.
  9861. */
  9862. diffuse: Color3;
  9863. /**
  9864. * Specular produces a highlight color on an object.
  9865. * Note: This is note affecting PBR materials.
  9866. */
  9867. specular: Color3;
  9868. /**
  9869. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9870. * falling off base on range or angle.
  9871. * This can be set to any values in Light.FALLOFF_x.
  9872. *
  9873. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9874. * other types of materials.
  9875. */
  9876. falloffType: number;
  9877. /**
  9878. * Strength of the light.
  9879. * Note: By default it is define in the framework own unit.
  9880. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9881. */
  9882. intensity: number;
  9883. private _range;
  9884. protected _inverseSquaredRange: number;
  9885. /**
  9886. * Defines how far from the source the light is impacting in scene units.
  9887. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9888. */
  9889. /**
  9890. * Defines how far from the source the light is impacting in scene units.
  9891. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9892. */
  9893. range: number;
  9894. /**
  9895. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9896. * of light.
  9897. */
  9898. private _photometricScale;
  9899. private _intensityMode;
  9900. /**
  9901. * Gets the photometric scale used to interpret the intensity.
  9902. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9903. */
  9904. /**
  9905. * Sets the photometric scale used to interpret the intensity.
  9906. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9907. */
  9908. intensityMode: number;
  9909. private _radius;
  9910. /**
  9911. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9912. */
  9913. /**
  9914. * sets the light radius used by PBR Materials to simulate soft area lights.
  9915. */
  9916. radius: number;
  9917. private _renderPriority;
  9918. /**
  9919. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9920. * exceeding the number allowed of the materials.
  9921. */
  9922. renderPriority: number;
  9923. private _shadowEnabled;
  9924. /**
  9925. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9926. * the current shadow generator.
  9927. */
  9928. /**
  9929. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9930. * the current shadow generator.
  9931. */
  9932. shadowEnabled: boolean;
  9933. private _includedOnlyMeshes;
  9934. /**
  9935. * Gets the only meshes impacted by this light.
  9936. */
  9937. /**
  9938. * Sets the only meshes impacted by this light.
  9939. */
  9940. includedOnlyMeshes: AbstractMesh[];
  9941. private _excludedMeshes;
  9942. /**
  9943. * Gets the meshes not impacted by this light.
  9944. */
  9945. /**
  9946. * Sets the meshes not impacted by this light.
  9947. */
  9948. excludedMeshes: AbstractMesh[];
  9949. private _excludeWithLayerMask;
  9950. /**
  9951. * Gets the layer id use to find what meshes are not impacted by the light.
  9952. * Inactive if 0
  9953. */
  9954. /**
  9955. * Sets the layer id use to find what meshes are not impacted by the light.
  9956. * Inactive if 0
  9957. */
  9958. excludeWithLayerMask: number;
  9959. private _includeOnlyWithLayerMask;
  9960. /**
  9961. * Gets the layer id use to find what meshes are impacted by the light.
  9962. * Inactive if 0
  9963. */
  9964. /**
  9965. * Sets the layer id use to find what meshes are impacted by the light.
  9966. * Inactive if 0
  9967. */
  9968. includeOnlyWithLayerMask: number;
  9969. private _lightmapMode;
  9970. /**
  9971. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9972. */
  9973. /**
  9974. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9975. */
  9976. lightmapMode: number;
  9977. /**
  9978. * Shadow generator associted to the light.
  9979. * @hidden Internal use only.
  9980. */
  9981. _shadowGenerator: Nullable<IShadowGenerator>;
  9982. /**
  9983. * @hidden Internal use only.
  9984. */
  9985. _excludedMeshesIds: string[];
  9986. /**
  9987. * @hidden Internal use only.
  9988. */
  9989. _includedOnlyMeshesIds: string[];
  9990. /**
  9991. * The current light unifom buffer.
  9992. * @hidden Internal use only.
  9993. */
  9994. _uniformBuffer: UniformBuffer;
  9995. /**
  9996. * Creates a Light object in the scene.
  9997. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9998. * @param name The firendly name of the light
  9999. * @param scene The scene the light belongs too
  10000. */
  10001. constructor(name: string, scene: Scene);
  10002. protected abstract _buildUniformLayout(): void;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightIndex The index of the light in the effect to update
  10007. * @returns The light
  10008. */
  10009. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10010. /**
  10011. * Sets the passed Effect "effect" with the Light information.
  10012. * @param effect The effect to update
  10013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10014. * @returns The light
  10015. */
  10016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10017. /**
  10018. * Returns the string "Light".
  10019. * @returns the class name
  10020. */
  10021. getClassName(): string;
  10022. /** @hidden */
  10023. readonly _isLight: boolean;
  10024. /**
  10025. * Converts the light information to a readable string for debug purpose.
  10026. * @param fullDetails Supports for multiple levels of logging within scene loading
  10027. * @returns the human readable light info
  10028. */
  10029. toString(fullDetails?: boolean): string;
  10030. /** @hidden */
  10031. protected _syncParentEnabledState(): void;
  10032. /**
  10033. * Set the enabled state of this node.
  10034. * @param value - the new enabled state
  10035. */
  10036. setEnabled(value: boolean): void;
  10037. /**
  10038. * Returns the Light associated shadow generator if any.
  10039. * @return the associated shadow generator.
  10040. */
  10041. getShadowGenerator(): Nullable<IShadowGenerator>;
  10042. /**
  10043. * Returns a Vector3, the absolute light position in the World.
  10044. * @returns the world space position of the light
  10045. */
  10046. getAbsolutePosition(): Vector3;
  10047. /**
  10048. * Specifies if the light will affect the passed mesh.
  10049. * @param mesh The mesh to test against the light
  10050. * @return true the mesh is affected otherwise, false.
  10051. */
  10052. canAffectMesh(mesh: AbstractMesh): boolean;
  10053. /**
  10054. * Sort function to order lights for rendering.
  10055. * @param a First Light object to compare to second.
  10056. * @param b Second Light object to compare first.
  10057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10058. */
  10059. static CompareLightsPriority(a: Light, b: Light): number;
  10060. /**
  10061. * Releases resources associated with this node.
  10062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10064. */
  10065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10066. /**
  10067. * Returns the light type ID (integer).
  10068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10069. */
  10070. getTypeID(): number;
  10071. /**
  10072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10073. * @returns the scaled intensity in intensity mode unit
  10074. */
  10075. getScaledIntensity(): number;
  10076. /**
  10077. * Returns a new Light object, named "name", from the current one.
  10078. * @param name The name of the cloned light
  10079. * @returns the new created light
  10080. */
  10081. clone(name: string): Nullable<Light>;
  10082. /**
  10083. * Serializes the current light into a Serialization object.
  10084. * @returns the serialized object.
  10085. */
  10086. serialize(): any;
  10087. /**
  10088. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10089. * This new light is named "name" and added to the passed scene.
  10090. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10091. * @param name The friendly name of the light
  10092. * @param scene The scene the new light will belong to
  10093. * @returns the constructor function
  10094. */
  10095. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10096. /**
  10097. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10098. * @param parsedLight The JSON representation of the light
  10099. * @param scene The scene to create the parsed light in
  10100. * @returns the created light after parsing
  10101. */
  10102. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10103. private _hookArrayForExcluded;
  10104. private _hookArrayForIncludedOnly;
  10105. private _resyncMeshes;
  10106. /**
  10107. * Forces the meshes to update their light related information in their rendering used effects
  10108. * @hidden Internal Use Only
  10109. */
  10110. _markMeshesAsLightDirty(): void;
  10111. /**
  10112. * Recomputes the cached photometric scale if needed.
  10113. */
  10114. private _computePhotometricScale;
  10115. /**
  10116. * Returns the Photometric Scale according to the light type and intensity mode.
  10117. */
  10118. private _getPhotometricScale;
  10119. /**
  10120. * Reorder the light in the scene according to their defined priority.
  10121. * @hidden Internal Use Only
  10122. */
  10123. _reorderLightsInScene(): void;
  10124. /**
  10125. * Prepares the list of defines specific to the light type.
  10126. * @param defines the list of defines
  10127. * @param lightIndex defines the index of the light for the effect
  10128. */
  10129. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10130. }
  10131. }
  10132. declare module "babylonjs/Actions/action" {
  10133. import { Observable } from "babylonjs/Misc/observable";
  10134. import { Condition } from "babylonjs/Actions/condition";
  10135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10136. import { ActionManager } from "babylonjs/Actions/actionManager";
  10137. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10138. /**
  10139. * Interface used to define Action
  10140. */
  10141. export interface IAction {
  10142. /**
  10143. * Trigger for the action
  10144. */
  10145. trigger: number;
  10146. /** Options of the trigger */
  10147. triggerOptions: any;
  10148. /**
  10149. * Gets the trigger parameters
  10150. * @returns the trigger parameters
  10151. */
  10152. getTriggerParameter(): any;
  10153. /**
  10154. * Internal only - executes current action event
  10155. * @hidden
  10156. */
  10157. _executeCurrent(evt?: ActionEvent): void;
  10158. /**
  10159. * Serialize placeholder for child classes
  10160. * @param parent of child
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _prepare(): void;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: AbstractActionManager;
  10174. /**
  10175. * Adds action to chain of actions, may be a DoNothingAction
  10176. * @param action defines the next action to execute
  10177. * @returns The action passed in
  10178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10179. */
  10180. then(action: IAction): IAction;
  10181. }
  10182. /**
  10183. * The action to be carried out following a trigger
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10185. */
  10186. export class Action implements IAction {
  10187. /** the trigger, with or without parameters, for the action */
  10188. triggerOptions: any;
  10189. /**
  10190. * Trigger for the action
  10191. */
  10192. trigger: number;
  10193. /**
  10194. * Internal only - manager for action
  10195. * @hidden
  10196. */
  10197. _actionManager: ActionManager;
  10198. private _nextActiveAction;
  10199. private _child;
  10200. private _condition?;
  10201. private _triggerParameter;
  10202. /**
  10203. * An event triggered prior to action being executed.
  10204. */
  10205. onBeforeExecuteObservable: Observable<Action>;
  10206. /**
  10207. * Creates a new Action
  10208. * @param triggerOptions the trigger, with or without parameters, for the action
  10209. * @param condition an optional determinant of action
  10210. */
  10211. constructor(
  10212. /** the trigger, with or without parameters, for the action */
  10213. triggerOptions: any, condition?: Condition);
  10214. /**
  10215. * Internal only
  10216. * @hidden
  10217. */
  10218. _prepare(): void;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Execute placeholder for child classes
  10231. * @param evt optional action event
  10232. */
  10233. execute(evt?: ActionEvent): void;
  10234. /**
  10235. * Skips to next active action
  10236. */
  10237. skipToNextActiveAction(): void;
  10238. /**
  10239. * Adds action to chain of actions, may be a DoNothingAction
  10240. * @param action defines the next action to execute
  10241. * @returns The action passed in
  10242. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10243. */
  10244. then(action: Action): Action;
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _getProperty(propertyPath: string): string;
  10250. /**
  10251. * Internal only
  10252. * @hidden
  10253. */
  10254. _getEffectiveTarget(target: any, propertyPath: string): any;
  10255. /**
  10256. * Serialize placeholder for child classes
  10257. * @param parent of child
  10258. * @returns the serialized object
  10259. */
  10260. serialize(parent: any): any;
  10261. /**
  10262. * Internal only called by serialize
  10263. * @hidden
  10264. */
  10265. protected _serialize(serializedAction: any, parent?: any): any;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. static _SerializeValueAsString: (value: any) => string;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10276. name: string;
  10277. targetType: string;
  10278. value: string;
  10279. };
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/condition" {
  10283. import { ActionManager } from "babylonjs/Actions/actionManager";
  10284. /**
  10285. * A Condition applied to an Action
  10286. */
  10287. export class Condition {
  10288. /**
  10289. * Internal only - manager for action
  10290. * @hidden
  10291. */
  10292. _actionManager: ActionManager;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _evaluationId: number;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. _currentResult: boolean;
  10303. /**
  10304. * Creates a new Condition
  10305. * @param actionManager the manager of the action the condition is applied to
  10306. */
  10307. constructor(actionManager: ActionManager);
  10308. /**
  10309. * Check if the current condition is valid
  10310. * @returns a boolean
  10311. */
  10312. isValid(): boolean;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. _getProperty(propertyPath: string): string;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /**
  10324. * Serialize placeholder for child classes
  10325. * @returns the serialized object
  10326. */
  10327. serialize(): any;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. protected _serialize(serializedCondition: any): any;
  10333. }
  10334. /**
  10335. * Defines specific conditional operators as extensions of Condition
  10336. */
  10337. export class ValueCondition extends Condition {
  10338. /** path to specify the property of the target the conditional operator uses */
  10339. propertyPath: string;
  10340. /** the value compared by the conditional operator against the current value of the property */
  10341. value: any;
  10342. /** the conditional operator, default ValueCondition.IsEqual */
  10343. operator: number;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. private static _IsEqual;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. private static _IsDifferent;
  10354. /**
  10355. * Internal only
  10356. * @hidden
  10357. */
  10358. private static _IsGreater;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. private static _IsLesser;
  10364. /**
  10365. * returns the number for IsEqual
  10366. */
  10367. static readonly IsEqual: number;
  10368. /**
  10369. * Returns the number for IsDifferent
  10370. */
  10371. static readonly IsDifferent: number;
  10372. /**
  10373. * Returns the number for IsGreater
  10374. */
  10375. static readonly IsGreater: number;
  10376. /**
  10377. * Returns the number for IsLesser
  10378. */
  10379. static readonly IsLesser: number;
  10380. /**
  10381. * Internal only The action manager for the condition
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private _effectiveTarget;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private _property;
  10400. /**
  10401. * Creates a new ValueCondition
  10402. * @param actionManager manager for the action the condition applies to
  10403. * @param target for the action
  10404. * @param propertyPath path to specify the property of the target the conditional operator uses
  10405. * @param value the value compared by the conditional operator against the current value of the property
  10406. * @param operator the conditional operator, default ValueCondition.IsEqual
  10407. */
  10408. constructor(actionManager: ActionManager, target: any,
  10409. /** path to specify the property of the target the conditional operator uses */
  10410. propertyPath: string,
  10411. /** the value compared by the conditional operator against the current value of the property */
  10412. value: any,
  10413. /** the conditional operator, default ValueCondition.IsEqual */
  10414. operator?: number);
  10415. /**
  10416. * Compares the given value with the property value for the specified conditional operator
  10417. * @returns the result of the comparison
  10418. */
  10419. isValid(): boolean;
  10420. /**
  10421. * Serialize the ValueCondition into a JSON compatible object
  10422. * @returns serialization object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Gets the name of the conditional operator for the ValueCondition
  10427. * @param operator the conditional operator
  10428. * @returns the name
  10429. */
  10430. static GetOperatorName(operator: number): string;
  10431. }
  10432. /**
  10433. * Defines a predicate condition as an extension of Condition
  10434. */
  10435. export class PredicateCondition extends Condition {
  10436. /** defines the predicate function used to validate the condition */
  10437. predicate: () => boolean;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Creates a new PredicateCondition
  10445. * @param actionManager manager for the action the condition applies to
  10446. * @param predicate defines the predicate function used to validate the condition
  10447. */
  10448. constructor(actionManager: ActionManager,
  10449. /** defines the predicate function used to validate the condition */
  10450. predicate: () => boolean);
  10451. /**
  10452. * @returns the validity of the predicate condition
  10453. */
  10454. isValid(): boolean;
  10455. }
  10456. /**
  10457. * Defines a state condition as an extension of Condition
  10458. */
  10459. export class StateCondition extends Condition {
  10460. /** Value to compare with target state */
  10461. value: string;
  10462. /**
  10463. * Internal only - manager for action
  10464. * @hidden
  10465. */
  10466. _actionManager: ActionManager;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. private _target;
  10472. /**
  10473. * Creates a new StateCondition
  10474. * @param actionManager manager for the action the condition applies to
  10475. * @param target of the condition
  10476. * @param value to compare with target state
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** Value to compare with target state */
  10480. value: string);
  10481. /**
  10482. * Gets a boolean indicating if the current condition is met
  10483. * @returns the validity of the state
  10484. */
  10485. isValid(): boolean;
  10486. /**
  10487. * Serialize the StateCondition into a JSON compatible object
  10488. * @returns serialization object
  10489. */
  10490. serialize(): any;
  10491. }
  10492. }
  10493. declare module "babylonjs/Actions/directActions" {
  10494. import { Action } from "babylonjs/Actions/action";
  10495. import { Condition } from "babylonjs/Actions/condition";
  10496. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10497. /**
  10498. * This defines an action responsible to toggle a boolean once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SwitchBooleanAction extends Action {
  10502. /**
  10503. * The path to the boolean property in the target object
  10504. */
  10505. propertyPath: string;
  10506. private _target;
  10507. private _effectiveTarget;
  10508. private _property;
  10509. /**
  10510. * Instantiate the action
  10511. * @param triggerOptions defines the trigger options
  10512. * @param target defines the object containing the boolean
  10513. * @param propertyPath defines the path to the boolean property in the target object
  10514. * @param condition defines the trigger related conditions
  10515. */
  10516. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10517. /** @hidden */
  10518. _prepare(): void;
  10519. /**
  10520. * Execute the action toggle the boolean value.
  10521. */
  10522. execute(): void;
  10523. /**
  10524. * Serializes the actions and its related information.
  10525. * @param parent defines the object to serialize in
  10526. * @returns the serialized object
  10527. */
  10528. serialize(parent: any): any;
  10529. }
  10530. /**
  10531. * This defines an action responsible to set a the state field of the target
  10532. * to a desired value once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class SetStateAction extends Action {
  10536. /**
  10537. * The value to store in the state field.
  10538. */
  10539. value: string;
  10540. private _target;
  10541. /**
  10542. * Instantiate the action
  10543. * @param triggerOptions defines the trigger options
  10544. * @param target defines the object containing the state property
  10545. * @param value defines the value to store in the state field
  10546. * @param condition defines the trigger related conditions
  10547. */
  10548. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10549. /**
  10550. * Execute the action and store the value on the target state property.
  10551. */
  10552. execute(): void;
  10553. /**
  10554. * Serializes the actions and its related information.
  10555. * @param parent defines the object to serialize in
  10556. * @returns the serialized object
  10557. */
  10558. serialize(parent: any): any;
  10559. }
  10560. /**
  10561. * This defines an action responsible to set a property of the target
  10562. * to a desired value once triggered.
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10564. */
  10565. export class SetValueAction extends Action {
  10566. /**
  10567. * The path of the property to set in the target.
  10568. */
  10569. propertyPath: string;
  10570. /**
  10571. * The value to set in the property
  10572. */
  10573. value: any;
  10574. private _target;
  10575. private _effectiveTarget;
  10576. private _property;
  10577. /**
  10578. * Instantiate the action
  10579. * @param triggerOptions defines the trigger options
  10580. * @param target defines the object containing the property
  10581. * @param propertyPath defines the path of the property to set in the target
  10582. * @param value defines the value to set in the property
  10583. * @param condition defines the trigger related conditions
  10584. */
  10585. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10586. /** @hidden */
  10587. _prepare(): void;
  10588. /**
  10589. * Execute the action and set the targetted property to the desired value.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to increment the target value
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class IncrementValueAction extends Action {
  10605. /**
  10606. * The path of the property to increment in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value we should increment the property by.
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to increment in the target
  10621. * @param value defines the value value we should increment the property by
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and increment the target of the value amount.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to start an animation once triggered.
  10640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10641. */
  10642. export class PlayAnimationAction extends Action {
  10643. /**
  10644. * Where the animation should start (animation frame)
  10645. */
  10646. from: number;
  10647. /**
  10648. * Where the animation should stop (animation frame)
  10649. */
  10650. to: number;
  10651. /**
  10652. * Define if the animation should loop or stop after the first play.
  10653. */
  10654. loop?: boolean;
  10655. private _target;
  10656. /**
  10657. * Instantiate the action
  10658. * @param triggerOptions defines the trigger options
  10659. * @param target defines the target animation or animation name
  10660. * @param from defines from where the animation should start (animation frame)
  10661. * @param end defines where the animation should stop (animation frame)
  10662. * @param loop defines if the animation should loop or stop after the first play
  10663. * @param condition defines the trigger related conditions
  10664. */
  10665. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10666. /** @hidden */
  10667. _prepare(): void;
  10668. /**
  10669. * Execute the action and play the animation.
  10670. */
  10671. execute(): void;
  10672. /**
  10673. * Serializes the actions and its related information.
  10674. * @param parent defines the object to serialize in
  10675. * @returns the serialized object
  10676. */
  10677. serialize(parent: any): any;
  10678. }
  10679. /**
  10680. * This defines an action responsible to stop an animation once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class StopAnimationAction extends Action {
  10684. private _target;
  10685. /**
  10686. * Instantiate the action
  10687. * @param triggerOptions defines the trigger options
  10688. * @param target defines the target animation or animation name
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and stop the animation.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible that does nothing once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class DoNothingAction extends Action {
  10710. /**
  10711. * Instantiate the action
  10712. * @param triggerOptions defines the trigger options
  10713. * @param condition defines the trigger related conditions
  10714. */
  10715. constructor(triggerOptions?: any, condition?: Condition);
  10716. /**
  10717. * Execute the action and do nothing.
  10718. */
  10719. execute(): void;
  10720. /**
  10721. * Serializes the actions and its related information.
  10722. * @param parent defines the object to serialize in
  10723. * @returns the serialized object
  10724. */
  10725. serialize(parent: any): any;
  10726. }
  10727. /**
  10728. * This defines an action responsible to trigger several actions once triggered.
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10730. */
  10731. export class CombineAction extends Action {
  10732. /**
  10733. * The list of aggregated animations to run.
  10734. */
  10735. children: Action[];
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param children defines the list of aggregated animations to run
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10743. /** @hidden */
  10744. _prepare(): void;
  10745. /**
  10746. * Execute the action and executes all the aggregated actions.
  10747. */
  10748. execute(evt: ActionEvent): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible to run code (external event) once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class ExecuteCodeAction extends Action {
  10761. /**
  10762. * The callback function to run.
  10763. */
  10764. func: (evt: ActionEvent) => void;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param func defines the callback function to run
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10772. /**
  10773. * Execute the action and run the attached code.
  10774. */
  10775. execute(evt: ActionEvent): void;
  10776. }
  10777. /**
  10778. * This defines an action responsible to set the parent property of the target once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class SetParentAction extends Action {
  10782. private _parent;
  10783. private _target;
  10784. /**
  10785. * Instantiate the action
  10786. * @param triggerOptions defines the trigger options
  10787. * @param target defines the target containing the parent property
  10788. * @param parent defines from where the animation should start (animation frame)
  10789. * @param condition defines the trigger related conditions
  10790. */
  10791. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10792. /** @hidden */
  10793. _prepare(): void;
  10794. /**
  10795. * Execute the action and set the parent property.
  10796. */
  10797. execute(): void;
  10798. /**
  10799. * Serializes the actions and its related information.
  10800. * @param parent defines the object to serialize in
  10801. * @returns the serialized object
  10802. */
  10803. serialize(parent: any): any;
  10804. }
  10805. }
  10806. declare module "babylonjs/Actions/actionManager" {
  10807. import { Nullable } from "babylonjs/types";
  10808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10809. import { Scene } from "babylonjs/scene";
  10810. import { IAction } from "babylonjs/Actions/action";
  10811. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10812. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10813. /**
  10814. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10815. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class ActionManager extends AbstractActionManager {
  10819. /**
  10820. * Nothing
  10821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10822. */
  10823. static readonly NothingTrigger: number;
  10824. /**
  10825. * On pick
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10827. */
  10828. static readonly OnPickTrigger: number;
  10829. /**
  10830. * On left pick
  10831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10832. */
  10833. static readonly OnLeftPickTrigger: number;
  10834. /**
  10835. * On right pick
  10836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10837. */
  10838. static readonly OnRightPickTrigger: number;
  10839. /**
  10840. * On center pick
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10842. */
  10843. static readonly OnCenterPickTrigger: number;
  10844. /**
  10845. * On pick down
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10847. */
  10848. static readonly OnPickDownTrigger: number;
  10849. /**
  10850. * On double pick
  10851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10852. */
  10853. static readonly OnDoublePickTrigger: number;
  10854. /**
  10855. * On pick up
  10856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10857. */
  10858. static readonly OnPickUpTrigger: number;
  10859. /**
  10860. * On pick out.
  10861. * This trigger will only be raised if you also declared a OnPickDown
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnPickOutTrigger: number;
  10865. /**
  10866. * On long press
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnLongPressTrigger: number;
  10870. /**
  10871. * On pointer over
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnPointerOverTrigger: number;
  10875. /**
  10876. * On pointer out
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPointerOutTrigger: number;
  10880. /**
  10881. * On every frame
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnEveryFrameTrigger: number;
  10885. /**
  10886. * On intersection enter
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnIntersectionEnterTrigger: number;
  10890. /**
  10891. * On intersection exit
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnIntersectionExitTrigger: number;
  10895. /**
  10896. * On key down
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnKeyDownTrigger: number;
  10900. /**
  10901. * On key up
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnKeyUpTrigger: number;
  10905. private _scene;
  10906. /**
  10907. * Creates a new action manager
  10908. * @param scene defines the hosting scene
  10909. */
  10910. constructor(scene: Scene);
  10911. /**
  10912. * Releases all associated resources
  10913. */
  10914. dispose(): void;
  10915. /**
  10916. * Gets hosting scene
  10917. * @returns the hosting scene
  10918. */
  10919. getScene(): Scene;
  10920. /**
  10921. * Does this action manager handles actions of any of the given triggers
  10922. * @param triggers defines the triggers to be tested
  10923. * @return a boolean indicating whether one (or more) of the triggers is handled
  10924. */
  10925. hasSpecificTriggers(triggers: number[]): boolean;
  10926. /**
  10927. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10928. * speed.
  10929. * @param triggerA defines the trigger to be tested
  10930. * @param triggerB defines the trigger to be tested
  10931. * @return a boolean indicating whether one (or more) of the triggers is handled
  10932. */
  10933. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10934. /**
  10935. * Does this action manager handles actions of a given trigger
  10936. * @param trigger defines the trigger to be tested
  10937. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10938. * @return whether the trigger is handled
  10939. */
  10940. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10941. /**
  10942. * Does this action manager has pointer triggers
  10943. */
  10944. readonly hasPointerTriggers: boolean;
  10945. /**
  10946. * Does this action manager has pick triggers
  10947. */
  10948. readonly hasPickTriggers: boolean;
  10949. /**
  10950. * Registers an action to this action manager
  10951. * @param action defines the action to be registered
  10952. * @return the action amended (prepared) after registration
  10953. */
  10954. registerAction(action: IAction): Nullable<IAction>;
  10955. /**
  10956. * Unregisters an action to this action manager
  10957. * @param action defines the action to be unregistered
  10958. * @return a boolean indicating whether the action has been unregistered
  10959. */
  10960. unregisterAction(action: IAction): Boolean;
  10961. /**
  10962. * Process a specific trigger
  10963. * @param trigger defines the trigger to process
  10964. * @param evt defines the event details to be processed
  10965. */
  10966. processTrigger(trigger: number, evt?: IActionEvent): void;
  10967. /** @hidden */
  10968. _getEffectiveTarget(target: any, propertyPath: string): any;
  10969. /** @hidden */
  10970. _getProperty(propertyPath: string): string;
  10971. /**
  10972. * Serialize this manager to a JSON object
  10973. * @param name defines the property name to store this manager
  10974. * @returns a JSON representation of this manager
  10975. */
  10976. serialize(name: string): any;
  10977. /**
  10978. * Creates a new ActionManager from a JSON data
  10979. * @param parsedActions defines the JSON data to read from
  10980. * @param object defines the hosting mesh
  10981. * @param scene defines the hosting scene
  10982. */
  10983. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10984. /**
  10985. * Get a trigger name by index
  10986. * @param trigger defines the trigger index
  10987. * @returns a trigger name
  10988. */
  10989. static GetTriggerName(trigger: number): string;
  10990. }
  10991. }
  10992. declare module "babylonjs/Culling/ray" {
  10993. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10994. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10997. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10998. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10999. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11000. import { Plane } from "babylonjs/Maths/math.plane";
  11001. /**
  11002. * Class representing a ray with position and direction
  11003. */
  11004. export class Ray {
  11005. /** origin point */
  11006. origin: Vector3;
  11007. /** direction */
  11008. direction: Vector3;
  11009. /** length of the ray */
  11010. length: number;
  11011. private static readonly TmpVector3;
  11012. private _tmpRay;
  11013. /**
  11014. * Creates a new ray
  11015. * @param origin origin point
  11016. * @param direction direction
  11017. * @param length length of the ray
  11018. */
  11019. constructor(
  11020. /** origin point */
  11021. origin: Vector3,
  11022. /** direction */
  11023. direction: Vector3,
  11024. /** length of the ray */
  11025. length?: number);
  11026. /**
  11027. * Checks if the ray intersects a box
  11028. * @param minimum bound of the box
  11029. * @param maximum bound of the box
  11030. * @param intersectionTreshold extra extend to be added to the box in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * Checks if the ray intersects a box
  11036. * @param box the bounding box to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11038. * @returns if the box was hit
  11039. */
  11040. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a sphere
  11043. * @param sphere the bounding sphere to check
  11044. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11045. * @returns true if it hits the sphere
  11046. */
  11047. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11048. /**
  11049. * If the ray hits a triange
  11050. * @param vertex0 triangle vertex
  11051. * @param vertex1 triangle vertex
  11052. * @param vertex2 triangle vertex
  11053. * @returns intersection information if hit
  11054. */
  11055. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11056. /**
  11057. * Checks if ray intersects a plane
  11058. * @param plane the plane to check
  11059. * @returns the distance away it was hit
  11060. */
  11061. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11062. /**
  11063. * Calculate the intercept of a ray on a given axis
  11064. * @param axis to check 'x' | 'y' | 'z'
  11065. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11066. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11067. */
  11068. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param mesh the mesh to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @returns picking info of the intersecton
  11074. */
  11075. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11076. /**
  11077. * Checks if ray intersects a mesh
  11078. * @param meshes the meshes to check
  11079. * @param fastCheck if only the bounding box should checked
  11080. * @param results array to store result in
  11081. * @returns Array of picking infos
  11082. */
  11083. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11084. private _comparePickingInfo;
  11085. private static smallnum;
  11086. private static rayl;
  11087. /**
  11088. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11089. * @param sega the first point of the segment to test the intersection against
  11090. * @param segb the second point of the segment to test the intersection against
  11091. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11092. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11093. */
  11094. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11095. /**
  11096. * Update the ray from viewport position
  11097. * @param x position
  11098. * @param y y position
  11099. * @param viewportWidth viewport width
  11100. * @param viewportHeight viewport height
  11101. * @param world world matrix
  11102. * @param view view matrix
  11103. * @param projection projection matrix
  11104. * @returns this ray updated
  11105. */
  11106. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11107. /**
  11108. * Creates a ray with origin and direction of 0,0,0
  11109. * @returns the new ray
  11110. */
  11111. static Zero(): Ray;
  11112. /**
  11113. * Creates a new ray from screen space and viewport
  11114. * @param x position
  11115. * @param y y position
  11116. * @param viewportWidth viewport width
  11117. * @param viewportHeight viewport height
  11118. * @param world world matrix
  11119. * @param view view matrix
  11120. * @param projection projection matrix
  11121. * @returns new ray
  11122. */
  11123. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11124. /**
  11125. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11126. * transformed to the given world matrix.
  11127. * @param origin The origin point
  11128. * @param end The end point
  11129. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11130. * @returns the new ray
  11131. */
  11132. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @returns the resulting new ray
  11138. */
  11139. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11140. /**
  11141. * Transforms a ray by a matrix
  11142. * @param ray ray to transform
  11143. * @param matrix matrix to apply
  11144. * @param result ray to store result in
  11145. */
  11146. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11147. /**
  11148. * Unproject a ray from screen space to object space
  11149. * @param sourceX defines the screen space x coordinate to use
  11150. * @param sourceY defines the screen space y coordinate to use
  11151. * @param viewportWidth defines the current width of the viewport
  11152. * @param viewportHeight defines the current height of the viewport
  11153. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11154. * @param view defines the view matrix to use
  11155. * @param projection defines the projection matrix to use
  11156. */
  11157. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11158. }
  11159. /**
  11160. * Type used to define predicate used to select faces when a mesh intersection is detected
  11161. */
  11162. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11163. module "babylonjs/scene" {
  11164. interface Scene {
  11165. /** @hidden */
  11166. _tempPickingRay: Nullable<Ray>;
  11167. /** @hidden */
  11168. _cachedRayForTransform: Ray;
  11169. /** @hidden */
  11170. _pickWithRayInverseMatrix: Matrix;
  11171. /** @hidden */
  11172. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11173. /** @hidden */
  11174. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11175. }
  11176. }
  11177. }
  11178. declare module "babylonjs/sceneComponent" {
  11179. import { Scene } from "babylonjs/scene";
  11180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11181. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11182. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11183. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11184. import { Nullable } from "babylonjs/types";
  11185. import { Camera } from "babylonjs/Cameras/camera";
  11186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11187. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11188. import { AbstractScene } from "babylonjs/abstractScene";
  11189. /**
  11190. * Groups all the scene component constants in one place to ease maintenance.
  11191. * @hidden
  11192. */
  11193. export class SceneComponentConstants {
  11194. static readonly NAME_EFFECTLAYER: string;
  11195. static readonly NAME_LAYER: string;
  11196. static readonly NAME_LENSFLARESYSTEM: string;
  11197. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11198. static readonly NAME_PARTICLESYSTEM: string;
  11199. static readonly NAME_GAMEPAD: string;
  11200. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11201. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11202. static readonly NAME_DEPTHRENDERER: string;
  11203. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11204. static readonly NAME_SPRITE: string;
  11205. static readonly NAME_OUTLINERENDERER: string;
  11206. static readonly NAME_PROCEDURALTEXTURE: string;
  11207. static readonly NAME_SHADOWGENERATOR: string;
  11208. static readonly NAME_OCTREE: string;
  11209. static readonly NAME_PHYSICSENGINE: string;
  11210. static readonly NAME_AUDIO: string;
  11211. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11212. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11213. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11216. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11217. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11218. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11219. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11220. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11221. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11222. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11223. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11224. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11225. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11226. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11227. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11228. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11229. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11230. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11231. static readonly STEP_AFTERRENDER_AUDIO: number;
  11232. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11233. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11235. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11236. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11237. static readonly STEP_POINTERMOVE_SPRITE: number;
  11238. static readonly STEP_POINTERDOWN_SPRITE: number;
  11239. static readonly STEP_POINTERUP_SPRITE: number;
  11240. }
  11241. /**
  11242. * This represents a scene component.
  11243. *
  11244. * This is used to decouple the dependency the scene is having on the different workloads like
  11245. * layers, post processes...
  11246. */
  11247. export interface ISceneComponent {
  11248. /**
  11249. * The name of the component. Each component must have a unique name.
  11250. */
  11251. name: string;
  11252. /**
  11253. * The scene the component belongs to.
  11254. */
  11255. scene: Scene;
  11256. /**
  11257. * Register the component to one instance of a scene.
  11258. */
  11259. register(): void;
  11260. /**
  11261. * Rebuilds the elements related to this component in case of
  11262. * context lost for instance.
  11263. */
  11264. rebuild(): void;
  11265. /**
  11266. * Disposes the component and the associated ressources.
  11267. */
  11268. dispose(): void;
  11269. }
  11270. /**
  11271. * This represents a SERIALIZABLE scene component.
  11272. *
  11273. * This extends Scene Component to add Serialization methods on top.
  11274. */
  11275. export interface ISceneSerializableComponent extends ISceneComponent {
  11276. /**
  11277. * Adds all the elements from the container to the scene
  11278. * @param container the container holding the elements
  11279. */
  11280. addFromContainer(container: AbstractScene): void;
  11281. /**
  11282. * Removes all the elements in the container from the scene
  11283. * @param container contains the elements to remove
  11284. * @param dispose if the removed element should be disposed (default: false)
  11285. */
  11286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11287. /**
  11288. * Serializes the component data to the specified json object
  11289. * @param serializationObject The object to serialize to
  11290. */
  11291. serialize(serializationObject: any): void;
  11292. }
  11293. /**
  11294. * Strong typing of a Mesh related stage step action
  11295. */
  11296. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11297. /**
  11298. * Strong typing of a Evaluate Sub Mesh related stage step action
  11299. */
  11300. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11301. /**
  11302. * Strong typing of a Active Mesh related stage step action
  11303. */
  11304. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11305. /**
  11306. * Strong typing of a Camera related stage step action
  11307. */
  11308. export type CameraStageAction = (camera: Camera) => void;
  11309. /**
  11310. * Strong typing of a Camera Frame buffer related stage step action
  11311. */
  11312. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11313. /**
  11314. * Strong typing of a Render Target related stage step action
  11315. */
  11316. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11317. /**
  11318. * Strong typing of a RenderingGroup related stage step action
  11319. */
  11320. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11321. /**
  11322. * Strong typing of a Mesh Render related stage step action
  11323. */
  11324. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11325. /**
  11326. * Strong typing of a simple stage step action
  11327. */
  11328. export type SimpleStageAction = () => void;
  11329. /**
  11330. * Strong typing of a render target action.
  11331. */
  11332. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11333. /**
  11334. * Strong typing of a pointer move action.
  11335. */
  11336. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11337. /**
  11338. * Strong typing of a pointer up/down action.
  11339. */
  11340. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11341. /**
  11342. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11343. * @hidden
  11344. */
  11345. export class Stage<T extends Function> extends Array<{
  11346. index: number;
  11347. component: ISceneComponent;
  11348. action: T;
  11349. }> {
  11350. /**
  11351. * Hide ctor from the rest of the world.
  11352. * @param items The items to add.
  11353. */
  11354. private constructor();
  11355. /**
  11356. * Creates a new Stage.
  11357. * @returns A new instance of a Stage
  11358. */
  11359. static Create<T extends Function>(): Stage<T>;
  11360. /**
  11361. * Registers a step in an ordered way in the targeted stage.
  11362. * @param index Defines the position to register the step in
  11363. * @param component Defines the component attached to the step
  11364. * @param action Defines the action to launch during the step
  11365. */
  11366. registerStep(index: number, component: ISceneComponent, action: T): void;
  11367. /**
  11368. * Clears all the steps from the stage.
  11369. */
  11370. clear(): void;
  11371. }
  11372. }
  11373. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11374. import { Nullable } from "babylonjs/types";
  11375. import { Observable } from "babylonjs/Misc/observable";
  11376. import { Scene } from "babylonjs/scene";
  11377. import { Sprite } from "babylonjs/Sprites/sprite";
  11378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11379. import { Ray } from "babylonjs/Culling/ray";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11382. import { ISceneComponent } from "babylonjs/sceneComponent";
  11383. module "babylonjs/scene" {
  11384. interface Scene {
  11385. /** @hidden */
  11386. _pointerOverSprite: Nullable<Sprite>;
  11387. /** @hidden */
  11388. _pickedDownSprite: Nullable<Sprite>;
  11389. /** @hidden */
  11390. _tempSpritePickingRay: Nullable<Ray>;
  11391. /**
  11392. * All of the sprite managers added to this scene
  11393. * @see http://doc.babylonjs.com/babylon101/sprites
  11394. */
  11395. spriteManagers: Array<ISpriteManager>;
  11396. /**
  11397. * An event triggered when sprites rendering is about to start
  11398. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11399. */
  11400. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11401. /**
  11402. * An event triggered when sprites rendering is done
  11403. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11404. */
  11405. onAfterSpritesRenderingObservable: Observable<Scene>;
  11406. /** @hidden */
  11407. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11408. /** Launch a ray to try to pick a sprite in the scene
  11409. * @param x position on screen
  11410. * @param y position on screen
  11411. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11412. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11413. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11414. * @returns a PickingInfo
  11415. */
  11416. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11417. /** Use the given ray to pick a sprite in the scene
  11418. * @param ray The ray (in world space) to use to pick meshes
  11419. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11420. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11421. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11422. * @returns a PickingInfo
  11423. */
  11424. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11425. /** @hidden */
  11426. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11427. /** Launch a ray to try to pick sprites in the scene
  11428. * @param x position on screen
  11429. * @param y position on screen
  11430. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11431. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /** Use the given ray to pick sprites in the scene
  11436. * @param ray The ray (in world space) to use to pick meshes
  11437. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11438. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11439. * @returns a PickingInfo array
  11440. */
  11441. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11442. /**
  11443. * Force the sprite under the pointer
  11444. * @param sprite defines the sprite to use
  11445. */
  11446. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11447. /**
  11448. * Gets the sprite under the pointer
  11449. * @returns a Sprite or null if no sprite is under the pointer
  11450. */
  11451. getPointerOverSprite(): Nullable<Sprite>;
  11452. }
  11453. }
  11454. /**
  11455. * Defines the sprite scene component responsible to manage sprites
  11456. * in a given scene.
  11457. */
  11458. export class SpriteSceneComponent implements ISceneComponent {
  11459. /**
  11460. * The component name helpfull to identify the component in the list of scene components.
  11461. */
  11462. readonly name: string;
  11463. /**
  11464. * The scene the component belongs to.
  11465. */
  11466. scene: Scene;
  11467. /** @hidden */
  11468. private _spritePredicate;
  11469. /**
  11470. * Creates a new instance of the component for the given scene
  11471. * @param scene Defines the scene to register the component in
  11472. */
  11473. constructor(scene: Scene);
  11474. /**
  11475. * Registers the component in a given scene
  11476. */
  11477. register(): void;
  11478. /**
  11479. * Rebuilds the elements related to this component in case of
  11480. * context lost for instance.
  11481. */
  11482. rebuild(): void;
  11483. /**
  11484. * Disposes the component and the associated ressources.
  11485. */
  11486. dispose(): void;
  11487. private _pickSpriteButKeepRay;
  11488. private _pointerMove;
  11489. private _pointerDown;
  11490. private _pointerUp;
  11491. }
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11494. /** @hidden */
  11495. export var fogFragmentDeclaration: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11501. /** @hidden */
  11502. export var fogFragment: {
  11503. name: string;
  11504. shader: string;
  11505. };
  11506. }
  11507. declare module "babylonjs/Shaders/sprites.fragment" {
  11508. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11510. /** @hidden */
  11511. export var spritesPixelShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11517. /** @hidden */
  11518. export var fogVertexDeclaration: {
  11519. name: string;
  11520. shader: string;
  11521. };
  11522. }
  11523. declare module "babylonjs/Shaders/sprites.vertex" {
  11524. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11525. /** @hidden */
  11526. export var spritesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Sprites/spriteManager" {
  11532. import { IDisposable, Scene } from "babylonjs/scene";
  11533. import { Nullable } from "babylonjs/types";
  11534. import { Observable } from "babylonjs/Misc/observable";
  11535. import { Sprite } from "babylonjs/Sprites/sprite";
  11536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11537. import { Camera } from "babylonjs/Cameras/camera";
  11538. import { Texture } from "babylonjs/Materials/Textures/texture";
  11539. import "babylonjs/Shaders/sprites.fragment";
  11540. import "babylonjs/Shaders/sprites.vertex";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. /**
  11543. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11544. */
  11545. export interface ISpriteManager extends IDisposable {
  11546. /**
  11547. * Restricts the camera to viewing objects with the same layerMask.
  11548. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11549. */
  11550. layerMask: number;
  11551. /**
  11552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11553. */
  11554. isPickable: boolean;
  11555. /**
  11556. * Specifies the rendering group id for this mesh (0 by default)
  11557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11558. */
  11559. renderingGroupId: number;
  11560. /**
  11561. * Defines the list of sprites managed by the manager.
  11562. */
  11563. sprites: Array<Sprite>;
  11564. /**
  11565. * Tests the intersection of a sprite with a specific ray.
  11566. * @param ray The ray we are sending to test the collision
  11567. * @param camera The camera space we are sending rays in
  11568. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11569. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11570. * @returns picking info or null.
  11571. */
  11572. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11573. /**
  11574. * Intersects the sprites with a ray
  11575. * @param ray defines the ray to intersect with
  11576. * @param camera defines the current active camera
  11577. * @param predicate defines a predicate used to select candidate sprites
  11578. * @returns null if no hit or a PickingInfo array
  11579. */
  11580. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11581. /**
  11582. * Renders the list of sprites on screen.
  11583. */
  11584. render(): void;
  11585. }
  11586. /**
  11587. * Class used to manage multiple sprites on the same spritesheet
  11588. * @see http://doc.babylonjs.com/babylon101/sprites
  11589. */
  11590. export class SpriteManager implements ISpriteManager {
  11591. /** defines the manager's name */
  11592. name: string;
  11593. /** Gets the list of sprites */
  11594. sprites: Sprite[];
  11595. /** Gets or sets the rendering group id (0 by default) */
  11596. renderingGroupId: number;
  11597. /** Gets or sets camera layer mask */
  11598. layerMask: number;
  11599. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11600. fogEnabled: boolean;
  11601. /** Gets or sets a boolean indicating if the sprites are pickable */
  11602. isPickable: boolean;
  11603. /** Defines the default width of a cell in the spritesheet */
  11604. cellWidth: number;
  11605. /** Defines the default height of a cell in the spritesheet */
  11606. cellHeight: number;
  11607. /** Associative array from JSON sprite data file */
  11608. private _cellData;
  11609. /** Array of sprite names from JSON sprite data file */
  11610. private _spriteMap;
  11611. /** True when packed cell data from JSON file is ready*/
  11612. private _packedAndReady;
  11613. /**
  11614. * An event triggered when the manager is disposed.
  11615. */
  11616. onDisposeObservable: Observable<SpriteManager>;
  11617. private _onDisposeObserver;
  11618. /**
  11619. * Callback called when the manager is disposed
  11620. */
  11621. onDispose: () => void;
  11622. private _capacity;
  11623. private _fromPacked;
  11624. private _spriteTexture;
  11625. private _epsilon;
  11626. private _scene;
  11627. private _vertexData;
  11628. private _buffer;
  11629. private _vertexBuffers;
  11630. private _indexBuffer;
  11631. private _effectBase;
  11632. private _effectFog;
  11633. /**
  11634. * Gets or sets the spritesheet texture
  11635. */
  11636. texture: Texture;
  11637. /**
  11638. * Creates a new sprite manager
  11639. * @param name defines the manager's name
  11640. * @param imgUrl defines the sprite sheet url
  11641. * @param capacity defines the maximum allowed number of sprites
  11642. * @param cellSize defines the size of a sprite cell
  11643. * @param scene defines the hosting scene
  11644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11645. * @param samplingMode defines the smapling mode to use with spritesheet
  11646. * @param fromPacked set to false; do not alter
  11647. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11648. */
  11649. constructor(
  11650. /** defines the manager's name */
  11651. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11652. private _makePacked;
  11653. private _appendSpriteVertex;
  11654. /**
  11655. * Intersects the sprites with a ray
  11656. * @param ray defines the ray to intersect with
  11657. * @param camera defines the current active camera
  11658. * @param predicate defines a predicate used to select candidate sprites
  11659. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11660. * @returns null if no hit or a PickingInfo
  11661. */
  11662. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11663. /**
  11664. * Intersects the sprites with a ray
  11665. * @param ray defines the ray to intersect with
  11666. * @param camera defines the current active camera
  11667. * @param predicate defines a predicate used to select candidate sprites
  11668. * @returns null if no hit or a PickingInfo array
  11669. */
  11670. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11671. /**
  11672. * Render all child sprites
  11673. */
  11674. render(): void;
  11675. /**
  11676. * Release associated resources
  11677. */
  11678. dispose(): void;
  11679. }
  11680. }
  11681. declare module "babylonjs/Sprites/sprite" {
  11682. import { Vector3 } from "babylonjs/Maths/math.vector";
  11683. import { Nullable } from "babylonjs/types";
  11684. import { ActionManager } from "babylonjs/Actions/actionManager";
  11685. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11686. import { Color4 } from "babylonjs/Maths/math.color";
  11687. /**
  11688. * Class used to represent a sprite
  11689. * @see http://doc.babylonjs.com/babylon101/sprites
  11690. */
  11691. export class Sprite {
  11692. /** defines the name */
  11693. name: string;
  11694. /** Gets or sets the current world position */
  11695. position: Vector3;
  11696. /** Gets or sets the main color */
  11697. color: Color4;
  11698. /** Gets or sets the width */
  11699. width: number;
  11700. /** Gets or sets the height */
  11701. height: number;
  11702. /** Gets or sets rotation angle */
  11703. angle: number;
  11704. /** Gets or sets the cell index in the sprite sheet */
  11705. cellIndex: number;
  11706. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11707. cellRef: string;
  11708. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11709. invertU: number;
  11710. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11711. invertV: number;
  11712. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11713. disposeWhenFinishedAnimating: boolean;
  11714. /** Gets the list of attached animations */
  11715. animations: Animation[];
  11716. /** Gets or sets a boolean indicating if the sprite can be picked */
  11717. isPickable: boolean;
  11718. /**
  11719. * Gets or sets the associated action manager
  11720. */
  11721. actionManager: Nullable<ActionManager>;
  11722. private _animationStarted;
  11723. private _loopAnimation;
  11724. private _fromIndex;
  11725. private _toIndex;
  11726. private _delay;
  11727. private _direction;
  11728. private _manager;
  11729. private _time;
  11730. private _onAnimationEnd;
  11731. /**
  11732. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11733. */
  11734. isVisible: boolean;
  11735. /**
  11736. * Gets or sets the sprite size
  11737. */
  11738. size: number;
  11739. /**
  11740. * Creates a new Sprite
  11741. * @param name defines the name
  11742. * @param manager defines the manager
  11743. */
  11744. constructor(
  11745. /** defines the name */
  11746. name: string, manager: ISpriteManager);
  11747. /**
  11748. * Starts an animation
  11749. * @param from defines the initial key
  11750. * @param to defines the end key
  11751. * @param loop defines if the animation must loop
  11752. * @param delay defines the start delay (in ms)
  11753. * @param onAnimationEnd defines a callback to call when animation ends
  11754. */
  11755. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11756. /** Stops current animation (if any) */
  11757. stopAnimation(): void;
  11758. /** @hidden */
  11759. _animate(deltaTime: number): void;
  11760. /** Release associated resources */
  11761. dispose(): void;
  11762. }
  11763. }
  11764. declare module "babylonjs/Collisions/pickingInfo" {
  11765. import { Nullable } from "babylonjs/types";
  11766. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { Ray } from "babylonjs/Culling/ray";
  11770. /**
  11771. * Information about the result of picking within a scene
  11772. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11773. */
  11774. export class PickingInfo {
  11775. /** @hidden */
  11776. _pickingUnavailable: boolean;
  11777. /**
  11778. * If the pick collided with an object
  11779. */
  11780. hit: boolean;
  11781. /**
  11782. * Distance away where the pick collided
  11783. */
  11784. distance: number;
  11785. /**
  11786. * The location of pick collision
  11787. */
  11788. pickedPoint: Nullable<Vector3>;
  11789. /**
  11790. * The mesh corresponding the the pick collision
  11791. */
  11792. pickedMesh: Nullable<AbstractMesh>;
  11793. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11794. bu: number;
  11795. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11796. bv: number;
  11797. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11798. faceId: number;
  11799. /** Id of the the submesh that was picked */
  11800. subMeshId: number;
  11801. /** If a sprite was picked, this will be the sprite the pick collided with */
  11802. pickedSprite: Nullable<Sprite>;
  11803. /**
  11804. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11805. */
  11806. originMesh: Nullable<AbstractMesh>;
  11807. /**
  11808. * The ray that was used to perform the picking.
  11809. */
  11810. ray: Nullable<Ray>;
  11811. /**
  11812. * Gets the normal correspodning to the face the pick collided with
  11813. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11814. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11815. * @returns The normal correspodning to the face the pick collided with
  11816. */
  11817. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11818. /**
  11819. * Gets the texture coordinates of where the pick occured
  11820. * @returns the vector containing the coordnates of the texture
  11821. */
  11822. getTextureCoordinates(): Nullable<Vector2>;
  11823. }
  11824. }
  11825. declare module "babylonjs/Events/pointerEvents" {
  11826. import { Nullable } from "babylonjs/types";
  11827. import { Vector2 } from "babylonjs/Maths/math.vector";
  11828. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11829. import { Ray } from "babylonjs/Culling/ray";
  11830. /**
  11831. * Gather the list of pointer event types as constants.
  11832. */
  11833. export class PointerEventTypes {
  11834. /**
  11835. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11836. */
  11837. static readonly POINTERDOWN: number;
  11838. /**
  11839. * The pointerup event is fired when a pointer is no longer active.
  11840. */
  11841. static readonly POINTERUP: number;
  11842. /**
  11843. * The pointermove event is fired when a pointer changes coordinates.
  11844. */
  11845. static readonly POINTERMOVE: number;
  11846. /**
  11847. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11848. */
  11849. static readonly POINTERWHEEL: number;
  11850. /**
  11851. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11852. */
  11853. static readonly POINTERPICK: number;
  11854. /**
  11855. * The pointertap event is fired when a the object has been touched and released without drag.
  11856. */
  11857. static readonly POINTERTAP: number;
  11858. /**
  11859. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11860. */
  11861. static readonly POINTERDOUBLETAP: number;
  11862. }
  11863. /**
  11864. * Base class of pointer info types.
  11865. */
  11866. export class PointerInfoBase {
  11867. /**
  11868. * Defines the type of event (PointerEventTypes)
  11869. */
  11870. type: number;
  11871. /**
  11872. * Defines the related dom event
  11873. */
  11874. event: PointerEvent | MouseWheelEvent;
  11875. /**
  11876. * Instantiates the base class of pointers info.
  11877. * @param type Defines the type of event (PointerEventTypes)
  11878. * @param event Defines the related dom event
  11879. */
  11880. constructor(
  11881. /**
  11882. * Defines the type of event (PointerEventTypes)
  11883. */
  11884. type: number,
  11885. /**
  11886. * Defines the related dom event
  11887. */
  11888. event: PointerEvent | MouseWheelEvent);
  11889. }
  11890. /**
  11891. * This class is used to store pointer related info for the onPrePointerObservable event.
  11892. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11893. */
  11894. export class PointerInfoPre extends PointerInfoBase {
  11895. /**
  11896. * Ray from a pointer if availible (eg. 6dof controller)
  11897. */
  11898. ray: Nullable<Ray>;
  11899. /**
  11900. * Defines the local position of the pointer on the canvas.
  11901. */
  11902. localPosition: Vector2;
  11903. /**
  11904. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11905. */
  11906. skipOnPointerObservable: boolean;
  11907. /**
  11908. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11909. * @param type Defines the type of event (PointerEventTypes)
  11910. * @param event Defines the related dom event
  11911. * @param localX Defines the local x coordinates of the pointer when the event occured
  11912. * @param localY Defines the local y coordinates of the pointer when the event occured
  11913. */
  11914. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11915. }
  11916. /**
  11917. * This type contains all the data related to a pointer event in Babylon.js.
  11918. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11919. */
  11920. export class PointerInfo extends PointerInfoBase {
  11921. /**
  11922. * Defines the picking info associated to the info (if any)\
  11923. */
  11924. pickInfo: Nullable<PickingInfo>;
  11925. /**
  11926. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11927. * @param type Defines the type of event (PointerEventTypes)
  11928. * @param event Defines the related dom event
  11929. * @param pickInfo Defines the picking info associated to the info (if any)\
  11930. */
  11931. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11932. /**
  11933. * Defines the picking info associated to the info (if any)\
  11934. */
  11935. pickInfo: Nullable<PickingInfo>);
  11936. }
  11937. /**
  11938. * Data relating to a touch event on the screen.
  11939. */
  11940. export interface PointerTouch {
  11941. /**
  11942. * X coordinate of touch.
  11943. */
  11944. x: number;
  11945. /**
  11946. * Y coordinate of touch.
  11947. */
  11948. y: number;
  11949. /**
  11950. * Id of touch. Unique for each finger.
  11951. */
  11952. pointerId: number;
  11953. /**
  11954. * Event type passed from DOM.
  11955. */
  11956. type: any;
  11957. }
  11958. }
  11959. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11960. import { Observable } from "babylonjs/Misc/observable";
  11961. import { Nullable } from "babylonjs/types";
  11962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11963. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11964. /**
  11965. * Manage the mouse inputs to control the movement of a free camera.
  11966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11967. */
  11968. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11969. /**
  11970. * Define if touch is enabled in the mouse input
  11971. */
  11972. touchEnabled: boolean;
  11973. /**
  11974. * Defines the camera the input is attached to.
  11975. */
  11976. camera: FreeCamera;
  11977. /**
  11978. * Defines the buttons associated with the input to handle camera move.
  11979. */
  11980. buttons: number[];
  11981. /**
  11982. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11983. */
  11984. angularSensibility: number;
  11985. private _pointerInput;
  11986. private _onMouseMove;
  11987. private _observer;
  11988. private previousPosition;
  11989. /**
  11990. * Observable for when a pointer move event occurs containing the move offset
  11991. */
  11992. onPointerMovedObservable: Observable<{
  11993. offsetX: number;
  11994. offsetY: number;
  11995. }>;
  11996. /**
  11997. * @hidden
  11998. * If the camera should be rotated automatically based on pointer movement
  11999. */
  12000. _allowCameraRotation: boolean;
  12001. /**
  12002. * Manage the mouse inputs to control the movement of a free camera.
  12003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12004. * @param touchEnabled Defines if touch is enabled or not
  12005. */
  12006. constructor(
  12007. /**
  12008. * Define if touch is enabled in the mouse input
  12009. */
  12010. touchEnabled?: boolean);
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Called on JS contextmenu event.
  12019. * Override this method to provide functionality.
  12020. */
  12021. protected onContextMenu(evt: PointerEvent): void;
  12022. /**
  12023. * Detach the current controls from the specified dom element.
  12024. * @param element Defines the element to stop listening the inputs from
  12025. */
  12026. detachControl(element: Nullable<HTMLElement>): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12040. import { Nullable } from "babylonjs/types";
  12041. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12043. /**
  12044. * Manage the touch inputs to control the movement of a free camera.
  12045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12046. */
  12047. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12048. /**
  12049. * Defines the camera the input is attached to.
  12050. */
  12051. camera: FreeCamera;
  12052. /**
  12053. * Defines the touch sensibility for rotation.
  12054. * The higher the faster.
  12055. */
  12056. touchAngularSensibility: number;
  12057. /**
  12058. * Defines the touch sensibility for move.
  12059. * The higher the faster.
  12060. */
  12061. touchMoveSensibility: number;
  12062. private _offsetX;
  12063. private _offsetY;
  12064. private _pointerPressed;
  12065. private _pointerInput;
  12066. private _observer;
  12067. private _onLostFocus;
  12068. /**
  12069. * Attach the input controls to a specific dom element to get the input from.
  12070. * @param element Defines the element the controls should be listened from
  12071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12072. */
  12073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12074. /**
  12075. * Detach the current controls from the specified dom element.
  12076. * @param element Defines the element to stop listening the inputs from
  12077. */
  12078. detachControl(element: Nullable<HTMLElement>): void;
  12079. /**
  12080. * Update the current camera state depending on the inputs that have been used this frame.
  12081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12082. */
  12083. checkInputs(): void;
  12084. /**
  12085. * Gets the class name of the current intput.
  12086. * @returns the class name
  12087. */
  12088. getClassName(): string;
  12089. /**
  12090. * Get the friendly name associated with the input class.
  12091. * @returns the input friendly name
  12092. */
  12093. getSimpleName(): string;
  12094. }
  12095. }
  12096. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12098. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12099. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12100. import { Nullable } from "babylonjs/types";
  12101. /**
  12102. * Default Inputs manager for the FreeCamera.
  12103. * It groups all the default supported inputs for ease of use.
  12104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12105. */
  12106. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12107. /**
  12108. * @hidden
  12109. */
  12110. _mouseInput: Nullable<FreeCameraMouseInput>;
  12111. /**
  12112. * Instantiates a new FreeCameraInputsManager.
  12113. * @param camera Defines the camera the inputs belong to
  12114. */
  12115. constructor(camera: FreeCamera);
  12116. /**
  12117. * Add keyboard input support to the input manager.
  12118. * @returns the current input manager
  12119. */
  12120. addKeyboard(): FreeCameraInputsManager;
  12121. /**
  12122. * Add mouse input support to the input manager.
  12123. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12124. * @returns the current input manager
  12125. */
  12126. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12127. /**
  12128. * Removes the mouse input support from the manager
  12129. * @returns the current input manager
  12130. */
  12131. removeMouse(): FreeCameraInputsManager;
  12132. /**
  12133. * Add touch input support to the input manager.
  12134. * @returns the current input manager
  12135. */
  12136. addTouch(): FreeCameraInputsManager;
  12137. /**
  12138. * Remove all attached input methods from a camera
  12139. */
  12140. clear(): void;
  12141. }
  12142. }
  12143. declare module "babylonjs/Cameras/freeCamera" {
  12144. import { Vector3 } from "babylonjs/Maths/math.vector";
  12145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12146. import { Scene } from "babylonjs/scene";
  12147. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12148. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12149. /**
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. */
  12154. export class FreeCamera extends TargetCamera {
  12155. /**
  12156. * Define the collision ellipsoid of the camera.
  12157. * This is helpful to simulate a camera body like the player body around the camera
  12158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12159. */
  12160. ellipsoid: Vector3;
  12161. /**
  12162. * Define an offset for the position of the ellipsoid around the camera.
  12163. * This can be helpful to determine the center of the body near the gravity center of the body
  12164. * instead of its head.
  12165. */
  12166. ellipsoidOffset: Vector3;
  12167. /**
  12168. * Enable or disable collisions of the camera with the rest of the scene objects.
  12169. */
  12170. checkCollisions: boolean;
  12171. /**
  12172. * Enable or disable gravity on the camera.
  12173. */
  12174. applyGravity: boolean;
  12175. /**
  12176. * Define the input manager associated to the camera.
  12177. */
  12178. inputs: FreeCameraInputsManager;
  12179. /**
  12180. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12181. * Higher values reduce sensitivity.
  12182. */
  12183. /**
  12184. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12185. * Higher values reduce sensitivity.
  12186. */
  12187. angularSensibility: number;
  12188. /**
  12189. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12190. */
  12191. keysUp: number[];
  12192. /**
  12193. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12194. */
  12195. keysDown: number[];
  12196. /**
  12197. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12198. */
  12199. keysLeft: number[];
  12200. /**
  12201. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12202. */
  12203. keysRight: number[];
  12204. /**
  12205. * Event raised when the camera collide with a mesh in the scene.
  12206. */
  12207. onCollide: (collidedMesh: AbstractMesh) => void;
  12208. private _collider;
  12209. private _needMoveForGravity;
  12210. private _oldPosition;
  12211. private _diffPosition;
  12212. private _newPosition;
  12213. /** @hidden */
  12214. _localDirection: Vector3;
  12215. /** @hidden */
  12216. _transformedDirection: Vector3;
  12217. /**
  12218. * Instantiates a Free Camera.
  12219. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12220. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12222. * @param name Define the name of the camera in the scene
  12223. * @param position Define the start position of the camera in the scene
  12224. * @param scene Define the scene the camera belongs to
  12225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12226. */
  12227. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12228. /**
  12229. * Attached controls to the current camera.
  12230. * @param element Defines the element the controls should be listened from
  12231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12232. */
  12233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12234. /**
  12235. * Detach the current controls from the camera.
  12236. * The camera will stop reacting to inputs.
  12237. * @param element Defines the element to stop listening the inputs from
  12238. */
  12239. detachControl(element: HTMLElement): void;
  12240. private _collisionMask;
  12241. /**
  12242. * Define a collision mask to limit the list of object the camera can collide with
  12243. */
  12244. collisionMask: number;
  12245. /** @hidden */
  12246. _collideWithWorld(displacement: Vector3): void;
  12247. private _onCollisionPositionChange;
  12248. /** @hidden */
  12249. _checkInputs(): void;
  12250. /** @hidden */
  12251. _decideIfNeedsToMove(): boolean;
  12252. /** @hidden */
  12253. _updatePosition(): void;
  12254. /**
  12255. * Destroy the camera and release the current resources hold by it.
  12256. */
  12257. dispose(): void;
  12258. /**
  12259. * Gets the current object class name.
  12260. * @return the class name
  12261. */
  12262. getClassName(): string;
  12263. }
  12264. }
  12265. declare module "babylonjs/Gamepads/gamepad" {
  12266. import { Observable } from "babylonjs/Misc/observable";
  12267. /**
  12268. * Represents a gamepad control stick position
  12269. */
  12270. export class StickValues {
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number;
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number;
  12279. /**
  12280. * Initializes the gamepad x and y control stick values
  12281. * @param x The x component of the gamepad control stick value
  12282. * @param y The y component of the gamepad control stick value
  12283. */
  12284. constructor(
  12285. /**
  12286. * The x component of the control stick
  12287. */
  12288. x: number,
  12289. /**
  12290. * The y component of the control stick
  12291. */
  12292. y: number);
  12293. }
  12294. /**
  12295. * An interface which manages callbacks for gamepad button changes
  12296. */
  12297. export interface GamepadButtonChanges {
  12298. /**
  12299. * Called when a gamepad has been changed
  12300. */
  12301. changed: boolean;
  12302. /**
  12303. * Called when a gamepad press event has been triggered
  12304. */
  12305. pressChanged: boolean;
  12306. /**
  12307. * Called when a touch event has been triggered
  12308. */
  12309. touchChanged: boolean;
  12310. /**
  12311. * Called when a value has changed
  12312. */
  12313. valueChanged: boolean;
  12314. }
  12315. /**
  12316. * Represents a gamepad
  12317. */
  12318. export class Gamepad {
  12319. /**
  12320. * The id of the gamepad
  12321. */
  12322. id: string;
  12323. /**
  12324. * The index of the gamepad
  12325. */
  12326. index: number;
  12327. /**
  12328. * The browser gamepad
  12329. */
  12330. browserGamepad: any;
  12331. /**
  12332. * Specifies what type of gamepad this represents
  12333. */
  12334. type: number;
  12335. private _leftStick;
  12336. private _rightStick;
  12337. /** @hidden */
  12338. _isConnected: boolean;
  12339. private _leftStickAxisX;
  12340. private _leftStickAxisY;
  12341. private _rightStickAxisX;
  12342. private _rightStickAxisY;
  12343. /**
  12344. * Triggered when the left control stick has been changed
  12345. */
  12346. private _onleftstickchanged;
  12347. /**
  12348. * Triggered when the right control stick has been changed
  12349. */
  12350. private _onrightstickchanged;
  12351. /**
  12352. * Represents a gamepad controller
  12353. */
  12354. static GAMEPAD: number;
  12355. /**
  12356. * Represents a generic controller
  12357. */
  12358. static GENERIC: number;
  12359. /**
  12360. * Represents an XBox controller
  12361. */
  12362. static XBOX: number;
  12363. /**
  12364. * Represents a pose-enabled controller
  12365. */
  12366. static POSE_ENABLED: number;
  12367. /**
  12368. * Represents an Dual Shock controller
  12369. */
  12370. static DUALSHOCK: number;
  12371. /**
  12372. * Specifies whether the left control stick should be Y-inverted
  12373. */
  12374. protected _invertLeftStickY: boolean;
  12375. /**
  12376. * Specifies if the gamepad has been connected
  12377. */
  12378. readonly isConnected: boolean;
  12379. /**
  12380. * Initializes the gamepad
  12381. * @param id The id of the gamepad
  12382. * @param index The index of the gamepad
  12383. * @param browserGamepad The browser gamepad
  12384. * @param leftStickX The x component of the left joystick
  12385. * @param leftStickY The y component of the left joystick
  12386. * @param rightStickX The x component of the right joystick
  12387. * @param rightStickY The y component of the right joystick
  12388. */
  12389. constructor(
  12390. /**
  12391. * The id of the gamepad
  12392. */
  12393. id: string,
  12394. /**
  12395. * The index of the gamepad
  12396. */
  12397. index: number,
  12398. /**
  12399. * The browser gamepad
  12400. */
  12401. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12402. /**
  12403. * Callback triggered when the left joystick has changed
  12404. * @param callback
  12405. */
  12406. onleftstickchanged(callback: (values: StickValues) => void): void;
  12407. /**
  12408. * Callback triggered when the right joystick has changed
  12409. * @param callback
  12410. */
  12411. onrightstickchanged(callback: (values: StickValues) => void): void;
  12412. /**
  12413. * Gets the left joystick
  12414. */
  12415. /**
  12416. * Sets the left joystick values
  12417. */
  12418. leftStick: StickValues;
  12419. /**
  12420. * Gets the right joystick
  12421. */
  12422. /**
  12423. * Sets the right joystick value
  12424. */
  12425. rightStick: StickValues;
  12426. /**
  12427. * Updates the gamepad joystick positions
  12428. */
  12429. update(): void;
  12430. /**
  12431. * Disposes the gamepad
  12432. */
  12433. dispose(): void;
  12434. }
  12435. /**
  12436. * Represents a generic gamepad
  12437. */
  12438. export class GenericPad extends Gamepad {
  12439. private _buttons;
  12440. private _onbuttondown;
  12441. private _onbuttonup;
  12442. /**
  12443. * Observable triggered when a button has been pressed
  12444. */
  12445. onButtonDownObservable: Observable<number>;
  12446. /**
  12447. * Observable triggered when a button has been released
  12448. */
  12449. onButtonUpObservable: Observable<number>;
  12450. /**
  12451. * Callback triggered when a button has been pressed
  12452. * @param callback Called when a button has been pressed
  12453. */
  12454. onbuttondown(callback: (buttonPressed: number) => void): void;
  12455. /**
  12456. * Callback triggered when a button has been released
  12457. * @param callback Called when a button has been released
  12458. */
  12459. onbuttonup(callback: (buttonReleased: number) => void): void;
  12460. /**
  12461. * Initializes the generic gamepad
  12462. * @param id The id of the generic gamepad
  12463. * @param index The index of the generic gamepad
  12464. * @param browserGamepad The browser gamepad
  12465. */
  12466. constructor(id: string, index: number, browserGamepad: any);
  12467. private _setButtonValue;
  12468. /**
  12469. * Updates the generic gamepad
  12470. */
  12471. update(): void;
  12472. /**
  12473. * Disposes the generic gamepad
  12474. */
  12475. dispose(): void;
  12476. }
  12477. }
  12478. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12479. import { Nullable } from "babylonjs/types";
  12480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12481. import { Scene } from "babylonjs/scene";
  12482. module "babylonjs/Engines/engine" {
  12483. interface Engine {
  12484. /**
  12485. * Creates a raw texture
  12486. * @param data defines the data to store in the texture
  12487. * @param width defines the width of the texture
  12488. * @param height defines the height of the texture
  12489. * @param format defines the format of the data
  12490. * @param generateMipMaps defines if the engine should generate the mip levels
  12491. * @param invertY defines if data must be stored with Y axis inverted
  12492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12493. * @param compression defines the compression used (null by default)
  12494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12495. * @returns the raw texture inside an InternalTexture
  12496. */
  12497. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12498. /**
  12499. * Update a raw texture
  12500. * @param texture defines the texture to update
  12501. * @param data defines the data to store in the texture
  12502. * @param format defines the format of the data
  12503. * @param invertY defines if data must be stored with Y axis inverted
  12504. */
  12505. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12506. /**
  12507. * Update a raw texture
  12508. * @param texture defines the texture to update
  12509. * @param data defines the data to store in the texture
  12510. * @param format defines the format of the data
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. * @param compression defines the compression used (null by default)
  12513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12514. */
  12515. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12516. /**
  12517. * Creates a new raw cube texture
  12518. * @param data defines the array of data to use to create each face
  12519. * @param size defines the size of the textures
  12520. * @param format defines the format of the data
  12521. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12522. * @param generateMipMaps defines if the engine should generate the mip levels
  12523. * @param invertY defines if data must be stored with Y axis inverted
  12524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12525. * @param compression defines the compression used (null by default)
  12526. * @returns the cube texture as an InternalTexture
  12527. */
  12528. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12529. /**
  12530. * Update a raw cube texture
  12531. * @param texture defines the texture to udpdate
  12532. * @param data defines the data to store
  12533. * @param format defines the data format
  12534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12535. * @param invertY defines if data must be stored with Y axis inverted
  12536. */
  12537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12538. /**
  12539. * Update a raw cube texture
  12540. * @param texture defines the texture to udpdate
  12541. * @param data defines the data to store
  12542. * @param format defines the data format
  12543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. * @param compression defines the compression used (null by default)
  12546. */
  12547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12548. /**
  12549. * Update a raw cube texture
  12550. * @param texture defines the texture to udpdate
  12551. * @param data defines the data to store
  12552. * @param format defines the data format
  12553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param compression defines the compression used (null by default)
  12556. * @param level defines which level of the texture to update
  12557. */
  12558. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12559. /**
  12560. * Creates a new raw cube texture from a specified url
  12561. * @param url defines the url where the data is located
  12562. * @param scene defines the current scene
  12563. * @param size defines the size of the textures
  12564. * @param format defines the format of the data
  12565. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12566. * @param noMipmap defines if the engine should avoid generating the mip levels
  12567. * @param callback defines a callback used to extract texture data from loaded data
  12568. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12569. * @param onLoad defines a callback called when texture is loaded
  12570. * @param onError defines a callback called if there is an error
  12571. * @returns the cube texture as an InternalTexture
  12572. */
  12573. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12574. /**
  12575. * Creates a new raw cube texture from a specified url
  12576. * @param url defines the url where the data is located
  12577. * @param scene defines the current scene
  12578. * @param size defines the size of the textures
  12579. * @param format defines the format of the data
  12580. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12581. * @param noMipmap defines if the engine should avoid generating the mip levels
  12582. * @param callback defines a callback used to extract texture data from loaded data
  12583. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12584. * @param onLoad defines a callback called when texture is loaded
  12585. * @param onError defines a callback called if there is an error
  12586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @returns the cube texture as an InternalTexture
  12589. */
  12590. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12591. /**
  12592. * Creates a new raw 3D texture
  12593. * @param data defines the data used to create the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param depth defines the depth of the texture
  12597. * @param format defines the format of the texture
  12598. * @param generateMipMaps defines if the engine must generate mip levels
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12601. * @param compression defines the compressed used (can be null)
  12602. * @param textureType defines the compressed used (can be null)
  12603. * @returns a new raw 3D texture (stored in an InternalTexture)
  12604. */
  12605. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12606. /**
  12607. * Update a raw 3D texture
  12608. * @param texture defines the texture to update
  12609. * @param data defines the data to store
  12610. * @param format defines the data format
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. */
  12613. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12614. /**
  12615. * Update a raw 3D texture
  12616. * @param texture defines the texture to update
  12617. * @param data defines the data to store
  12618. * @param format defines the data format
  12619. * @param invertY defines if data must be stored with Y axis inverted
  12620. * @param compression defines the used compression (can be null)
  12621. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12622. */
  12623. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12624. }
  12625. }
  12626. }
  12627. declare module "babylonjs/Materials/Textures/rawTexture" {
  12628. import { Scene } from "babylonjs/scene";
  12629. import { Texture } from "babylonjs/Materials/Textures/texture";
  12630. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12631. /**
  12632. * Raw texture can help creating a texture directly from an array of data.
  12633. * This can be super useful if you either get the data from an uncompressed source or
  12634. * if you wish to create your texture pixel by pixel.
  12635. */
  12636. export class RawTexture extends Texture {
  12637. /**
  12638. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12639. */
  12640. format: number;
  12641. private _engine;
  12642. /**
  12643. * Instantiates a new RawTexture.
  12644. * Raw texture can help creating a texture directly from an array of data.
  12645. * This can be super useful if you either get the data from an uncompressed source or
  12646. * if you wish to create your texture pixel by pixel.
  12647. * @param data define the array of data to use to create the texture
  12648. * @param width define the width of the texture
  12649. * @param height define the height of the texture
  12650. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12651. * @param scene define the scene the texture belongs to
  12652. * @param generateMipMaps define whether mip maps should be generated or not
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. */
  12657. constructor(data: ArrayBufferView, width: number, height: number,
  12658. /**
  12659. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12660. */
  12661. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12662. /**
  12663. * Updates the texture underlying data.
  12664. * @param data Define the new data of the texture
  12665. */
  12666. update(data: ArrayBufferView): void;
  12667. /**
  12668. * Creates a luminance texture from some data.
  12669. * @param data Define the texture data
  12670. * @param width Define the width of the texture
  12671. * @param height Define the height of the texture
  12672. * @param scene Define the scene the texture belongs to
  12673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12676. * @returns the luminance texture
  12677. */
  12678. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12679. /**
  12680. * Creates a luminance alpha texture from some data.
  12681. * @param data Define the texture data
  12682. * @param width Define the width of the texture
  12683. * @param height Define the height of the texture
  12684. * @param scene Define the scene the texture belongs to
  12685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @returns the luminance alpha texture
  12689. */
  12690. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12691. /**
  12692. * Creates an alpha texture from some data.
  12693. * @param data Define the texture data
  12694. * @param width Define the width of the texture
  12695. * @param height Define the height of the texture
  12696. * @param scene Define the scene the texture belongs to
  12697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12700. * @returns the alpha texture
  12701. */
  12702. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12703. /**
  12704. * Creates a RGB texture from some data.
  12705. * @param data Define the texture data
  12706. * @param width Define the width of the texture
  12707. * @param height Define the height of the texture
  12708. * @param scene Define the scene the texture belongs to
  12709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12713. * @returns the RGB alpha texture
  12714. */
  12715. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12716. /**
  12717. * Creates a RGBA texture from some data.
  12718. * @param data Define the texture data
  12719. * @param width Define the width of the texture
  12720. * @param height Define the height of the texture
  12721. * @param scene Define the scene the texture belongs to
  12722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12726. * @returns the RGBA texture
  12727. */
  12728. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12729. /**
  12730. * Creates a R texture from some data.
  12731. * @param data Define the texture data
  12732. * @param width Define the width of the texture
  12733. * @param height Define the height of the texture
  12734. * @param scene Define the scene the texture belongs to
  12735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12739. * @returns the R texture
  12740. */
  12741. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12742. }
  12743. }
  12744. declare module "babylonjs/Maths/math.size" {
  12745. /**
  12746. * Interface for the size containing width and height
  12747. */
  12748. export interface ISize {
  12749. /**
  12750. * Width
  12751. */
  12752. width: number;
  12753. /**
  12754. * Heighht
  12755. */
  12756. height: number;
  12757. }
  12758. /**
  12759. * Size containing widht and height
  12760. */
  12761. export class Size implements ISize {
  12762. /**
  12763. * Width
  12764. */
  12765. width: number;
  12766. /**
  12767. * Height
  12768. */
  12769. height: number;
  12770. /**
  12771. * Creates a Size object from the given width and height (floats).
  12772. * @param width width of the new size
  12773. * @param height height of the new size
  12774. */
  12775. constructor(width: number, height: number);
  12776. /**
  12777. * Returns a string with the Size width and height
  12778. * @returns a string with the Size width and height
  12779. */
  12780. toString(): string;
  12781. /**
  12782. * "Size"
  12783. * @returns the string "Size"
  12784. */
  12785. getClassName(): string;
  12786. /**
  12787. * Returns the Size hash code.
  12788. * @returns a hash code for a unique width and height
  12789. */
  12790. getHashCode(): number;
  12791. /**
  12792. * Updates the current size from the given one.
  12793. * @param src the given size
  12794. */
  12795. copyFrom(src: Size): void;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width of the new size
  12799. * @param height height of the new size
  12800. * @returns the updated Size.
  12801. */
  12802. copyFromFloats(width: number, height: number): Size;
  12803. /**
  12804. * Updates in place the current Size from the given floats.
  12805. * @param width width to set
  12806. * @param height height to set
  12807. * @returns the updated Size.
  12808. */
  12809. set(width: number, height: number): Size;
  12810. /**
  12811. * Multiplies the width and height by numbers
  12812. * @param w factor to multiple the width by
  12813. * @param h factor to multiple the height by
  12814. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12815. */
  12816. multiplyByFloats(w: number, h: number): Size;
  12817. /**
  12818. * Clones the size
  12819. * @returns a new Size copied from the given one.
  12820. */
  12821. clone(): Size;
  12822. /**
  12823. * True if the current Size and the given one width and height are strictly equal.
  12824. * @param other the other size to compare against
  12825. * @returns True if the current Size and the given one width and height are strictly equal.
  12826. */
  12827. equals(other: Size): boolean;
  12828. /**
  12829. * The surface of the Size : width * height (float).
  12830. */
  12831. readonly surface: number;
  12832. /**
  12833. * Create a new size of zero
  12834. * @returns a new Size set to (0.0, 0.0)
  12835. */
  12836. static Zero(): Size;
  12837. /**
  12838. * Sums the width and height of two sizes
  12839. * @param otherSize size to add to this size
  12840. * @returns a new Size set as the addition result of the current Size and the given one.
  12841. */
  12842. add(otherSize: Size): Size;
  12843. /**
  12844. * Subtracts the width and height of two
  12845. * @param otherSize size to subtract to this size
  12846. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12847. */
  12848. subtract(otherSize: Size): Size;
  12849. /**
  12850. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12851. * @param start starting size to lerp between
  12852. * @param end end size to lerp between
  12853. * @param amount amount to lerp between the start and end values
  12854. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12855. */
  12856. static Lerp(start: Size, end: Size, amount: number): Size;
  12857. }
  12858. }
  12859. declare module "babylonjs/Animations/runtimeAnimation" {
  12860. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12861. import { Animatable } from "babylonjs/Animations/animatable";
  12862. import { Scene } from "babylonjs/scene";
  12863. /**
  12864. * Defines a runtime animation
  12865. */
  12866. export class RuntimeAnimation {
  12867. private _events;
  12868. /**
  12869. * The current frame of the runtime animation
  12870. */
  12871. private _currentFrame;
  12872. /**
  12873. * The animation used by the runtime animation
  12874. */
  12875. private _animation;
  12876. /**
  12877. * The target of the runtime animation
  12878. */
  12879. private _target;
  12880. /**
  12881. * The initiating animatable
  12882. */
  12883. private _host;
  12884. /**
  12885. * The original value of the runtime animation
  12886. */
  12887. private _originalValue;
  12888. /**
  12889. * The original blend value of the runtime animation
  12890. */
  12891. private _originalBlendValue;
  12892. /**
  12893. * The offsets cache of the runtime animation
  12894. */
  12895. private _offsetsCache;
  12896. /**
  12897. * The high limits cache of the runtime animation
  12898. */
  12899. private _highLimitsCache;
  12900. /**
  12901. * Specifies if the runtime animation has been stopped
  12902. */
  12903. private _stopped;
  12904. /**
  12905. * The blending factor of the runtime animation
  12906. */
  12907. private _blendingFactor;
  12908. /**
  12909. * The BabylonJS scene
  12910. */
  12911. private _scene;
  12912. /**
  12913. * The current value of the runtime animation
  12914. */
  12915. private _currentValue;
  12916. /** @hidden */
  12917. _animationState: _IAnimationState;
  12918. /**
  12919. * The active target of the runtime animation
  12920. */
  12921. private _activeTargets;
  12922. private _currentActiveTarget;
  12923. private _directTarget;
  12924. /**
  12925. * The target path of the runtime animation
  12926. */
  12927. private _targetPath;
  12928. /**
  12929. * The weight of the runtime animation
  12930. */
  12931. private _weight;
  12932. /**
  12933. * The ratio offset of the runtime animation
  12934. */
  12935. private _ratioOffset;
  12936. /**
  12937. * The previous delay of the runtime animation
  12938. */
  12939. private _previousDelay;
  12940. /**
  12941. * The previous ratio of the runtime animation
  12942. */
  12943. private _previousRatio;
  12944. private _enableBlending;
  12945. private _keys;
  12946. private _minFrame;
  12947. private _maxFrame;
  12948. private _minValue;
  12949. private _maxValue;
  12950. private _targetIsArray;
  12951. /**
  12952. * Gets the current frame of the runtime animation
  12953. */
  12954. readonly currentFrame: number;
  12955. /**
  12956. * Gets the weight of the runtime animation
  12957. */
  12958. readonly weight: number;
  12959. /**
  12960. * Gets the current value of the runtime animation
  12961. */
  12962. readonly currentValue: any;
  12963. /**
  12964. * Gets the target path of the runtime animation
  12965. */
  12966. readonly targetPath: string;
  12967. /**
  12968. * Gets the actual target of the runtime animation
  12969. */
  12970. readonly target: any;
  12971. /** @hidden */
  12972. _onLoop: () => void;
  12973. /**
  12974. * Create a new RuntimeAnimation object
  12975. * @param target defines the target of the animation
  12976. * @param animation defines the source animation object
  12977. * @param scene defines the hosting scene
  12978. * @param host defines the initiating Animatable
  12979. */
  12980. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12981. private _preparePath;
  12982. /**
  12983. * Gets the animation from the runtime animation
  12984. */
  12985. readonly animation: Animation;
  12986. /**
  12987. * Resets the runtime animation to the beginning
  12988. * @param restoreOriginal defines whether to restore the target property to the original value
  12989. */
  12990. reset(restoreOriginal?: boolean): void;
  12991. /**
  12992. * Specifies if the runtime animation is stopped
  12993. * @returns Boolean specifying if the runtime animation is stopped
  12994. */
  12995. isStopped(): boolean;
  12996. /**
  12997. * Disposes of the runtime animation
  12998. */
  12999. dispose(): void;
  13000. /**
  13001. * Apply the interpolated value to the target
  13002. * @param currentValue defines the value computed by the animation
  13003. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13004. */
  13005. setValue(currentValue: any, weight: number): void;
  13006. private _getOriginalValues;
  13007. private _setValue;
  13008. /**
  13009. * Gets the loop pmode of the runtime animation
  13010. * @returns Loop Mode
  13011. */
  13012. private _getCorrectLoopMode;
  13013. /**
  13014. * Move the current animation to a given frame
  13015. * @param frame defines the frame to move to
  13016. */
  13017. goToFrame(frame: number): void;
  13018. /**
  13019. * @hidden Internal use only
  13020. */
  13021. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13022. /**
  13023. * Execute the current animation
  13024. * @param delay defines the delay to add to the current frame
  13025. * @param from defines the lower bound of the animation range
  13026. * @param to defines the upper bound of the animation range
  13027. * @param loop defines if the current animation must loop
  13028. * @param speedRatio defines the current speed ratio
  13029. * @param weight defines the weight of the animation (default is -1 so no weight)
  13030. * @param onLoop optional callback called when animation loops
  13031. * @returns a boolean indicating if the animation is running
  13032. */
  13033. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13034. }
  13035. }
  13036. declare module "babylonjs/Animations/animatable" {
  13037. import { Animation } from "babylonjs/Animations/animation";
  13038. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13039. import { Nullable } from "babylonjs/types";
  13040. import { Observable } from "babylonjs/Misc/observable";
  13041. import { Scene } from "babylonjs/scene";
  13042. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13043. import { Node } from "babylonjs/node";
  13044. /**
  13045. * Class used to store an actual running animation
  13046. */
  13047. export class Animatable {
  13048. /** defines the target object */
  13049. target: any;
  13050. /** defines the starting frame number (default is 0) */
  13051. fromFrame: number;
  13052. /** defines the ending frame number (default is 100) */
  13053. toFrame: number;
  13054. /** defines if the animation must loop (default is false) */
  13055. loopAnimation: boolean;
  13056. /** defines a callback to call when animation ends if it is not looping */
  13057. onAnimationEnd?: (() => void) | null | undefined;
  13058. /** defines a callback to call when animation loops */
  13059. onAnimationLoop?: (() => void) | null | undefined;
  13060. private _localDelayOffset;
  13061. private _pausedDelay;
  13062. private _runtimeAnimations;
  13063. private _paused;
  13064. private _scene;
  13065. private _speedRatio;
  13066. private _weight;
  13067. private _syncRoot;
  13068. /**
  13069. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13070. * This will only apply for non looping animation (default is true)
  13071. */
  13072. disposeOnEnd: boolean;
  13073. /**
  13074. * Gets a boolean indicating if the animation has started
  13075. */
  13076. animationStarted: boolean;
  13077. /**
  13078. * Observer raised when the animation ends
  13079. */
  13080. onAnimationEndObservable: Observable<Animatable>;
  13081. /**
  13082. * Observer raised when the animation loops
  13083. */
  13084. onAnimationLoopObservable: Observable<Animatable>;
  13085. /**
  13086. * Gets the root Animatable used to synchronize and normalize animations
  13087. */
  13088. readonly syncRoot: Nullable<Animatable>;
  13089. /**
  13090. * Gets the current frame of the first RuntimeAnimation
  13091. * Used to synchronize Animatables
  13092. */
  13093. readonly masterFrame: number;
  13094. /**
  13095. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13096. */
  13097. weight: number;
  13098. /**
  13099. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13100. */
  13101. speedRatio: number;
  13102. /**
  13103. * Creates a new Animatable
  13104. * @param scene defines the hosting scene
  13105. * @param target defines the target object
  13106. * @param fromFrame defines the starting frame number (default is 0)
  13107. * @param toFrame defines the ending frame number (default is 100)
  13108. * @param loopAnimation defines if the animation must loop (default is false)
  13109. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13110. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13111. * @param animations defines a group of animation to add to the new Animatable
  13112. * @param onAnimationLoop defines a callback to call when animation loops
  13113. */
  13114. constructor(scene: Scene,
  13115. /** defines the target object */
  13116. target: any,
  13117. /** defines the starting frame number (default is 0) */
  13118. fromFrame?: number,
  13119. /** defines the ending frame number (default is 100) */
  13120. toFrame?: number,
  13121. /** defines if the animation must loop (default is false) */
  13122. loopAnimation?: boolean, speedRatio?: number,
  13123. /** defines a callback to call when animation ends if it is not looping */
  13124. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13125. /** defines a callback to call when animation loops */
  13126. onAnimationLoop?: (() => void) | null | undefined);
  13127. /**
  13128. * Synchronize and normalize current Animatable with a source Animatable
  13129. * This is useful when using animation weights and when animations are not of the same length
  13130. * @param root defines the root Animatable to synchronize with
  13131. * @returns the current Animatable
  13132. */
  13133. syncWith(root: Animatable): Animatable;
  13134. /**
  13135. * Gets the list of runtime animations
  13136. * @returns an array of RuntimeAnimation
  13137. */
  13138. getAnimations(): RuntimeAnimation[];
  13139. /**
  13140. * Adds more animations to the current animatable
  13141. * @param target defines the target of the animations
  13142. * @param animations defines the new animations to add
  13143. */
  13144. appendAnimations(target: any, animations: Animation[]): void;
  13145. /**
  13146. * Gets the source animation for a specific property
  13147. * @param property defines the propertyu to look for
  13148. * @returns null or the source animation for the given property
  13149. */
  13150. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13151. /**
  13152. * Gets the runtime animation for a specific property
  13153. * @param property defines the propertyu to look for
  13154. * @returns null or the runtime animation for the given property
  13155. */
  13156. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13157. /**
  13158. * Resets the animatable to its original state
  13159. */
  13160. reset(): void;
  13161. /**
  13162. * Allows the animatable to blend with current running animations
  13163. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13164. * @param blendingSpeed defines the blending speed to use
  13165. */
  13166. enableBlending(blendingSpeed: number): void;
  13167. /**
  13168. * Disable animation blending
  13169. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13170. */
  13171. disableBlending(): void;
  13172. /**
  13173. * Jump directly to a given frame
  13174. * @param frame defines the frame to jump to
  13175. */
  13176. goToFrame(frame: number): void;
  13177. /**
  13178. * Pause the animation
  13179. */
  13180. pause(): void;
  13181. /**
  13182. * Restart the animation
  13183. */
  13184. restart(): void;
  13185. private _raiseOnAnimationEnd;
  13186. /**
  13187. * Stop and delete the current animation
  13188. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13189. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13190. */
  13191. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13192. /**
  13193. * Wait asynchronously for the animation to end
  13194. * @returns a promise which will be fullfilled when the animation ends
  13195. */
  13196. waitAsync(): Promise<Animatable>;
  13197. /** @hidden */
  13198. _animate(delay: number): boolean;
  13199. }
  13200. module "babylonjs/scene" {
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. }
  13308. }
  13309. module "babylonjs/Bones/bone" {
  13310. interface Bone {
  13311. /**
  13312. * Copy an animation range from another bone
  13313. * @param source defines the source bone
  13314. * @param rangeName defines the range name to copy
  13315. * @param frameOffset defines the frame offset
  13316. * @param rescaleAsRequired defines if rescaling must be applied if required
  13317. * @param skelDimensionsRatio defines the scaling ratio
  13318. * @returns true if operation was successful
  13319. */
  13320. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13321. }
  13322. }
  13323. }
  13324. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13325. /**
  13326. * Class used to override all child animations of a given target
  13327. */
  13328. export class AnimationPropertiesOverride {
  13329. /**
  13330. * Gets or sets a value indicating if animation blending must be used
  13331. */
  13332. enableBlending: boolean;
  13333. /**
  13334. * Gets or sets the blending speed to use when enableBlending is true
  13335. */
  13336. blendingSpeed: number;
  13337. /**
  13338. * Gets or sets the default loop mode to use
  13339. */
  13340. loopMode: number;
  13341. }
  13342. }
  13343. declare module "babylonjs/Bones/skeleton" {
  13344. import { Bone } from "babylonjs/Bones/bone";
  13345. import { Observable } from "babylonjs/Misc/observable";
  13346. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13347. import { Scene } from "babylonjs/scene";
  13348. import { Nullable } from "babylonjs/types";
  13349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13350. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13351. import { Animatable } from "babylonjs/Animations/animatable";
  13352. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13353. import { Animation } from "babylonjs/Animations/animation";
  13354. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13355. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13356. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13357. /**
  13358. * Class used to handle skinning animations
  13359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13360. */
  13361. export class Skeleton implements IAnimatable {
  13362. /** defines the skeleton name */
  13363. name: string;
  13364. /** defines the skeleton Id */
  13365. id: string;
  13366. /**
  13367. * Defines the list of child bones
  13368. */
  13369. bones: Bone[];
  13370. /**
  13371. * Defines an estimate of the dimension of the skeleton at rest
  13372. */
  13373. dimensionsAtRest: Vector3;
  13374. /**
  13375. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13376. */
  13377. needInitialSkinMatrix: boolean;
  13378. /**
  13379. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13380. */
  13381. overrideMesh: Nullable<AbstractMesh>;
  13382. /**
  13383. * Gets the list of animations attached to this skeleton
  13384. */
  13385. animations: Array<Animation>;
  13386. private _scene;
  13387. private _isDirty;
  13388. private _transformMatrices;
  13389. private _transformMatrixTexture;
  13390. private _meshesWithPoseMatrix;
  13391. private _animatables;
  13392. private _identity;
  13393. private _synchronizedWithMesh;
  13394. private _ranges;
  13395. private _lastAbsoluteTransformsUpdateId;
  13396. private _canUseTextureForBones;
  13397. private _uniqueId;
  13398. /** @hidden */
  13399. _numBonesWithLinkedTransformNode: number;
  13400. /** @hidden */
  13401. _hasWaitingData: Nullable<boolean>;
  13402. /**
  13403. * Specifies if the skeleton should be serialized
  13404. */
  13405. doNotSerialize: boolean;
  13406. private _useTextureToStoreBoneMatrices;
  13407. /**
  13408. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13409. * Please note that this option is not available if the hardware does not support it
  13410. */
  13411. useTextureToStoreBoneMatrices: boolean;
  13412. private _animationPropertiesOverride;
  13413. /**
  13414. * Gets or sets the animation properties override
  13415. */
  13416. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13417. /**
  13418. * List of inspectable custom properties (used by the Inspector)
  13419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13420. */
  13421. inspectableCustomProperties: IInspectable[];
  13422. /**
  13423. * An observable triggered before computing the skeleton's matrices
  13424. */
  13425. onBeforeComputeObservable: Observable<Skeleton>;
  13426. /**
  13427. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13428. */
  13429. readonly isUsingTextureForMatrices: boolean;
  13430. /**
  13431. * Gets the unique ID of this skeleton
  13432. */
  13433. readonly uniqueId: number;
  13434. /**
  13435. * Creates a new skeleton
  13436. * @param name defines the skeleton name
  13437. * @param id defines the skeleton Id
  13438. * @param scene defines the hosting scene
  13439. */
  13440. constructor(
  13441. /** defines the skeleton name */
  13442. name: string,
  13443. /** defines the skeleton Id */
  13444. id: string, scene: Scene);
  13445. /**
  13446. * Gets the current object class name.
  13447. * @return the class name
  13448. */
  13449. getClassName(): string;
  13450. /**
  13451. * Returns an array containing the root bones
  13452. * @returns an array containing the root bones
  13453. */
  13454. getChildren(): Array<Bone>;
  13455. /**
  13456. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13457. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13458. * @returns a Float32Array containing matrices data
  13459. */
  13460. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13461. /**
  13462. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13464. * @returns a raw texture containing the data
  13465. */
  13466. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13467. /**
  13468. * Gets the current hosting scene
  13469. * @returns a scene object
  13470. */
  13471. getScene(): Scene;
  13472. /**
  13473. * Gets a string representing the current skeleton data
  13474. * @param fullDetails defines a boolean indicating if we want a verbose version
  13475. * @returns a string representing the current skeleton data
  13476. */
  13477. toString(fullDetails?: boolean): string;
  13478. /**
  13479. * Get bone's index searching by name
  13480. * @param name defines bone's name to search for
  13481. * @return the indice of the bone. Returns -1 if not found
  13482. */
  13483. getBoneIndexByName(name: string): number;
  13484. /**
  13485. * Creater a new animation range
  13486. * @param name defines the name of the range
  13487. * @param from defines the start key
  13488. * @param to defines the end key
  13489. */
  13490. createAnimationRange(name: string, from: number, to: number): void;
  13491. /**
  13492. * Delete a specific animation range
  13493. * @param name defines the name of the range
  13494. * @param deleteFrames defines if frames must be removed as well
  13495. */
  13496. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13497. /**
  13498. * Gets a specific animation range
  13499. * @param name defines the name of the range to look for
  13500. * @returns the requested animation range or null if not found
  13501. */
  13502. getAnimationRange(name: string): Nullable<AnimationRange>;
  13503. /**
  13504. * Gets the list of all animation ranges defined on this skeleton
  13505. * @returns an array
  13506. */
  13507. getAnimationRanges(): Nullable<AnimationRange>[];
  13508. /**
  13509. * Copy animation range from a source skeleton.
  13510. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13511. * @param source defines the source skeleton
  13512. * @param name defines the name of the range to copy
  13513. * @param rescaleAsRequired defines if rescaling must be applied if required
  13514. * @returns true if operation was successful
  13515. */
  13516. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13517. /**
  13518. * Forces the skeleton to go to rest pose
  13519. */
  13520. returnToRest(): void;
  13521. private _getHighestAnimationFrame;
  13522. /**
  13523. * Begin a specific animation range
  13524. * @param name defines the name of the range to start
  13525. * @param loop defines if looping must be turned on (false by default)
  13526. * @param speedRatio defines the speed ratio to apply (1 by default)
  13527. * @param onAnimationEnd defines a callback which will be called when animation will end
  13528. * @returns a new animatable
  13529. */
  13530. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13531. /** @hidden */
  13532. _markAsDirty(): void;
  13533. /** @hidden */
  13534. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13535. /** @hidden */
  13536. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13537. private _computeTransformMatrices;
  13538. /**
  13539. * Build all resources required to render a skeleton
  13540. */
  13541. prepare(): void;
  13542. /**
  13543. * Gets the list of animatables currently running for this skeleton
  13544. * @returns an array of animatables
  13545. */
  13546. getAnimatables(): IAnimatable[];
  13547. /**
  13548. * Clone the current skeleton
  13549. * @param name defines the name of the new skeleton
  13550. * @param id defines the id of the new skeleton
  13551. * @returns the new skeleton
  13552. */
  13553. clone(name: string, id: string): Skeleton;
  13554. /**
  13555. * Enable animation blending for this skeleton
  13556. * @param blendingSpeed defines the blending speed to apply
  13557. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13558. */
  13559. enableBlending(blendingSpeed?: number): void;
  13560. /**
  13561. * Releases all resources associated with the current skeleton
  13562. */
  13563. dispose(): void;
  13564. /**
  13565. * Serialize the skeleton in a JSON object
  13566. * @returns a JSON object
  13567. */
  13568. serialize(): any;
  13569. /**
  13570. * Creates a new skeleton from serialized data
  13571. * @param parsedSkeleton defines the serialized data
  13572. * @param scene defines the hosting scene
  13573. * @returns a new skeleton
  13574. */
  13575. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13576. /**
  13577. * Compute all node absolute transforms
  13578. * @param forceUpdate defines if computation must be done even if cache is up to date
  13579. */
  13580. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13581. /**
  13582. * Gets the root pose matrix
  13583. * @returns a matrix
  13584. */
  13585. getPoseMatrix(): Nullable<Matrix>;
  13586. /**
  13587. * Sorts bones per internal index
  13588. */
  13589. sortBones(): void;
  13590. private _sortBones;
  13591. }
  13592. }
  13593. declare module "babylonjs/Bones/bone" {
  13594. import { Skeleton } from "babylonjs/Bones/skeleton";
  13595. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Nullable } from "babylonjs/types";
  13597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13599. import { Node } from "babylonjs/node";
  13600. import { Space } from "babylonjs/Maths/math.axis";
  13601. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13602. /**
  13603. * Class used to store bone information
  13604. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13605. */
  13606. export class Bone extends Node {
  13607. /**
  13608. * defines the bone name
  13609. */
  13610. name: string;
  13611. private static _tmpVecs;
  13612. private static _tmpQuat;
  13613. private static _tmpMats;
  13614. /**
  13615. * Gets the list of child bones
  13616. */
  13617. children: Bone[];
  13618. /** Gets the animations associated with this bone */
  13619. animations: import("babylonjs/Animations/animation").Animation[];
  13620. /**
  13621. * Gets or sets bone length
  13622. */
  13623. length: number;
  13624. /**
  13625. * @hidden Internal only
  13626. * Set this value to map this bone to a different index in the transform matrices
  13627. * Set this value to -1 to exclude the bone from the transform matrices
  13628. */
  13629. _index: Nullable<number>;
  13630. private _skeleton;
  13631. private _localMatrix;
  13632. private _restPose;
  13633. private _baseMatrix;
  13634. private _absoluteTransform;
  13635. private _invertedAbsoluteTransform;
  13636. private _parent;
  13637. private _scalingDeterminant;
  13638. private _worldTransform;
  13639. private _localScaling;
  13640. private _localRotation;
  13641. private _localPosition;
  13642. private _needToDecompose;
  13643. private _needToCompose;
  13644. /** @hidden */
  13645. _linkedTransformNode: Nullable<TransformNode>;
  13646. /** @hidden */
  13647. _waitingTransformNodeId: Nullable<string>;
  13648. /** @hidden */
  13649. /** @hidden */
  13650. _matrix: Matrix;
  13651. /**
  13652. * Create a new bone
  13653. * @param name defines the bone name
  13654. * @param skeleton defines the parent skeleton
  13655. * @param parentBone defines the parent (can be null if the bone is the root)
  13656. * @param localMatrix defines the local matrix
  13657. * @param restPose defines the rest pose matrix
  13658. * @param baseMatrix defines the base matrix
  13659. * @param index defines index of the bone in the hiearchy
  13660. */
  13661. constructor(
  13662. /**
  13663. * defines the bone name
  13664. */
  13665. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13666. /**
  13667. * Gets the current object class name.
  13668. * @return the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Gets the parent skeleton
  13673. * @returns a skeleton
  13674. */
  13675. getSkeleton(): Skeleton;
  13676. /**
  13677. * Gets parent bone
  13678. * @returns a bone or null if the bone is the root of the bone hierarchy
  13679. */
  13680. getParent(): Nullable<Bone>;
  13681. /**
  13682. * Returns an array containing the root bones
  13683. * @returns an array containing the root bones
  13684. */
  13685. getChildren(): Array<Bone>;
  13686. /**
  13687. * Sets the parent bone
  13688. * @param parent defines the parent (can be null if the bone is the root)
  13689. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13690. */
  13691. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13692. /**
  13693. * Gets the local matrix
  13694. * @returns a matrix
  13695. */
  13696. getLocalMatrix(): Matrix;
  13697. /**
  13698. * Gets the base matrix (initial matrix which remains unchanged)
  13699. * @returns a matrix
  13700. */
  13701. getBaseMatrix(): Matrix;
  13702. /**
  13703. * Gets the rest pose matrix
  13704. * @returns a matrix
  13705. */
  13706. getRestPose(): Matrix;
  13707. /**
  13708. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13709. */
  13710. getWorldMatrix(): Matrix;
  13711. /**
  13712. * Sets the local matrix to rest pose matrix
  13713. */
  13714. returnToRest(): void;
  13715. /**
  13716. * Gets the inverse of the absolute transform matrix.
  13717. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13718. * @returns a matrix
  13719. */
  13720. getInvertedAbsoluteTransform(): Matrix;
  13721. /**
  13722. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13723. * @returns a matrix
  13724. */
  13725. getAbsoluteTransform(): Matrix;
  13726. /**
  13727. * Links with the given transform node.
  13728. * The local matrix of this bone is copied from the transform node every frame.
  13729. * @param transformNode defines the transform node to link to
  13730. */
  13731. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13732. /**
  13733. * Gets the node used to drive the bone's transformation
  13734. * @returns a transform node or null
  13735. */
  13736. getTransformNode(): Nullable<TransformNode>;
  13737. /** Gets or sets current position (in local space) */
  13738. position: Vector3;
  13739. /** Gets or sets current rotation (in local space) */
  13740. rotation: Vector3;
  13741. /** Gets or sets current rotation quaternion (in local space) */
  13742. rotationQuaternion: Quaternion;
  13743. /** Gets or sets current scaling (in local space) */
  13744. scaling: Vector3;
  13745. /**
  13746. * Gets the animation properties override
  13747. */
  13748. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13749. private _decompose;
  13750. private _compose;
  13751. /**
  13752. * Update the base and local matrices
  13753. * @param matrix defines the new base or local matrix
  13754. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13755. * @param updateLocalMatrix defines if the local matrix should be updated
  13756. */
  13757. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13758. /** @hidden */
  13759. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13760. /**
  13761. * Flag the bone as dirty (Forcing it to update everything)
  13762. */
  13763. markAsDirty(): void;
  13764. /** @hidden */
  13765. _markAsDirtyAndCompose(): void;
  13766. private _markAsDirtyAndDecompose;
  13767. /**
  13768. * Translate the bone in local or world space
  13769. * @param vec The amount to translate the bone
  13770. * @param space The space that the translation is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the postion of the bone in local or world space
  13776. * @param position The position to set the bone
  13777. * @param space The space that the position is in
  13778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13779. */
  13780. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13781. /**
  13782. * Set the absolute position of the bone (world space)
  13783. * @param position The position to set the bone
  13784. * @param mesh The mesh that this bone is attached to
  13785. */
  13786. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13787. /**
  13788. * Scale the bone on the x, y and z axes (in local space)
  13789. * @param x The amount to scale the bone on the x axis
  13790. * @param y The amount to scale the bone on the y axis
  13791. * @param z The amount to scale the bone on the z axis
  13792. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13793. */
  13794. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13795. /**
  13796. * Set the bone scaling in local space
  13797. * @param scale defines the scaling vector
  13798. */
  13799. setScale(scale: Vector3): void;
  13800. /**
  13801. * Gets the current scaling in local space
  13802. * @returns the current scaling vector
  13803. */
  13804. getScale(): Vector3;
  13805. /**
  13806. * Gets the current scaling in local space and stores it in a target vector
  13807. * @param result defines the target vector
  13808. */
  13809. getScaleToRef(result: Vector3): void;
  13810. /**
  13811. * Set the yaw, pitch, and roll of the bone in local or world space
  13812. * @param yaw The rotation of the bone on the y axis
  13813. * @param pitch The rotation of the bone on the x axis
  13814. * @param roll The rotation of the bone on the z axis
  13815. * @param space The space that the axes of rotation are in
  13816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13817. */
  13818. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13819. /**
  13820. * Add a rotation to the bone on an axis in local or world space
  13821. * @param axis The axis to rotate the bone on
  13822. * @param amount The amount to rotate the bone
  13823. * @param space The space that the axis is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the rotation of the bone to a particular axis angle in local or world space
  13829. * @param axis The axis to rotate the bone on
  13830. * @param angle The angle that the bone should be rotated to
  13831. * @param space The space that the axis is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the euler rotation of the bone in local of world space
  13837. * @param rotation The euler rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the quaternion rotation of the bone in local of world space
  13844. * @param quat The quaternion rotation that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13849. /**
  13850. * Set the rotation matrix of the bone in local of world space
  13851. * @param rotMat The rotation matrix that the bone should be set to
  13852. * @param space The space that the rotation is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. */
  13855. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13856. private _rotateWithMatrix;
  13857. private _getNegativeRotationToRef;
  13858. /**
  13859. * Get the position of the bone in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @returns The position of the bone
  13863. */
  13864. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13865. /**
  13866. * Copy the position of the bone to a vector3 in local or world space
  13867. * @param space The space that the returned position is in
  13868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13869. * @param result The vector3 to copy the position to
  13870. */
  13871. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13872. /**
  13873. * Get the absolute position of the bone (world space)
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The absolute position of the bone
  13876. */
  13877. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Copy the absolute position of the bone (world space) to the result param
  13880. * @param mesh The mesh that this bone is attached to
  13881. * @param result The vector3 to copy the absolute position to
  13882. */
  13883. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13884. /**
  13885. * Compute the absolute transforms of this bone and its children
  13886. */
  13887. computeAbsoluteTransforms(): void;
  13888. /**
  13889. * Get the world direction from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @returns The world direction
  13893. */
  13894. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13895. /**
  13896. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13897. * @param localAxis The local direction that is used to compute the world direction
  13898. * @param mesh The mesh that this bone is attached to
  13899. * @param result The vector3 that the world direction will be copied to
  13900. */
  13901. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13902. /**
  13903. * Get the euler rotation of the bone in local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @returns The euler rotation
  13907. */
  13908. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13909. /**
  13910. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @param result The vector3 that the rotation should be copied to
  13914. */
  13915. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13916. /**
  13917. * Get the quaternion rotation of the bone in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @returns The quaternion rotation
  13921. */
  13922. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13923. /**
  13924. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @param result The quaternion that the rotation should be copied to
  13928. */
  13929. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13930. /**
  13931. * Get the rotation matrix of the bone in local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @returns The rotation matrix
  13935. */
  13936. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13937. /**
  13938. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @param result The quaternion that the rotation should be copied to
  13942. */
  13943. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @returns The world position
  13949. */
  13950. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13951. /**
  13952. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13953. * @param position The local position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @param result The vector3 that the world position should be copied to
  13956. */
  13957. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13958. /**
  13959. * Get the local position of a point that is in world space
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @returns The local position
  13963. */
  13964. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13965. /**
  13966. * Get the local position of a point that is in world space and copy it to the result param
  13967. * @param position The world position
  13968. * @param mesh The mesh that this bone is attached to
  13969. * @param result The vector3 that the local position should be copied to
  13970. */
  13971. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13972. }
  13973. }
  13974. declare module "babylonjs/Meshes/transformNode" {
  13975. import { DeepImmutable } from "babylonjs/types";
  13976. import { Observable } from "babylonjs/Misc/observable";
  13977. import { Nullable } from "babylonjs/types";
  13978. import { Camera } from "babylonjs/Cameras/camera";
  13979. import { Scene } from "babylonjs/scene";
  13980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13981. import { Node } from "babylonjs/node";
  13982. import { Bone } from "babylonjs/Bones/bone";
  13983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13984. import { Space } from "babylonjs/Maths/math.axis";
  13985. /**
  13986. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13987. * @see https://doc.babylonjs.com/how_to/transformnode
  13988. */
  13989. export class TransformNode extends Node {
  13990. /**
  13991. * Object will not rotate to face the camera
  13992. */
  13993. static BILLBOARDMODE_NONE: number;
  13994. /**
  13995. * Object will rotate to face the camera but only on the x axis
  13996. */
  13997. static BILLBOARDMODE_X: number;
  13998. /**
  13999. * Object will rotate to face the camera but only on the y axis
  14000. */
  14001. static BILLBOARDMODE_Y: number;
  14002. /**
  14003. * Object will rotate to face the camera but only on the z axis
  14004. */
  14005. static BILLBOARDMODE_Z: number;
  14006. /**
  14007. * Object will rotate to face the camera
  14008. */
  14009. static BILLBOARDMODE_ALL: number;
  14010. /**
  14011. * Object will rotate to face the camera's position instead of orientation
  14012. */
  14013. static BILLBOARDMODE_USE_POSITION: number;
  14014. private _forward;
  14015. private _forwardInverted;
  14016. private _up;
  14017. private _right;
  14018. private _rightInverted;
  14019. private _position;
  14020. private _rotation;
  14021. private _rotationQuaternion;
  14022. protected _scaling: Vector3;
  14023. protected _isDirty: boolean;
  14024. private _transformToBoneReferal;
  14025. private _isAbsoluteSynced;
  14026. private _billboardMode;
  14027. /**
  14028. * Gets or sets the billboard mode. Default is 0.
  14029. *
  14030. * | Value | Type | Description |
  14031. * | --- | --- | --- |
  14032. * | 0 | BILLBOARDMODE_NONE | |
  14033. * | 1 | BILLBOARDMODE_X | |
  14034. * | 2 | BILLBOARDMODE_Y | |
  14035. * | 4 | BILLBOARDMODE_Z | |
  14036. * | 7 | BILLBOARDMODE_ALL | |
  14037. *
  14038. */
  14039. billboardMode: number;
  14040. private _preserveParentRotationForBillboard;
  14041. /**
  14042. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14043. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14044. */
  14045. preserveParentRotationForBillboard: boolean;
  14046. /**
  14047. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14048. */
  14049. scalingDeterminant: number;
  14050. private _infiniteDistance;
  14051. /**
  14052. * Gets or sets the distance of the object to max, often used by skybox
  14053. */
  14054. infiniteDistance: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14057. * By default the system will update normals to compensate
  14058. */
  14059. ignoreNonUniformScaling: boolean;
  14060. /**
  14061. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14062. */
  14063. reIntegrateRotationIntoRotationQuaternion: boolean;
  14064. /** @hidden */
  14065. _poseMatrix: Nullable<Matrix>;
  14066. /** @hidden */
  14067. _localMatrix: Matrix;
  14068. private _usePivotMatrix;
  14069. private _absolutePosition;
  14070. private _absoluteScaling;
  14071. private _absoluteRotationQuaternion;
  14072. private _pivotMatrix;
  14073. private _pivotMatrixInverse;
  14074. protected _postMultiplyPivotMatrix: boolean;
  14075. protected _isWorldMatrixFrozen: boolean;
  14076. /** @hidden */
  14077. _indexInSceneTransformNodesArray: number;
  14078. /**
  14079. * An event triggered after the world matrix is updated
  14080. */
  14081. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14082. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14083. /**
  14084. * Gets a string identifying the name of the class
  14085. * @returns "TransformNode" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14090. */
  14091. position: Vector3;
  14092. /**
  14093. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14094. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14095. */
  14096. rotation: Vector3;
  14097. /**
  14098. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14099. */
  14100. scaling: Vector3;
  14101. /**
  14102. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14103. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14104. */
  14105. rotationQuaternion: Nullable<Quaternion>;
  14106. /**
  14107. * The forward direction of that transform in world space.
  14108. */
  14109. readonly forward: Vector3;
  14110. /**
  14111. * The up direction of that transform in world space.
  14112. */
  14113. readonly up: Vector3;
  14114. /**
  14115. * The right direction of that transform in world space.
  14116. */
  14117. readonly right: Vector3;
  14118. /**
  14119. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14120. * @param matrix the matrix to copy the pose from
  14121. * @returns this TransformNode.
  14122. */
  14123. updatePoseMatrix(matrix: Matrix): TransformNode;
  14124. /**
  14125. * Returns the mesh Pose matrix.
  14126. * @returns the pose matrix
  14127. */
  14128. getPoseMatrix(): Matrix;
  14129. /** @hidden */
  14130. _isSynchronized(): boolean;
  14131. /** @hidden */
  14132. _initCache(): void;
  14133. /**
  14134. * Flag the transform node as dirty (Forcing it to update everything)
  14135. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14136. * @returns this transform node
  14137. */
  14138. markAsDirty(property: string): TransformNode;
  14139. /**
  14140. * Returns the current mesh absolute position.
  14141. * Returns a Vector3.
  14142. */
  14143. readonly absolutePosition: Vector3;
  14144. /**
  14145. * Returns the current mesh absolute scaling.
  14146. * Returns a Vector3.
  14147. */
  14148. readonly absoluteScaling: Vector3;
  14149. /**
  14150. * Returns the current mesh absolute rotation.
  14151. * Returns a Quaternion.
  14152. */
  14153. readonly absoluteRotationQuaternion: Quaternion;
  14154. /**
  14155. * Sets a new matrix to apply before all other transformation
  14156. * @param matrix defines the transform matrix
  14157. * @returns the current TransformNode
  14158. */
  14159. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14160. /**
  14161. * Sets a new pivot matrix to the current node
  14162. * @param matrix defines the new pivot matrix to use
  14163. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14164. * @returns the current TransformNode
  14165. */
  14166. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14167. /**
  14168. * Returns the mesh pivot matrix.
  14169. * Default : Identity.
  14170. * @returns the matrix
  14171. */
  14172. getPivotMatrix(): Matrix;
  14173. /**
  14174. * Instantiate (when possible) or clone that node with its hierarchy
  14175. * @param newParent defines the new parent to use for the instance (or clone)
  14176. * @returns an instance (or a clone) of the current node with its hiearchy
  14177. */
  14178. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14179. /**
  14180. * Prevents the World matrix to be computed any longer
  14181. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14182. * @returns the TransformNode.
  14183. */
  14184. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14185. /**
  14186. * Allows back the World matrix computation.
  14187. * @returns the TransformNode.
  14188. */
  14189. unfreezeWorldMatrix(): this;
  14190. /**
  14191. * True if the World matrix has been frozen.
  14192. */
  14193. readonly isWorldMatrixFrozen: boolean;
  14194. /**
  14195. * Retuns the mesh absolute position in the World.
  14196. * @returns a Vector3.
  14197. */
  14198. getAbsolutePosition(): Vector3;
  14199. /**
  14200. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14201. * @param absolutePosition the absolute position to set
  14202. * @returns the TransformNode.
  14203. */
  14204. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14205. /**
  14206. * Sets the mesh position in its local space.
  14207. * @param vector3 the position to set in localspace
  14208. * @returns the TransformNode.
  14209. */
  14210. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14211. /**
  14212. * Returns the mesh position in the local space from the current World matrix values.
  14213. * @returns a new Vector3.
  14214. */
  14215. getPositionExpressedInLocalSpace(): Vector3;
  14216. /**
  14217. * Translates the mesh along the passed Vector3 in its local space.
  14218. * @param vector3 the distance to translate in localspace
  14219. * @returns the TransformNode.
  14220. */
  14221. locallyTranslate(vector3: Vector3): TransformNode;
  14222. private static _lookAtVectorCache;
  14223. /**
  14224. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14225. * @param targetPoint the position (must be in same space as current mesh) to look at
  14226. * @param yawCor optional yaw (y-axis) correction in radians
  14227. * @param pitchCor optional pitch (x-axis) correction in radians
  14228. * @param rollCor optional roll (z-axis) correction in radians
  14229. * @param space the choosen space of the target
  14230. * @returns the TransformNode.
  14231. */
  14232. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14233. /**
  14234. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14235. * This Vector3 is expressed in the World space.
  14236. * @param localAxis axis to rotate
  14237. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14238. */
  14239. getDirection(localAxis: Vector3): Vector3;
  14240. /**
  14241. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14242. * localAxis is expressed in the mesh local space.
  14243. * result is computed in the Wordl space from the mesh World matrix.
  14244. * @param localAxis axis to rotate
  14245. * @param result the resulting transformnode
  14246. * @returns this TransformNode.
  14247. */
  14248. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14249. /**
  14250. * Sets this transform node rotation to the given local axis.
  14251. * @param localAxis the axis in local space
  14252. * @param yawCor optional yaw (y-axis) correction in radians
  14253. * @param pitchCor optional pitch (x-axis) correction in radians
  14254. * @param rollCor optional roll (z-axis) correction in radians
  14255. * @returns this TransformNode
  14256. */
  14257. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14258. /**
  14259. * Sets a new pivot point to the current node
  14260. * @param point defines the new pivot point to use
  14261. * @param space defines if the point is in world or local space (local by default)
  14262. * @returns the current TransformNode
  14263. */
  14264. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14265. /**
  14266. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14267. * @returns the pivot point
  14268. */
  14269. getPivotPoint(): Vector3;
  14270. /**
  14271. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14272. * @param result the vector3 to store the result
  14273. * @returns this TransformNode.
  14274. */
  14275. getPivotPointToRef(result: Vector3): TransformNode;
  14276. /**
  14277. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14278. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14279. */
  14280. getAbsolutePivotPoint(): Vector3;
  14281. /**
  14282. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14283. * @param result vector3 to store the result
  14284. * @returns this TransformNode.
  14285. */
  14286. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14287. /**
  14288. * Defines the passed node as the parent of the current node.
  14289. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14290. * @see https://doc.babylonjs.com/how_to/parenting
  14291. * @param node the node ot set as the parent
  14292. * @returns this TransformNode.
  14293. */
  14294. setParent(node: Nullable<Node>): TransformNode;
  14295. private _nonUniformScaling;
  14296. /**
  14297. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14298. */
  14299. readonly nonUniformScaling: boolean;
  14300. /** @hidden */
  14301. _updateNonUniformScalingState(value: boolean): boolean;
  14302. /**
  14303. * Attach the current TransformNode to another TransformNode associated with a bone
  14304. * @param bone Bone affecting the TransformNode
  14305. * @param affectedTransformNode TransformNode associated with the bone
  14306. * @returns this object
  14307. */
  14308. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14309. /**
  14310. * Detach the transform node if its associated with a bone
  14311. * @returns this object
  14312. */
  14313. detachFromBone(): TransformNode;
  14314. private static _rotationAxisCache;
  14315. /**
  14316. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14317. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14318. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14319. * The passed axis is also normalized.
  14320. * @param axis the axis to rotate around
  14321. * @param amount the amount to rotate in radians
  14322. * @param space Space to rotate in (Default: local)
  14323. * @returns the TransformNode.
  14324. */
  14325. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14326. /**
  14327. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14328. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14329. * The passed axis is also normalized. .
  14330. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14331. * @param point the point to rotate around
  14332. * @param axis the axis to rotate around
  14333. * @param amount the amount to rotate in radians
  14334. * @returns the TransformNode
  14335. */
  14336. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14337. /**
  14338. * Translates the mesh along the axis vector for the passed distance in the given space.
  14339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14340. * @param axis the axis to translate in
  14341. * @param distance the distance to translate
  14342. * @param space Space to rotate in (Default: local)
  14343. * @returns the TransformNode.
  14344. */
  14345. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14346. /**
  14347. * Adds a rotation step to the mesh current rotation.
  14348. * x, y, z are Euler angles expressed in radians.
  14349. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14350. * This means this rotation is made in the mesh local space only.
  14351. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14352. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14353. * ```javascript
  14354. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14355. * ```
  14356. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14357. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14358. * @param x Rotation to add
  14359. * @param y Rotation to add
  14360. * @param z Rotation to add
  14361. * @returns the TransformNode.
  14362. */
  14363. addRotation(x: number, y: number, z: number): TransformNode;
  14364. /**
  14365. * @hidden
  14366. */
  14367. protected _getEffectiveParent(): Nullable<Node>;
  14368. /**
  14369. * Computes the world matrix of the node
  14370. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14371. * @returns the world matrix
  14372. */
  14373. computeWorldMatrix(force?: boolean): Matrix;
  14374. protected _afterComputeWorldMatrix(): void;
  14375. /**
  14376. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14377. * @param func callback function to add
  14378. *
  14379. * @returns the TransformNode.
  14380. */
  14381. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14382. /**
  14383. * Removes a registered callback function.
  14384. * @param func callback function to remove
  14385. * @returns the TransformNode.
  14386. */
  14387. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14388. /**
  14389. * Gets the position of the current mesh in camera space
  14390. * @param camera defines the camera to use
  14391. * @returns a position
  14392. */
  14393. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14394. /**
  14395. * Returns the distance from the mesh to the active camera
  14396. * @param camera defines the camera to use
  14397. * @returns the distance
  14398. */
  14399. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14400. /**
  14401. * Clone the current transform node
  14402. * @param name Name of the new clone
  14403. * @param newParent New parent for the clone
  14404. * @param doNotCloneChildren Do not clone children hierarchy
  14405. * @returns the new transform node
  14406. */
  14407. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14408. /**
  14409. * Serializes the objects information.
  14410. * @param currentSerializationObject defines the object to serialize in
  14411. * @returns the serialized object
  14412. */
  14413. serialize(currentSerializationObject?: any): any;
  14414. /**
  14415. * Returns a new TransformNode object parsed from the source provided.
  14416. * @param parsedTransformNode is the source.
  14417. * @param scene the scne the object belongs to
  14418. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14419. * @returns a new TransformNode object parsed from the source provided.
  14420. */
  14421. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14422. /**
  14423. * Get all child-transformNodes of this node
  14424. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14425. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14426. * @returns an array of TransformNode
  14427. */
  14428. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14429. /**
  14430. * Releases resources associated with this transform node.
  14431. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14432. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14433. */
  14434. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14435. /**
  14436. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14437. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14438. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14439. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14440. * @returns the current mesh
  14441. */
  14442. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14443. private _syncAbsoluteScalingAndRotation;
  14444. }
  14445. }
  14446. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14447. import { Observable } from "babylonjs/Misc/observable";
  14448. import { Nullable } from "babylonjs/types";
  14449. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14450. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14452. import { Ray } from "babylonjs/Culling/ray";
  14453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14454. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14456. /**
  14457. * Defines the types of pose enabled controllers that are supported
  14458. */
  14459. export enum PoseEnabledControllerType {
  14460. /**
  14461. * HTC Vive
  14462. */
  14463. VIVE = 0,
  14464. /**
  14465. * Oculus Rift
  14466. */
  14467. OCULUS = 1,
  14468. /**
  14469. * Windows mixed reality
  14470. */
  14471. WINDOWS = 2,
  14472. /**
  14473. * Samsung gear VR
  14474. */
  14475. GEAR_VR = 3,
  14476. /**
  14477. * Google Daydream
  14478. */
  14479. DAYDREAM = 4,
  14480. /**
  14481. * Generic
  14482. */
  14483. GENERIC = 5
  14484. }
  14485. /**
  14486. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14487. */
  14488. export interface MutableGamepadButton {
  14489. /**
  14490. * Value of the button/trigger
  14491. */
  14492. value: number;
  14493. /**
  14494. * If the button/trigger is currently touched
  14495. */
  14496. touched: boolean;
  14497. /**
  14498. * If the button/trigger is currently pressed
  14499. */
  14500. pressed: boolean;
  14501. }
  14502. /**
  14503. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14504. * @hidden
  14505. */
  14506. export interface ExtendedGamepadButton extends GamepadButton {
  14507. /**
  14508. * If the button/trigger is currently pressed
  14509. */
  14510. readonly pressed: boolean;
  14511. /**
  14512. * If the button/trigger is currently touched
  14513. */
  14514. readonly touched: boolean;
  14515. /**
  14516. * Value of the button/trigger
  14517. */
  14518. readonly value: number;
  14519. }
  14520. /** @hidden */
  14521. export interface _GamePadFactory {
  14522. /**
  14523. * Returns wether or not the current gamepad can be created for this type of controller.
  14524. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14525. * @returns true if it can be created, otherwise false
  14526. */
  14527. canCreate(gamepadInfo: any): boolean;
  14528. /**
  14529. * Creates a new instance of the Gamepad.
  14530. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14531. * @returns the new gamepad instance
  14532. */
  14533. create(gamepadInfo: any): Gamepad;
  14534. }
  14535. /**
  14536. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14537. */
  14538. export class PoseEnabledControllerHelper {
  14539. /** @hidden */
  14540. static _ControllerFactories: _GamePadFactory[];
  14541. /** @hidden */
  14542. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14543. /**
  14544. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14545. * @param vrGamepad the gamepad to initialized
  14546. * @returns a vr controller of the type the gamepad identified as
  14547. */
  14548. static InitiateController(vrGamepad: any): Gamepad;
  14549. }
  14550. /**
  14551. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14552. */
  14553. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14554. /**
  14555. * If the controller is used in a webXR session
  14556. */
  14557. isXR: boolean;
  14558. private _deviceRoomPosition;
  14559. private _deviceRoomRotationQuaternion;
  14560. /**
  14561. * The device position in babylon space
  14562. */
  14563. devicePosition: Vector3;
  14564. /**
  14565. * The device rotation in babylon space
  14566. */
  14567. deviceRotationQuaternion: Quaternion;
  14568. /**
  14569. * The scale factor of the device in babylon space
  14570. */
  14571. deviceScaleFactor: number;
  14572. /**
  14573. * (Likely devicePosition should be used instead) The device position in its room space
  14574. */
  14575. position: Vector3;
  14576. /**
  14577. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14578. */
  14579. rotationQuaternion: Quaternion;
  14580. /**
  14581. * The type of controller (Eg. Windows mixed reality)
  14582. */
  14583. controllerType: PoseEnabledControllerType;
  14584. protected _calculatedPosition: Vector3;
  14585. private _calculatedRotation;
  14586. /**
  14587. * The raw pose from the device
  14588. */
  14589. rawPose: DevicePose;
  14590. private _trackPosition;
  14591. private _maxRotationDistFromHeadset;
  14592. private _draggedRoomRotation;
  14593. /**
  14594. * @hidden
  14595. */
  14596. _disableTrackPosition(fixedPosition: Vector3): void;
  14597. /**
  14598. * Internal, the mesh attached to the controller
  14599. * @hidden
  14600. */
  14601. _mesh: Nullable<AbstractMesh>;
  14602. private _poseControlledCamera;
  14603. private _leftHandSystemQuaternion;
  14604. /**
  14605. * Internal, matrix used to convert room space to babylon space
  14606. * @hidden
  14607. */
  14608. _deviceToWorld: Matrix;
  14609. /**
  14610. * Node to be used when casting a ray from the controller
  14611. * @hidden
  14612. */
  14613. _pointingPoseNode: Nullable<TransformNode>;
  14614. /**
  14615. * Name of the child mesh that can be used to cast a ray from the controller
  14616. */
  14617. static readonly POINTING_POSE: string;
  14618. /**
  14619. * Creates a new PoseEnabledController from a gamepad
  14620. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14621. */
  14622. constructor(browserGamepad: any);
  14623. private _workingMatrix;
  14624. /**
  14625. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14626. */
  14627. update(): void;
  14628. /**
  14629. * Updates only the pose device and mesh without doing any button event checking
  14630. */
  14631. protected _updatePoseAndMesh(): void;
  14632. /**
  14633. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14634. * @param poseData raw pose fromthe device
  14635. */
  14636. updateFromDevice(poseData: DevicePose): void;
  14637. /**
  14638. * @hidden
  14639. */
  14640. _meshAttachedObservable: Observable<AbstractMesh>;
  14641. /**
  14642. * Attaches a mesh to the controller
  14643. * @param mesh the mesh to be attached
  14644. */
  14645. attachToMesh(mesh: AbstractMesh): void;
  14646. /**
  14647. * Attaches the controllers mesh to a camera
  14648. * @param camera the camera the mesh should be attached to
  14649. */
  14650. attachToPoseControlledCamera(camera: TargetCamera): void;
  14651. /**
  14652. * Disposes of the controller
  14653. */
  14654. dispose(): void;
  14655. /**
  14656. * The mesh that is attached to the controller
  14657. */
  14658. readonly mesh: Nullable<AbstractMesh>;
  14659. /**
  14660. * Gets the ray of the controller in the direction the controller is pointing
  14661. * @param length the length the resulting ray should be
  14662. * @returns a ray in the direction the controller is pointing
  14663. */
  14664. getForwardRay(length?: number): Ray;
  14665. }
  14666. }
  14667. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14668. import { Observable } from "babylonjs/Misc/observable";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14671. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14672. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14673. /**
  14674. * Defines the WebVRController object that represents controllers tracked in 3D space
  14675. */
  14676. export abstract class WebVRController extends PoseEnabledController {
  14677. /**
  14678. * Internal, the default controller model for the controller
  14679. */
  14680. protected _defaultModel: AbstractMesh;
  14681. /**
  14682. * Fired when the trigger state has changed
  14683. */
  14684. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14685. /**
  14686. * Fired when the main button state has changed
  14687. */
  14688. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14689. /**
  14690. * Fired when the secondary button state has changed
  14691. */
  14692. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14693. /**
  14694. * Fired when the pad state has changed
  14695. */
  14696. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14697. /**
  14698. * Fired when controllers stick values have changed
  14699. */
  14700. onPadValuesChangedObservable: Observable<StickValues>;
  14701. /**
  14702. * Array of button availible on the controller
  14703. */
  14704. protected _buttons: Array<MutableGamepadButton>;
  14705. private _onButtonStateChange;
  14706. /**
  14707. * Fired when a controller button's state has changed
  14708. * @param callback the callback containing the button that was modified
  14709. */
  14710. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14711. /**
  14712. * X and Y axis corresponding to the controllers joystick
  14713. */
  14714. pad: StickValues;
  14715. /**
  14716. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14717. */
  14718. hand: string;
  14719. /**
  14720. * The default controller model for the controller
  14721. */
  14722. readonly defaultModel: AbstractMesh;
  14723. /**
  14724. * Creates a new WebVRController from a gamepad
  14725. * @param vrGamepad the gamepad that the WebVRController should be created from
  14726. */
  14727. constructor(vrGamepad: any);
  14728. /**
  14729. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14730. */
  14731. update(): void;
  14732. /**
  14733. * Function to be called when a button is modified
  14734. */
  14735. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14736. /**
  14737. * Loads a mesh and attaches it to the controller
  14738. * @param scene the scene the mesh should be added to
  14739. * @param meshLoaded callback for when the mesh has been loaded
  14740. */
  14741. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14742. private _setButtonValue;
  14743. private _changes;
  14744. private _checkChanges;
  14745. /**
  14746. * Disposes of th webVRCOntroller
  14747. */
  14748. dispose(): void;
  14749. }
  14750. }
  14751. declare module "babylonjs/Lights/hemisphericLight" {
  14752. import { Nullable } from "babylonjs/types";
  14753. import { Scene } from "babylonjs/scene";
  14754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14755. import { Color3 } from "babylonjs/Maths/math.color";
  14756. import { Effect } from "babylonjs/Materials/effect";
  14757. import { Light } from "babylonjs/Lights/light";
  14758. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14759. /**
  14760. * The HemisphericLight simulates the ambient environment light,
  14761. * so the passed direction is the light reflection direction, not the incoming direction.
  14762. */
  14763. export class HemisphericLight extends Light {
  14764. /**
  14765. * The groundColor is the light in the opposite direction to the one specified during creation.
  14766. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14767. */
  14768. groundColor: Color3;
  14769. /**
  14770. * The light reflection direction, not the incoming direction.
  14771. */
  14772. direction: Vector3;
  14773. /**
  14774. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14775. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14776. * The HemisphericLight can't cast shadows.
  14777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14778. * @param name The friendly name of the light
  14779. * @param direction The direction of the light reflection
  14780. * @param scene The scene the light belongs to
  14781. */
  14782. constructor(name: string, direction: Vector3, scene: Scene);
  14783. protected _buildUniformLayout(): void;
  14784. /**
  14785. * Returns the string "HemisphericLight".
  14786. * @return The class name
  14787. */
  14788. getClassName(): string;
  14789. /**
  14790. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14791. * Returns the updated direction.
  14792. * @param target The target the direction should point to
  14793. * @return The computed direction
  14794. */
  14795. setDirectionToTarget(target: Vector3): Vector3;
  14796. /**
  14797. * Returns the shadow generator associated to the light.
  14798. * @returns Always null for hemispheric lights because it does not support shadows.
  14799. */
  14800. getShadowGenerator(): Nullable<IShadowGenerator>;
  14801. /**
  14802. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14803. * @param effect The effect to update
  14804. * @param lightIndex The index of the light in the effect to update
  14805. * @returns The hemispheric light
  14806. */
  14807. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14808. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14809. /**
  14810. * Computes the world matrix of the node
  14811. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14812. * @param useWasUpdatedFlag defines a reserved property
  14813. * @returns the world matrix
  14814. */
  14815. computeWorldMatrix(): Matrix;
  14816. /**
  14817. * Returns the integer 3.
  14818. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14819. */
  14820. getTypeID(): number;
  14821. /**
  14822. * Prepares the list of defines specific to the light type.
  14823. * @param defines the list of defines
  14824. * @param lightIndex defines the index of the light for the effect
  14825. */
  14826. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14827. }
  14828. }
  14829. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14830. /** @hidden */
  14831. export var vrMultiviewToSingleviewPixelShader: {
  14832. name: string;
  14833. shader: string;
  14834. };
  14835. }
  14836. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14838. import { Scene } from "babylonjs/scene";
  14839. /**
  14840. * Renders to multiple views with a single draw call
  14841. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14842. */
  14843. export class MultiviewRenderTarget extends RenderTargetTexture {
  14844. /**
  14845. * Creates a multiview render target
  14846. * @param scene scene used with the render target
  14847. * @param size the size of the render target (used for each view)
  14848. */
  14849. constructor(scene: Scene, size?: number | {
  14850. width: number;
  14851. height: number;
  14852. } | {
  14853. ratio: number;
  14854. });
  14855. /**
  14856. * @hidden
  14857. * @param faceIndex the face index, if its a cube texture
  14858. */
  14859. _bindFrameBuffer(faceIndex?: number): void;
  14860. /**
  14861. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14862. * @returns the view count
  14863. */
  14864. getViewCount(): number;
  14865. }
  14866. }
  14867. declare module "babylonjs/Maths/math.frustum" {
  14868. import { Matrix } from "babylonjs/Maths/math.vector";
  14869. import { DeepImmutable } from "babylonjs/types";
  14870. import { Plane } from "babylonjs/Maths/math.plane";
  14871. /**
  14872. * Represents a camera frustum
  14873. */
  14874. export class Frustum {
  14875. /**
  14876. * Gets the planes representing the frustum
  14877. * @param transform matrix to be applied to the returned planes
  14878. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14879. */
  14880. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14881. /**
  14882. * Gets the near frustum plane transformed by the transform matrix
  14883. * @param transform transformation matrix to be applied to the resulting frustum plane
  14884. * @param frustumPlane the resuling frustum plane
  14885. */
  14886. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14887. /**
  14888. * Gets the far frustum plane transformed by the transform matrix
  14889. * @param transform transformation matrix to be applied to the resulting frustum plane
  14890. * @param frustumPlane the resuling frustum plane
  14891. */
  14892. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14893. /**
  14894. * Gets the left frustum plane transformed by the transform matrix
  14895. * @param transform transformation matrix to be applied to the resulting frustum plane
  14896. * @param frustumPlane the resuling frustum plane
  14897. */
  14898. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14899. /**
  14900. * Gets the right frustum plane transformed by the transform matrix
  14901. * @param transform transformation matrix to be applied to the resulting frustum plane
  14902. * @param frustumPlane the resuling frustum plane
  14903. */
  14904. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14905. /**
  14906. * Gets the top frustum plane transformed by the transform matrix
  14907. * @param transform transformation matrix to be applied to the resulting frustum plane
  14908. * @param frustumPlane the resuling frustum plane
  14909. */
  14910. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14911. /**
  14912. * Gets the bottom frustum plane transformed by the transform matrix
  14913. * @param transform transformation matrix to be applied to the resulting frustum plane
  14914. * @param frustumPlane the resuling frustum plane
  14915. */
  14916. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14917. /**
  14918. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14919. * @param transform transformation matrix to be applied to the resulting frustum planes
  14920. * @param frustumPlanes the resuling frustum planes
  14921. */
  14922. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14923. }
  14924. }
  14925. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14926. import { Camera } from "babylonjs/Cameras/camera";
  14927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14928. import { Nullable } from "babylonjs/types";
  14929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14930. import { Matrix } from "babylonjs/Maths/math.vector";
  14931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14932. module "babylonjs/Engines/engine" {
  14933. interface Engine {
  14934. /**
  14935. * Creates a new multiview render target
  14936. * @param width defines the width of the texture
  14937. * @param height defines the height of the texture
  14938. * @returns the created multiview texture
  14939. */
  14940. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14941. /**
  14942. * Binds a multiview framebuffer to be drawn to
  14943. * @param multiviewTexture texture to bind
  14944. */
  14945. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14946. }
  14947. }
  14948. module "babylonjs/Cameras/camera" {
  14949. interface Camera {
  14950. /**
  14951. * @hidden
  14952. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14953. */
  14954. _useMultiviewToSingleView: boolean;
  14955. /**
  14956. * @hidden
  14957. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14958. */
  14959. _multiviewTexture: Nullable<RenderTargetTexture>;
  14960. /**
  14961. * @hidden
  14962. * ensures the multiview texture of the camera exists and has the specified width/height
  14963. * @param width height to set on the multiview texture
  14964. * @param height width to set on the multiview texture
  14965. */
  14966. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14967. }
  14968. }
  14969. module "babylonjs/scene" {
  14970. interface Scene {
  14971. /** @hidden */
  14972. _transformMatrixR: Matrix;
  14973. /** @hidden */
  14974. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14975. /** @hidden */
  14976. _createMultiviewUbo(): void;
  14977. /** @hidden */
  14978. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14979. /** @hidden */
  14980. _renderMultiviewToSingleView(camera: Camera): void;
  14981. }
  14982. }
  14983. }
  14984. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14987. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14988. import "babylonjs/Engines/Extensions/engine.multiview";
  14989. /**
  14990. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14991. * This will not be used for webXR as it supports displaying texture arrays directly
  14992. */
  14993. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14994. /**
  14995. * Initializes a VRMultiviewToSingleview
  14996. * @param name name of the post process
  14997. * @param camera camera to be applied to
  14998. * @param scaleFactor scaling factor to the size of the output texture
  14999. */
  15000. constructor(name: string, camera: Camera, scaleFactor: number);
  15001. }
  15002. }
  15003. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15004. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15005. import { Nullable } from "babylonjs/types";
  15006. import { Size } from "babylonjs/Maths/math.size";
  15007. import { Observable } from "babylonjs/Misc/observable";
  15008. module "babylonjs/Engines/engine" {
  15009. interface Engine {
  15010. /** @hidden */
  15011. _vrDisplay: any;
  15012. /** @hidden */
  15013. _vrSupported: boolean;
  15014. /** @hidden */
  15015. _oldSize: Size;
  15016. /** @hidden */
  15017. _oldHardwareScaleFactor: number;
  15018. /** @hidden */
  15019. _vrExclusivePointerMode: boolean;
  15020. /** @hidden */
  15021. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15022. /** @hidden */
  15023. _onVRDisplayPointerRestricted: () => void;
  15024. /** @hidden */
  15025. _onVRDisplayPointerUnrestricted: () => void;
  15026. /** @hidden */
  15027. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15028. /** @hidden */
  15029. _onVrDisplayDisconnect: Nullable<() => void>;
  15030. /** @hidden */
  15031. _onVrDisplayPresentChange: Nullable<() => void>;
  15032. /**
  15033. * Observable signaled when VR display mode changes
  15034. */
  15035. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15036. /**
  15037. * Observable signaled when VR request present is complete
  15038. */
  15039. onVRRequestPresentComplete: Observable<boolean>;
  15040. /**
  15041. * Observable signaled when VR request present starts
  15042. */
  15043. onVRRequestPresentStart: Observable<Engine>;
  15044. /**
  15045. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15046. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15047. */
  15048. isInVRExclusivePointerMode: boolean;
  15049. /**
  15050. * Gets a boolean indicating if a webVR device was detected
  15051. * @returns true if a webVR device was detected
  15052. */
  15053. isVRDevicePresent(): boolean;
  15054. /**
  15055. * Gets the current webVR device
  15056. * @returns the current webVR device (or null)
  15057. */
  15058. getVRDevice(): any;
  15059. /**
  15060. * Initializes a webVR display and starts listening to display change events
  15061. * The onVRDisplayChangedObservable will be notified upon these changes
  15062. * @returns A promise containing a VRDisplay and if vr is supported
  15063. */
  15064. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15067. /**
  15068. * Call this function to switch to webVR mode
  15069. * Will do nothing if webVR is not supported or if there is no webVR device
  15070. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15071. */
  15072. enableVR(): void;
  15073. /** @hidden */
  15074. _onVRFullScreenTriggered(): void;
  15075. }
  15076. }
  15077. }
  15078. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15079. import { Nullable } from "babylonjs/types";
  15080. import { Observable } from "babylonjs/Misc/observable";
  15081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15082. import { Scene } from "babylonjs/scene";
  15083. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15084. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15085. import { Node } from "babylonjs/node";
  15086. import { Ray } from "babylonjs/Culling/ray";
  15087. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15088. import "babylonjs/Engines/Extensions/engine.webVR";
  15089. /**
  15090. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15091. * IMPORTANT!! The data is right-hand data.
  15092. * @export
  15093. * @interface DevicePose
  15094. */
  15095. export interface DevicePose {
  15096. /**
  15097. * The position of the device, values in array are [x,y,z].
  15098. */
  15099. readonly position: Nullable<Float32Array>;
  15100. /**
  15101. * The linearVelocity of the device, values in array are [x,y,z].
  15102. */
  15103. readonly linearVelocity: Nullable<Float32Array>;
  15104. /**
  15105. * The linearAcceleration of the device, values in array are [x,y,z].
  15106. */
  15107. readonly linearAcceleration: Nullable<Float32Array>;
  15108. /**
  15109. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15110. */
  15111. readonly orientation: Nullable<Float32Array>;
  15112. /**
  15113. * The angularVelocity of the device, values in array are [x,y,z].
  15114. */
  15115. readonly angularVelocity: Nullable<Float32Array>;
  15116. /**
  15117. * The angularAcceleration of the device, values in array are [x,y,z].
  15118. */
  15119. readonly angularAcceleration: Nullable<Float32Array>;
  15120. }
  15121. /**
  15122. * Interface representing a pose controlled object in Babylon.
  15123. * A pose controlled object has both regular pose values as well as pose values
  15124. * from an external device such as a VR head mounted display
  15125. */
  15126. export interface PoseControlled {
  15127. /**
  15128. * The position of the object in babylon space.
  15129. */
  15130. position: Vector3;
  15131. /**
  15132. * The rotation quaternion of the object in babylon space.
  15133. */
  15134. rotationQuaternion: Quaternion;
  15135. /**
  15136. * The position of the device in babylon space.
  15137. */
  15138. devicePosition?: Vector3;
  15139. /**
  15140. * The rotation quaternion of the device in babylon space.
  15141. */
  15142. deviceRotationQuaternion: Quaternion;
  15143. /**
  15144. * The raw pose coming from the device.
  15145. */
  15146. rawPose: Nullable<DevicePose>;
  15147. /**
  15148. * The scale of the device to be used when translating from device space to babylon space.
  15149. */
  15150. deviceScaleFactor: number;
  15151. /**
  15152. * Updates the poseControlled values based on the input device pose.
  15153. * @param poseData the pose data to update the object with
  15154. */
  15155. updateFromDevice(poseData: DevicePose): void;
  15156. }
  15157. /**
  15158. * Set of options to customize the webVRCamera
  15159. */
  15160. export interface WebVROptions {
  15161. /**
  15162. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15163. */
  15164. trackPosition?: boolean;
  15165. /**
  15166. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15167. */
  15168. positionScale?: number;
  15169. /**
  15170. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15171. */
  15172. displayName?: string;
  15173. /**
  15174. * Should the native controller meshes be initialized. (default: true)
  15175. */
  15176. controllerMeshes?: boolean;
  15177. /**
  15178. * Creating a default HemiLight only on controllers. (default: true)
  15179. */
  15180. defaultLightingOnControllers?: boolean;
  15181. /**
  15182. * If you don't want to use the default VR button of the helper. (default: false)
  15183. */
  15184. useCustomVRButton?: boolean;
  15185. /**
  15186. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15187. */
  15188. customVRButton?: HTMLButtonElement;
  15189. /**
  15190. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15191. */
  15192. rayLength?: number;
  15193. /**
  15194. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15195. */
  15196. defaultHeight?: number;
  15197. /**
  15198. * If multiview should be used if availible (default: false)
  15199. */
  15200. useMultiview?: boolean;
  15201. }
  15202. /**
  15203. * This represents a WebVR camera.
  15204. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15205. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15206. */
  15207. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15208. private webVROptions;
  15209. /**
  15210. * @hidden
  15211. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15212. */
  15213. _vrDevice: any;
  15214. /**
  15215. * The rawPose of the vrDevice.
  15216. */
  15217. rawPose: Nullable<DevicePose>;
  15218. private _onVREnabled;
  15219. private _specsVersion;
  15220. private _attached;
  15221. private _frameData;
  15222. protected _descendants: Array<Node>;
  15223. private _deviceRoomPosition;
  15224. /** @hidden */
  15225. _deviceRoomRotationQuaternion: Quaternion;
  15226. private _standingMatrix;
  15227. /**
  15228. * Represents device position in babylon space.
  15229. */
  15230. devicePosition: Vector3;
  15231. /**
  15232. * Represents device rotation in babylon space.
  15233. */
  15234. deviceRotationQuaternion: Quaternion;
  15235. /**
  15236. * The scale of the device to be used when translating from device space to babylon space.
  15237. */
  15238. deviceScaleFactor: number;
  15239. private _deviceToWorld;
  15240. private _worldToDevice;
  15241. /**
  15242. * References to the webVR controllers for the vrDevice.
  15243. */
  15244. controllers: Array<WebVRController>;
  15245. /**
  15246. * Emits an event when a controller is attached.
  15247. */
  15248. onControllersAttachedObservable: Observable<WebVRController[]>;
  15249. /**
  15250. * Emits an event when a controller's mesh has been loaded;
  15251. */
  15252. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15253. /**
  15254. * Emits an event when the HMD's pose has been updated.
  15255. */
  15256. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15257. private _poseSet;
  15258. /**
  15259. * If the rig cameras be used as parent instead of this camera.
  15260. */
  15261. rigParenting: boolean;
  15262. private _lightOnControllers;
  15263. private _defaultHeight?;
  15264. /**
  15265. * Instantiates a WebVRFreeCamera.
  15266. * @param name The name of the WebVRFreeCamera
  15267. * @param position The starting anchor position for the camera
  15268. * @param scene The scene the camera belongs to
  15269. * @param webVROptions a set of customizable options for the webVRCamera
  15270. */
  15271. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15272. /**
  15273. * Gets the device distance from the ground in meters.
  15274. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15275. */
  15276. deviceDistanceToRoomGround(): number;
  15277. /**
  15278. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15279. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15280. */
  15281. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15282. /**
  15283. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15284. * @returns A promise with a boolean set to if the standing matrix is supported.
  15285. */
  15286. useStandingMatrixAsync(): Promise<boolean>;
  15287. /**
  15288. * Disposes the camera
  15289. */
  15290. dispose(): void;
  15291. /**
  15292. * Gets a vrController by name.
  15293. * @param name The name of the controller to retreive
  15294. * @returns the controller matching the name specified or null if not found
  15295. */
  15296. getControllerByName(name: string): Nullable<WebVRController>;
  15297. private _leftController;
  15298. /**
  15299. * The controller corresponding to the users left hand.
  15300. */
  15301. readonly leftController: Nullable<WebVRController>;
  15302. private _rightController;
  15303. /**
  15304. * The controller corresponding to the users right hand.
  15305. */
  15306. readonly rightController: Nullable<WebVRController>;
  15307. /**
  15308. * Casts a ray forward from the vrCamera's gaze.
  15309. * @param length Length of the ray (default: 100)
  15310. * @returns the ray corresponding to the gaze
  15311. */
  15312. getForwardRay(length?: number): Ray;
  15313. /**
  15314. * @hidden
  15315. * Updates the camera based on device's frame data
  15316. */
  15317. _checkInputs(): void;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData Pose coming from the device
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. private _htmlElementAttached;
  15324. private _detachIfAttached;
  15325. /**
  15326. * WebVR's attach control will start broadcasting frames to the device.
  15327. * Note that in certain browsers (chrome for example) this function must be called
  15328. * within a user-interaction callback. Example:
  15329. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15330. *
  15331. * @param element html element to attach the vrDevice to
  15332. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15333. */
  15334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15335. /**
  15336. * Detaches the camera from the html element and disables VR
  15337. *
  15338. * @param element html element to detach from
  15339. */
  15340. detachControl(element: HTMLElement): void;
  15341. /**
  15342. * @returns the name of this class
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Calls resetPose on the vrDisplay
  15347. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15348. */
  15349. resetToCurrentRotation(): void;
  15350. /**
  15351. * @hidden
  15352. * Updates the rig cameras (left and right eye)
  15353. */
  15354. _updateRigCameras(): void;
  15355. private _workingVector;
  15356. private _oneVector;
  15357. private _workingMatrix;
  15358. private updateCacheCalled;
  15359. private _correctPositionIfNotTrackPosition;
  15360. /**
  15361. * @hidden
  15362. * Updates the cached values of the camera
  15363. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15364. */
  15365. _updateCache(ignoreParentClass?: boolean): void;
  15366. /**
  15367. * @hidden
  15368. * Get current device position in babylon world
  15369. */
  15370. _computeDevicePosition(): void;
  15371. /**
  15372. * Updates the current device position and rotation in the babylon world
  15373. */
  15374. update(): void;
  15375. /**
  15376. * @hidden
  15377. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15378. * @returns an identity matrix
  15379. */
  15380. _getViewMatrix(): Matrix;
  15381. private _tmpMatrix;
  15382. /**
  15383. * This function is called by the two RIG cameras.
  15384. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15385. * @hidden
  15386. */
  15387. _getWebVRViewMatrix(): Matrix;
  15388. /** @hidden */
  15389. _getWebVRProjectionMatrix(): Matrix;
  15390. private _onGamepadConnectedObserver;
  15391. private _onGamepadDisconnectedObserver;
  15392. private _updateCacheWhenTrackingDisabledObserver;
  15393. /**
  15394. * Initializes the controllers and their meshes
  15395. */
  15396. initControllers(): void;
  15397. }
  15398. }
  15399. declare module "babylonjs/PostProcesses/postProcess" {
  15400. import { Nullable } from "babylonjs/types";
  15401. import { SmartArray } from "babylonjs/Misc/smartArray";
  15402. import { Observable } from "babylonjs/Misc/observable";
  15403. import { Vector2 } from "babylonjs/Maths/math.vector";
  15404. import { Camera } from "babylonjs/Cameras/camera";
  15405. import { Effect } from "babylonjs/Materials/effect";
  15406. import "babylonjs/Shaders/postprocess.vertex";
  15407. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15408. import { Engine } from "babylonjs/Engines/engine";
  15409. import { Color4 } from "babylonjs/Maths/math.color";
  15410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15411. /**
  15412. * Size options for a post process
  15413. */
  15414. export type PostProcessOptions = {
  15415. width: number;
  15416. height: number;
  15417. };
  15418. /**
  15419. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15420. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15421. */
  15422. export class PostProcess {
  15423. /** Name of the PostProcess. */
  15424. name: string;
  15425. /**
  15426. * Gets or sets the unique id of the post process
  15427. */
  15428. uniqueId: number;
  15429. /**
  15430. * Width of the texture to apply the post process on
  15431. */
  15432. width: number;
  15433. /**
  15434. * Height of the texture to apply the post process on
  15435. */
  15436. height: number;
  15437. /**
  15438. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15439. * @hidden
  15440. */
  15441. _outputTexture: Nullable<InternalTexture>;
  15442. /**
  15443. * Sampling mode used by the shader
  15444. * See https://doc.babylonjs.com/classes/3.1/texture
  15445. */
  15446. renderTargetSamplingMode: number;
  15447. /**
  15448. * Clear color to use when screen clearing
  15449. */
  15450. clearColor: Color4;
  15451. /**
  15452. * If the buffer needs to be cleared before applying the post process. (default: true)
  15453. * Should be set to false if shader will overwrite all previous pixels.
  15454. */
  15455. autoClear: boolean;
  15456. /**
  15457. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15458. */
  15459. alphaMode: number;
  15460. /**
  15461. * Sets the setAlphaBlendConstants of the babylon engine
  15462. */
  15463. alphaConstants: Color4;
  15464. /**
  15465. * Animations to be used for the post processing
  15466. */
  15467. animations: import("babylonjs/Animations/animation").Animation[];
  15468. /**
  15469. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15470. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15471. */
  15472. enablePixelPerfectMode: boolean;
  15473. /**
  15474. * Force the postprocess to be applied without taking in account viewport
  15475. */
  15476. forceFullscreenViewport: boolean;
  15477. /**
  15478. * List of inspectable custom properties (used by the Inspector)
  15479. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15480. */
  15481. inspectableCustomProperties: IInspectable[];
  15482. /**
  15483. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15484. *
  15485. * | Value | Type | Description |
  15486. * | ----- | ----------------------------------- | ----------- |
  15487. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15488. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15489. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15490. *
  15491. */
  15492. scaleMode: number;
  15493. /**
  15494. * Force textures to be a power of two (default: false)
  15495. */
  15496. alwaysForcePOT: boolean;
  15497. private _samples;
  15498. /**
  15499. * Number of sample textures (default: 1)
  15500. */
  15501. samples: number;
  15502. /**
  15503. * Modify the scale of the post process to be the same as the viewport (default: false)
  15504. */
  15505. adaptScaleToCurrentViewport: boolean;
  15506. private _camera;
  15507. private _scene;
  15508. private _engine;
  15509. private _options;
  15510. private _reusable;
  15511. private _textureType;
  15512. /**
  15513. * Smart array of input and output textures for the post process.
  15514. * @hidden
  15515. */
  15516. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15517. /**
  15518. * The index in _textures that corresponds to the output texture.
  15519. * @hidden
  15520. */
  15521. _currentRenderTextureInd: number;
  15522. private _effect;
  15523. private _samplers;
  15524. private _fragmentUrl;
  15525. private _vertexUrl;
  15526. private _parameters;
  15527. private _scaleRatio;
  15528. protected _indexParameters: any;
  15529. private _shareOutputWithPostProcess;
  15530. private _texelSize;
  15531. private _forcedOutputTexture;
  15532. /**
  15533. * Returns the fragment url or shader name used in the post process.
  15534. * @returns the fragment url or name in the shader store.
  15535. */
  15536. getEffectName(): string;
  15537. /**
  15538. * An event triggered when the postprocess is activated.
  15539. */
  15540. onActivateObservable: Observable<Camera>;
  15541. private _onActivateObserver;
  15542. /**
  15543. * A function that is added to the onActivateObservable
  15544. */
  15545. onActivate: Nullable<(camera: Camera) => void>;
  15546. /**
  15547. * An event triggered when the postprocess changes its size.
  15548. */
  15549. onSizeChangedObservable: Observable<PostProcess>;
  15550. private _onSizeChangedObserver;
  15551. /**
  15552. * A function that is added to the onSizeChangedObservable
  15553. */
  15554. onSizeChanged: (postProcess: PostProcess) => void;
  15555. /**
  15556. * An event triggered when the postprocess applies its effect.
  15557. */
  15558. onApplyObservable: Observable<Effect>;
  15559. private _onApplyObserver;
  15560. /**
  15561. * A function that is added to the onApplyObservable
  15562. */
  15563. onApply: (effect: Effect) => void;
  15564. /**
  15565. * An event triggered before rendering the postprocess
  15566. */
  15567. onBeforeRenderObservable: Observable<Effect>;
  15568. private _onBeforeRenderObserver;
  15569. /**
  15570. * A function that is added to the onBeforeRenderObservable
  15571. */
  15572. onBeforeRender: (effect: Effect) => void;
  15573. /**
  15574. * An event triggered after rendering the postprocess
  15575. */
  15576. onAfterRenderObservable: Observable<Effect>;
  15577. private _onAfterRenderObserver;
  15578. /**
  15579. * A function that is added to the onAfterRenderObservable
  15580. */
  15581. onAfterRender: (efect: Effect) => void;
  15582. /**
  15583. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15584. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15585. */
  15586. inputTexture: InternalTexture;
  15587. /**
  15588. * Gets the camera which post process is applied to.
  15589. * @returns The camera the post process is applied to.
  15590. */
  15591. getCamera(): Camera;
  15592. /**
  15593. * Gets the texel size of the postprocess.
  15594. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15595. */
  15596. readonly texelSize: Vector2;
  15597. /**
  15598. * Creates a new instance PostProcess
  15599. * @param name The name of the PostProcess.
  15600. * @param fragmentUrl The url of the fragment shader to be used.
  15601. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15602. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15603. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15604. * @param camera The camera to apply the render pass to.
  15605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15606. * @param engine The engine which the post process will be applied. (default: current engine)
  15607. * @param reusable If the post process can be reused on the same frame. (default: false)
  15608. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15609. * @param textureType Type of textures used when performing the post process. (default: 0)
  15610. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15611. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15612. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15613. */
  15614. constructor(
  15615. /** Name of the PostProcess. */
  15616. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15617. /**
  15618. * Gets a string idenfifying the name of the class
  15619. * @returns "PostProcess" string
  15620. */
  15621. getClassName(): string;
  15622. /**
  15623. * Gets the engine which this post process belongs to.
  15624. * @returns The engine the post process was enabled with.
  15625. */
  15626. getEngine(): Engine;
  15627. /**
  15628. * The effect that is created when initializing the post process.
  15629. * @returns The created effect corresponding the the postprocess.
  15630. */
  15631. getEffect(): Effect;
  15632. /**
  15633. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15634. * @param postProcess The post process to share the output with.
  15635. * @returns This post process.
  15636. */
  15637. shareOutputWith(postProcess: PostProcess): PostProcess;
  15638. /**
  15639. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15640. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15641. */
  15642. useOwnOutput(): void;
  15643. /**
  15644. * Updates the effect with the current post process compile time values and recompiles the shader.
  15645. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15646. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15647. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15648. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15649. * @param onCompiled Called when the shader has been compiled.
  15650. * @param onError Called if there is an error when compiling a shader.
  15651. */
  15652. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15653. /**
  15654. * The post process is reusable if it can be used multiple times within one frame.
  15655. * @returns If the post process is reusable
  15656. */
  15657. isReusable(): boolean;
  15658. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15659. markTextureDirty(): void;
  15660. /**
  15661. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15662. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15663. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15664. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15665. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15666. * @returns The target texture that was bound to be written to.
  15667. */
  15668. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15669. /**
  15670. * If the post process is supported.
  15671. */
  15672. readonly isSupported: boolean;
  15673. /**
  15674. * The aspect ratio of the output texture.
  15675. */
  15676. readonly aspectRatio: number;
  15677. /**
  15678. * Get a value indicating if the post-process is ready to be used
  15679. * @returns true if the post-process is ready (shader is compiled)
  15680. */
  15681. isReady(): boolean;
  15682. /**
  15683. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15684. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15685. */
  15686. apply(): Nullable<Effect>;
  15687. private _disposeTextures;
  15688. /**
  15689. * Disposes the post process.
  15690. * @param camera The camera to dispose the post process on.
  15691. */
  15692. dispose(camera?: Camera): void;
  15693. }
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15696. /** @hidden */
  15697. export var kernelBlurVaryingDeclaration: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15710. /** @hidden */
  15711. export var kernelBlurFragment2: {
  15712. name: string;
  15713. shader: string;
  15714. };
  15715. }
  15716. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15717. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15718. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15719. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15720. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15721. /** @hidden */
  15722. export var kernelBlurPixelShader: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15728. /** @hidden */
  15729. export var kernelBlurVertex: {
  15730. name: string;
  15731. shader: string;
  15732. };
  15733. }
  15734. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15735. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15736. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15737. /** @hidden */
  15738. export var kernelBlurVertexShader: {
  15739. name: string;
  15740. shader: string;
  15741. };
  15742. }
  15743. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15744. import { Vector2 } from "babylonjs/Maths/math.vector";
  15745. import { Nullable } from "babylonjs/types";
  15746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15747. import { Camera } from "babylonjs/Cameras/camera";
  15748. import { Effect } from "babylonjs/Materials/effect";
  15749. import { Engine } from "babylonjs/Engines/engine";
  15750. import "babylonjs/Shaders/kernelBlur.fragment";
  15751. import "babylonjs/Shaders/kernelBlur.vertex";
  15752. /**
  15753. * The Blur Post Process which blurs an image based on a kernel and direction.
  15754. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15755. */
  15756. export class BlurPostProcess extends PostProcess {
  15757. /** The direction in which to blur the image. */
  15758. direction: Vector2;
  15759. private blockCompilation;
  15760. protected _kernel: number;
  15761. protected _idealKernel: number;
  15762. protected _packedFloat: boolean;
  15763. private _staticDefines;
  15764. /**
  15765. * Sets the length in pixels of the blur sample region
  15766. */
  15767. /**
  15768. * Gets the length in pixels of the blur sample region
  15769. */
  15770. kernel: number;
  15771. /**
  15772. * Sets wether or not the blur needs to unpack/repack floats
  15773. */
  15774. /**
  15775. * Gets wether or not the blur is unpacking/repacking floats
  15776. */
  15777. packedFloat: boolean;
  15778. /**
  15779. * Creates a new instance BlurPostProcess
  15780. * @param name The name of the effect.
  15781. * @param direction The direction in which to blur the image.
  15782. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15783. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15784. * @param camera The camera to apply the render pass to.
  15785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15786. * @param engine The engine which the post process will be applied. (default: current engine)
  15787. * @param reusable If the post process can be reused on the same frame. (default: false)
  15788. * @param textureType Type of textures used when performing the post process. (default: 0)
  15789. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15790. */
  15791. constructor(name: string,
  15792. /** The direction in which to blur the image. */
  15793. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15794. /**
  15795. * Updates the effect with the current post process compile time values and recompiles the shader.
  15796. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15797. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15798. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15799. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15800. * @param onCompiled Called when the shader has been compiled.
  15801. * @param onError Called if there is an error when compiling a shader.
  15802. */
  15803. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15804. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15805. /**
  15806. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15807. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15808. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15809. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15810. * The gaps between physical kernels are compensated for in the weighting of the samples
  15811. * @param idealKernel Ideal blur kernel.
  15812. * @return Nearest best kernel.
  15813. */
  15814. protected _nearestBestKernel(idealKernel: number): number;
  15815. /**
  15816. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15817. * @param x The point on the Gaussian distribution to sample.
  15818. * @return the value of the Gaussian function at x.
  15819. */
  15820. protected _gaussianWeight(x: number): number;
  15821. /**
  15822. * Generates a string that can be used as a floating point number in GLSL.
  15823. * @param x Value to print.
  15824. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15825. * @return GLSL float string.
  15826. */
  15827. protected _glslFloat(x: number, decimalFigures?: number): string;
  15828. }
  15829. }
  15830. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15831. import { Scene } from "babylonjs/scene";
  15832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15833. import { Plane } from "babylonjs/Maths/math.plane";
  15834. /**
  15835. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15836. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15837. * You can then easily use it as a reflectionTexture on a flat surface.
  15838. * In case the surface is not a plane, please consider relying on reflection probes.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. export class MirrorTexture extends RenderTargetTexture {
  15842. private scene;
  15843. /**
  15844. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15845. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15846. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15847. */
  15848. mirrorPlane: Plane;
  15849. /**
  15850. * Define the blur ratio used to blur the reflection if needed.
  15851. */
  15852. blurRatio: number;
  15853. /**
  15854. * Define the adaptive blur kernel used to blur the reflection if needed.
  15855. * This will autocompute the closest best match for the `blurKernel`
  15856. */
  15857. adaptiveBlurKernel: number;
  15858. /**
  15859. * Define the blur kernel used to blur the reflection if needed.
  15860. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15861. */
  15862. blurKernel: number;
  15863. /**
  15864. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15865. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15866. */
  15867. blurKernelX: number;
  15868. /**
  15869. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15870. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15871. */
  15872. blurKernelY: number;
  15873. private _autoComputeBlurKernel;
  15874. protected _onRatioRescale(): void;
  15875. private _updateGammaSpace;
  15876. private _imageProcessingConfigChangeObserver;
  15877. private _transformMatrix;
  15878. private _mirrorMatrix;
  15879. private _savedViewMatrix;
  15880. private _blurX;
  15881. private _blurY;
  15882. private _adaptiveBlurKernel;
  15883. private _blurKernelX;
  15884. private _blurKernelY;
  15885. private _blurRatio;
  15886. /**
  15887. * Instantiates a Mirror Texture.
  15888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15890. * You can then easily use it as a reflectionTexture on a flat surface.
  15891. * In case the surface is not a plane, please consider relying on reflection probes.
  15892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15893. * @param name
  15894. * @param size
  15895. * @param scene
  15896. * @param generateMipMaps
  15897. * @param type
  15898. * @param samplingMode
  15899. * @param generateDepthBuffer
  15900. */
  15901. constructor(name: string, size: number | {
  15902. width: number;
  15903. height: number;
  15904. } | {
  15905. ratio: number;
  15906. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15907. private _preparePostProcesses;
  15908. /**
  15909. * Clone the mirror texture.
  15910. * @returns the cloned texture
  15911. */
  15912. clone(): MirrorTexture;
  15913. /**
  15914. * Serialize the texture to a JSON representation you could use in Parse later on
  15915. * @returns the serialized JSON representation
  15916. */
  15917. serialize(): any;
  15918. /**
  15919. * Dispose the texture and release its associated resources.
  15920. */
  15921. dispose(): void;
  15922. }
  15923. }
  15924. declare module "babylonjs/Materials/Textures/texture" {
  15925. import { Observable } from "babylonjs/Misc/observable";
  15926. import { Nullable } from "babylonjs/types";
  15927. import { Scene } from "babylonjs/scene";
  15928. import { Matrix } from "babylonjs/Maths/math.vector";
  15929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15930. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15931. import { Engine } from "babylonjs/Engines/engine";
  15932. /**
  15933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15934. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15935. */
  15936. export class Texture extends BaseTexture {
  15937. /**
  15938. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15939. */
  15940. static SerializeBuffers: boolean;
  15941. /** @hidden */
  15942. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15943. /** @hidden */
  15944. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15945. /** @hidden */
  15946. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15947. /** nearest is mag = nearest and min = nearest and mip = linear */
  15948. static readonly NEAREST_SAMPLINGMODE: number;
  15949. /** nearest is mag = nearest and min = nearest and mip = linear */
  15950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15952. static readonly BILINEAR_SAMPLINGMODE: number;
  15953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15955. /** Trilinear is mag = linear and min = linear and mip = linear */
  15956. static readonly TRILINEAR_SAMPLINGMODE: number;
  15957. /** Trilinear is mag = linear and min = linear and mip = linear */
  15958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15959. /** mag = nearest and min = nearest and mip = nearest */
  15960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15961. /** mag = nearest and min = linear and mip = nearest */
  15962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15963. /** mag = nearest and min = linear and mip = linear */
  15964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15965. /** mag = nearest and min = linear and mip = none */
  15966. static readonly NEAREST_LINEAR: number;
  15967. /** mag = nearest and min = nearest and mip = none */
  15968. static readonly NEAREST_NEAREST: number;
  15969. /** mag = linear and min = nearest and mip = nearest */
  15970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15971. /** mag = linear and min = nearest and mip = linear */
  15972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15973. /** mag = linear and min = linear and mip = none */
  15974. static readonly LINEAR_LINEAR: number;
  15975. /** mag = linear and min = nearest and mip = none */
  15976. static readonly LINEAR_NEAREST: number;
  15977. /** Explicit coordinates mode */
  15978. static readonly EXPLICIT_MODE: number;
  15979. /** Spherical coordinates mode */
  15980. static readonly SPHERICAL_MODE: number;
  15981. /** Planar coordinates mode */
  15982. static readonly PLANAR_MODE: number;
  15983. /** Cubic coordinates mode */
  15984. static readonly CUBIC_MODE: number;
  15985. /** Projection coordinates mode */
  15986. static readonly PROJECTION_MODE: number;
  15987. /** Inverse Cubic coordinates mode */
  15988. static readonly SKYBOX_MODE: number;
  15989. /** Inverse Cubic coordinates mode */
  15990. static readonly INVCUBIC_MODE: number;
  15991. /** Equirectangular coordinates mode */
  15992. static readonly EQUIRECTANGULAR_MODE: number;
  15993. /** Equirectangular Fixed coordinates mode */
  15994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15995. /** Equirectangular Fixed Mirrored coordinates mode */
  15996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15997. /** Texture is not repeating outside of 0..1 UVs */
  15998. static readonly CLAMP_ADDRESSMODE: number;
  15999. /** Texture is repeating outside of 0..1 UVs */
  16000. static readonly WRAP_ADDRESSMODE: number;
  16001. /** Texture is repeating and mirrored */
  16002. static readonly MIRROR_ADDRESSMODE: number;
  16003. /**
  16004. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16005. */
  16006. static UseSerializedUrlIfAny: boolean;
  16007. /**
  16008. * Define the url of the texture.
  16009. */
  16010. url: Nullable<string>;
  16011. /**
  16012. * Define an offset on the texture to offset the u coordinates of the UVs
  16013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16014. */
  16015. uOffset: number;
  16016. /**
  16017. * Define an offset on the texture to offset the v coordinates of the UVs
  16018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16019. */
  16020. vOffset: number;
  16021. /**
  16022. * Define an offset on the texture to scale the u coordinates of the UVs
  16023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16024. */
  16025. uScale: number;
  16026. /**
  16027. * Define an offset on the texture to scale the v coordinates of the UVs
  16028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16029. */
  16030. vScale: number;
  16031. /**
  16032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16033. * @see http://doc.babylonjs.com/how_to/more_materials
  16034. */
  16035. uAng: number;
  16036. /**
  16037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16038. * @see http://doc.babylonjs.com/how_to/more_materials
  16039. */
  16040. vAng: number;
  16041. /**
  16042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16043. * @see http://doc.babylonjs.com/how_to/more_materials
  16044. */
  16045. wAng: number;
  16046. /**
  16047. * Defines the center of rotation (U)
  16048. */
  16049. uRotationCenter: number;
  16050. /**
  16051. * Defines the center of rotation (V)
  16052. */
  16053. vRotationCenter: number;
  16054. /**
  16055. * Defines the center of rotation (W)
  16056. */
  16057. wRotationCenter: number;
  16058. /**
  16059. * Are mip maps generated for this texture or not.
  16060. */
  16061. readonly noMipmap: boolean;
  16062. /**
  16063. * List of inspectable custom properties (used by the Inspector)
  16064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16065. */
  16066. inspectableCustomProperties: Nullable<IInspectable[]>;
  16067. private _noMipmap;
  16068. /** @hidden */
  16069. _invertY: boolean;
  16070. private _rowGenerationMatrix;
  16071. private _cachedTextureMatrix;
  16072. private _projectionModeMatrix;
  16073. private _t0;
  16074. private _t1;
  16075. private _t2;
  16076. private _cachedUOffset;
  16077. private _cachedVOffset;
  16078. private _cachedUScale;
  16079. private _cachedVScale;
  16080. private _cachedUAng;
  16081. private _cachedVAng;
  16082. private _cachedWAng;
  16083. private _cachedProjectionMatrixId;
  16084. private _cachedCoordinatesMode;
  16085. /** @hidden */
  16086. protected _initialSamplingMode: number;
  16087. /** @hidden */
  16088. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16089. private _deleteBuffer;
  16090. protected _format: Nullable<number>;
  16091. private _delayedOnLoad;
  16092. private _delayedOnError;
  16093. /**
  16094. * Observable triggered once the texture has been loaded.
  16095. */
  16096. onLoadObservable: Observable<Texture>;
  16097. protected _isBlocking: boolean;
  16098. /**
  16099. * Is the texture preventing material to render while loading.
  16100. * If false, a default texture will be used instead of the loading one during the preparation step.
  16101. */
  16102. isBlocking: boolean;
  16103. /**
  16104. * Get the current sampling mode associated with the texture.
  16105. */
  16106. readonly samplingMode: number;
  16107. /**
  16108. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16109. */
  16110. readonly invertY: boolean;
  16111. /**
  16112. * Instantiates a new texture.
  16113. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16114. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16115. * @param url define the url of the picture to load as a texture
  16116. * @param scene define the scene or engine the texture will belong to
  16117. * @param noMipmap define if the texture will require mip maps or not
  16118. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16119. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16120. * @param onLoad define a callback triggered when the texture has been loaded
  16121. * @param onError define a callback triggered when an error occurred during the loading session
  16122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16123. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16125. */
  16126. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16127. /**
  16128. * Update the url (and optional buffer) of this texture if url was null during construction.
  16129. * @param url the url of the texture
  16130. * @param buffer the buffer of the texture (defaults to null)
  16131. * @param onLoad callback called when the texture is loaded (defaults to null)
  16132. */
  16133. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16134. /**
  16135. * Finish the loading sequence of a texture flagged as delayed load.
  16136. * @hidden
  16137. */
  16138. delayLoad(): void;
  16139. private _prepareRowForTextureGeneration;
  16140. /**
  16141. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16142. * @returns the transform matrix of the texture.
  16143. */
  16144. getTextureMatrix(): Matrix;
  16145. /**
  16146. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16147. * @returns The reflection texture transform
  16148. */
  16149. getReflectionTextureMatrix(): Matrix;
  16150. /**
  16151. * Clones the texture.
  16152. * @returns the cloned texture
  16153. */
  16154. clone(): Texture;
  16155. /**
  16156. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16157. * @returns The JSON representation of the texture
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Get the current class name of the texture useful for serialization or dynamic coding.
  16162. * @returns "Texture"
  16163. */
  16164. getClassName(): string;
  16165. /**
  16166. * Dispose the texture and release its associated resources.
  16167. */
  16168. dispose(): void;
  16169. /**
  16170. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16171. * @param parsedTexture Define the JSON representation of the texture
  16172. * @param scene Define the scene the parsed texture should be instantiated in
  16173. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16174. * @returns The parsed texture if successful
  16175. */
  16176. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16177. /**
  16178. * Creates a texture from its base 64 representation.
  16179. * @param data Define the base64 payload without the data: prefix
  16180. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16181. * @param scene Define the scene the texture should belong to
  16182. * @param noMipmap Forces the texture to not create mip map information if true
  16183. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16184. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16185. * @param onLoad define a callback triggered when the texture has been loaded
  16186. * @param onError define a callback triggered when an error occurred during the loading session
  16187. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16188. * @returns the created texture
  16189. */
  16190. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16191. /**
  16192. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16193. * @param data Define the base64 payload without the data: prefix
  16194. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16195. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16196. * @param scene Define the scene the texture should belong to
  16197. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16198. * @param noMipmap Forces the texture to not create mip map information if true
  16199. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16200. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16201. * @param onLoad define a callback triggered when the texture has been loaded
  16202. * @param onError define a callback triggered when an error occurred during the loading session
  16203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16204. * @returns the created texture
  16205. */
  16206. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16207. }
  16208. }
  16209. declare module "babylonjs/PostProcesses/postProcessManager" {
  16210. import { Nullable } from "babylonjs/types";
  16211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16212. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16213. import { Scene } from "babylonjs/scene";
  16214. /**
  16215. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16217. */
  16218. export class PostProcessManager {
  16219. private _scene;
  16220. private _indexBuffer;
  16221. private _vertexBuffers;
  16222. /**
  16223. * Creates a new instance PostProcess
  16224. * @param scene The scene that the post process is associated with.
  16225. */
  16226. constructor(scene: Scene);
  16227. private _prepareBuffers;
  16228. private _buildIndexBuffer;
  16229. /**
  16230. * Rebuilds the vertex buffers of the manager.
  16231. * @hidden
  16232. */
  16233. _rebuild(): void;
  16234. /**
  16235. * Prepares a frame to be run through a post process.
  16236. * @param sourceTexture The input texture to the post procesess. (default: null)
  16237. * @param postProcesses An array of post processes to be run. (default: null)
  16238. * @returns True if the post processes were able to be run.
  16239. * @hidden
  16240. */
  16241. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16242. /**
  16243. * Manually render a set of post processes to a texture.
  16244. * @param postProcesses An array of post processes to be run.
  16245. * @param targetTexture The target texture to render to.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16247. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16248. * @param lodLevel defines which lod of the texture to render to
  16249. */
  16250. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16251. /**
  16252. * Finalize the result of the output of the postprocesses.
  16253. * @param doNotPresent If true the result will not be displayed to the screen.
  16254. * @param targetTexture The target texture to render to.
  16255. * @param faceIndex The index of the face to bind the target texture to.
  16256. * @param postProcesses The array of post processes to render.
  16257. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16258. * @hidden
  16259. */
  16260. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16261. /**
  16262. * Disposes of the post process manager.
  16263. */
  16264. dispose(): void;
  16265. }
  16266. }
  16267. declare module "babylonjs/Misc/gradients" {
  16268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16269. /** Interface used by value gradients (color, factor, ...) */
  16270. export interface IValueGradient {
  16271. /**
  16272. * Gets or sets the gradient value (between 0 and 1)
  16273. */
  16274. gradient: number;
  16275. }
  16276. /** Class used to store color4 gradient */
  16277. export class ColorGradient implements IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. /**
  16283. * Gets or sets first associated color
  16284. */
  16285. color1: Color4;
  16286. /**
  16287. * Gets or sets second associated color
  16288. */
  16289. color2?: Color4;
  16290. /**
  16291. * Will get a color picked randomly between color1 and color2.
  16292. * If color2 is undefined then color1 will be used
  16293. * @param result defines the target Color4 to store the result in
  16294. */
  16295. getColorToRef(result: Color4): void;
  16296. }
  16297. /** Class used to store color 3 gradient */
  16298. export class Color3Gradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets the associated color
  16305. */
  16306. color: Color3;
  16307. }
  16308. /** Class used to store factor gradient */
  16309. export class FactorGradient implements IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. /**
  16315. * Gets or sets first associated factor
  16316. */
  16317. factor1: number;
  16318. /**
  16319. * Gets or sets second associated factor
  16320. */
  16321. factor2?: number;
  16322. /**
  16323. * Will get a number picked randomly between factor1 and factor2.
  16324. * If factor2 is undefined then factor1 will be used
  16325. * @returns the picked number
  16326. */
  16327. getFactor(): number;
  16328. }
  16329. /**
  16330. * Helper used to simplify some generic gradient tasks
  16331. */
  16332. export class GradientHelper {
  16333. /**
  16334. * Gets the current gradient from an array of IValueGradient
  16335. * @param ratio defines the current ratio to get
  16336. * @param gradients defines the array of IValueGradient
  16337. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16338. */
  16339. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16343. import { Scene } from "babylonjs/scene";
  16344. import { Texture } from "babylonjs/Materials/Textures/texture";
  16345. /**
  16346. * A class extending Texture allowing drawing on a texture
  16347. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16348. */
  16349. export class DynamicTexture extends Texture {
  16350. private _generateMipMaps;
  16351. private _canvas;
  16352. private _context;
  16353. private _engine;
  16354. /**
  16355. * Creates a DynamicTexture
  16356. * @param name defines the name of the texture
  16357. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16358. * @param scene defines the scene where you want the texture
  16359. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16360. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16361. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16362. */
  16363. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16364. /**
  16365. * Get the current class name of the texture useful for serialization or dynamic coding.
  16366. * @returns "DynamicTexture"
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Gets the current state of canRescale
  16371. */
  16372. readonly canRescale: boolean;
  16373. private _recreate;
  16374. /**
  16375. * Scales the texture
  16376. * @param ratio the scale factor to apply to both width and height
  16377. */
  16378. scale(ratio: number): void;
  16379. /**
  16380. * Resizes the texture
  16381. * @param width the new width
  16382. * @param height the new height
  16383. */
  16384. scaleTo(width: number, height: number): void;
  16385. /**
  16386. * Gets the context of the canvas used by the texture
  16387. * @returns the canvas context of the dynamic texture
  16388. */
  16389. getContext(): CanvasRenderingContext2D;
  16390. /**
  16391. * Clears the texture
  16392. */
  16393. clear(): void;
  16394. /**
  16395. * Updates the texture
  16396. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16397. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16398. */
  16399. update(invertY?: boolean, premulAlpha?: boolean): void;
  16400. /**
  16401. * Draws text onto the texture
  16402. * @param text defines the text to be drawn
  16403. * @param x defines the placement of the text from the left
  16404. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16405. * @param font defines the font to be used with font-style, font-size, font-name
  16406. * @param color defines the color used for the text
  16407. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16408. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16409. * @param update defines whether texture is immediately update (default is true)
  16410. */
  16411. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16412. /**
  16413. * Clones the texture
  16414. * @returns the clone of the texture.
  16415. */
  16416. clone(): DynamicTexture;
  16417. /**
  16418. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16419. * @returns a serialized dynamic texture object
  16420. */
  16421. serialize(): any;
  16422. /** @hidden */
  16423. _rebuild(): void;
  16424. }
  16425. }
  16426. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16427. import { Scene } from "babylonjs/scene";
  16428. import { ISceneComponent } from "babylonjs/sceneComponent";
  16429. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16430. module "babylonjs/abstractScene" {
  16431. interface AbstractScene {
  16432. /**
  16433. * The list of procedural textures added to the scene
  16434. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16435. */
  16436. proceduralTextures: Array<ProceduralTexture>;
  16437. }
  16438. }
  16439. /**
  16440. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16441. * in a given scene.
  16442. */
  16443. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16444. /**
  16445. * The component name helpfull to identify the component in the list of scene components.
  16446. */
  16447. readonly name: string;
  16448. /**
  16449. * The scene the component belongs to.
  16450. */
  16451. scene: Scene;
  16452. /**
  16453. * Creates a new instance of the component for the given scene
  16454. * @param scene Defines the scene to register the component in
  16455. */
  16456. constructor(scene: Scene);
  16457. /**
  16458. * Registers the component in a given scene
  16459. */
  16460. register(): void;
  16461. /**
  16462. * Rebuilds the elements related to this component in case of
  16463. * context lost for instance.
  16464. */
  16465. rebuild(): void;
  16466. /**
  16467. * Disposes the component and the associated ressources.
  16468. */
  16469. dispose(): void;
  16470. private _beforeClear;
  16471. }
  16472. }
  16473. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16476. module "babylonjs/Engines/engine" {
  16477. interface Engine {
  16478. /**
  16479. * Creates a new render target cube texture
  16480. * @param size defines the size of the texture
  16481. * @param options defines the options used to create the texture
  16482. * @returns a new render target cube texture stored in an InternalTexture
  16483. */
  16484. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16485. }
  16486. }
  16487. }
  16488. declare module "babylonjs/Shaders/procedural.vertex" {
  16489. /** @hidden */
  16490. export var proceduralVertexShader: {
  16491. name: string;
  16492. shader: string;
  16493. };
  16494. }
  16495. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16496. import { Observable } from "babylonjs/Misc/observable";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { Scene } from "babylonjs/scene";
  16499. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16500. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16501. import { Effect } from "babylonjs/Materials/effect";
  16502. import { Texture } from "babylonjs/Materials/Textures/texture";
  16503. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16504. import "babylonjs/Shaders/procedural.vertex";
  16505. /**
  16506. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16507. * This is the base class of any Procedural texture and contains most of the shareable code.
  16508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16509. */
  16510. export class ProceduralTexture extends Texture {
  16511. isCube: boolean;
  16512. /**
  16513. * Define if the texture is enabled or not (disabled texture will not render)
  16514. */
  16515. isEnabled: boolean;
  16516. /**
  16517. * Define if the texture must be cleared before rendering (default is true)
  16518. */
  16519. autoClear: boolean;
  16520. /**
  16521. * Callback called when the texture is generated
  16522. */
  16523. onGenerated: () => void;
  16524. /**
  16525. * Event raised when the texture is generated
  16526. */
  16527. onGeneratedObservable: Observable<ProceduralTexture>;
  16528. /** @hidden */
  16529. _generateMipMaps: boolean;
  16530. /** @hidden **/
  16531. _effect: Effect;
  16532. /** @hidden */
  16533. _textures: {
  16534. [key: string]: Texture;
  16535. };
  16536. private _size;
  16537. private _currentRefreshId;
  16538. private _refreshRate;
  16539. private _vertexBuffers;
  16540. private _indexBuffer;
  16541. private _uniforms;
  16542. private _samplers;
  16543. private _fragment;
  16544. private _floats;
  16545. private _ints;
  16546. private _floatsArrays;
  16547. private _colors3;
  16548. private _colors4;
  16549. private _vectors2;
  16550. private _vectors3;
  16551. private _matrices;
  16552. private _fallbackTexture;
  16553. private _fallbackTextureUsed;
  16554. private _engine;
  16555. private _cachedDefines;
  16556. private _contentUpdateId;
  16557. private _contentData;
  16558. /**
  16559. * Instantiates a new procedural texture.
  16560. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16561. * This is the base class of any Procedural texture and contains most of the shareable code.
  16562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16563. * @param name Define the name of the texture
  16564. * @param size Define the size of the texture to create
  16565. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16566. * @param scene Define the scene the texture belongs to
  16567. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16568. * @param generateMipMaps Define if the texture should creates mip maps or not
  16569. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16570. */
  16571. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16572. /**
  16573. * The effect that is created when initializing the post process.
  16574. * @returns The created effect corresponding the the postprocess.
  16575. */
  16576. getEffect(): Effect;
  16577. /**
  16578. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16579. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16580. */
  16581. getContent(): Nullable<ArrayBufferView>;
  16582. private _createIndexBuffer;
  16583. /** @hidden */
  16584. _rebuild(): void;
  16585. /**
  16586. * Resets the texture in order to recreate its associated resources.
  16587. * This can be called in case of context loss
  16588. */
  16589. reset(): void;
  16590. protected _getDefines(): string;
  16591. /**
  16592. * Is the texture ready to be used ? (rendered at least once)
  16593. * @returns true if ready, otherwise, false.
  16594. */
  16595. isReady(): boolean;
  16596. /**
  16597. * Resets the refresh counter of the texture and start bak from scratch.
  16598. * Could be useful to regenerate the texture if it is setup to render only once.
  16599. */
  16600. resetRefreshCounter(): void;
  16601. /**
  16602. * Set the fragment shader to use in order to render the texture.
  16603. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16604. */
  16605. setFragment(fragment: any): void;
  16606. /**
  16607. * Define the refresh rate of the texture or the rendering frequency.
  16608. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16609. */
  16610. refreshRate: number;
  16611. /** @hidden */
  16612. _shouldRender(): boolean;
  16613. /**
  16614. * Get the size the texture is rendering at.
  16615. * @returns the size (texture is always squared)
  16616. */
  16617. getRenderSize(): number;
  16618. /**
  16619. * Resize the texture to new value.
  16620. * @param size Define the new size the texture should have
  16621. * @param generateMipMaps Define whether the new texture should create mip maps
  16622. */
  16623. resize(size: number, generateMipMaps: boolean): void;
  16624. private _checkUniform;
  16625. /**
  16626. * Set a texture in the shader program used to render.
  16627. * @param name Define the name of the uniform samplers as defined in the shader
  16628. * @param texture Define the texture to bind to this sampler
  16629. * @return the texture itself allowing "fluent" like uniform updates
  16630. */
  16631. setTexture(name: string, texture: Texture): ProceduralTexture;
  16632. /**
  16633. * Set a float in the shader.
  16634. * @param name Define the name of the uniform as defined in the shader
  16635. * @param value Define the value to give to the uniform
  16636. * @return the texture itself allowing "fluent" like uniform updates
  16637. */
  16638. setFloat(name: string, value: number): ProceduralTexture;
  16639. /**
  16640. * Set a int in the shader.
  16641. * @param name Define the name of the uniform as defined in the shader
  16642. * @param value Define the value to give to the uniform
  16643. * @return the texture itself allowing "fluent" like uniform updates
  16644. */
  16645. setInt(name: string, value: number): ProceduralTexture;
  16646. /**
  16647. * Set an array of floats in the shader.
  16648. * @param name Define the name of the uniform as defined in the shader
  16649. * @param value Define the value to give to the uniform
  16650. * @return the texture itself allowing "fluent" like uniform updates
  16651. */
  16652. setFloats(name: string, value: number[]): ProceduralTexture;
  16653. /**
  16654. * Set a vec3 in the shader from a Color3.
  16655. * @param name Define the name of the uniform as defined in the shader
  16656. * @param value Define the value to give to the uniform
  16657. * @return the texture itself allowing "fluent" like uniform updates
  16658. */
  16659. setColor3(name: string, value: Color3): ProceduralTexture;
  16660. /**
  16661. * Set a vec4 in the shader from a Color4.
  16662. * @param name Define the name of the uniform as defined in the shader
  16663. * @param value Define the value to give to the uniform
  16664. * @return the texture itself allowing "fluent" like uniform updates
  16665. */
  16666. setColor4(name: string, value: Color4): ProceduralTexture;
  16667. /**
  16668. * Set a vec2 in the shader from a Vector2.
  16669. * @param name Define the name of the uniform as defined in the shader
  16670. * @param value Define the value to give to the uniform
  16671. * @return the texture itself allowing "fluent" like uniform updates
  16672. */
  16673. setVector2(name: string, value: Vector2): ProceduralTexture;
  16674. /**
  16675. * Set a vec3 in the shader from a Vector3.
  16676. * @param name Define the name of the uniform as defined in the shader
  16677. * @param value Define the value to give to the uniform
  16678. * @return the texture itself allowing "fluent" like uniform updates
  16679. */
  16680. setVector3(name: string, value: Vector3): ProceduralTexture;
  16681. /**
  16682. * Set a mat4 in the shader from a MAtrix.
  16683. * @param name Define the name of the uniform as defined in the shader
  16684. * @param value Define the value to give to the uniform
  16685. * @return the texture itself allowing "fluent" like uniform updates
  16686. */
  16687. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16688. /**
  16689. * Render the texture to its associated render target.
  16690. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16691. */
  16692. render(useCameraPostProcess?: boolean): void;
  16693. /**
  16694. * Clone the texture.
  16695. * @returns the cloned texture
  16696. */
  16697. clone(): ProceduralTexture;
  16698. /**
  16699. * Dispose the texture and release its asoociated resources.
  16700. */
  16701. dispose(): void;
  16702. }
  16703. }
  16704. declare module "babylonjs/Particles/baseParticleSystem" {
  16705. import { Nullable } from "babylonjs/types";
  16706. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16708. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16709. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16710. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16711. import { Scene } from "babylonjs/scene";
  16712. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16713. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16714. import { Texture } from "babylonjs/Materials/Textures/texture";
  16715. import { Color4 } from "babylonjs/Maths/math.color";
  16716. import { Animation } from "babylonjs/Animations/animation";
  16717. /**
  16718. * This represents the base class for particle system in Babylon.
  16719. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16721. * @example https://doc.babylonjs.com/babylon101/particles
  16722. */
  16723. export class BaseParticleSystem {
  16724. /**
  16725. * Source color is added to the destination color without alpha affecting the result
  16726. */
  16727. static BLENDMODE_ONEONE: number;
  16728. /**
  16729. * Blend current color and particle color using particle’s alpha
  16730. */
  16731. static BLENDMODE_STANDARD: number;
  16732. /**
  16733. * Add current color and particle color multiplied by particle’s alpha
  16734. */
  16735. static BLENDMODE_ADD: number;
  16736. /**
  16737. * Multiply current color with particle color
  16738. */
  16739. static BLENDMODE_MULTIPLY: number;
  16740. /**
  16741. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16742. */
  16743. static BLENDMODE_MULTIPLYADD: number;
  16744. /**
  16745. * List of animations used by the particle system.
  16746. */
  16747. animations: Animation[];
  16748. /**
  16749. * The id of the Particle system.
  16750. */
  16751. id: string;
  16752. /**
  16753. * The friendly name of the Particle system.
  16754. */
  16755. name: string;
  16756. /**
  16757. * The rendering group used by the Particle system to chose when to render.
  16758. */
  16759. renderingGroupId: number;
  16760. /**
  16761. * The emitter represents the Mesh or position we are attaching the particle system to.
  16762. */
  16763. emitter: Nullable<AbstractMesh | Vector3>;
  16764. /**
  16765. * The maximum number of particles to emit per frame
  16766. */
  16767. emitRate: number;
  16768. /**
  16769. * If you want to launch only a few particles at once, that can be done, as well.
  16770. */
  16771. manualEmitCount: number;
  16772. /**
  16773. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16774. */
  16775. updateSpeed: number;
  16776. /**
  16777. * The amount of time the particle system is running (depends of the overall update speed).
  16778. */
  16779. targetStopDuration: number;
  16780. /**
  16781. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16782. */
  16783. disposeOnStop: boolean;
  16784. /**
  16785. * Minimum power of emitting particles.
  16786. */
  16787. minEmitPower: number;
  16788. /**
  16789. * Maximum power of emitting particles.
  16790. */
  16791. maxEmitPower: number;
  16792. /**
  16793. * Minimum life time of emitting particles.
  16794. */
  16795. minLifeTime: number;
  16796. /**
  16797. * Maximum life time of emitting particles.
  16798. */
  16799. maxLifeTime: number;
  16800. /**
  16801. * Minimum Size of emitting particles.
  16802. */
  16803. minSize: number;
  16804. /**
  16805. * Maximum Size of emitting particles.
  16806. */
  16807. maxSize: number;
  16808. /**
  16809. * Minimum scale of emitting particles on X axis.
  16810. */
  16811. minScaleX: number;
  16812. /**
  16813. * Maximum scale of emitting particles on X axis.
  16814. */
  16815. maxScaleX: number;
  16816. /**
  16817. * Minimum scale of emitting particles on Y axis.
  16818. */
  16819. minScaleY: number;
  16820. /**
  16821. * Maximum scale of emitting particles on Y axis.
  16822. */
  16823. maxScaleY: number;
  16824. /**
  16825. * Gets or sets the minimal initial rotation in radians.
  16826. */
  16827. minInitialRotation: number;
  16828. /**
  16829. * Gets or sets the maximal initial rotation in radians.
  16830. */
  16831. maxInitialRotation: number;
  16832. /**
  16833. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16834. */
  16835. minAngularSpeed: number;
  16836. /**
  16837. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16838. */
  16839. maxAngularSpeed: number;
  16840. /**
  16841. * The texture used to render each particle. (this can be a spritesheet)
  16842. */
  16843. particleTexture: Nullable<Texture>;
  16844. /**
  16845. * The layer mask we are rendering the particles through.
  16846. */
  16847. layerMask: number;
  16848. /**
  16849. * This can help using your own shader to render the particle system.
  16850. * The according effect will be created
  16851. */
  16852. customShader: any;
  16853. /**
  16854. * By default particle system starts as soon as they are created. This prevents the
  16855. * automatic start to happen and let you decide when to start emitting particles.
  16856. */
  16857. preventAutoStart: boolean;
  16858. private _noiseTexture;
  16859. /**
  16860. * Gets or sets a texture used to add random noise to particle positions
  16861. */
  16862. noiseTexture: Nullable<ProceduralTexture>;
  16863. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16864. noiseStrength: Vector3;
  16865. /**
  16866. * Callback triggered when the particle animation is ending.
  16867. */
  16868. onAnimationEnd: Nullable<() => void>;
  16869. /**
  16870. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16871. */
  16872. blendMode: number;
  16873. /**
  16874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16875. * to override the particles.
  16876. */
  16877. forceDepthWrite: boolean;
  16878. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16879. preWarmCycles: number;
  16880. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16881. preWarmStepOffset: number;
  16882. /**
  16883. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16884. */
  16885. spriteCellChangeSpeed: number;
  16886. /**
  16887. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16888. */
  16889. startSpriteCellID: number;
  16890. /**
  16891. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16892. */
  16893. endSpriteCellID: number;
  16894. /**
  16895. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16896. */
  16897. spriteCellWidth: number;
  16898. /**
  16899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16900. */
  16901. spriteCellHeight: number;
  16902. /**
  16903. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16904. */
  16905. spriteRandomStartCell: boolean;
  16906. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16907. translationPivot: Vector2;
  16908. /** @hidden */
  16909. protected _isAnimationSheetEnabled: boolean;
  16910. /**
  16911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16912. */
  16913. beginAnimationOnStart: boolean;
  16914. /**
  16915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16916. */
  16917. beginAnimationFrom: number;
  16918. /**
  16919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16920. */
  16921. beginAnimationTo: number;
  16922. /**
  16923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16924. */
  16925. beginAnimationLoop: boolean;
  16926. /**
  16927. * Gets or sets a world offset applied to all particles
  16928. */
  16929. worldOffset: Vector3;
  16930. /**
  16931. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16932. */
  16933. isAnimationSheetEnabled: boolean;
  16934. /**
  16935. * Get hosting scene
  16936. * @returns the scene
  16937. */
  16938. getScene(): Scene;
  16939. /**
  16940. * You can use gravity if you want to give an orientation to your particles.
  16941. */
  16942. gravity: Vector3;
  16943. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16944. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16945. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16946. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16947. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16948. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16949. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16950. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16951. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16952. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16953. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16954. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16955. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16956. /**
  16957. * Defines the delay in milliseconds before starting the system (0 by default)
  16958. */
  16959. startDelay: number;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16967. limitVelocityDamping: number;
  16968. /**
  16969. * Gets the current list of limit velocity gradients.
  16970. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16971. * @returns the list of limit velocity gradients
  16972. */
  16973. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16974. /**
  16975. * Gets the current list of color gradients.
  16976. * You must use addColorGradient and removeColorGradient to udpate this list
  16977. * @returns the list of color gradients
  16978. */
  16979. getColorGradients(): Nullable<Array<ColorGradient>>;
  16980. /**
  16981. * Gets the current list of size gradients.
  16982. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16983. * @returns the list of size gradients
  16984. */
  16985. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Gets the current list of color remap gradients.
  16988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16989. * @returns the list of color remap gradients
  16990. */
  16991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16992. /**
  16993. * Gets the current list of alpha remap gradients.
  16994. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16995. * @returns the list of alpha remap gradients
  16996. */
  16997. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16998. /**
  16999. * Gets the current list of life time gradients.
  17000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17001. * @returns the list of life time gradients
  17002. */
  17003. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17004. /**
  17005. * Gets the current list of angular speed gradients.
  17006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17007. * @returns the list of angular speed gradients
  17008. */
  17009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17010. /**
  17011. * Gets the current list of velocity gradients.
  17012. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17013. * @returns the list of velocity gradients
  17014. */
  17015. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17016. /**
  17017. * Gets the current list of start size gradients.
  17018. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17019. * @returns the list of start size gradients
  17020. */
  17021. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17022. /**
  17023. * Gets the current list of emit rate gradients.
  17024. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17025. * @returns the list of emit rate gradients
  17026. */
  17027. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17028. /**
  17029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17031. */
  17032. direction1: Vector3;
  17033. /**
  17034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17036. */
  17037. direction2: Vector3;
  17038. /**
  17039. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17041. */
  17042. minEmitBox: Vector3;
  17043. /**
  17044. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17045. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17046. */
  17047. maxEmitBox: Vector3;
  17048. /**
  17049. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17050. */
  17051. color1: Color4;
  17052. /**
  17053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17054. */
  17055. color2: Color4;
  17056. /**
  17057. * Color the particle will have at the end of its lifetime
  17058. */
  17059. colorDead: Color4;
  17060. /**
  17061. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17062. */
  17063. textureMask: Color4;
  17064. /**
  17065. * The particle emitter type defines the emitter used by the particle system.
  17066. * It can be for example box, sphere, or cone...
  17067. */
  17068. particleEmitterType: IParticleEmitterType;
  17069. /** @hidden */
  17070. _isSubEmitter: boolean;
  17071. /**
  17072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17074. */
  17075. billboardMode: number;
  17076. protected _isBillboardBased: boolean;
  17077. /**
  17078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17079. */
  17080. isBillboardBased: boolean;
  17081. /**
  17082. * The scene the particle system belongs to.
  17083. */
  17084. protected _scene: Scene;
  17085. /**
  17086. * Local cache of defines for image processing.
  17087. */
  17088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17089. /**
  17090. * Default configuration related to image processing available in the standard Material.
  17091. */
  17092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17093. /**
  17094. * Gets the image processing configuration used either in this material.
  17095. */
  17096. /**
  17097. * Sets the Default image processing configuration used either in the this material.
  17098. *
  17099. * If sets to null, the scene one is in use.
  17100. */
  17101. imageProcessingConfiguration: ImageProcessingConfiguration;
  17102. /**
  17103. * Attaches a new image processing configuration to the Standard Material.
  17104. * @param configuration
  17105. */
  17106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17107. /** @hidden */
  17108. protected _reset(): void;
  17109. /** @hidden */
  17110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17111. /**
  17112. * Instantiates a particle system.
  17113. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17114. * @param name The name of the particle system
  17115. */
  17116. constructor(name: string);
  17117. /**
  17118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17121. * @returns the emitter
  17122. */
  17123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17124. /**
  17125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17126. * @param radius The radius of the hemisphere to emit from
  17127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17128. * @returns the emitter
  17129. */
  17130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17131. /**
  17132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17133. * @param radius The radius of the sphere to emit from
  17134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17135. * @returns the emitter
  17136. */
  17137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17138. /**
  17139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17140. * @param radius The radius of the sphere to emit from
  17141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17143. * @returns the emitter
  17144. */
  17145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17146. /**
  17147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17148. * @param radius The radius of the emission cylinder
  17149. * @param height The height of the emission cylinder
  17150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17152. * @returns the emitter
  17153. */
  17154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17155. /**
  17156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17157. * @param radius The radius of the cylinder to emit from
  17158. * @param height The height of the emission cylinder
  17159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17162. * @returns the emitter
  17163. */
  17164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17165. /**
  17166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17167. * @param radius The radius of the cone to emit from
  17168. * @param angle The base angle of the cone
  17169. * @returns the emitter
  17170. */
  17171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17172. /**
  17173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17178. * @returns the emitter
  17179. */
  17180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17181. }
  17182. }
  17183. declare module "babylonjs/Particles/subEmitter" {
  17184. import { Scene } from "babylonjs/scene";
  17185. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17186. /**
  17187. * Type of sub emitter
  17188. */
  17189. export enum SubEmitterType {
  17190. /**
  17191. * Attached to the particle over it's lifetime
  17192. */
  17193. ATTACHED = 0,
  17194. /**
  17195. * Created when the particle dies
  17196. */
  17197. END = 1
  17198. }
  17199. /**
  17200. * Sub emitter class used to emit particles from an existing particle
  17201. */
  17202. export class SubEmitter {
  17203. /**
  17204. * the particle system to be used by the sub emitter
  17205. */
  17206. particleSystem: ParticleSystem;
  17207. /**
  17208. * Type of the submitter (Default: END)
  17209. */
  17210. type: SubEmitterType;
  17211. /**
  17212. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17213. * Note: This only is supported when using an emitter of type Mesh
  17214. */
  17215. inheritDirection: boolean;
  17216. /**
  17217. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17218. */
  17219. inheritedVelocityAmount: number;
  17220. /**
  17221. * Creates a sub emitter
  17222. * @param particleSystem the particle system to be used by the sub emitter
  17223. */
  17224. constructor(
  17225. /**
  17226. * the particle system to be used by the sub emitter
  17227. */
  17228. particleSystem: ParticleSystem);
  17229. /**
  17230. * Clones the sub emitter
  17231. * @returns the cloned sub emitter
  17232. */
  17233. clone(): SubEmitter;
  17234. /**
  17235. * Serialize current object to a JSON object
  17236. * @returns the serialized object
  17237. */
  17238. serialize(): any;
  17239. /** @hidden */
  17240. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17241. /**
  17242. * Creates a new SubEmitter from a serialized JSON version
  17243. * @param serializationObject defines the JSON object to read from
  17244. * @param scene defines the hosting scene
  17245. * @param rootUrl defines the rootUrl for data loading
  17246. * @returns a new SubEmitter
  17247. */
  17248. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17249. /** Release associated resources */
  17250. dispose(): void;
  17251. }
  17252. }
  17253. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17254. /** @hidden */
  17255. export var clipPlaneFragmentDeclaration: {
  17256. name: string;
  17257. shader: string;
  17258. };
  17259. }
  17260. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17261. /** @hidden */
  17262. export var imageProcessingDeclaration: {
  17263. name: string;
  17264. shader: string;
  17265. };
  17266. }
  17267. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17268. /** @hidden */
  17269. export var imageProcessingFunctions: {
  17270. name: string;
  17271. shader: string;
  17272. };
  17273. }
  17274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17275. /** @hidden */
  17276. export var clipPlaneFragment: {
  17277. name: string;
  17278. shader: string;
  17279. };
  17280. }
  17281. declare module "babylonjs/Shaders/particles.fragment" {
  17282. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17283. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17285. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17286. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17287. /** @hidden */
  17288. export var particlesPixelShader: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17294. /** @hidden */
  17295. export var clipPlaneVertexDeclaration: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17301. /** @hidden */
  17302. export var clipPlaneVertex: {
  17303. name: string;
  17304. shader: string;
  17305. };
  17306. }
  17307. declare module "babylonjs/Shaders/particles.vertex" {
  17308. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17309. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17310. /** @hidden */
  17311. export var particlesVertexShader: {
  17312. name: string;
  17313. shader: string;
  17314. };
  17315. }
  17316. declare module "babylonjs/Particles/particleSystem" {
  17317. import { Nullable } from "babylonjs/types";
  17318. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17319. import { Observable } from "babylonjs/Misc/observable";
  17320. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17321. import { Effect } from "babylonjs/Materials/effect";
  17322. import { Scene, IDisposable } from "babylonjs/scene";
  17323. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17324. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17325. import { Particle } from "babylonjs/Particles/particle";
  17326. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17328. import "babylonjs/Shaders/particles.fragment";
  17329. import "babylonjs/Shaders/particles.vertex";
  17330. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17331. /**
  17332. * This represents a particle system in Babylon.
  17333. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17334. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17335. * @example https://doc.babylonjs.com/babylon101/particles
  17336. */
  17337. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17338. /**
  17339. * Billboard mode will only apply to Y axis
  17340. */
  17341. static readonly BILLBOARDMODE_Y: number;
  17342. /**
  17343. * Billboard mode will apply to all axes
  17344. */
  17345. static readonly BILLBOARDMODE_ALL: number;
  17346. /**
  17347. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17348. */
  17349. static readonly BILLBOARDMODE_STRETCHED: number;
  17350. /**
  17351. * This function can be defined to provide custom update for active particles.
  17352. * This function will be called instead of regular update (age, position, color, etc.).
  17353. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17354. */
  17355. updateFunction: (particles: Particle[]) => void;
  17356. private _emitterWorldMatrix;
  17357. /**
  17358. * This function can be defined to specify initial direction for every new particle.
  17359. * It by default use the emitterType defined function
  17360. */
  17361. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17362. /**
  17363. * This function can be defined to specify initial position for every new particle.
  17364. * It by default use the emitterType defined function
  17365. */
  17366. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17367. /**
  17368. * @hidden
  17369. */
  17370. _inheritedVelocityOffset: Vector3;
  17371. /**
  17372. * An event triggered when the system is disposed
  17373. */
  17374. onDisposeObservable: Observable<ParticleSystem>;
  17375. private _onDisposeObserver;
  17376. /**
  17377. * Sets a callback that will be triggered when the system is disposed
  17378. */
  17379. onDispose: () => void;
  17380. private _particles;
  17381. private _epsilon;
  17382. private _capacity;
  17383. private _stockParticles;
  17384. private _newPartsExcess;
  17385. private _vertexData;
  17386. private _vertexBuffer;
  17387. private _vertexBuffers;
  17388. private _spriteBuffer;
  17389. private _indexBuffer;
  17390. private _effect;
  17391. private _customEffect;
  17392. private _cachedDefines;
  17393. private _scaledColorStep;
  17394. private _colorDiff;
  17395. private _scaledDirection;
  17396. private _scaledGravity;
  17397. private _currentRenderId;
  17398. private _alive;
  17399. private _useInstancing;
  17400. private _started;
  17401. private _stopped;
  17402. private _actualFrame;
  17403. private _scaledUpdateSpeed;
  17404. private _vertexBufferSize;
  17405. /** @hidden */
  17406. _currentEmitRateGradient: Nullable<FactorGradient>;
  17407. /** @hidden */
  17408. _currentEmitRate1: number;
  17409. /** @hidden */
  17410. _currentEmitRate2: number;
  17411. /** @hidden */
  17412. _currentStartSizeGradient: Nullable<FactorGradient>;
  17413. /** @hidden */
  17414. _currentStartSize1: number;
  17415. /** @hidden */
  17416. _currentStartSize2: number;
  17417. private readonly _rawTextureWidth;
  17418. private _rampGradientsTexture;
  17419. private _useRampGradients;
  17420. /** Gets or sets a boolean indicating that ramp gradients must be used
  17421. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17422. */
  17423. useRampGradients: boolean;
  17424. /**
  17425. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17426. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17427. */
  17428. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17429. private _subEmitters;
  17430. /**
  17431. * @hidden
  17432. * If the particle systems emitter should be disposed when the particle system is disposed
  17433. */
  17434. _disposeEmitterOnDispose: boolean;
  17435. /**
  17436. * The current active Sub-systems, this property is used by the root particle system only.
  17437. */
  17438. activeSubSystems: Array<ParticleSystem>;
  17439. private _rootParticleSystem;
  17440. /**
  17441. * Gets the current list of active particles
  17442. */
  17443. readonly particles: Particle[];
  17444. /**
  17445. * Returns the string "ParticleSystem"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Instantiates a particle system.
  17451. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17452. * @param name The name of the particle system
  17453. * @param capacity The max number of particles alive at the same time
  17454. * @param scene The scene the particle system belongs to
  17455. * @param customEffect a custom effect used to change the way particles are rendered by default
  17456. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17457. * @param epsilon Offset used to render the particles
  17458. */
  17459. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17460. private _addFactorGradient;
  17461. private _removeFactorGradient;
  17462. /**
  17463. * Adds a new life time gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the life time factor to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific life time gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new size gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the size factor to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific size gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeSizeGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Adds a new color remap gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param min defines the color remap minimal range
  17494. * @param max defines the color remap maximal range
  17495. * @returns the current particle system
  17496. */
  17497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific color remap gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeColorRemapGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Adds a new alpha remap gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param min defines the alpha remap minimal range
  17508. * @param max defines the alpha remap maximal range
  17509. * @returns the current particle system
  17510. */
  17511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific alpha remap gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Adds a new angular speed gradient
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param factor defines the angular speed to affect to the specified gradient
  17522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17523. * @returns the current particle system
  17524. */
  17525. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17526. /**
  17527. * Remove a specific angular speed gradient
  17528. * @param gradient defines the gradient to remove
  17529. * @returns the current particle system
  17530. */
  17531. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17532. /**
  17533. * Adds a new velocity gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the velocity to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific velocity gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeVelocityGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new limit velocity gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the limit velocity value to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific limit velocity gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new drag gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param factor defines the drag value to affect to the specified gradient
  17564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17565. * @returns the current particle system
  17566. */
  17567. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific drag gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeDragGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param factor defines the emit rate value to affect to the specified gradient
  17578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17579. * @returns the current particle system
  17580. */
  17581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific emit rate gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeEmitRateGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the start size value to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific start size gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeStartSizeGradient(gradient: number): IParticleSystem;
  17602. private _createRampGradientTexture;
  17603. /**
  17604. * Gets the current list of ramp gradients.
  17605. * You must use addRampGradient and removeRampGradient to udpate this list
  17606. * @returns the list of ramp gradients
  17607. */
  17608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17609. /**
  17610. * Adds a new ramp gradient used to remap particle colors
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param color defines the color to affect to the specified gradient
  17613. * @returns the current particle system
  17614. */
  17615. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17616. /**
  17617. * Remove a specific ramp gradient
  17618. * @param gradient defines the gradient to remove
  17619. * @returns the current particle system
  17620. */
  17621. removeRampGradient(gradient: number): ParticleSystem;
  17622. /**
  17623. * Adds a new color gradient
  17624. * @param gradient defines the gradient to use (between 0 and 1)
  17625. * @param color1 defines the color to affect to the specified gradient
  17626. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17627. * @returns this particle system
  17628. */
  17629. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17630. /**
  17631. * Remove a specific color gradient
  17632. * @param gradient defines the gradient to remove
  17633. * @returns this particle system
  17634. */
  17635. removeColorGradient(gradient: number): IParticleSystem;
  17636. private _fetchR;
  17637. protected _reset(): void;
  17638. private _resetEffect;
  17639. private _createVertexBuffers;
  17640. private _createIndexBuffer;
  17641. /**
  17642. * Gets the maximum number of particles active at the same time.
  17643. * @returns The max number of active particles.
  17644. */
  17645. getCapacity(): number;
  17646. /**
  17647. * Gets whether there are still active particles in the system.
  17648. * @returns True if it is alive, otherwise false.
  17649. */
  17650. isAlive(): boolean;
  17651. /**
  17652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. private _prepareSubEmitterInternalArray;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17665. */
  17666. stop(stopSubEmitters?: boolean): void;
  17667. /**
  17668. * Remove all active particles
  17669. */
  17670. reset(): void;
  17671. /**
  17672. * @hidden (for internal use only)
  17673. */
  17674. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17675. /**
  17676. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17677. * Its lifetime will start back at 0.
  17678. */
  17679. recycleParticle: (particle: Particle) => void;
  17680. private _stopSubEmitters;
  17681. private _createParticle;
  17682. private _removeFromRoot;
  17683. private _emitFromParticle;
  17684. private _update;
  17685. /** @hidden */
  17686. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17687. /** @hidden */
  17688. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17689. /** @hidden */
  17690. private _getEffect;
  17691. /**
  17692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17693. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17694. */
  17695. animate(preWarmOnly?: boolean): void;
  17696. private _appendParticleVertices;
  17697. /**
  17698. * Rebuilds the particle system.
  17699. */
  17700. rebuild(): void;
  17701. /**
  17702. * Is this system ready to be used/rendered
  17703. * @return true if the system is ready
  17704. */
  17705. isReady(): boolean;
  17706. private _render;
  17707. /**
  17708. * Renders the particle system in its current state.
  17709. * @returns the current number of particles
  17710. */
  17711. render(): number;
  17712. /**
  17713. * Disposes the particle system and free the associated resources
  17714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17715. */
  17716. dispose(disposeTexture?: boolean): void;
  17717. /**
  17718. * Clones the particle system.
  17719. * @param name The name of the cloned object
  17720. * @param newEmitter The new emitter to use
  17721. * @returns the cloned particle system
  17722. */
  17723. clone(name: string, newEmitter: any): ParticleSystem;
  17724. /**
  17725. * Serializes the particle system to a JSON object.
  17726. * @returns the JSON object
  17727. */
  17728. serialize(): any;
  17729. /** @hidden */
  17730. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17731. /** @hidden */
  17732. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17733. /**
  17734. * Parses a JSON object to create a particle system.
  17735. * @param parsedParticleSystem The JSON object to parse
  17736. * @param scene The scene to create the particle system in
  17737. * @param rootUrl The root url to use to load external dependencies like texture
  17738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17739. * @returns the Parsed particle system
  17740. */
  17741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17742. }
  17743. }
  17744. declare module "babylonjs/Particles/particle" {
  17745. import { Nullable } from "babylonjs/types";
  17746. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17747. import { Color4 } from "babylonjs/Maths/math.color";
  17748. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17749. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17750. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17751. /**
  17752. * A particle represents one of the element emitted by a particle system.
  17753. * This is mainly define by its coordinates, direction, velocity and age.
  17754. */
  17755. export class Particle {
  17756. /**
  17757. * The particle system the particle belongs to.
  17758. */
  17759. particleSystem: ParticleSystem;
  17760. private static _Count;
  17761. /**
  17762. * Unique ID of the particle
  17763. */
  17764. id: number;
  17765. /**
  17766. * The world position of the particle in the scene.
  17767. */
  17768. position: Vector3;
  17769. /**
  17770. * The world direction of the particle in the scene.
  17771. */
  17772. direction: Vector3;
  17773. /**
  17774. * The color of the particle.
  17775. */
  17776. color: Color4;
  17777. /**
  17778. * The color change of the particle per step.
  17779. */
  17780. colorStep: Color4;
  17781. /**
  17782. * Defines how long will the life of the particle be.
  17783. */
  17784. lifeTime: number;
  17785. /**
  17786. * The current age of the particle.
  17787. */
  17788. age: number;
  17789. /**
  17790. * The current size of the particle.
  17791. */
  17792. size: number;
  17793. /**
  17794. * The current scale of the particle.
  17795. */
  17796. scale: Vector2;
  17797. /**
  17798. * The current angle of the particle.
  17799. */
  17800. angle: number;
  17801. /**
  17802. * Defines how fast is the angle changing.
  17803. */
  17804. angularSpeed: number;
  17805. /**
  17806. * Defines the cell index used by the particle to be rendered from a sprite.
  17807. */
  17808. cellIndex: number;
  17809. /**
  17810. * The information required to support color remapping
  17811. */
  17812. remapData: Vector4;
  17813. /** @hidden */
  17814. _randomCellOffset?: number;
  17815. /** @hidden */
  17816. _initialDirection: Nullable<Vector3>;
  17817. /** @hidden */
  17818. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17819. /** @hidden */
  17820. _initialStartSpriteCellID: number;
  17821. /** @hidden */
  17822. _initialEndSpriteCellID: number;
  17823. /** @hidden */
  17824. _currentColorGradient: Nullable<ColorGradient>;
  17825. /** @hidden */
  17826. _currentColor1: Color4;
  17827. /** @hidden */
  17828. _currentColor2: Color4;
  17829. /** @hidden */
  17830. _currentSizeGradient: Nullable<FactorGradient>;
  17831. /** @hidden */
  17832. _currentSize1: number;
  17833. /** @hidden */
  17834. _currentSize2: number;
  17835. /** @hidden */
  17836. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentAngularSpeed1: number;
  17839. /** @hidden */
  17840. _currentAngularSpeed2: number;
  17841. /** @hidden */
  17842. _currentVelocityGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentVelocity1: number;
  17845. /** @hidden */
  17846. _currentVelocity2: number;
  17847. /** @hidden */
  17848. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentLimitVelocity1: number;
  17851. /** @hidden */
  17852. _currentLimitVelocity2: number;
  17853. /** @hidden */
  17854. _currentDragGradient: Nullable<FactorGradient>;
  17855. /** @hidden */
  17856. _currentDrag1: number;
  17857. /** @hidden */
  17858. _currentDrag2: number;
  17859. /** @hidden */
  17860. _randomNoiseCoordinates1: Vector3;
  17861. /** @hidden */
  17862. _randomNoiseCoordinates2: Vector3;
  17863. /**
  17864. * Creates a new instance Particle
  17865. * @param particleSystem the particle system the particle belongs to
  17866. */
  17867. constructor(
  17868. /**
  17869. * The particle system the particle belongs to.
  17870. */
  17871. particleSystem: ParticleSystem);
  17872. private updateCellInfoFromSystem;
  17873. /**
  17874. * Defines how the sprite cell index is updated for the particle
  17875. */
  17876. updateCellIndex(): void;
  17877. /** @hidden */
  17878. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17879. /** @hidden */
  17880. _inheritParticleInfoToSubEmitters(): void;
  17881. /** @hidden */
  17882. _reset(): void;
  17883. /**
  17884. * Copy the properties of particle to another one.
  17885. * @param other the particle to copy the information to.
  17886. */
  17887. copyTo(other: Particle): void;
  17888. }
  17889. }
  17890. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17891. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17892. import { Effect } from "babylonjs/Materials/effect";
  17893. import { Particle } from "babylonjs/Particles/particle";
  17894. /**
  17895. * Particle emitter represents a volume emitting particles.
  17896. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17897. */
  17898. export interface IParticleEmitterType {
  17899. /**
  17900. * Called by the particle System when the direction is computed for the created particle.
  17901. * @param worldMatrix is the world matrix of the particle system
  17902. * @param directionToUpdate is the direction vector to update with the result
  17903. * @param particle is the particle we are computed the direction for
  17904. */
  17905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17906. /**
  17907. * Called by the particle System when the position is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param positionToUpdate is the position vector to update with the result
  17910. * @param particle is the particle we are computed the position for
  17911. */
  17912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Clones the current emitter and returns a copy of it
  17915. * @returns the new emitter
  17916. */
  17917. clone(): IParticleEmitterType;
  17918. /**
  17919. * Called by the GPUParticleSystem to setup the update shader
  17920. * @param effect defines the update shader
  17921. */
  17922. applyToShader(effect: Effect): void;
  17923. /**
  17924. * Returns a string to use to update the GPU particles update shader
  17925. * @returns the effect defines string
  17926. */
  17927. getEffectDefines(): string;
  17928. /**
  17929. * Returns a string representing the class name
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Serializes the particle system to a JSON object.
  17935. * @returns the JSON object
  17936. */
  17937. serialize(): any;
  17938. /**
  17939. * Parse properties from a JSON object
  17940. * @param serializationObject defines the JSON object
  17941. */
  17942. parse(serializationObject: any): void;
  17943. }
  17944. }
  17945. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17947. import { Effect } from "babylonjs/Materials/effect";
  17948. import { Particle } from "babylonjs/Particles/particle";
  17949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17950. /**
  17951. * Particle emitter emitting particles from the inside of a box.
  17952. * It emits the particles randomly between 2 given directions.
  17953. */
  17954. export class BoxParticleEmitter implements IParticleEmitterType {
  17955. /**
  17956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17957. */
  17958. direction1: Vector3;
  17959. /**
  17960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17961. */
  17962. direction2: Vector3;
  17963. /**
  17964. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17965. */
  17966. minEmitBox: Vector3;
  17967. /**
  17968. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17969. */
  17970. maxEmitBox: Vector3;
  17971. /**
  17972. * Creates a new instance BoxParticleEmitter
  17973. */
  17974. constructor();
  17975. /**
  17976. * Called by the particle System when the direction is computed for the created particle.
  17977. * @param worldMatrix is the world matrix of the particle system
  17978. * @param directionToUpdate is the direction vector to update with the result
  17979. * @param particle is the particle we are computed the direction for
  17980. */
  17981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17982. /**
  17983. * Called by the particle System when the position is computed for the created particle.
  17984. * @param worldMatrix is the world matrix of the particle system
  17985. * @param positionToUpdate is the position vector to update with the result
  17986. * @param particle is the particle we are computed the position for
  17987. */
  17988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17989. /**
  17990. * Clones the current emitter and returns a copy of it
  17991. * @returns the new emitter
  17992. */
  17993. clone(): BoxParticleEmitter;
  17994. /**
  17995. * Called by the GPUParticleSystem to setup the update shader
  17996. * @param effect defines the update shader
  17997. */
  17998. applyToShader(effect: Effect): void;
  17999. /**
  18000. * Returns a string to use to update the GPU particles update shader
  18001. * @returns a string containng the defines string
  18002. */
  18003. getEffectDefines(): string;
  18004. /**
  18005. * Returns the string "BoxParticleEmitter"
  18006. * @returns a string containing the class name
  18007. */
  18008. getClassName(): string;
  18009. /**
  18010. * Serializes the particle system to a JSON object.
  18011. * @returns the JSON object
  18012. */
  18013. serialize(): any;
  18014. /**
  18015. * Parse properties from a JSON object
  18016. * @param serializationObject defines the JSON object
  18017. */
  18018. parse(serializationObject: any): void;
  18019. }
  18020. }
  18021. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18023. import { Effect } from "babylonjs/Materials/effect";
  18024. import { Particle } from "babylonjs/Particles/particle";
  18025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18026. /**
  18027. * Particle emitter emitting particles from the inside of a cone.
  18028. * It emits the particles alongside the cone volume from the base to the particle.
  18029. * The emission direction might be randomized.
  18030. */
  18031. export class ConeParticleEmitter implements IParticleEmitterType {
  18032. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18033. directionRandomizer: number;
  18034. private _radius;
  18035. private _angle;
  18036. private _height;
  18037. /**
  18038. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18039. */
  18040. radiusRange: number;
  18041. /**
  18042. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18043. */
  18044. heightRange: number;
  18045. /**
  18046. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18047. */
  18048. emitFromSpawnPointOnly: boolean;
  18049. /**
  18050. * Gets or sets the radius of the emission cone
  18051. */
  18052. radius: number;
  18053. /**
  18054. * Gets or sets the angle of the emission cone
  18055. */
  18056. angle: number;
  18057. private _buildHeight;
  18058. /**
  18059. * Creates a new instance ConeParticleEmitter
  18060. * @param radius the radius of the emission cone (1 by default)
  18061. * @param angle the cone base angle (PI by default)
  18062. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18063. */
  18064. constructor(radius?: number, angle?: number,
  18065. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18066. directionRandomizer?: number);
  18067. /**
  18068. * Called by the particle System when the direction is computed for the created particle.
  18069. * @param worldMatrix is the world matrix of the particle system
  18070. * @param directionToUpdate is the direction vector to update with the result
  18071. * @param particle is the particle we are computed the direction for
  18072. */
  18073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18074. /**
  18075. * Called by the particle System when the position is computed for the created particle.
  18076. * @param worldMatrix is the world matrix of the particle system
  18077. * @param positionToUpdate is the position vector to update with the result
  18078. * @param particle is the particle we are computed the position for
  18079. */
  18080. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18081. /**
  18082. * Clones the current emitter and returns a copy of it
  18083. * @returns the new emitter
  18084. */
  18085. clone(): ConeParticleEmitter;
  18086. /**
  18087. * Called by the GPUParticleSystem to setup the update shader
  18088. * @param effect defines the update shader
  18089. */
  18090. applyToShader(effect: Effect): void;
  18091. /**
  18092. * Returns a string to use to update the GPU particles update shader
  18093. * @returns a string containng the defines string
  18094. */
  18095. getEffectDefines(): string;
  18096. /**
  18097. * Returns the string "ConeParticleEmitter"
  18098. * @returns a string containing the class name
  18099. */
  18100. getClassName(): string;
  18101. /**
  18102. * Serializes the particle system to a JSON object.
  18103. * @returns the JSON object
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Parse properties from a JSON object
  18108. * @param serializationObject defines the JSON object
  18109. */
  18110. parse(serializationObject: any): void;
  18111. }
  18112. }
  18113. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18114. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18115. import { Effect } from "babylonjs/Materials/effect";
  18116. import { Particle } from "babylonjs/Particles/particle";
  18117. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18118. /**
  18119. * Particle emitter emitting particles from the inside of a cylinder.
  18120. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18121. */
  18122. export class CylinderParticleEmitter implements IParticleEmitterType {
  18123. /**
  18124. * The radius of the emission cylinder.
  18125. */
  18126. radius: number;
  18127. /**
  18128. * The height of the emission cylinder.
  18129. */
  18130. height: number;
  18131. /**
  18132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18133. */
  18134. radiusRange: number;
  18135. /**
  18136. * How much to randomize the particle direction [0-1].
  18137. */
  18138. directionRandomizer: number;
  18139. /**
  18140. * Creates a new instance CylinderParticleEmitter
  18141. * @param radius the radius of the emission cylinder (1 by default)
  18142. * @param height the height of the emission cylinder (1 by default)
  18143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18145. */
  18146. constructor(
  18147. /**
  18148. * The radius of the emission cylinder.
  18149. */
  18150. radius?: number,
  18151. /**
  18152. * The height of the emission cylinder.
  18153. */
  18154. height?: number,
  18155. /**
  18156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18157. */
  18158. radiusRange?: number,
  18159. /**
  18160. * How much to randomize the particle direction [0-1].
  18161. */
  18162. directionRandomizer?: number);
  18163. /**
  18164. * Called by the particle System when the direction is computed for the created particle.
  18165. * @param worldMatrix is the world matrix of the particle system
  18166. * @param directionToUpdate is the direction vector to update with the result
  18167. * @param particle is the particle we are computed the direction for
  18168. */
  18169. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18170. /**
  18171. * Called by the particle System when the position is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param positionToUpdate is the position vector to update with the result
  18174. * @param particle is the particle we are computed the position for
  18175. */
  18176. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Clones the current emitter and returns a copy of it
  18179. * @returns the new emitter
  18180. */
  18181. clone(): CylinderParticleEmitter;
  18182. /**
  18183. * Called by the GPUParticleSystem to setup the update shader
  18184. * @param effect defines the update shader
  18185. */
  18186. applyToShader(effect: Effect): void;
  18187. /**
  18188. * Returns a string to use to update the GPU particles update shader
  18189. * @returns a string containng the defines string
  18190. */
  18191. getEffectDefines(): string;
  18192. /**
  18193. * Returns the string "CylinderParticleEmitter"
  18194. * @returns a string containing the class name
  18195. */
  18196. getClassName(): string;
  18197. /**
  18198. * Serializes the particle system to a JSON object.
  18199. * @returns the JSON object
  18200. */
  18201. serialize(): any;
  18202. /**
  18203. * Parse properties from a JSON object
  18204. * @param serializationObject defines the JSON object
  18205. */
  18206. parse(serializationObject: any): void;
  18207. }
  18208. /**
  18209. * Particle emitter emitting particles from the inside of a cylinder.
  18210. * It emits the particles randomly between two vectors.
  18211. */
  18212. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18213. /**
  18214. * The min limit of the emission direction.
  18215. */
  18216. direction1: Vector3;
  18217. /**
  18218. * The max limit of the emission direction.
  18219. */
  18220. direction2: Vector3;
  18221. /**
  18222. * Creates a new instance CylinderDirectedParticleEmitter
  18223. * @param radius the radius of the emission cylinder (1 by default)
  18224. * @param height the height of the emission cylinder (1 by default)
  18225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18226. * @param direction1 the min limit of the emission direction (up vector by default)
  18227. * @param direction2 the max limit of the emission direction (up vector by default)
  18228. */
  18229. constructor(radius?: number, height?: number, radiusRange?: number,
  18230. /**
  18231. * The min limit of the emission direction.
  18232. */
  18233. direction1?: Vector3,
  18234. /**
  18235. * The max limit of the emission direction.
  18236. */
  18237. direction2?: Vector3);
  18238. /**
  18239. * Called by the particle System when the direction is computed for the created particle.
  18240. * @param worldMatrix is the world matrix of the particle system
  18241. * @param directionToUpdate is the direction vector to update with the result
  18242. * @param particle is the particle we are computed the direction for
  18243. */
  18244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18245. /**
  18246. * Clones the current emitter and returns a copy of it
  18247. * @returns the new emitter
  18248. */
  18249. clone(): CylinderDirectedParticleEmitter;
  18250. /**
  18251. * Called by the GPUParticleSystem to setup the update shader
  18252. * @param effect defines the update shader
  18253. */
  18254. applyToShader(effect: Effect): void;
  18255. /**
  18256. * Returns a string to use to update the GPU particles update shader
  18257. * @returns a string containng the defines string
  18258. */
  18259. getEffectDefines(): string;
  18260. /**
  18261. * Returns the string "CylinderDirectedParticleEmitter"
  18262. * @returns a string containing the class name
  18263. */
  18264. getClassName(): string;
  18265. /**
  18266. * Serializes the particle system to a JSON object.
  18267. * @returns the JSON object
  18268. */
  18269. serialize(): any;
  18270. /**
  18271. * Parse properties from a JSON object
  18272. * @param serializationObject defines the JSON object
  18273. */
  18274. parse(serializationObject: any): void;
  18275. }
  18276. }
  18277. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18278. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18279. import { Effect } from "babylonjs/Materials/effect";
  18280. import { Particle } from "babylonjs/Particles/particle";
  18281. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18282. /**
  18283. * Particle emitter emitting particles from the inside of a hemisphere.
  18284. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18285. */
  18286. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18287. /**
  18288. * The radius of the emission hemisphere.
  18289. */
  18290. radius: number;
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange: number;
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer: number;
  18299. /**
  18300. * Creates a new instance HemisphericParticleEmitter
  18301. * @param radius the radius of the emission hemisphere (1 by default)
  18302. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18304. */
  18305. constructor(
  18306. /**
  18307. * The radius of the emission hemisphere.
  18308. */
  18309. radius?: number,
  18310. /**
  18311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18312. */
  18313. radiusRange?: number,
  18314. /**
  18315. * How much to randomize the particle direction [0-1].
  18316. */
  18317. directionRandomizer?: number);
  18318. /**
  18319. * Called by the particle System when the direction is computed for the created particle.
  18320. * @param worldMatrix is the world matrix of the particle system
  18321. * @param directionToUpdate is the direction vector to update with the result
  18322. * @param particle is the particle we are computed the direction for
  18323. */
  18324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18325. /**
  18326. * Called by the particle System when the position is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param positionToUpdate is the position vector to update with the result
  18329. * @param particle is the particle we are computed the position for
  18330. */
  18331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Clones the current emitter and returns a copy of it
  18334. * @returns the new emitter
  18335. */
  18336. clone(): HemisphericParticleEmitter;
  18337. /**
  18338. * Called by the GPUParticleSystem to setup the update shader
  18339. * @param effect defines the update shader
  18340. */
  18341. applyToShader(effect: Effect): void;
  18342. /**
  18343. * Returns a string to use to update the GPU particles update shader
  18344. * @returns a string containng the defines string
  18345. */
  18346. getEffectDefines(): string;
  18347. /**
  18348. * Returns the string "HemisphericParticleEmitter"
  18349. * @returns a string containing the class name
  18350. */
  18351. getClassName(): string;
  18352. /**
  18353. * Serializes the particle system to a JSON object.
  18354. * @returns the JSON object
  18355. */
  18356. serialize(): any;
  18357. /**
  18358. * Parse properties from a JSON object
  18359. * @param serializationObject defines the JSON object
  18360. */
  18361. parse(serializationObject: any): void;
  18362. }
  18363. }
  18364. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18365. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18366. import { Effect } from "babylonjs/Materials/effect";
  18367. import { Particle } from "babylonjs/Particles/particle";
  18368. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18369. /**
  18370. * Particle emitter emitting particles from a point.
  18371. * It emits the particles randomly between 2 given directions.
  18372. */
  18373. export class PointParticleEmitter implements IParticleEmitterType {
  18374. /**
  18375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18376. */
  18377. direction1: Vector3;
  18378. /**
  18379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18380. */
  18381. direction2: Vector3;
  18382. /**
  18383. * Creates a new instance PointParticleEmitter
  18384. */
  18385. constructor();
  18386. /**
  18387. * Called by the particle System when the direction is computed for the created particle.
  18388. * @param worldMatrix is the world matrix of the particle system
  18389. * @param directionToUpdate is the direction vector to update with the result
  18390. * @param particle is the particle we are computed the direction for
  18391. */
  18392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18393. /**
  18394. * Called by the particle System when the position is computed for the created particle.
  18395. * @param worldMatrix is the world matrix of the particle system
  18396. * @param positionToUpdate is the position vector to update with the result
  18397. * @param particle is the particle we are computed the position for
  18398. */
  18399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18400. /**
  18401. * Clones the current emitter and returns a copy of it
  18402. * @returns the new emitter
  18403. */
  18404. clone(): PointParticleEmitter;
  18405. /**
  18406. * Called by the GPUParticleSystem to setup the update shader
  18407. * @param effect defines the update shader
  18408. */
  18409. applyToShader(effect: Effect): void;
  18410. /**
  18411. * Returns a string to use to update the GPU particles update shader
  18412. * @returns a string containng the defines string
  18413. */
  18414. getEffectDefines(): string;
  18415. /**
  18416. * Returns the string "PointParticleEmitter"
  18417. * @returns a string containing the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Serializes the particle system to a JSON object.
  18422. * @returns the JSON object
  18423. */
  18424. serialize(): any;
  18425. /**
  18426. * Parse properties from a JSON object
  18427. * @param serializationObject defines the JSON object
  18428. */
  18429. parse(serializationObject: any): void;
  18430. }
  18431. }
  18432. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18434. import { Effect } from "babylonjs/Materials/effect";
  18435. import { Particle } from "babylonjs/Particles/particle";
  18436. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18437. /**
  18438. * Particle emitter emitting particles from the inside of a sphere.
  18439. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18440. */
  18441. export class SphereParticleEmitter implements IParticleEmitterType {
  18442. /**
  18443. * The radius of the emission sphere.
  18444. */
  18445. radius: number;
  18446. /**
  18447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18448. */
  18449. radiusRange: number;
  18450. /**
  18451. * How much to randomize the particle direction [0-1].
  18452. */
  18453. directionRandomizer: number;
  18454. /**
  18455. * Creates a new instance SphereParticleEmitter
  18456. * @param radius the radius of the emission sphere (1 by default)
  18457. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18459. */
  18460. constructor(
  18461. /**
  18462. * The radius of the emission sphere.
  18463. */
  18464. radius?: number,
  18465. /**
  18466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18467. */
  18468. radiusRange?: number,
  18469. /**
  18470. * How much to randomize the particle direction [0-1].
  18471. */
  18472. directionRandomizer?: number);
  18473. /**
  18474. * Called by the particle System when the direction is computed for the created particle.
  18475. * @param worldMatrix is the world matrix of the particle system
  18476. * @param directionToUpdate is the direction vector to update with the result
  18477. * @param particle is the particle we are computed the direction for
  18478. */
  18479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18480. /**
  18481. * Called by the particle System when the position is computed for the created particle.
  18482. * @param worldMatrix is the world matrix of the particle system
  18483. * @param positionToUpdate is the position vector to update with the result
  18484. * @param particle is the particle we are computed the position for
  18485. */
  18486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18487. /**
  18488. * Clones the current emitter and returns a copy of it
  18489. * @returns the new emitter
  18490. */
  18491. clone(): SphereParticleEmitter;
  18492. /**
  18493. * Called by the GPUParticleSystem to setup the update shader
  18494. * @param effect defines the update shader
  18495. */
  18496. applyToShader(effect: Effect): void;
  18497. /**
  18498. * Returns a string to use to update the GPU particles update shader
  18499. * @returns a string containng the defines string
  18500. */
  18501. getEffectDefines(): string;
  18502. /**
  18503. * Returns the string "SphereParticleEmitter"
  18504. * @returns a string containing the class name
  18505. */
  18506. getClassName(): string;
  18507. /**
  18508. * Serializes the particle system to a JSON object.
  18509. * @returns the JSON object
  18510. */
  18511. serialize(): any;
  18512. /**
  18513. * Parse properties from a JSON object
  18514. * @param serializationObject defines the JSON object
  18515. */
  18516. parse(serializationObject: any): void;
  18517. }
  18518. /**
  18519. * Particle emitter emitting particles from the inside of a sphere.
  18520. * It emits the particles randomly between two vectors.
  18521. */
  18522. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18523. /**
  18524. * The min limit of the emission direction.
  18525. */
  18526. direction1: Vector3;
  18527. /**
  18528. * The max limit of the emission direction.
  18529. */
  18530. direction2: Vector3;
  18531. /**
  18532. * Creates a new instance SphereDirectedParticleEmitter
  18533. * @param radius the radius of the emission sphere (1 by default)
  18534. * @param direction1 the min limit of the emission direction (up vector by default)
  18535. * @param direction2 the max limit of the emission direction (up vector by default)
  18536. */
  18537. constructor(radius?: number,
  18538. /**
  18539. * The min limit of the emission direction.
  18540. */
  18541. direction1?: Vector3,
  18542. /**
  18543. * The max limit of the emission direction.
  18544. */
  18545. direction2?: Vector3);
  18546. /**
  18547. * Called by the particle System when the direction is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param directionToUpdate is the direction vector to update with the result
  18550. * @param particle is the particle we are computed the direction for
  18551. */
  18552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereDirectedParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereDirectedParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Particles/EmitterTypes/index" {
  18586. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18587. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18588. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18589. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18590. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18591. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18592. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18593. }
  18594. declare module "babylonjs/Particles/IParticleSystem" {
  18595. import { Nullable } from "babylonjs/types";
  18596. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18600. import { Texture } from "babylonjs/Materials/Textures/texture";
  18601. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18602. import { Scene } from "babylonjs/scene";
  18603. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18604. import { Animation } from "babylonjs/Animations/animation";
  18605. /**
  18606. * Interface representing a particle system in Babylon.js.
  18607. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18608. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18609. */
  18610. export interface IParticleSystem {
  18611. /**
  18612. * List of animations used by the particle system.
  18613. */
  18614. animations: Animation[];
  18615. /**
  18616. * The id of the Particle system.
  18617. */
  18618. id: string;
  18619. /**
  18620. * The name of the Particle system.
  18621. */
  18622. name: string;
  18623. /**
  18624. * The emitter represents the Mesh or position we are attaching the particle system to.
  18625. */
  18626. emitter: Nullable<AbstractMesh | Vector3>;
  18627. /**
  18628. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18629. */
  18630. isBillboardBased: boolean;
  18631. /**
  18632. * The rendering group used by the Particle system to chose when to render.
  18633. */
  18634. renderingGroupId: number;
  18635. /**
  18636. * The layer mask we are rendering the particles through.
  18637. */
  18638. layerMask: number;
  18639. /**
  18640. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18641. */
  18642. updateSpeed: number;
  18643. /**
  18644. * The amount of time the particle system is running (depends of the overall update speed).
  18645. */
  18646. targetStopDuration: number;
  18647. /**
  18648. * The texture used to render each particle. (this can be a spritesheet)
  18649. */
  18650. particleTexture: Nullable<Texture>;
  18651. /**
  18652. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18653. */
  18654. blendMode: number;
  18655. /**
  18656. * Minimum life time of emitting particles.
  18657. */
  18658. minLifeTime: number;
  18659. /**
  18660. * Maximum life time of emitting particles.
  18661. */
  18662. maxLifeTime: number;
  18663. /**
  18664. * Minimum Size of emitting particles.
  18665. */
  18666. minSize: number;
  18667. /**
  18668. * Maximum Size of emitting particles.
  18669. */
  18670. maxSize: number;
  18671. /**
  18672. * Minimum scale of emitting particles on X axis.
  18673. */
  18674. minScaleX: number;
  18675. /**
  18676. * Maximum scale of emitting particles on X axis.
  18677. */
  18678. maxScaleX: number;
  18679. /**
  18680. * Minimum scale of emitting particles on Y axis.
  18681. */
  18682. minScaleY: number;
  18683. /**
  18684. * Maximum scale of emitting particles on Y axis.
  18685. */
  18686. maxScaleY: number;
  18687. /**
  18688. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18689. */
  18690. color1: Color4;
  18691. /**
  18692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18693. */
  18694. color2: Color4;
  18695. /**
  18696. * Color the particle will have at the end of its lifetime.
  18697. */
  18698. colorDead: Color4;
  18699. /**
  18700. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18701. */
  18702. emitRate: number;
  18703. /**
  18704. * You can use gravity if you want to give an orientation to your particles.
  18705. */
  18706. gravity: Vector3;
  18707. /**
  18708. * Minimum power of emitting particles.
  18709. */
  18710. minEmitPower: number;
  18711. /**
  18712. * Maximum power of emitting particles.
  18713. */
  18714. maxEmitPower: number;
  18715. /**
  18716. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18717. */
  18718. minAngularSpeed: number;
  18719. /**
  18720. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18721. */
  18722. maxAngularSpeed: number;
  18723. /**
  18724. * Gets or sets the minimal initial rotation in radians.
  18725. */
  18726. minInitialRotation: number;
  18727. /**
  18728. * Gets or sets the maximal initial rotation in radians.
  18729. */
  18730. maxInitialRotation: number;
  18731. /**
  18732. * The particle emitter type defines the emitter used by the particle system.
  18733. * It can be for example box, sphere, or cone...
  18734. */
  18735. particleEmitterType: Nullable<IParticleEmitterType>;
  18736. /**
  18737. * Defines the delay in milliseconds before starting the system (0 by default)
  18738. */
  18739. startDelay: number;
  18740. /**
  18741. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18742. */
  18743. preWarmCycles: number;
  18744. /**
  18745. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18746. */
  18747. preWarmStepOffset: number;
  18748. /**
  18749. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18750. */
  18751. spriteCellChangeSpeed: number;
  18752. /**
  18753. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18754. */
  18755. startSpriteCellID: number;
  18756. /**
  18757. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18758. */
  18759. endSpriteCellID: number;
  18760. /**
  18761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18762. */
  18763. spriteCellWidth: number;
  18764. /**
  18765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18766. */
  18767. spriteCellHeight: number;
  18768. /**
  18769. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18770. */
  18771. spriteRandomStartCell: boolean;
  18772. /**
  18773. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18774. */
  18775. isAnimationSheetEnabled: boolean;
  18776. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18777. translationPivot: Vector2;
  18778. /**
  18779. * Gets or sets a texture used to add random noise to particle positions
  18780. */
  18781. noiseTexture: Nullable<BaseTexture>;
  18782. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18783. noiseStrength: Vector3;
  18784. /**
  18785. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18786. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18787. */
  18788. billboardMode: number;
  18789. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18790. limitVelocityDamping: number;
  18791. /**
  18792. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18793. */
  18794. beginAnimationOnStart: boolean;
  18795. /**
  18796. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18797. */
  18798. beginAnimationFrom: number;
  18799. /**
  18800. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18801. */
  18802. beginAnimationTo: number;
  18803. /**
  18804. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18805. */
  18806. beginAnimationLoop: boolean;
  18807. /**
  18808. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18809. */
  18810. disposeOnStop: boolean;
  18811. /**
  18812. * Gets the maximum number of particles active at the same time.
  18813. * @returns The max number of active particles.
  18814. */
  18815. getCapacity(): number;
  18816. /**
  18817. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18818. * @returns True if it has been started, otherwise false.
  18819. */
  18820. isStarted(): boolean;
  18821. /**
  18822. * Animates the particle system for this frame.
  18823. */
  18824. animate(): void;
  18825. /**
  18826. * Renders the particle system in its current state.
  18827. * @returns the current number of particles
  18828. */
  18829. render(): number;
  18830. /**
  18831. * Dispose the particle system and frees its associated resources.
  18832. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18833. */
  18834. dispose(disposeTexture?: boolean): void;
  18835. /**
  18836. * Clones the particle system.
  18837. * @param name The name of the cloned object
  18838. * @param newEmitter The new emitter to use
  18839. * @returns the cloned particle system
  18840. */
  18841. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18842. /**
  18843. * Serializes the particle system to a JSON object.
  18844. * @returns the JSON object
  18845. */
  18846. serialize(): any;
  18847. /**
  18848. * Rebuild the particle system
  18849. */
  18850. rebuild(): void;
  18851. /**
  18852. * Starts the particle system and begins to emit
  18853. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18854. */
  18855. start(delay?: number): void;
  18856. /**
  18857. * Stops the particle system.
  18858. */
  18859. stop(): void;
  18860. /**
  18861. * Remove all active particles
  18862. */
  18863. reset(): void;
  18864. /**
  18865. * Is this system ready to be used/rendered
  18866. * @return true if the system is ready
  18867. */
  18868. isReady(): boolean;
  18869. /**
  18870. * Adds a new color gradient
  18871. * @param gradient defines the gradient to use (between 0 and 1)
  18872. * @param color1 defines the color to affect to the specified gradient
  18873. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18874. * @returns the current particle system
  18875. */
  18876. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18877. /**
  18878. * Remove a specific color gradient
  18879. * @param gradient defines the gradient to remove
  18880. * @returns the current particle system
  18881. */
  18882. removeColorGradient(gradient: number): IParticleSystem;
  18883. /**
  18884. * Adds a new size gradient
  18885. * @param gradient defines the gradient to use (between 0 and 1)
  18886. * @param factor defines the size factor to affect to the specified gradient
  18887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18888. * @returns the current particle system
  18889. */
  18890. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18891. /**
  18892. * Remove a specific size gradient
  18893. * @param gradient defines the gradient to remove
  18894. * @returns the current particle system
  18895. */
  18896. removeSizeGradient(gradient: number): IParticleSystem;
  18897. /**
  18898. * Gets the current list of color gradients.
  18899. * You must use addColorGradient and removeColorGradient to udpate this list
  18900. * @returns the list of color gradients
  18901. */
  18902. getColorGradients(): Nullable<Array<ColorGradient>>;
  18903. /**
  18904. * Gets the current list of size gradients.
  18905. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18906. * @returns the list of size gradients
  18907. */
  18908. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18909. /**
  18910. * Gets the current list of angular speed gradients.
  18911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18912. * @returns the list of angular speed gradients
  18913. */
  18914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18915. /**
  18916. * Adds a new angular speed gradient
  18917. * @param gradient defines the gradient to use (between 0 and 1)
  18918. * @param factor defines the angular speed to affect to the specified gradient
  18919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18920. * @returns the current particle system
  18921. */
  18922. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18923. /**
  18924. * Remove a specific angular speed gradient
  18925. * @param gradient defines the gradient to remove
  18926. * @returns the current particle system
  18927. */
  18928. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of velocity gradients.
  18931. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18932. * @returns the list of velocity gradients
  18933. */
  18934. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Adds a new velocity gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param factor defines the velocity to affect to the specified gradient
  18939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18940. * @returns the current particle system
  18941. */
  18942. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18943. /**
  18944. * Remove a specific velocity gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeVelocityGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Gets the current list of limit velocity gradients.
  18951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18952. * @returns the list of limit velocity gradients
  18953. */
  18954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18955. /**
  18956. * Adds a new limit velocity gradient
  18957. * @param gradient defines the gradient to use (between 0 and 1)
  18958. * @param factor defines the limit velocity to affect to the specified gradient
  18959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18960. * @returns the current particle system
  18961. */
  18962. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18963. /**
  18964. * Remove a specific limit velocity gradient
  18965. * @param gradient defines the gradient to remove
  18966. * @returns the current particle system
  18967. */
  18968. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18969. /**
  18970. * Adds a new drag gradient
  18971. * @param gradient defines the gradient to use (between 0 and 1)
  18972. * @param factor defines the drag to affect to the specified gradient
  18973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18974. * @returns the current particle system
  18975. */
  18976. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18977. /**
  18978. * Remove a specific drag gradient
  18979. * @param gradient defines the gradient to remove
  18980. * @returns the current particle system
  18981. */
  18982. removeDragGradient(gradient: number): IParticleSystem;
  18983. /**
  18984. * Gets the current list of drag gradients.
  18985. * You must use addDragGradient and removeDragGradient to udpate this list
  18986. * @returns the list of drag gradients
  18987. */
  18988. getDragGradients(): Nullable<Array<FactorGradient>>;
  18989. /**
  18990. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18991. * @param gradient defines the gradient to use (between 0 and 1)
  18992. * @param factor defines the emit rate to affect to the specified gradient
  18993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18994. * @returns the current particle system
  18995. */
  18996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18997. /**
  18998. * Remove a specific emit rate gradient
  18999. * @param gradient defines the gradient to remove
  19000. * @returns the current particle system
  19001. */
  19002. removeEmitRateGradient(gradient: number): IParticleSystem;
  19003. /**
  19004. * Gets the current list of emit rate gradients.
  19005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19006. * @returns the list of emit rate gradients
  19007. */
  19008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19009. /**
  19010. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19011. * @param gradient defines the gradient to use (between 0 and 1)
  19012. * @param factor defines the start size to affect to the specified gradient
  19013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19014. * @returns the current particle system
  19015. */
  19016. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19017. /**
  19018. * Remove a specific start size gradient
  19019. * @param gradient defines the gradient to remove
  19020. * @returns the current particle system
  19021. */
  19022. removeStartSizeGradient(gradient: number): IParticleSystem;
  19023. /**
  19024. * Gets the current list of start size gradients.
  19025. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19026. * @returns the list of start size gradients
  19027. */
  19028. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Adds a new life time gradient
  19031. * @param gradient defines the gradient to use (between 0 and 1)
  19032. * @param factor defines the life time factor to affect to the specified gradient
  19033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19034. * @returns the current particle system
  19035. */
  19036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19037. /**
  19038. * Remove a specific life time gradient
  19039. * @param gradient defines the gradient to remove
  19040. * @returns the current particle system
  19041. */
  19042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of life time gradients.
  19045. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19046. * @returns the list of life time gradients
  19047. */
  19048. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19049. /**
  19050. * Gets the current list of color gradients.
  19051. * You must use addColorGradient and removeColorGradient to udpate this list
  19052. * @returns the list of color gradients
  19053. */
  19054. getColorGradients(): Nullable<Array<ColorGradient>>;
  19055. /**
  19056. * Adds a new ramp gradient used to remap particle colors
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param color defines the color to affect to the specified gradient
  19059. * @returns the current particle system
  19060. */
  19061. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19062. /**
  19063. * Gets the current list of ramp gradients.
  19064. * You must use addRampGradient and removeRampGradient to udpate this list
  19065. * @returns the list of ramp gradients
  19066. */
  19067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19068. /** Gets or sets a boolean indicating that ramp gradients must be used
  19069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19070. */
  19071. useRampGradients: boolean;
  19072. /**
  19073. * Adds a new color remap gradient
  19074. * @param gradient defines the gradient to use (between 0 and 1)
  19075. * @param min defines the color remap minimal range
  19076. * @param max defines the color remap maximal range
  19077. * @returns the current particle system
  19078. */
  19079. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19080. /**
  19081. * Gets the current list of color remap gradients.
  19082. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19083. * @returns the list of color remap gradients
  19084. */
  19085. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19086. /**
  19087. * Adds a new alpha remap gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param min defines the alpha remap minimal range
  19090. * @param max defines the alpha remap maximal range
  19091. * @returns the current particle system
  19092. */
  19093. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19094. /**
  19095. * Gets the current list of alpha remap gradients.
  19096. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19097. * @returns the list of alpha remap gradients
  19098. */
  19099. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19100. /**
  19101. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19104. * @returns the emitter
  19105. */
  19106. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19107. /**
  19108. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19109. * @param radius The radius of the hemisphere to emit from
  19110. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19111. * @returns the emitter
  19112. */
  19113. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19114. /**
  19115. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19116. * @param radius The radius of the sphere to emit from
  19117. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19118. * @returns the emitter
  19119. */
  19120. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19121. /**
  19122. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19123. * @param radius The radius of the sphere to emit from
  19124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19126. * @returns the emitter
  19127. */
  19128. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19129. /**
  19130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19131. * @param radius The radius of the emission cylinder
  19132. * @param height The height of the emission cylinder
  19133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19135. * @returns the emitter
  19136. */
  19137. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19138. /**
  19139. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19140. * @param radius The radius of the cylinder to emit from
  19141. * @param height The height of the emission cylinder
  19142. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19145. * @returns the emitter
  19146. */
  19147. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19148. /**
  19149. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19150. * @param radius The radius of the cone to emit from
  19151. * @param angle The base angle of the cone
  19152. * @returns the emitter
  19153. */
  19154. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19155. /**
  19156. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19159. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19160. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19161. * @returns the emitter
  19162. */
  19163. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19164. /**
  19165. * Get hosting scene
  19166. * @returns the scene
  19167. */
  19168. getScene(): Scene;
  19169. }
  19170. }
  19171. declare module "babylonjs/Meshes/instancedMesh" {
  19172. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19174. import { Camera } from "babylonjs/Cameras/camera";
  19175. import { Node } from "babylonjs/node";
  19176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19177. import { Mesh } from "babylonjs/Meshes/mesh";
  19178. import { Material } from "babylonjs/Materials/material";
  19179. import { Skeleton } from "babylonjs/Bones/skeleton";
  19180. import { Light } from "babylonjs/Lights/light";
  19181. /**
  19182. * Creates an instance based on a source mesh.
  19183. */
  19184. export class InstancedMesh extends AbstractMesh {
  19185. private _sourceMesh;
  19186. private _currentLOD;
  19187. /** @hidden */
  19188. _indexInSourceMeshInstanceArray: number;
  19189. constructor(name: string, source: Mesh);
  19190. /**
  19191. * Returns the string "InstancedMesh".
  19192. */
  19193. getClassName(): string;
  19194. /** Gets the list of lights affecting that mesh */
  19195. readonly lightSources: Light[];
  19196. _resyncLightSources(): void;
  19197. _resyncLighSource(light: Light): void;
  19198. _removeLightSource(light: Light, dispose: boolean): void;
  19199. /**
  19200. * If the source mesh receives shadows
  19201. */
  19202. readonly receiveShadows: boolean;
  19203. /**
  19204. * The material of the source mesh
  19205. */
  19206. readonly material: Nullable<Material>;
  19207. /**
  19208. * Visibility of the source mesh
  19209. */
  19210. readonly visibility: number;
  19211. /**
  19212. * Skeleton of the source mesh
  19213. */
  19214. readonly skeleton: Nullable<Skeleton>;
  19215. /**
  19216. * Rendering ground id of the source mesh
  19217. */
  19218. renderingGroupId: number;
  19219. /**
  19220. * Returns the total number of vertices (integer).
  19221. */
  19222. getTotalVertices(): number;
  19223. /**
  19224. * Returns a positive integer : the total number of indices in this mesh geometry.
  19225. * @returns the numner of indices or zero if the mesh has no geometry.
  19226. */
  19227. getTotalIndices(): number;
  19228. /**
  19229. * The source mesh of the instance
  19230. */
  19231. readonly sourceMesh: Mesh;
  19232. /**
  19233. * Is this node ready to be used/rendered
  19234. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19235. * @return {boolean} is it ready
  19236. */
  19237. isReady(completeCheck?: boolean): boolean;
  19238. /**
  19239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19240. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19241. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19242. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19243. */
  19244. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19245. /**
  19246. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19247. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19248. * The `data` are either a numeric array either a Float32Array.
  19249. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19250. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19251. * Note that a new underlying VertexBuffer object is created each call.
  19252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19253. *
  19254. * Possible `kind` values :
  19255. * - VertexBuffer.PositionKind
  19256. * - VertexBuffer.UVKind
  19257. * - VertexBuffer.UV2Kind
  19258. * - VertexBuffer.UV3Kind
  19259. * - VertexBuffer.UV4Kind
  19260. * - VertexBuffer.UV5Kind
  19261. * - VertexBuffer.UV6Kind
  19262. * - VertexBuffer.ColorKind
  19263. * - VertexBuffer.MatricesIndicesKind
  19264. * - VertexBuffer.MatricesIndicesExtraKind
  19265. * - VertexBuffer.MatricesWeightsKind
  19266. * - VertexBuffer.MatricesWeightsExtraKind
  19267. *
  19268. * Returns the Mesh.
  19269. */
  19270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19271. /**
  19272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19273. * If the mesh has no geometry, it is simply returned as it is.
  19274. * The `data` are either a numeric array either a Float32Array.
  19275. * No new underlying VertexBuffer object is created.
  19276. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19277. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19278. *
  19279. * Possible `kind` values :
  19280. * - VertexBuffer.PositionKind
  19281. * - VertexBuffer.UVKind
  19282. * - VertexBuffer.UV2Kind
  19283. * - VertexBuffer.UV3Kind
  19284. * - VertexBuffer.UV4Kind
  19285. * - VertexBuffer.UV5Kind
  19286. * - VertexBuffer.UV6Kind
  19287. * - VertexBuffer.ColorKind
  19288. * - VertexBuffer.MatricesIndicesKind
  19289. * - VertexBuffer.MatricesIndicesExtraKind
  19290. * - VertexBuffer.MatricesWeightsKind
  19291. * - VertexBuffer.MatricesWeightsExtraKind
  19292. *
  19293. * Returns the Mesh.
  19294. */
  19295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19296. /**
  19297. * Sets the mesh indices.
  19298. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19299. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19300. * This method creates a new index buffer each call.
  19301. * Returns the Mesh.
  19302. */
  19303. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19304. /**
  19305. * Boolean : True if the mesh owns the requested kind of data.
  19306. */
  19307. isVerticesDataPresent(kind: string): boolean;
  19308. /**
  19309. * Returns an array of indices (IndicesArray).
  19310. */
  19311. getIndices(): Nullable<IndicesArray>;
  19312. readonly _positions: Nullable<Vector3[]>;
  19313. /**
  19314. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19315. * This means the mesh underlying bounding box and sphere are recomputed.
  19316. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19317. * @returns the current mesh
  19318. */
  19319. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19320. /** @hidden */
  19321. _preActivate(): InstancedMesh;
  19322. /** @hidden */
  19323. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19324. /** @hidden */
  19325. _postActivate(): void;
  19326. getWorldMatrix(): Matrix;
  19327. readonly isAnInstance: boolean;
  19328. /**
  19329. * Returns the current associated LOD AbstractMesh.
  19330. */
  19331. getLOD(camera: Camera): AbstractMesh;
  19332. /** @hidden */
  19333. _syncSubMeshes(): InstancedMesh;
  19334. /** @hidden */
  19335. _generatePointsArray(): boolean;
  19336. /**
  19337. * Creates a new InstancedMesh from the current mesh.
  19338. * - name (string) : the cloned mesh name
  19339. * - newParent (optional Node) : the optional Node to parent the clone to.
  19340. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19341. *
  19342. * Returns the clone.
  19343. */
  19344. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19345. /**
  19346. * Disposes the InstancedMesh.
  19347. * Returns nothing.
  19348. */
  19349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19350. }
  19351. }
  19352. declare module "babylonjs/Materials/shaderMaterial" {
  19353. import { Scene } from "babylonjs/scene";
  19354. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19356. import { Mesh } from "babylonjs/Meshes/mesh";
  19357. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19359. import { Texture } from "babylonjs/Materials/Textures/texture";
  19360. import { Material } from "babylonjs/Materials/material";
  19361. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19362. /**
  19363. * Defines the options associated with the creation of a shader material.
  19364. */
  19365. export interface IShaderMaterialOptions {
  19366. /**
  19367. * Does the material work in alpha blend mode
  19368. */
  19369. needAlphaBlending: boolean;
  19370. /**
  19371. * Does the material work in alpha test mode
  19372. */
  19373. needAlphaTesting: boolean;
  19374. /**
  19375. * The list of attribute names used in the shader
  19376. */
  19377. attributes: string[];
  19378. /**
  19379. * The list of unifrom names used in the shader
  19380. */
  19381. uniforms: string[];
  19382. /**
  19383. * The list of UBO names used in the shader
  19384. */
  19385. uniformBuffers: string[];
  19386. /**
  19387. * The list of sampler names used in the shader
  19388. */
  19389. samplers: string[];
  19390. /**
  19391. * The list of defines used in the shader
  19392. */
  19393. defines: string[];
  19394. }
  19395. /**
  19396. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19397. *
  19398. * This returned material effects how the mesh will look based on the code in the shaders.
  19399. *
  19400. * @see http://doc.babylonjs.com/how_to/shader_material
  19401. */
  19402. export class ShaderMaterial extends Material {
  19403. private _shaderPath;
  19404. private _options;
  19405. private _textures;
  19406. private _textureArrays;
  19407. private _floats;
  19408. private _ints;
  19409. private _floatsArrays;
  19410. private _colors3;
  19411. private _colors3Arrays;
  19412. private _colors4;
  19413. private _colors4Arrays;
  19414. private _vectors2;
  19415. private _vectors3;
  19416. private _vectors4;
  19417. private _matrices;
  19418. private _matrices3x3;
  19419. private _matrices2x2;
  19420. private _vectors2Arrays;
  19421. private _vectors3Arrays;
  19422. private _vectors4Arrays;
  19423. private _cachedWorldViewMatrix;
  19424. private _cachedWorldViewProjectionMatrix;
  19425. private _renderId;
  19426. /**
  19427. * Instantiate a new shader material.
  19428. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19429. * This returned material effects how the mesh will look based on the code in the shaders.
  19430. * @see http://doc.babylonjs.com/how_to/shader_material
  19431. * @param name Define the name of the material in the scene
  19432. * @param scene Define the scene the material belongs to
  19433. * @param shaderPath Defines the route to the shader code in one of three ways:
  19434. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19435. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19436. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19437. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19438. * @param options Define the options used to create the shader
  19439. */
  19440. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19441. /**
  19442. * Gets the options used to compile the shader.
  19443. * They can be modified to trigger a new compilation
  19444. */
  19445. readonly options: IShaderMaterialOptions;
  19446. /**
  19447. * Gets the current class name of the material e.g. "ShaderMaterial"
  19448. * Mainly use in serialization.
  19449. * @returns the class name
  19450. */
  19451. getClassName(): string;
  19452. /**
  19453. * Specifies if the material will require alpha blending
  19454. * @returns a boolean specifying if alpha blending is needed
  19455. */
  19456. needAlphaBlending(): boolean;
  19457. /**
  19458. * Specifies if this material should be rendered in alpha test mode
  19459. * @returns a boolean specifying if an alpha test is needed.
  19460. */
  19461. needAlphaTesting(): boolean;
  19462. private _checkUniform;
  19463. /**
  19464. * Set a texture in the shader.
  19465. * @param name Define the name of the uniform samplers as defined in the shader
  19466. * @param texture Define the texture to bind to this sampler
  19467. * @return the material itself allowing "fluent" like uniform updates
  19468. */
  19469. setTexture(name: string, texture: Texture): ShaderMaterial;
  19470. /**
  19471. * Set a texture array in the shader.
  19472. * @param name Define the name of the uniform sampler array as defined in the shader
  19473. * @param textures Define the list of textures to bind to this sampler
  19474. * @return the material itself allowing "fluent" like uniform updates
  19475. */
  19476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19477. /**
  19478. * Set a float in the shader.
  19479. * @param name Define the name of the uniform as defined in the shader
  19480. * @param value Define the value to give to the uniform
  19481. * @return the material itself allowing "fluent" like uniform updates
  19482. */
  19483. setFloat(name: string, value: number): ShaderMaterial;
  19484. /**
  19485. * Set a int in the shader.
  19486. * @param name Define the name of the uniform as defined in the shader
  19487. * @param value Define the value to give to the uniform
  19488. * @return the material itself allowing "fluent" like uniform updates
  19489. */
  19490. setInt(name: string, value: number): ShaderMaterial;
  19491. /**
  19492. * Set an array of floats in the shader.
  19493. * @param name Define the name of the uniform as defined in the shader
  19494. * @param value Define the value to give to the uniform
  19495. * @return the material itself allowing "fluent" like uniform updates
  19496. */
  19497. setFloats(name: string, value: number[]): ShaderMaterial;
  19498. /**
  19499. * Set a vec3 in the shader from a Color3.
  19500. * @param name Define the name of the uniform as defined in the shader
  19501. * @param value Define the value to give to the uniform
  19502. * @return the material itself allowing "fluent" like uniform updates
  19503. */
  19504. setColor3(name: string, value: Color3): ShaderMaterial;
  19505. /**
  19506. * Set a vec3 array in the shader from a Color3 array.
  19507. * @param name Define the name of the uniform as defined in the shader
  19508. * @param value Define the value to give to the uniform
  19509. * @return the material itself allowing "fluent" like uniform updates
  19510. */
  19511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19512. /**
  19513. * Set a vec4 in the shader from a Color4.
  19514. * @param name Define the name of the uniform as defined in the shader
  19515. * @param value Define the value to give to the uniform
  19516. * @return the material itself allowing "fluent" like uniform updates
  19517. */
  19518. setColor4(name: string, value: Color4): ShaderMaterial;
  19519. /**
  19520. * Set a vec4 array in the shader from a Color4 array.
  19521. * @param name Define the name of the uniform as defined in the shader
  19522. * @param value Define the value to give to the uniform
  19523. * @return the material itself allowing "fluent" like uniform updates
  19524. */
  19525. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19526. /**
  19527. * Set a vec2 in the shader from a Vector2.
  19528. * @param name Define the name of the uniform as defined in the shader
  19529. * @param value Define the value to give to the uniform
  19530. * @return the material itself allowing "fluent" like uniform updates
  19531. */
  19532. setVector2(name: string, value: Vector2): ShaderMaterial;
  19533. /**
  19534. * Set a vec3 in the shader from a Vector3.
  19535. * @param name Define the name of the uniform as defined in the shader
  19536. * @param value Define the value to give to the uniform
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setVector3(name: string, value: Vector3): ShaderMaterial;
  19540. /**
  19541. * Set a vec4 in the shader from a Vector4.
  19542. * @param name Define the name of the uniform as defined in the shader
  19543. * @param value Define the value to give to the uniform
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setVector4(name: string, value: Vector4): ShaderMaterial;
  19547. /**
  19548. * Set a mat4 in the shader from a Matrix.
  19549. * @param name Define the name of the uniform as defined in the shader
  19550. * @param value Define the value to give to the uniform
  19551. * @return the material itself allowing "fluent" like uniform updates
  19552. */
  19553. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19554. /**
  19555. * Set a mat3 in the shader from a Float32Array.
  19556. * @param name Define the name of the uniform as defined in the shader
  19557. * @param value Define the value to give to the uniform
  19558. * @return the material itself allowing "fluent" like uniform updates
  19559. */
  19560. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19561. /**
  19562. * Set a mat2 in the shader from a Float32Array.
  19563. * @param name Define the name of the uniform as defined in the shader
  19564. * @param value Define the value to give to the uniform
  19565. * @return the material itself allowing "fluent" like uniform updates
  19566. */
  19567. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19568. /**
  19569. * Set a vec2 array in the shader from a number array.
  19570. * @param name Define the name of the uniform as defined in the shader
  19571. * @param value Define the value to give to the uniform
  19572. * @return the material itself allowing "fluent" like uniform updates
  19573. */
  19574. setArray2(name: string, value: number[]): ShaderMaterial;
  19575. /**
  19576. * Set a vec3 array in the shader from a number array.
  19577. * @param name Define the name of the uniform as defined in the shader
  19578. * @param value Define the value to give to the uniform
  19579. * @return the material itself allowing "fluent" like uniform updates
  19580. */
  19581. setArray3(name: string, value: number[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec4 array in the shader from a number array.
  19584. * @param name Define the name of the uniform as defined in the shader
  19585. * @param value Define the value to give to the uniform
  19586. * @return the material itself allowing "fluent" like uniform updates
  19587. */
  19588. setArray4(name: string, value: number[]): ShaderMaterial;
  19589. private _checkCache;
  19590. /**
  19591. * Specifies that the submesh is ready to be used
  19592. * @param mesh defines the mesh to check
  19593. * @param subMesh defines which submesh to check
  19594. * @param useInstances specifies that instances should be used
  19595. * @returns a boolean indicating that the submesh is ready or not
  19596. */
  19597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19598. /**
  19599. * Checks if the material is ready to render the requested mesh
  19600. * @param mesh Define the mesh to render
  19601. * @param useInstances Define whether or not the material is used with instances
  19602. * @returns true if ready, otherwise false
  19603. */
  19604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19605. /**
  19606. * Binds the world matrix to the material
  19607. * @param world defines the world transformation matrix
  19608. */
  19609. bindOnlyWorldMatrix(world: Matrix): void;
  19610. /**
  19611. * Binds the material to the mesh
  19612. * @param world defines the world transformation matrix
  19613. * @param mesh defines the mesh to bind the material to
  19614. */
  19615. bind(world: Matrix, mesh?: Mesh): void;
  19616. /**
  19617. * Gets the active textures from the material
  19618. * @returns an array of textures
  19619. */
  19620. getActiveTextures(): BaseTexture[];
  19621. /**
  19622. * Specifies if the material uses a texture
  19623. * @param texture defines the texture to check against the material
  19624. * @returns a boolean specifying if the material uses the texture
  19625. */
  19626. hasTexture(texture: BaseTexture): boolean;
  19627. /**
  19628. * Makes a duplicate of the material, and gives it a new name
  19629. * @param name defines the new name for the duplicated material
  19630. * @returns the cloned material
  19631. */
  19632. clone(name: string): ShaderMaterial;
  19633. /**
  19634. * Disposes the material
  19635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19638. */
  19639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19640. /**
  19641. * Serializes this material in a JSON representation
  19642. * @returns the serialized material object
  19643. */
  19644. serialize(): any;
  19645. /**
  19646. * Creates a shader material from parsed shader material data
  19647. * @param source defines the JSON represnetation of the material
  19648. * @param scene defines the hosting scene
  19649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19650. * @returns a new material
  19651. */
  19652. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19653. }
  19654. }
  19655. declare module "babylonjs/Shaders/color.fragment" {
  19656. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19658. /** @hidden */
  19659. export var colorPixelShader: {
  19660. name: string;
  19661. shader: string;
  19662. };
  19663. }
  19664. declare module "babylonjs/Shaders/color.vertex" {
  19665. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19666. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19667. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19668. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19669. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19671. /** @hidden */
  19672. export var colorVertexShader: {
  19673. name: string;
  19674. shader: string;
  19675. };
  19676. }
  19677. declare module "babylonjs/Meshes/linesMesh" {
  19678. import { Nullable } from "babylonjs/types";
  19679. import { Scene } from "babylonjs/scene";
  19680. import { Color3 } from "babylonjs/Maths/math.color";
  19681. import { Node } from "babylonjs/node";
  19682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19683. import { Mesh } from "babylonjs/Meshes/mesh";
  19684. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19685. import { Effect } from "babylonjs/Materials/effect";
  19686. import { Material } from "babylonjs/Materials/material";
  19687. import "babylonjs/Shaders/color.fragment";
  19688. import "babylonjs/Shaders/color.vertex";
  19689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19690. /**
  19691. * Line mesh
  19692. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19693. */
  19694. export class LinesMesh extends Mesh {
  19695. /**
  19696. * If vertex color should be applied to the mesh
  19697. */
  19698. readonly useVertexColor?: boolean | undefined;
  19699. /**
  19700. * If vertex alpha should be applied to the mesh
  19701. */
  19702. readonly useVertexAlpha?: boolean | undefined;
  19703. /**
  19704. * Color of the line (Default: White)
  19705. */
  19706. color: Color3;
  19707. /**
  19708. * Alpha of the line (Default: 1)
  19709. */
  19710. alpha: number;
  19711. /**
  19712. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19713. * This margin is expressed in world space coordinates, so its value may vary.
  19714. * Default value is 0.1
  19715. */
  19716. intersectionThreshold: number;
  19717. private _colorShader;
  19718. private color4;
  19719. /**
  19720. * Creates a new LinesMesh
  19721. * @param name defines the name
  19722. * @param scene defines the hosting scene
  19723. * @param parent defines the parent mesh if any
  19724. * @param source defines the optional source LinesMesh used to clone data from
  19725. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19726. * When false, achieved by calling a clone(), also passing False.
  19727. * This will make creation of children, recursive.
  19728. * @param useVertexColor defines if this LinesMesh supports vertex color
  19729. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19730. */
  19731. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19732. /**
  19733. * If vertex color should be applied to the mesh
  19734. */
  19735. useVertexColor?: boolean | undefined,
  19736. /**
  19737. * If vertex alpha should be applied to the mesh
  19738. */
  19739. useVertexAlpha?: boolean | undefined);
  19740. private _addClipPlaneDefine;
  19741. private _removeClipPlaneDefine;
  19742. isReady(): boolean;
  19743. /**
  19744. * Returns the string "LineMesh"
  19745. */
  19746. getClassName(): string;
  19747. /**
  19748. * @hidden
  19749. */
  19750. /**
  19751. * @hidden
  19752. */
  19753. material: Material;
  19754. /**
  19755. * @hidden
  19756. */
  19757. readonly checkCollisions: boolean;
  19758. /** @hidden */
  19759. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19760. /** @hidden */
  19761. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19762. /**
  19763. * Disposes of the line mesh
  19764. * @param doNotRecurse If children should be disposed
  19765. */
  19766. dispose(doNotRecurse?: boolean): void;
  19767. /**
  19768. * Returns a new LineMesh object cloned from the current one.
  19769. */
  19770. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19771. /**
  19772. * Creates a new InstancedLinesMesh object from the mesh model.
  19773. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19774. * @param name defines the name of the new instance
  19775. * @returns a new InstancedLinesMesh
  19776. */
  19777. createInstance(name: string): InstancedLinesMesh;
  19778. }
  19779. /**
  19780. * Creates an instance based on a source LinesMesh
  19781. */
  19782. export class InstancedLinesMesh extends InstancedMesh {
  19783. /**
  19784. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19785. * This margin is expressed in world space coordinates, so its value may vary.
  19786. * Initilized with the intersectionThreshold value of the source LinesMesh
  19787. */
  19788. intersectionThreshold: number;
  19789. constructor(name: string, source: LinesMesh);
  19790. /**
  19791. * Returns the string "InstancedLinesMesh".
  19792. */
  19793. getClassName(): string;
  19794. }
  19795. }
  19796. declare module "babylonjs/Shaders/line.fragment" {
  19797. /** @hidden */
  19798. export var linePixelShader: {
  19799. name: string;
  19800. shader: string;
  19801. };
  19802. }
  19803. declare module "babylonjs/Shaders/line.vertex" {
  19804. /** @hidden */
  19805. export var lineVertexShader: {
  19806. name: string;
  19807. shader: string;
  19808. };
  19809. }
  19810. declare module "babylonjs/Rendering/edgesRenderer" {
  19811. import { Nullable } from "babylonjs/types";
  19812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Vector3 } from "babylonjs/Maths/math.vector";
  19815. import { IDisposable } from "babylonjs/scene";
  19816. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19817. import "babylonjs/Shaders/line.fragment";
  19818. import "babylonjs/Shaders/line.vertex";
  19819. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19820. module "babylonjs/Meshes/abstractMesh" {
  19821. interface AbstractMesh {
  19822. /**
  19823. * Gets the edgesRenderer associated with the mesh
  19824. */
  19825. edgesRenderer: Nullable<EdgesRenderer>;
  19826. }
  19827. }
  19828. module "babylonjs/Meshes/linesMesh" {
  19829. interface LinesMesh {
  19830. /**
  19831. * Enables the edge rendering mode on the mesh.
  19832. * This mode makes the mesh edges visible
  19833. * @param epsilon defines the maximal distance between two angles to detect a face
  19834. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19835. * @returns the currentAbstractMesh
  19836. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19837. */
  19838. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19839. }
  19840. }
  19841. module "babylonjs/Meshes/linesMesh" {
  19842. interface InstancedLinesMesh {
  19843. /**
  19844. * Enables the edge rendering mode on the mesh.
  19845. * This mode makes the mesh edges visible
  19846. * @param epsilon defines the maximal distance between two angles to detect a face
  19847. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19848. * @returns the current InstancedLinesMesh
  19849. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19850. */
  19851. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19852. }
  19853. }
  19854. /**
  19855. * Defines the minimum contract an Edges renderer should follow.
  19856. */
  19857. export interface IEdgesRenderer extends IDisposable {
  19858. /**
  19859. * Gets or sets a boolean indicating if the edgesRenderer is active
  19860. */
  19861. isEnabled: boolean;
  19862. /**
  19863. * Renders the edges of the attached mesh,
  19864. */
  19865. render(): void;
  19866. /**
  19867. * Checks wether or not the edges renderer is ready to render.
  19868. * @return true if ready, otherwise false.
  19869. */
  19870. isReady(): boolean;
  19871. }
  19872. /**
  19873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19874. */
  19875. export class EdgesRenderer implements IEdgesRenderer {
  19876. /**
  19877. * Define the size of the edges with an orthographic camera
  19878. */
  19879. edgesWidthScalerForOrthographic: number;
  19880. /**
  19881. * Define the size of the edges with a perspective camera
  19882. */
  19883. edgesWidthScalerForPerspective: number;
  19884. protected _source: AbstractMesh;
  19885. protected _linesPositions: number[];
  19886. protected _linesNormals: number[];
  19887. protected _linesIndices: number[];
  19888. protected _epsilon: number;
  19889. protected _indicesCount: number;
  19890. protected _lineShader: ShaderMaterial;
  19891. protected _ib: DataBuffer;
  19892. protected _buffers: {
  19893. [key: string]: Nullable<VertexBuffer>;
  19894. };
  19895. protected _checkVerticesInsteadOfIndices: boolean;
  19896. private _meshRebuildObserver;
  19897. private _meshDisposeObserver;
  19898. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19899. isEnabled: boolean;
  19900. /**
  19901. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19902. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19903. * @param source Mesh used to create edges
  19904. * @param epsilon sum of angles in adjacency to check for edge
  19905. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19906. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19907. */
  19908. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19909. protected _prepareRessources(): void;
  19910. /** @hidden */
  19911. _rebuild(): void;
  19912. /**
  19913. * Releases the required resources for the edges renderer
  19914. */
  19915. dispose(): void;
  19916. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19917. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19918. /**
  19919. * Checks if the pair of p0 and p1 is en edge
  19920. * @param faceIndex
  19921. * @param edge
  19922. * @param faceNormals
  19923. * @param p0
  19924. * @param p1
  19925. * @private
  19926. */
  19927. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19928. /**
  19929. * push line into the position, normal and index buffer
  19930. * @protected
  19931. */
  19932. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19933. /**
  19934. * Generates lines edges from adjacencjes
  19935. * @private
  19936. */
  19937. _generateEdgesLines(): void;
  19938. /**
  19939. * Checks wether or not the edges renderer is ready to render.
  19940. * @return true if ready, otherwise false.
  19941. */
  19942. isReady(): boolean;
  19943. /**
  19944. * Renders the edges of the attached mesh,
  19945. */
  19946. render(): void;
  19947. }
  19948. /**
  19949. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19950. */
  19951. export class LineEdgesRenderer extends EdgesRenderer {
  19952. /**
  19953. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19954. * @param source LineMesh used to generate edges
  19955. * @param epsilon not important (specified angle for edge detection)
  19956. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19957. */
  19958. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19959. /**
  19960. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19961. */
  19962. _generateEdgesLines(): void;
  19963. }
  19964. }
  19965. declare module "babylonjs/Rendering/renderingGroup" {
  19966. import { SmartArray } from "babylonjs/Misc/smartArray";
  19967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19969. import { Nullable } from "babylonjs/types";
  19970. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19971. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19973. import { Material } from "babylonjs/Materials/material";
  19974. import { Scene } from "babylonjs/scene";
  19975. /**
  19976. * This represents the object necessary to create a rendering group.
  19977. * This is exclusively used and created by the rendering manager.
  19978. * To modify the behavior, you use the available helpers in your scene or meshes.
  19979. * @hidden
  19980. */
  19981. export class RenderingGroup {
  19982. index: number;
  19983. private static _zeroVector;
  19984. private _scene;
  19985. private _opaqueSubMeshes;
  19986. private _transparentSubMeshes;
  19987. private _alphaTestSubMeshes;
  19988. private _depthOnlySubMeshes;
  19989. private _particleSystems;
  19990. private _spriteManagers;
  19991. private _opaqueSortCompareFn;
  19992. private _alphaTestSortCompareFn;
  19993. private _transparentSortCompareFn;
  19994. private _renderOpaque;
  19995. private _renderAlphaTest;
  19996. private _renderTransparent;
  19997. /** @hidden */
  19998. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19999. onBeforeTransparentRendering: () => void;
  20000. /**
  20001. * Set the opaque sort comparison function.
  20002. * If null the sub meshes will be render in the order they were created
  20003. */
  20004. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20005. /**
  20006. * Set the alpha test sort comparison function.
  20007. * If null the sub meshes will be render in the order they were created
  20008. */
  20009. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20010. /**
  20011. * Set the transparent sort comparison function.
  20012. * If null the sub meshes will be render in the order they were created
  20013. */
  20014. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20015. /**
  20016. * Creates a new rendering group.
  20017. * @param index The rendering group index
  20018. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20019. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20020. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20021. */
  20022. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20023. /**
  20024. * Render all the sub meshes contained in the group.
  20025. * @param customRenderFunction Used to override the default render behaviour of the group.
  20026. * @returns true if rendered some submeshes.
  20027. */
  20028. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20029. /**
  20030. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20031. * @param subMeshes The submeshes to render
  20032. */
  20033. private renderOpaqueSorted;
  20034. /**
  20035. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20036. * @param subMeshes The submeshes to render
  20037. */
  20038. private renderAlphaTestSorted;
  20039. /**
  20040. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20041. * @param subMeshes The submeshes to render
  20042. */
  20043. private renderTransparentSorted;
  20044. /**
  20045. * Renders the submeshes in a specified order.
  20046. * @param subMeshes The submeshes to sort before render
  20047. * @param sortCompareFn The comparison function use to sort
  20048. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20049. * @param transparent Specifies to activate blending if true
  20050. */
  20051. private static renderSorted;
  20052. /**
  20053. * Renders the submeshes in the order they were dispatched (no sort applied).
  20054. * @param subMeshes The submeshes to render
  20055. */
  20056. private static renderUnsorted;
  20057. /**
  20058. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20059. * are rendered back to front if in the same alpha index.
  20060. *
  20061. * @param a The first submesh
  20062. * @param b The second submesh
  20063. * @returns The result of the comparison
  20064. */
  20065. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20066. /**
  20067. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20068. * are rendered back to front.
  20069. *
  20070. * @param a The first submesh
  20071. * @param b The second submesh
  20072. * @returns The result of the comparison
  20073. */
  20074. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20075. /**
  20076. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20077. * are rendered front to back (prevent overdraw).
  20078. *
  20079. * @param a The first submesh
  20080. * @param b The second submesh
  20081. * @returns The result of the comparison
  20082. */
  20083. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20084. /**
  20085. * Resets the different lists of submeshes to prepare a new frame.
  20086. */
  20087. prepare(): void;
  20088. dispose(): void;
  20089. /**
  20090. * Inserts the submesh in its correct queue depending on its material.
  20091. * @param subMesh The submesh to dispatch
  20092. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20093. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20094. */
  20095. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20096. dispatchSprites(spriteManager: ISpriteManager): void;
  20097. dispatchParticles(particleSystem: IParticleSystem): void;
  20098. private _renderParticles;
  20099. private _renderSprites;
  20100. }
  20101. }
  20102. declare module "babylonjs/Rendering/renderingManager" {
  20103. import { Nullable } from "babylonjs/types";
  20104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20106. import { SmartArray } from "babylonjs/Misc/smartArray";
  20107. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20108. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20109. import { Material } from "babylonjs/Materials/material";
  20110. import { Scene } from "babylonjs/scene";
  20111. import { Camera } from "babylonjs/Cameras/camera";
  20112. /**
  20113. * Interface describing the different options available in the rendering manager
  20114. * regarding Auto Clear between groups.
  20115. */
  20116. export interface IRenderingManagerAutoClearSetup {
  20117. /**
  20118. * Defines whether or not autoclear is enable.
  20119. */
  20120. autoClear: boolean;
  20121. /**
  20122. * Defines whether or not to autoclear the depth buffer.
  20123. */
  20124. depth: boolean;
  20125. /**
  20126. * Defines whether or not to autoclear the stencil buffer.
  20127. */
  20128. stencil: boolean;
  20129. }
  20130. /**
  20131. * This class is used by the onRenderingGroupObservable
  20132. */
  20133. export class RenderingGroupInfo {
  20134. /**
  20135. * The Scene that being rendered
  20136. */
  20137. scene: Scene;
  20138. /**
  20139. * The camera currently used for the rendering pass
  20140. */
  20141. camera: Nullable<Camera>;
  20142. /**
  20143. * The ID of the renderingGroup being processed
  20144. */
  20145. renderingGroupId: number;
  20146. }
  20147. /**
  20148. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20149. * It is enable to manage the different groups as well as the different necessary sort functions.
  20150. * This should not be used directly aside of the few static configurations
  20151. */
  20152. export class RenderingManager {
  20153. /**
  20154. * The max id used for rendering groups (not included)
  20155. */
  20156. static MAX_RENDERINGGROUPS: number;
  20157. /**
  20158. * The min id used for rendering groups (included)
  20159. */
  20160. static MIN_RENDERINGGROUPS: number;
  20161. /**
  20162. * Used to globally prevent autoclearing scenes.
  20163. */
  20164. static AUTOCLEAR: boolean;
  20165. /**
  20166. * @hidden
  20167. */
  20168. _useSceneAutoClearSetup: boolean;
  20169. private _scene;
  20170. private _renderingGroups;
  20171. private _depthStencilBufferAlreadyCleaned;
  20172. private _autoClearDepthStencil;
  20173. private _customOpaqueSortCompareFn;
  20174. private _customAlphaTestSortCompareFn;
  20175. private _customTransparentSortCompareFn;
  20176. private _renderingGroupInfo;
  20177. /**
  20178. * Instantiates a new rendering group for a particular scene
  20179. * @param scene Defines the scene the groups belongs to
  20180. */
  20181. constructor(scene: Scene);
  20182. private _clearDepthStencilBuffer;
  20183. /**
  20184. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20185. * @hidden
  20186. */
  20187. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20188. /**
  20189. * Resets the different information of the group to prepare a new frame
  20190. * @hidden
  20191. */
  20192. reset(): void;
  20193. /**
  20194. * Dispose and release the group and its associated resources.
  20195. * @hidden
  20196. */
  20197. dispose(): void;
  20198. /**
  20199. * Clear the info related to rendering groups preventing retention points during dispose.
  20200. */
  20201. freeRenderingGroups(): void;
  20202. private _prepareRenderingGroup;
  20203. /**
  20204. * Add a sprite manager to the rendering manager in order to render it this frame.
  20205. * @param spriteManager Define the sprite manager to render
  20206. */
  20207. dispatchSprites(spriteManager: ISpriteManager): void;
  20208. /**
  20209. * Add a particle system to the rendering manager in order to render it this frame.
  20210. * @param particleSystem Define the particle system to render
  20211. */
  20212. dispatchParticles(particleSystem: IParticleSystem): void;
  20213. /**
  20214. * Add a submesh to the manager in order to render it this frame
  20215. * @param subMesh The submesh to dispatch
  20216. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20217. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20218. */
  20219. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20220. /**
  20221. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20222. * This allowed control for front to back rendering or reversly depending of the special needs.
  20223. *
  20224. * @param renderingGroupId The rendering group id corresponding to its index
  20225. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20226. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20227. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20228. */
  20229. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20230. /**
  20231. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20232. *
  20233. * @param renderingGroupId The rendering group id corresponding to its index
  20234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20235. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20236. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20237. */
  20238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20239. /**
  20240. * Gets the current auto clear configuration for one rendering group of the rendering
  20241. * manager.
  20242. * @param index the rendering group index to get the information for
  20243. * @returns The auto clear setup for the requested rendering group
  20244. */
  20245. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20246. }
  20247. }
  20248. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20249. import { Observable } from "babylonjs/Misc/observable";
  20250. import { SmartArray } from "babylonjs/Misc/smartArray";
  20251. import { Nullable } from "babylonjs/types";
  20252. import { Camera } from "babylonjs/Cameras/camera";
  20253. import { Scene } from "babylonjs/scene";
  20254. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20255. import { Color4 } from "babylonjs/Maths/math.color";
  20256. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20260. import { Texture } from "babylonjs/Materials/Textures/texture";
  20261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20262. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20263. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20264. import { Engine } from "babylonjs/Engines/engine";
  20265. /**
  20266. * This Helps creating a texture that will be created from a camera in your scene.
  20267. * It is basically a dynamic texture that could be used to create special effects for instance.
  20268. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20269. */
  20270. export class RenderTargetTexture extends Texture {
  20271. isCube: boolean;
  20272. /**
  20273. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20274. */
  20275. static readonly REFRESHRATE_RENDER_ONCE: number;
  20276. /**
  20277. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20278. */
  20279. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20280. /**
  20281. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20282. * the central point of your effect and can save a lot of performances.
  20283. */
  20284. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20285. /**
  20286. * Use this predicate to dynamically define the list of mesh you want to render.
  20287. * If set, the renderList property will be overwritten.
  20288. */
  20289. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20290. private _renderList;
  20291. /**
  20292. * Use this list to define the list of mesh you want to render.
  20293. */
  20294. renderList: Nullable<Array<AbstractMesh>>;
  20295. private _hookArray;
  20296. /**
  20297. * Define if particles should be rendered in your texture.
  20298. */
  20299. renderParticles: boolean;
  20300. /**
  20301. * Define if sprites should be rendered in your texture.
  20302. */
  20303. renderSprites: boolean;
  20304. /**
  20305. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20306. */
  20307. coordinatesMode: number;
  20308. /**
  20309. * Define the camera used to render the texture.
  20310. */
  20311. activeCamera: Nullable<Camera>;
  20312. /**
  20313. * Override the render function of the texture with your own one.
  20314. */
  20315. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20316. /**
  20317. * Define if camera post processes should be use while rendering the texture.
  20318. */
  20319. useCameraPostProcesses: boolean;
  20320. /**
  20321. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20322. */
  20323. ignoreCameraViewport: boolean;
  20324. private _postProcessManager;
  20325. private _postProcesses;
  20326. private _resizeObserver;
  20327. /**
  20328. * An event triggered when the texture is unbind.
  20329. */
  20330. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20331. /**
  20332. * An event triggered when the texture is unbind.
  20333. */
  20334. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20335. private _onAfterUnbindObserver;
  20336. /**
  20337. * Set a after unbind callback in the texture.
  20338. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20339. */
  20340. onAfterUnbind: () => void;
  20341. /**
  20342. * An event triggered before rendering the texture
  20343. */
  20344. onBeforeRenderObservable: Observable<number>;
  20345. private _onBeforeRenderObserver;
  20346. /**
  20347. * Set a before render callback in the texture.
  20348. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20349. */
  20350. onBeforeRender: (faceIndex: number) => void;
  20351. /**
  20352. * An event triggered after rendering the texture
  20353. */
  20354. onAfterRenderObservable: Observable<number>;
  20355. private _onAfterRenderObserver;
  20356. /**
  20357. * Set a after render callback in the texture.
  20358. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20359. */
  20360. onAfterRender: (faceIndex: number) => void;
  20361. /**
  20362. * An event triggered after the texture clear
  20363. */
  20364. onClearObservable: Observable<Engine>;
  20365. private _onClearObserver;
  20366. /**
  20367. * Set a clear callback in the texture.
  20368. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20369. */
  20370. onClear: (Engine: Engine) => void;
  20371. /**
  20372. * An event triggered when the texture is resized.
  20373. */
  20374. onResizeObservable: Observable<RenderTargetTexture>;
  20375. /**
  20376. * Define the clear color of the Render Target if it should be different from the scene.
  20377. */
  20378. clearColor: Color4;
  20379. protected _size: number | {
  20380. width: number;
  20381. height: number;
  20382. };
  20383. protected _initialSizeParameter: number | {
  20384. width: number;
  20385. height: number;
  20386. } | {
  20387. ratio: number;
  20388. };
  20389. protected _sizeRatio: Nullable<number>;
  20390. /** @hidden */
  20391. _generateMipMaps: boolean;
  20392. protected _renderingManager: RenderingManager;
  20393. /** @hidden */
  20394. _waitingRenderList: string[];
  20395. protected _doNotChangeAspectRatio: boolean;
  20396. protected _currentRefreshId: number;
  20397. protected _refreshRate: number;
  20398. protected _textureMatrix: Matrix;
  20399. protected _samples: number;
  20400. protected _renderTargetOptions: RenderTargetCreationOptions;
  20401. /**
  20402. * Gets render target creation options that were used.
  20403. */
  20404. readonly renderTargetOptions: RenderTargetCreationOptions;
  20405. protected _engine: Engine;
  20406. protected _onRatioRescale(): void;
  20407. /**
  20408. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20409. * It must define where the camera used to render the texture is set
  20410. */
  20411. boundingBoxPosition: Vector3;
  20412. private _boundingBoxSize;
  20413. /**
  20414. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20415. * When defined, the cubemap will switch to local mode
  20416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20417. * @example https://www.babylonjs-playground.com/#RNASML
  20418. */
  20419. boundingBoxSize: Vector3;
  20420. /**
  20421. * In case the RTT has been created with a depth texture, get the associated
  20422. * depth texture.
  20423. * Otherwise, return null.
  20424. */
  20425. depthStencilTexture: Nullable<InternalTexture>;
  20426. /**
  20427. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20428. * or used a shadow, depth texture...
  20429. * @param name The friendly name of the texture
  20430. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20431. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20432. * @param generateMipMaps True if mip maps need to be generated after render.
  20433. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20434. * @param type The type of the buffer in the RTT (int, half float, float...)
  20435. * @param isCube True if a cube texture needs to be created
  20436. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20437. * @param generateDepthBuffer True to generate a depth buffer
  20438. * @param generateStencilBuffer True to generate a stencil buffer
  20439. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20440. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20441. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20442. */
  20443. constructor(name: string, size: number | {
  20444. width: number;
  20445. height: number;
  20446. } | {
  20447. ratio: number;
  20448. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20449. /**
  20450. * Creates a depth stencil texture.
  20451. * This is only available in WebGL 2 or with the depth texture extension available.
  20452. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20453. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20454. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20455. */
  20456. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20457. private _processSizeParameter;
  20458. /**
  20459. * Define the number of samples to use in case of MSAA.
  20460. * It defaults to one meaning no MSAA has been enabled.
  20461. */
  20462. samples: number;
  20463. /**
  20464. * Resets the refresh counter of the texture and start bak from scratch.
  20465. * Could be useful to regenerate the texture if it is setup to render only once.
  20466. */
  20467. resetRefreshCounter(): void;
  20468. /**
  20469. * Define the refresh rate of the texture or the rendering frequency.
  20470. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20471. */
  20472. refreshRate: number;
  20473. /**
  20474. * Adds a post process to the render target rendering passes.
  20475. * @param postProcess define the post process to add
  20476. */
  20477. addPostProcess(postProcess: PostProcess): void;
  20478. /**
  20479. * Clear all the post processes attached to the render target
  20480. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20481. */
  20482. clearPostProcesses(dispose?: boolean): void;
  20483. /**
  20484. * Remove one of the post process from the list of attached post processes to the texture
  20485. * @param postProcess define the post process to remove from the list
  20486. */
  20487. removePostProcess(postProcess: PostProcess): void;
  20488. /** @hidden */
  20489. _shouldRender(): boolean;
  20490. /**
  20491. * Gets the actual render size of the texture.
  20492. * @returns the width of the render size
  20493. */
  20494. getRenderSize(): number;
  20495. /**
  20496. * Gets the actual render width of the texture.
  20497. * @returns the width of the render size
  20498. */
  20499. getRenderWidth(): number;
  20500. /**
  20501. * Gets the actual render height of the texture.
  20502. * @returns the height of the render size
  20503. */
  20504. getRenderHeight(): number;
  20505. /**
  20506. * Get if the texture can be rescaled or not.
  20507. */
  20508. readonly canRescale: boolean;
  20509. /**
  20510. * Resize the texture using a ratio.
  20511. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20512. */
  20513. scale(ratio: number): void;
  20514. /**
  20515. * Get the texture reflection matrix used to rotate/transform the reflection.
  20516. * @returns the reflection matrix
  20517. */
  20518. getReflectionTextureMatrix(): Matrix;
  20519. /**
  20520. * Resize the texture to a new desired size.
  20521. * Be carrefull as it will recreate all the data in the new texture.
  20522. * @param size Define the new size. It can be:
  20523. * - a number for squared texture,
  20524. * - an object containing { width: number, height: number }
  20525. * - or an object containing a ratio { ratio: number }
  20526. */
  20527. resize(size: number | {
  20528. width: number;
  20529. height: number;
  20530. } | {
  20531. ratio: number;
  20532. }): void;
  20533. /**
  20534. * Renders all the objects from the render list into the texture.
  20535. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20536. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20537. */
  20538. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20539. private _bestReflectionRenderTargetDimension;
  20540. /**
  20541. * @hidden
  20542. * @param faceIndex face index to bind to if this is a cubetexture
  20543. */
  20544. _bindFrameBuffer(faceIndex?: number): void;
  20545. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20546. private renderToTarget;
  20547. /**
  20548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20549. * This allowed control for front to back rendering or reversly depending of the special needs.
  20550. *
  20551. * @param renderingGroupId The rendering group id corresponding to its index
  20552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20555. */
  20556. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20557. /**
  20558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20559. *
  20560. * @param renderingGroupId The rendering group id corresponding to its index
  20561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20562. */
  20563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20564. /**
  20565. * Clones the texture.
  20566. * @returns the cloned texture
  20567. */
  20568. clone(): RenderTargetTexture;
  20569. /**
  20570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20571. * @returns The JSON representation of the texture
  20572. */
  20573. serialize(): any;
  20574. /**
  20575. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20576. */
  20577. disposeFramebufferObjects(): void;
  20578. /**
  20579. * Dispose the texture and release its associated resources.
  20580. */
  20581. dispose(): void;
  20582. /** @hidden */
  20583. _rebuild(): void;
  20584. /**
  20585. * Clear the info related to rendering groups preventing retention point in material dispose.
  20586. */
  20587. freeRenderingGroups(): void;
  20588. /**
  20589. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20590. * @returns the view count
  20591. */
  20592. getViewCount(): number;
  20593. }
  20594. }
  20595. declare module "babylonjs/Materials/material" {
  20596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20597. import { SmartArray } from "babylonjs/Misc/smartArray";
  20598. import { Observable } from "babylonjs/Misc/observable";
  20599. import { Nullable } from "babylonjs/types";
  20600. import { Scene } from "babylonjs/scene";
  20601. import { Matrix } from "babylonjs/Maths/math.vector";
  20602. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20605. import { Effect } from "babylonjs/Materials/effect";
  20606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20608. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20609. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20610. import { Mesh } from "babylonjs/Meshes/mesh";
  20611. import { Animation } from "babylonjs/Animations/animation";
  20612. /**
  20613. * Base class for the main features of a material in Babylon.js
  20614. */
  20615. export class Material implements IAnimatable {
  20616. /**
  20617. * Returns the triangle fill mode
  20618. */
  20619. static readonly TriangleFillMode: number;
  20620. /**
  20621. * Returns the wireframe mode
  20622. */
  20623. static readonly WireFrameFillMode: number;
  20624. /**
  20625. * Returns the point fill mode
  20626. */
  20627. static readonly PointFillMode: number;
  20628. /**
  20629. * Returns the point list draw mode
  20630. */
  20631. static readonly PointListDrawMode: number;
  20632. /**
  20633. * Returns the line list draw mode
  20634. */
  20635. static readonly LineListDrawMode: number;
  20636. /**
  20637. * Returns the line loop draw mode
  20638. */
  20639. static readonly LineLoopDrawMode: number;
  20640. /**
  20641. * Returns the line strip draw mode
  20642. */
  20643. static readonly LineStripDrawMode: number;
  20644. /**
  20645. * Returns the triangle strip draw mode
  20646. */
  20647. static readonly TriangleStripDrawMode: number;
  20648. /**
  20649. * Returns the triangle fan draw mode
  20650. */
  20651. static readonly TriangleFanDrawMode: number;
  20652. /**
  20653. * Stores the clock-wise side orientation
  20654. */
  20655. static readonly ClockWiseSideOrientation: number;
  20656. /**
  20657. * Stores the counter clock-wise side orientation
  20658. */
  20659. static readonly CounterClockWiseSideOrientation: number;
  20660. /**
  20661. * The dirty texture flag value
  20662. */
  20663. static readonly TextureDirtyFlag: number;
  20664. /**
  20665. * The dirty light flag value
  20666. */
  20667. static readonly LightDirtyFlag: number;
  20668. /**
  20669. * The dirty fresnel flag value
  20670. */
  20671. static readonly FresnelDirtyFlag: number;
  20672. /**
  20673. * The dirty attribute flag value
  20674. */
  20675. static readonly AttributesDirtyFlag: number;
  20676. /**
  20677. * The dirty misc flag value
  20678. */
  20679. static readonly MiscDirtyFlag: number;
  20680. /**
  20681. * The all dirty flag value
  20682. */
  20683. static readonly AllDirtyFlag: number;
  20684. /**
  20685. * The ID of the material
  20686. */
  20687. id: string;
  20688. /**
  20689. * Gets or sets the unique id of the material
  20690. */
  20691. uniqueId: number;
  20692. /**
  20693. * The name of the material
  20694. */
  20695. name: string;
  20696. /**
  20697. * Gets or sets user defined metadata
  20698. */
  20699. metadata: any;
  20700. /**
  20701. * For internal use only. Please do not use.
  20702. */
  20703. reservedDataStore: any;
  20704. /**
  20705. * Specifies if the ready state should be checked on each call
  20706. */
  20707. checkReadyOnEveryCall: boolean;
  20708. /**
  20709. * Specifies if the ready state should be checked once
  20710. */
  20711. checkReadyOnlyOnce: boolean;
  20712. /**
  20713. * The state of the material
  20714. */
  20715. state: string;
  20716. /**
  20717. * The alpha value of the material
  20718. */
  20719. protected _alpha: number;
  20720. /**
  20721. * List of inspectable custom properties (used by the Inspector)
  20722. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20723. */
  20724. inspectableCustomProperties: IInspectable[];
  20725. /**
  20726. * Sets the alpha value of the material
  20727. */
  20728. /**
  20729. * Gets the alpha value of the material
  20730. */
  20731. alpha: number;
  20732. /**
  20733. * Specifies if back face culling is enabled
  20734. */
  20735. protected _backFaceCulling: boolean;
  20736. /**
  20737. * Sets the back-face culling state
  20738. */
  20739. /**
  20740. * Gets the back-face culling state
  20741. */
  20742. backFaceCulling: boolean;
  20743. /**
  20744. * Stores the value for side orientation
  20745. */
  20746. sideOrientation: number;
  20747. /**
  20748. * Callback triggered when the material is compiled
  20749. */
  20750. onCompiled: Nullable<(effect: Effect) => void>;
  20751. /**
  20752. * Callback triggered when an error occurs
  20753. */
  20754. onError: Nullable<(effect: Effect, errors: string) => void>;
  20755. /**
  20756. * Callback triggered to get the render target textures
  20757. */
  20758. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20759. /**
  20760. * Gets a boolean indicating that current material needs to register RTT
  20761. */
  20762. readonly hasRenderTargetTextures: boolean;
  20763. /**
  20764. * Specifies if the material should be serialized
  20765. */
  20766. doNotSerialize: boolean;
  20767. /**
  20768. * @hidden
  20769. */
  20770. _storeEffectOnSubMeshes: boolean;
  20771. /**
  20772. * Stores the animations for the material
  20773. */
  20774. animations: Nullable<Array<Animation>>;
  20775. /**
  20776. * An event triggered when the material is disposed
  20777. */
  20778. onDisposeObservable: Observable<Material>;
  20779. /**
  20780. * An observer which watches for dispose events
  20781. */
  20782. private _onDisposeObserver;
  20783. private _onUnBindObservable;
  20784. /**
  20785. * Called during a dispose event
  20786. */
  20787. onDispose: () => void;
  20788. private _onBindObservable;
  20789. /**
  20790. * An event triggered when the material is bound
  20791. */
  20792. readonly onBindObservable: Observable<AbstractMesh>;
  20793. /**
  20794. * An observer which watches for bind events
  20795. */
  20796. private _onBindObserver;
  20797. /**
  20798. * Called during a bind event
  20799. */
  20800. onBind: (Mesh: AbstractMesh) => void;
  20801. /**
  20802. * An event triggered when the material is unbound
  20803. */
  20804. readonly onUnBindObservable: Observable<Material>;
  20805. /**
  20806. * Stores the value of the alpha mode
  20807. */
  20808. private _alphaMode;
  20809. /**
  20810. * Sets the value of the alpha mode.
  20811. *
  20812. * | Value | Type | Description |
  20813. * | --- | --- | --- |
  20814. * | 0 | ALPHA_DISABLE | |
  20815. * | 1 | ALPHA_ADD | |
  20816. * | 2 | ALPHA_COMBINE | |
  20817. * | 3 | ALPHA_SUBTRACT | |
  20818. * | 4 | ALPHA_MULTIPLY | |
  20819. * | 5 | ALPHA_MAXIMIZED | |
  20820. * | 6 | ALPHA_ONEONE | |
  20821. * | 7 | ALPHA_PREMULTIPLIED | |
  20822. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20823. * | 9 | ALPHA_INTERPOLATE | |
  20824. * | 10 | ALPHA_SCREENMODE | |
  20825. *
  20826. */
  20827. /**
  20828. * Gets the value of the alpha mode
  20829. */
  20830. alphaMode: number;
  20831. /**
  20832. * Stores the state of the need depth pre-pass value
  20833. */
  20834. private _needDepthPrePass;
  20835. /**
  20836. * Sets the need depth pre-pass value
  20837. */
  20838. /**
  20839. * Gets the depth pre-pass value
  20840. */
  20841. needDepthPrePass: boolean;
  20842. /**
  20843. * Specifies if depth writing should be disabled
  20844. */
  20845. disableDepthWrite: boolean;
  20846. /**
  20847. * Specifies if depth writing should be forced
  20848. */
  20849. forceDepthWrite: boolean;
  20850. /**
  20851. * Specifies if there should be a separate pass for culling
  20852. */
  20853. separateCullingPass: boolean;
  20854. /**
  20855. * Stores the state specifing if fog should be enabled
  20856. */
  20857. private _fogEnabled;
  20858. /**
  20859. * Sets the state for enabling fog
  20860. */
  20861. /**
  20862. * Gets the value of the fog enabled state
  20863. */
  20864. fogEnabled: boolean;
  20865. /**
  20866. * Stores the size of points
  20867. */
  20868. pointSize: number;
  20869. /**
  20870. * Stores the z offset value
  20871. */
  20872. zOffset: number;
  20873. /**
  20874. * Gets a value specifying if wireframe mode is enabled
  20875. */
  20876. /**
  20877. * Sets the state of wireframe mode
  20878. */
  20879. wireframe: boolean;
  20880. /**
  20881. * Gets the value specifying if point clouds are enabled
  20882. */
  20883. /**
  20884. * Sets the state of point cloud mode
  20885. */
  20886. pointsCloud: boolean;
  20887. /**
  20888. * Gets the material fill mode
  20889. */
  20890. /**
  20891. * Sets the material fill mode
  20892. */
  20893. fillMode: number;
  20894. /**
  20895. * @hidden
  20896. * Stores the effects for the material
  20897. */
  20898. _effect: Nullable<Effect>;
  20899. /**
  20900. * @hidden
  20901. * Specifies if the material was previously ready
  20902. */
  20903. _wasPreviouslyReady: boolean;
  20904. /**
  20905. * Specifies if uniform buffers should be used
  20906. */
  20907. private _useUBO;
  20908. /**
  20909. * Stores a reference to the scene
  20910. */
  20911. private _scene;
  20912. /**
  20913. * Stores the fill mode state
  20914. */
  20915. private _fillMode;
  20916. /**
  20917. * Specifies if the depth write state should be cached
  20918. */
  20919. private _cachedDepthWriteState;
  20920. /**
  20921. * Stores the uniform buffer
  20922. */
  20923. protected _uniformBuffer: UniformBuffer;
  20924. /** @hidden */
  20925. _indexInSceneMaterialArray: number;
  20926. /** @hidden */
  20927. meshMap: Nullable<{
  20928. [id: string]: AbstractMesh | undefined;
  20929. }>;
  20930. /**
  20931. * Creates a material instance
  20932. * @param name defines the name of the material
  20933. * @param scene defines the scene to reference
  20934. * @param doNotAdd specifies if the material should be added to the scene
  20935. */
  20936. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20937. /**
  20938. * Returns a string representation of the current material
  20939. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20940. * @returns a string with material information
  20941. */
  20942. toString(fullDetails?: boolean): string;
  20943. /**
  20944. * Gets the class name of the material
  20945. * @returns a string with the class name of the material
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Specifies if updates for the material been locked
  20950. */
  20951. readonly isFrozen: boolean;
  20952. /**
  20953. * Locks updates for the material
  20954. */
  20955. freeze(): void;
  20956. /**
  20957. * Unlocks updates for the material
  20958. */
  20959. unfreeze(): void;
  20960. /**
  20961. * Specifies if the material is ready to be used
  20962. * @param mesh defines the mesh to check
  20963. * @param useInstances specifies if instances should be used
  20964. * @returns a boolean indicating if the material is ready to be used
  20965. */
  20966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20967. /**
  20968. * Specifies that the submesh is ready to be used
  20969. * @param mesh defines the mesh to check
  20970. * @param subMesh defines which submesh to check
  20971. * @param useInstances specifies that instances should be used
  20972. * @returns a boolean indicating that the submesh is ready or not
  20973. */
  20974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20975. /**
  20976. * Returns the material effect
  20977. * @returns the effect associated with the material
  20978. */
  20979. getEffect(): Nullable<Effect>;
  20980. /**
  20981. * Returns the current scene
  20982. * @returns a Scene
  20983. */
  20984. getScene(): Scene;
  20985. /**
  20986. * Specifies if the material will require alpha blending
  20987. * @returns a boolean specifying if alpha blending is needed
  20988. */
  20989. needAlphaBlending(): boolean;
  20990. /**
  20991. * Specifies if the mesh will require alpha blending
  20992. * @param mesh defines the mesh to check
  20993. * @returns a boolean specifying if alpha blending is needed for the mesh
  20994. */
  20995. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20996. /**
  20997. * Specifies if this material should be rendered in alpha test mode
  20998. * @returns a boolean specifying if an alpha test is needed.
  20999. */
  21000. needAlphaTesting(): boolean;
  21001. /**
  21002. * Gets the texture used for the alpha test
  21003. * @returns the texture to use for alpha testing
  21004. */
  21005. getAlphaTestTexture(): Nullable<BaseTexture>;
  21006. /**
  21007. * Marks the material to indicate that it needs to be re-calculated
  21008. */
  21009. markDirty(): void;
  21010. /** @hidden */
  21011. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21012. /**
  21013. * Binds the material to the mesh
  21014. * @param world defines the world transformation matrix
  21015. * @param mesh defines the mesh to bind the material to
  21016. */
  21017. bind(world: Matrix, mesh?: Mesh): void;
  21018. /**
  21019. * Binds the submesh to the material
  21020. * @param world defines the world transformation matrix
  21021. * @param mesh defines the mesh containing the submesh
  21022. * @param subMesh defines the submesh to bind the material to
  21023. */
  21024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21025. /**
  21026. * Binds the world matrix to the material
  21027. * @param world defines the world transformation matrix
  21028. */
  21029. bindOnlyWorldMatrix(world: Matrix): void;
  21030. /**
  21031. * Binds the scene's uniform buffer to the effect.
  21032. * @param effect defines the effect to bind to the scene uniform buffer
  21033. * @param sceneUbo defines the uniform buffer storing scene data
  21034. */
  21035. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21036. /**
  21037. * Binds the view matrix to the effect
  21038. * @param effect defines the effect to bind the view matrix to
  21039. */
  21040. bindView(effect: Effect): void;
  21041. /**
  21042. * Binds the view projection matrix to the effect
  21043. * @param effect defines the effect to bind the view projection matrix to
  21044. */
  21045. bindViewProjection(effect: Effect): void;
  21046. /**
  21047. * Specifies if material alpha testing should be turned on for the mesh
  21048. * @param mesh defines the mesh to check
  21049. */
  21050. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21051. /**
  21052. * Processes to execute after binding the material to a mesh
  21053. * @param mesh defines the rendered mesh
  21054. */
  21055. protected _afterBind(mesh?: Mesh): void;
  21056. /**
  21057. * Unbinds the material from the mesh
  21058. */
  21059. unbind(): void;
  21060. /**
  21061. * Gets the active textures from the material
  21062. * @returns an array of textures
  21063. */
  21064. getActiveTextures(): BaseTexture[];
  21065. /**
  21066. * Specifies if the material uses a texture
  21067. * @param texture defines the texture to check against the material
  21068. * @returns a boolean specifying if the material uses the texture
  21069. */
  21070. hasTexture(texture: BaseTexture): boolean;
  21071. /**
  21072. * Makes a duplicate of the material, and gives it a new name
  21073. * @param name defines the new name for the duplicated material
  21074. * @returns the cloned material
  21075. */
  21076. clone(name: string): Nullable<Material>;
  21077. /**
  21078. * Gets the meshes bound to the material
  21079. * @returns an array of meshes bound to the material
  21080. */
  21081. getBindedMeshes(): AbstractMesh[];
  21082. /**
  21083. * Force shader compilation
  21084. * @param mesh defines the mesh associated with this material
  21085. * @param onCompiled defines a function to execute once the material is compiled
  21086. * @param options defines the options to configure the compilation
  21087. */
  21088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21089. clipPlane: boolean;
  21090. }>): void;
  21091. /**
  21092. * Force shader compilation
  21093. * @param mesh defines the mesh that will use this material
  21094. * @param options defines additional options for compiling the shaders
  21095. * @returns a promise that resolves when the compilation completes
  21096. */
  21097. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21098. clipPlane: boolean;
  21099. }>): Promise<void>;
  21100. private static readonly _AllDirtyCallBack;
  21101. private static readonly _ImageProcessingDirtyCallBack;
  21102. private static readonly _TextureDirtyCallBack;
  21103. private static readonly _FresnelDirtyCallBack;
  21104. private static readonly _MiscDirtyCallBack;
  21105. private static readonly _LightsDirtyCallBack;
  21106. private static readonly _AttributeDirtyCallBack;
  21107. private static _FresnelAndMiscDirtyCallBack;
  21108. private static _TextureAndMiscDirtyCallBack;
  21109. private static readonly _DirtyCallbackArray;
  21110. private static readonly _RunDirtyCallBacks;
  21111. /**
  21112. * Marks a define in the material to indicate that it needs to be re-computed
  21113. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21114. */
  21115. markAsDirty(flag: number): void;
  21116. /**
  21117. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21118. * @param func defines a function which checks material defines against the submeshes
  21119. */
  21120. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21121. /**
  21122. * Indicates that we need to re-calculated for all submeshes
  21123. */
  21124. protected _markAllSubMeshesAsAllDirty(): void;
  21125. /**
  21126. * Indicates that image processing needs to be re-calculated for all submeshes
  21127. */
  21128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21129. /**
  21130. * Indicates that textures need to be re-calculated for all submeshes
  21131. */
  21132. protected _markAllSubMeshesAsTexturesDirty(): void;
  21133. /**
  21134. * Indicates that fresnel needs to be re-calculated for all submeshes
  21135. */
  21136. protected _markAllSubMeshesAsFresnelDirty(): void;
  21137. /**
  21138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21139. */
  21140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21141. /**
  21142. * Indicates that lights need to be re-calculated for all submeshes
  21143. */
  21144. protected _markAllSubMeshesAsLightsDirty(): void;
  21145. /**
  21146. * Indicates that attributes need to be re-calculated for all submeshes
  21147. */
  21148. protected _markAllSubMeshesAsAttributesDirty(): void;
  21149. /**
  21150. * Indicates that misc needs to be re-calculated for all submeshes
  21151. */
  21152. protected _markAllSubMeshesAsMiscDirty(): void;
  21153. /**
  21154. * Indicates that textures and misc need to be re-calculated for all submeshes
  21155. */
  21156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21157. /**
  21158. * Disposes the material
  21159. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21160. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21161. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21162. */
  21163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21164. /** @hidden */
  21165. private releaseVertexArrayObject;
  21166. /**
  21167. * Serializes this material
  21168. * @returns the serialized material object
  21169. */
  21170. serialize(): any;
  21171. /**
  21172. * Creates a material from parsed material data
  21173. * @param parsedMaterial defines parsed material data
  21174. * @param scene defines the hosting scene
  21175. * @param rootUrl defines the root URL to use to load textures
  21176. * @returns a new material
  21177. */
  21178. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21179. }
  21180. }
  21181. declare module "babylonjs/Materials/multiMaterial" {
  21182. import { Nullable } from "babylonjs/types";
  21183. import { Scene } from "babylonjs/scene";
  21184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21185. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21187. import { Material } from "babylonjs/Materials/material";
  21188. /**
  21189. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21190. * separate meshes. This can be use to improve performances.
  21191. * @see http://doc.babylonjs.com/how_to/multi_materials
  21192. */
  21193. export class MultiMaterial extends Material {
  21194. private _subMaterials;
  21195. /**
  21196. * Gets or Sets the list of Materials used within the multi material.
  21197. * They need to be ordered according to the submeshes order in the associated mesh
  21198. */
  21199. subMaterials: Nullable<Material>[];
  21200. /**
  21201. * Function used to align with Node.getChildren()
  21202. * @returns the list of Materials used within the multi material
  21203. */
  21204. getChildren(): Nullable<Material>[];
  21205. /**
  21206. * Instantiates a new Multi Material
  21207. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21208. * separate meshes. This can be use to improve performances.
  21209. * @see http://doc.babylonjs.com/how_to/multi_materials
  21210. * @param name Define the name in the scene
  21211. * @param scene Define the scene the material belongs to
  21212. */
  21213. constructor(name: string, scene: Scene);
  21214. private _hookArray;
  21215. /**
  21216. * Get one of the submaterial by its index in the submaterials array
  21217. * @param index The index to look the sub material at
  21218. * @returns The Material if the index has been defined
  21219. */
  21220. getSubMaterial(index: number): Nullable<Material>;
  21221. /**
  21222. * Get the list of active textures for the whole sub materials list.
  21223. * @returns All the textures that will be used during the rendering
  21224. */
  21225. getActiveTextures(): BaseTexture[];
  21226. /**
  21227. * Gets the current class name of the material e.g. "MultiMaterial"
  21228. * Mainly use in serialization.
  21229. * @returns the class name
  21230. */
  21231. getClassName(): string;
  21232. /**
  21233. * Checks if the material is ready to render the requested sub mesh
  21234. * @param mesh Define the mesh the submesh belongs to
  21235. * @param subMesh Define the sub mesh to look readyness for
  21236. * @param useInstances Define whether or not the material is used with instances
  21237. * @returns true if ready, otherwise false
  21238. */
  21239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21240. /**
  21241. * Clones the current material and its related sub materials
  21242. * @param name Define the name of the newly cloned material
  21243. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21244. * @returns the cloned material
  21245. */
  21246. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21247. /**
  21248. * Serializes the materials into a JSON representation.
  21249. * @returns the JSON representation
  21250. */
  21251. serialize(): any;
  21252. /**
  21253. * Dispose the material and release its associated resources
  21254. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21255. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21256. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21257. */
  21258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21259. /**
  21260. * Creates a MultiMaterial from parsed MultiMaterial data.
  21261. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21262. * @param scene defines the hosting scene
  21263. * @returns a new MultiMaterial
  21264. */
  21265. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21266. }
  21267. }
  21268. declare module "babylonjs/Meshes/subMesh" {
  21269. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21270. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21271. import { Engine } from "babylonjs/Engines/engine";
  21272. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21273. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21274. import { Effect } from "babylonjs/Materials/effect";
  21275. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21276. import { Plane } from "babylonjs/Maths/math.plane";
  21277. import { Collider } from "babylonjs/Collisions/collider";
  21278. import { Material } from "babylonjs/Materials/material";
  21279. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21281. import { Mesh } from "babylonjs/Meshes/mesh";
  21282. import { Ray } from "babylonjs/Culling/ray";
  21283. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21284. /**
  21285. * Base class for submeshes
  21286. */
  21287. export class BaseSubMesh {
  21288. /** @hidden */
  21289. _materialDefines: Nullable<MaterialDefines>;
  21290. /** @hidden */
  21291. _materialEffect: Nullable<Effect>;
  21292. /**
  21293. * Gets associated effect
  21294. */
  21295. readonly effect: Nullable<Effect>;
  21296. /**
  21297. * Sets associated effect (effect used to render this submesh)
  21298. * @param effect defines the effect to associate with
  21299. * @param defines defines the set of defines used to compile this effect
  21300. */
  21301. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21302. }
  21303. /**
  21304. * Defines a subdivision inside a mesh
  21305. */
  21306. export class SubMesh extends BaseSubMesh implements ICullable {
  21307. /** the material index to use */
  21308. materialIndex: number;
  21309. /** vertex index start */
  21310. verticesStart: number;
  21311. /** vertices count */
  21312. verticesCount: number;
  21313. /** index start */
  21314. indexStart: number;
  21315. /** indices count */
  21316. indexCount: number;
  21317. /** @hidden */
  21318. _linesIndexCount: number;
  21319. private _mesh;
  21320. private _renderingMesh;
  21321. private _boundingInfo;
  21322. private _linesIndexBuffer;
  21323. /** @hidden */
  21324. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21325. /** @hidden */
  21326. _trianglePlanes: Plane[];
  21327. /** @hidden */
  21328. _lastColliderTransformMatrix: Nullable<Matrix>;
  21329. /** @hidden */
  21330. _renderId: number;
  21331. /** @hidden */
  21332. _alphaIndex: number;
  21333. /** @hidden */
  21334. _distanceToCamera: number;
  21335. /** @hidden */
  21336. _id: number;
  21337. private _currentMaterial;
  21338. /**
  21339. * Add a new submesh to a mesh
  21340. * @param materialIndex defines the material index to use
  21341. * @param verticesStart defines vertex index start
  21342. * @param verticesCount defines vertices count
  21343. * @param indexStart defines index start
  21344. * @param indexCount defines indices count
  21345. * @param mesh defines the parent mesh
  21346. * @param renderingMesh defines an optional rendering mesh
  21347. * @param createBoundingBox defines if bounding box should be created for this submesh
  21348. * @returns the new submesh
  21349. */
  21350. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21351. /**
  21352. * Creates a new submesh
  21353. * @param materialIndex defines the material index to use
  21354. * @param verticesStart defines vertex index start
  21355. * @param verticesCount defines vertices count
  21356. * @param indexStart defines index start
  21357. * @param indexCount defines indices count
  21358. * @param mesh defines the parent mesh
  21359. * @param renderingMesh defines an optional rendering mesh
  21360. * @param createBoundingBox defines if bounding box should be created for this submesh
  21361. */
  21362. constructor(
  21363. /** the material index to use */
  21364. materialIndex: number,
  21365. /** vertex index start */
  21366. verticesStart: number,
  21367. /** vertices count */
  21368. verticesCount: number,
  21369. /** index start */
  21370. indexStart: number,
  21371. /** indices count */
  21372. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21373. /**
  21374. * Returns true if this submesh covers the entire parent mesh
  21375. * @ignorenaming
  21376. */
  21377. readonly IsGlobal: boolean;
  21378. /**
  21379. * Returns the submesh BoudingInfo object
  21380. * @returns current bounding info (or mesh's one if the submesh is global)
  21381. */
  21382. getBoundingInfo(): BoundingInfo;
  21383. /**
  21384. * Sets the submesh BoundingInfo
  21385. * @param boundingInfo defines the new bounding info to use
  21386. * @returns the SubMesh
  21387. */
  21388. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21389. /**
  21390. * Returns the mesh of the current submesh
  21391. * @return the parent mesh
  21392. */
  21393. getMesh(): AbstractMesh;
  21394. /**
  21395. * Returns the rendering mesh of the submesh
  21396. * @returns the rendering mesh (could be different from parent mesh)
  21397. */
  21398. getRenderingMesh(): Mesh;
  21399. /**
  21400. * Returns the submesh material
  21401. * @returns null or the current material
  21402. */
  21403. getMaterial(): Nullable<Material>;
  21404. /**
  21405. * Sets a new updated BoundingInfo object to the submesh
  21406. * @param data defines an optional position array to use to determine the bounding info
  21407. * @returns the SubMesh
  21408. */
  21409. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21410. /** @hidden */
  21411. _checkCollision(collider: Collider): boolean;
  21412. /**
  21413. * Updates the submesh BoundingInfo
  21414. * @param world defines the world matrix to use to update the bounding info
  21415. * @returns the submesh
  21416. */
  21417. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21418. /**
  21419. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21420. * @param frustumPlanes defines the frustum planes
  21421. * @returns true if the submesh is intersecting with the frustum
  21422. */
  21423. isInFrustum(frustumPlanes: Plane[]): boolean;
  21424. /**
  21425. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21426. * @param frustumPlanes defines the frustum planes
  21427. * @returns true if the submesh is inside the frustum
  21428. */
  21429. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21430. /**
  21431. * Renders the submesh
  21432. * @param enableAlphaMode defines if alpha needs to be used
  21433. * @returns the submesh
  21434. */
  21435. render(enableAlphaMode: boolean): SubMesh;
  21436. /**
  21437. * @hidden
  21438. */
  21439. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21440. /**
  21441. * Checks if the submesh intersects with a ray
  21442. * @param ray defines the ray to test
  21443. * @returns true is the passed ray intersects the submesh bounding box
  21444. */
  21445. canIntersects(ray: Ray): boolean;
  21446. /**
  21447. * Intersects current submesh with a ray
  21448. * @param ray defines the ray to test
  21449. * @param positions defines mesh's positions array
  21450. * @param indices defines mesh's indices array
  21451. * @param fastCheck defines if only bounding info should be used
  21452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21453. * @returns intersection info or null if no intersection
  21454. */
  21455. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21456. /** @hidden */
  21457. private _intersectLines;
  21458. /** @hidden */
  21459. private _intersectUnIndexedLines;
  21460. /** @hidden */
  21461. private _intersectTriangles;
  21462. /** @hidden */
  21463. private _intersectUnIndexedTriangles;
  21464. /** @hidden */
  21465. _rebuild(): void;
  21466. /**
  21467. * Creates a new submesh from the passed mesh
  21468. * @param newMesh defines the new hosting mesh
  21469. * @param newRenderingMesh defines an optional rendering mesh
  21470. * @returns the new submesh
  21471. */
  21472. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21473. /**
  21474. * Release associated resources
  21475. */
  21476. dispose(): void;
  21477. /**
  21478. * Gets the class name
  21479. * @returns the string "SubMesh".
  21480. */
  21481. getClassName(): string;
  21482. /**
  21483. * Creates a new submesh from indices data
  21484. * @param materialIndex the index of the main mesh material
  21485. * @param startIndex the index where to start the copy in the mesh indices array
  21486. * @param indexCount the number of indices to copy then from the startIndex
  21487. * @param mesh the main mesh to create the submesh from
  21488. * @param renderingMesh the optional rendering mesh
  21489. * @returns a new submesh
  21490. */
  21491. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21492. }
  21493. }
  21494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21495. /**
  21496. * Class used to represent data loading progression
  21497. */
  21498. export class SceneLoaderFlags {
  21499. private static _ForceFullSceneLoadingForIncremental;
  21500. private static _ShowLoadingScreen;
  21501. private static _CleanBoneMatrixWeights;
  21502. private static _loggingLevel;
  21503. /**
  21504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21505. */
  21506. static ForceFullSceneLoadingForIncremental: boolean;
  21507. /**
  21508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21509. */
  21510. static ShowLoadingScreen: boolean;
  21511. /**
  21512. * Defines the current logging level (while loading the scene)
  21513. * @ignorenaming
  21514. */
  21515. static loggingLevel: number;
  21516. /**
  21517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21518. */
  21519. static CleanBoneMatrixWeights: boolean;
  21520. }
  21521. }
  21522. declare module "babylonjs/Meshes/geometry" {
  21523. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21524. import { Scene } from "babylonjs/scene";
  21525. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21526. import { Engine } from "babylonjs/Engines/engine";
  21527. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21528. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21529. import { Effect } from "babylonjs/Materials/effect";
  21530. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21532. import { Mesh } from "babylonjs/Meshes/mesh";
  21533. /**
  21534. * Class used to store geometry data (vertex buffers + index buffer)
  21535. */
  21536. export class Geometry implements IGetSetVerticesData {
  21537. /**
  21538. * Gets or sets the ID of the geometry
  21539. */
  21540. id: string;
  21541. /**
  21542. * Gets or sets the unique ID of the geometry
  21543. */
  21544. uniqueId: number;
  21545. /**
  21546. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21547. */
  21548. delayLoadState: number;
  21549. /**
  21550. * Gets the file containing the data to load when running in delay load state
  21551. */
  21552. delayLoadingFile: Nullable<string>;
  21553. /**
  21554. * Callback called when the geometry is updated
  21555. */
  21556. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21557. private _scene;
  21558. private _engine;
  21559. private _meshes;
  21560. private _totalVertices;
  21561. /** @hidden */
  21562. _indices: IndicesArray;
  21563. /** @hidden */
  21564. _vertexBuffers: {
  21565. [key: string]: VertexBuffer;
  21566. };
  21567. private _isDisposed;
  21568. private _extend;
  21569. private _boundingBias;
  21570. /** @hidden */
  21571. _delayInfo: Array<string>;
  21572. private _indexBuffer;
  21573. private _indexBufferIsUpdatable;
  21574. /** @hidden */
  21575. _boundingInfo: Nullable<BoundingInfo>;
  21576. /** @hidden */
  21577. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21578. /** @hidden */
  21579. _softwareSkinningFrameId: number;
  21580. private _vertexArrayObjects;
  21581. private _updatable;
  21582. /** @hidden */
  21583. _positions: Nullable<Vector3[]>;
  21584. /**
  21585. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21586. */
  21587. /**
  21588. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21589. */
  21590. boundingBias: Vector2;
  21591. /**
  21592. * Static function used to attach a new empty geometry to a mesh
  21593. * @param mesh defines the mesh to attach the geometry to
  21594. * @returns the new Geometry
  21595. */
  21596. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21597. /**
  21598. * Creates a new geometry
  21599. * @param id defines the unique ID
  21600. * @param scene defines the hosting scene
  21601. * @param vertexData defines the VertexData used to get geometry data
  21602. * @param updatable defines if geometry must be updatable (false by default)
  21603. * @param mesh defines the mesh that will be associated with the geometry
  21604. */
  21605. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21606. /**
  21607. * Gets the current extend of the geometry
  21608. */
  21609. readonly extend: {
  21610. minimum: Vector3;
  21611. maximum: Vector3;
  21612. };
  21613. /**
  21614. * Gets the hosting scene
  21615. * @returns the hosting Scene
  21616. */
  21617. getScene(): Scene;
  21618. /**
  21619. * Gets the hosting engine
  21620. * @returns the hosting Engine
  21621. */
  21622. getEngine(): Engine;
  21623. /**
  21624. * Defines if the geometry is ready to use
  21625. * @returns true if the geometry is ready to be used
  21626. */
  21627. isReady(): boolean;
  21628. /**
  21629. * Gets a value indicating that the geometry should not be serialized
  21630. */
  21631. readonly doNotSerialize: boolean;
  21632. /** @hidden */
  21633. _rebuild(): void;
  21634. /**
  21635. * Affects all geometry data in one call
  21636. * @param vertexData defines the geometry data
  21637. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21638. */
  21639. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21640. /**
  21641. * Set specific vertex data
  21642. * @param kind defines the data kind (Position, normal, etc...)
  21643. * @param data defines the vertex data to use
  21644. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21645. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21646. */
  21647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21648. /**
  21649. * Removes a specific vertex data
  21650. * @param kind defines the data kind (Position, normal, etc...)
  21651. */
  21652. removeVerticesData(kind: string): void;
  21653. /**
  21654. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21655. * @param buffer defines the vertex buffer to use
  21656. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21657. */
  21658. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21659. /**
  21660. * Update a specific vertex buffer
  21661. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21662. * It will do nothing if the buffer is not updatable
  21663. * @param kind defines the data kind (Position, normal, etc...)
  21664. * @param data defines the data to use
  21665. * @param offset defines the offset in the target buffer where to store the data
  21666. * @param useBytes set to true if the offset is in bytes
  21667. */
  21668. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21669. /**
  21670. * Update a specific vertex buffer
  21671. * This function will create a new buffer if the current one is not updatable
  21672. * @param kind defines the data kind (Position, normal, etc...)
  21673. * @param data defines the data to use
  21674. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21675. */
  21676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21677. private _updateBoundingInfo;
  21678. /** @hidden */
  21679. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21680. /**
  21681. * Gets total number of vertices
  21682. * @returns the total number of vertices
  21683. */
  21684. getTotalVertices(): number;
  21685. /**
  21686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21687. * @param kind defines the data kind (Position, normal, etc...)
  21688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21690. * @returns a float array containing vertex data
  21691. */
  21692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21693. /**
  21694. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21695. * @param kind defines the data kind (Position, normal, etc...)
  21696. * @returns true if the vertex buffer with the specified kind is updatable
  21697. */
  21698. isVertexBufferUpdatable(kind: string): boolean;
  21699. /**
  21700. * Gets a specific vertex buffer
  21701. * @param kind defines the data kind (Position, normal, etc...)
  21702. * @returns a VertexBuffer
  21703. */
  21704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21705. /**
  21706. * Returns all vertex buffers
  21707. * @return an object holding all vertex buffers indexed by kind
  21708. */
  21709. getVertexBuffers(): Nullable<{
  21710. [key: string]: VertexBuffer;
  21711. }>;
  21712. /**
  21713. * Gets a boolean indicating if specific vertex buffer is present
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @returns true if data is present
  21716. */
  21717. isVerticesDataPresent(kind: string): boolean;
  21718. /**
  21719. * Gets a list of all attached data kinds (Position, normal, etc...)
  21720. * @returns a list of string containing all kinds
  21721. */
  21722. getVerticesDataKinds(): string[];
  21723. /**
  21724. * Update index buffer
  21725. * @param indices defines the indices to store in the index buffer
  21726. * @param offset defines the offset in the target buffer where to store the data
  21727. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21728. */
  21729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21730. /**
  21731. * Creates a new index buffer
  21732. * @param indices defines the indices to store in the index buffer
  21733. * @param totalVertices defines the total number of vertices (could be null)
  21734. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21735. */
  21736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21737. /**
  21738. * Return the total number of indices
  21739. * @returns the total number of indices
  21740. */
  21741. getTotalIndices(): number;
  21742. /**
  21743. * Gets the index buffer array
  21744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21746. * @returns the index buffer array
  21747. */
  21748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21749. /**
  21750. * Gets the index buffer
  21751. * @return the index buffer
  21752. */
  21753. getIndexBuffer(): Nullable<DataBuffer>;
  21754. /** @hidden */
  21755. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21756. /**
  21757. * Release the associated resources for a specific mesh
  21758. * @param mesh defines the source mesh
  21759. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21760. */
  21761. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21762. /**
  21763. * Apply current geometry to a given mesh
  21764. * @param mesh defines the mesh to apply geometry to
  21765. */
  21766. applyToMesh(mesh: Mesh): void;
  21767. private _updateExtend;
  21768. private _applyToMesh;
  21769. private notifyUpdate;
  21770. /**
  21771. * Load the geometry if it was flagged as delay loaded
  21772. * @param scene defines the hosting scene
  21773. * @param onLoaded defines a callback called when the geometry is loaded
  21774. */
  21775. load(scene: Scene, onLoaded?: () => void): void;
  21776. private _queueLoad;
  21777. /**
  21778. * Invert the geometry to move from a right handed system to a left handed one.
  21779. */
  21780. toLeftHanded(): void;
  21781. /** @hidden */
  21782. _resetPointsArrayCache(): void;
  21783. /** @hidden */
  21784. _generatePointsArray(): boolean;
  21785. /**
  21786. * Gets a value indicating if the geometry is disposed
  21787. * @returns true if the geometry was disposed
  21788. */
  21789. isDisposed(): boolean;
  21790. private _disposeVertexArrayObjects;
  21791. /**
  21792. * Free all associated resources
  21793. */
  21794. dispose(): void;
  21795. /**
  21796. * Clone the current geometry into a new geometry
  21797. * @param id defines the unique ID of the new geometry
  21798. * @returns a new geometry object
  21799. */
  21800. copy(id: string): Geometry;
  21801. /**
  21802. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21803. * @return a JSON representation of the current geometry data (without the vertices data)
  21804. */
  21805. serialize(): any;
  21806. private toNumberArray;
  21807. /**
  21808. * Serialize all vertices data into a JSON oject
  21809. * @returns a JSON representation of the current geometry data
  21810. */
  21811. serializeVerticeData(): any;
  21812. /**
  21813. * Extracts a clone of a mesh geometry
  21814. * @param mesh defines the source mesh
  21815. * @param id defines the unique ID of the new geometry object
  21816. * @returns the new geometry object
  21817. */
  21818. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21819. /**
  21820. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21822. * Be aware Math.random() could cause collisions, but:
  21823. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21824. * @returns a string containing a new GUID
  21825. */
  21826. static RandomId(): string;
  21827. /** @hidden */
  21828. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21829. private static _CleanMatricesWeights;
  21830. /**
  21831. * Create a new geometry from persisted data (Using .babylon file format)
  21832. * @param parsedVertexData defines the persisted data
  21833. * @param scene defines the hosting scene
  21834. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21835. * @returns the new geometry object
  21836. */
  21837. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21838. }
  21839. }
  21840. declare module "babylonjs/Meshes/mesh.vertexData" {
  21841. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21842. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21843. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21844. import { Geometry } from "babylonjs/Meshes/geometry";
  21845. import { Mesh } from "babylonjs/Meshes/mesh";
  21846. /**
  21847. * Define an interface for all classes that will get and set the data on vertices
  21848. */
  21849. export interface IGetSetVerticesData {
  21850. /**
  21851. * Gets a boolean indicating if specific vertex data is present
  21852. * @param kind defines the vertex data kind to use
  21853. * @returns true is data kind is present
  21854. */
  21855. isVerticesDataPresent(kind: string): boolean;
  21856. /**
  21857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21861. * @returns a float array containing vertex data
  21862. */
  21863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21864. /**
  21865. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21866. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21867. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21868. * @returns the indices array or an empty array if the mesh has no geometry
  21869. */
  21870. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21871. /**
  21872. * Set specific vertex data
  21873. * @param kind defines the data kind (Position, normal, etc...)
  21874. * @param data defines the vertex data to use
  21875. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21876. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21877. */
  21878. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21879. /**
  21880. * Update a specific associated vertex buffer
  21881. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21882. * - VertexBuffer.PositionKind
  21883. * - VertexBuffer.UVKind
  21884. * - VertexBuffer.UV2Kind
  21885. * - VertexBuffer.UV3Kind
  21886. * - VertexBuffer.UV4Kind
  21887. * - VertexBuffer.UV5Kind
  21888. * - VertexBuffer.UV6Kind
  21889. * - VertexBuffer.ColorKind
  21890. * - VertexBuffer.MatricesIndicesKind
  21891. * - VertexBuffer.MatricesIndicesExtraKind
  21892. * - VertexBuffer.MatricesWeightsKind
  21893. * - VertexBuffer.MatricesWeightsExtraKind
  21894. * @param data defines the data source
  21895. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21896. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21897. */
  21898. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21899. /**
  21900. * Creates a new index buffer
  21901. * @param indices defines the indices to store in the index buffer
  21902. * @param totalVertices defines the total number of vertices (could be null)
  21903. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21904. */
  21905. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21906. }
  21907. /**
  21908. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21909. */
  21910. export class VertexData {
  21911. /**
  21912. * Mesh side orientation : usually the external or front surface
  21913. */
  21914. static readonly FRONTSIDE: number;
  21915. /**
  21916. * Mesh side orientation : usually the internal or back surface
  21917. */
  21918. static readonly BACKSIDE: number;
  21919. /**
  21920. * Mesh side orientation : both internal and external or front and back surfaces
  21921. */
  21922. static readonly DOUBLESIDE: number;
  21923. /**
  21924. * Mesh side orientation : by default, `FRONTSIDE`
  21925. */
  21926. static readonly DEFAULTSIDE: number;
  21927. /**
  21928. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21929. */
  21930. positions: Nullable<FloatArray>;
  21931. /**
  21932. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21933. */
  21934. normals: Nullable<FloatArray>;
  21935. /**
  21936. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21937. */
  21938. tangents: Nullable<FloatArray>;
  21939. /**
  21940. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21941. */
  21942. uvs: Nullable<FloatArray>;
  21943. /**
  21944. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21945. */
  21946. uvs2: Nullable<FloatArray>;
  21947. /**
  21948. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21949. */
  21950. uvs3: Nullable<FloatArray>;
  21951. /**
  21952. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21953. */
  21954. uvs4: Nullable<FloatArray>;
  21955. /**
  21956. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21957. */
  21958. uvs5: Nullable<FloatArray>;
  21959. /**
  21960. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21961. */
  21962. uvs6: Nullable<FloatArray>;
  21963. /**
  21964. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21965. */
  21966. colors: Nullable<FloatArray>;
  21967. /**
  21968. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21969. */
  21970. matricesIndices: Nullable<FloatArray>;
  21971. /**
  21972. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21973. */
  21974. matricesWeights: Nullable<FloatArray>;
  21975. /**
  21976. * An array extending the number of possible indices
  21977. */
  21978. matricesIndicesExtra: Nullable<FloatArray>;
  21979. /**
  21980. * An array extending the number of possible weights when the number of indices is extended
  21981. */
  21982. matricesWeightsExtra: Nullable<FloatArray>;
  21983. /**
  21984. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21985. */
  21986. indices: Nullable<IndicesArray>;
  21987. /**
  21988. * Uses the passed data array to set the set the values for the specified kind of data
  21989. * @param data a linear array of floating numbers
  21990. * @param kind the type of data that is being set, eg positions, colors etc
  21991. */
  21992. set(data: FloatArray, kind: string): void;
  21993. /**
  21994. * Associates the vertexData to the passed Mesh.
  21995. * Sets it as updatable or not (default `false`)
  21996. * @param mesh the mesh the vertexData is applied to
  21997. * @param updatable when used and having the value true allows new data to update the vertexData
  21998. * @returns the VertexData
  21999. */
  22000. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22001. /**
  22002. * Associates the vertexData to the passed Geometry.
  22003. * Sets it as updatable or not (default `false`)
  22004. * @param geometry the geometry the vertexData is applied to
  22005. * @param updatable when used and having the value true allows new data to update the vertexData
  22006. * @returns VertexData
  22007. */
  22008. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22009. /**
  22010. * Updates the associated mesh
  22011. * @param mesh the mesh to be updated
  22012. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22013. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22014. * @returns VertexData
  22015. */
  22016. updateMesh(mesh: Mesh): VertexData;
  22017. /**
  22018. * Updates the associated geometry
  22019. * @param geometry the geometry to be updated
  22020. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22021. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22022. * @returns VertexData.
  22023. */
  22024. updateGeometry(geometry: Geometry): VertexData;
  22025. private _applyTo;
  22026. private _update;
  22027. /**
  22028. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22029. * @param matrix the transforming matrix
  22030. * @returns the VertexData
  22031. */
  22032. transform(matrix: Matrix): VertexData;
  22033. /**
  22034. * Merges the passed VertexData into the current one
  22035. * @param other the VertexData to be merged into the current one
  22036. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22037. * @returns the modified VertexData
  22038. */
  22039. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22040. private _mergeElement;
  22041. private _validate;
  22042. /**
  22043. * Serializes the VertexData
  22044. * @returns a serialized object
  22045. */
  22046. serialize(): any;
  22047. /**
  22048. * Extracts the vertexData from a mesh
  22049. * @param mesh the mesh from which to extract the VertexData
  22050. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22051. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22052. * @returns the object VertexData associated to the passed mesh
  22053. */
  22054. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22055. /**
  22056. * Extracts the vertexData from the geometry
  22057. * @param geometry the geometry from which to extract the VertexData
  22058. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22059. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22060. * @returns the object VertexData associated to the passed mesh
  22061. */
  22062. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22063. private static _ExtractFrom;
  22064. /**
  22065. * Creates the VertexData for a Ribbon
  22066. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22067. * * pathArray array of paths, each of which an array of successive Vector3
  22068. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22069. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22070. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22072. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22073. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22074. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22075. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22076. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22077. * @returns the VertexData of the ribbon
  22078. */
  22079. static CreateRibbon(options: {
  22080. pathArray: Vector3[][];
  22081. closeArray?: boolean;
  22082. closePath?: boolean;
  22083. offset?: number;
  22084. sideOrientation?: number;
  22085. frontUVs?: Vector4;
  22086. backUVs?: Vector4;
  22087. invertUV?: boolean;
  22088. uvs?: Vector2[];
  22089. colors?: Color4[];
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData for a box
  22093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22094. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22095. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22096. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22097. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22098. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22099. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22101. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22102. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22103. * @returns the VertexData of the box
  22104. */
  22105. static CreateBox(options: {
  22106. size?: number;
  22107. width?: number;
  22108. height?: number;
  22109. depth?: number;
  22110. faceUV?: Vector4[];
  22111. faceColors?: Color4[];
  22112. sideOrientation?: number;
  22113. frontUVs?: Vector4;
  22114. backUVs?: Vector4;
  22115. }): VertexData;
  22116. /**
  22117. * Creates the VertexData for a tiled box
  22118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22119. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22120. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22121. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22123. * @returns the VertexData of the box
  22124. */
  22125. static CreateTiledBox(options: {
  22126. pattern?: number;
  22127. width?: number;
  22128. height?: number;
  22129. depth?: number;
  22130. tileSize?: number;
  22131. tileWidth?: number;
  22132. tileHeight?: number;
  22133. alignHorizontal?: number;
  22134. alignVertical?: number;
  22135. faceUV?: Vector4[];
  22136. faceColors?: Color4[];
  22137. sideOrientation?: number;
  22138. }): VertexData;
  22139. /**
  22140. * Creates the VertexData for a tiled plane
  22141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22142. * * pattern a limited pattern arrangement depending on the number
  22143. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22144. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22145. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22147. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22148. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22149. * @returns the VertexData of the tiled plane
  22150. */
  22151. static CreateTiledPlane(options: {
  22152. pattern?: number;
  22153. tileSize?: number;
  22154. tileWidth?: number;
  22155. tileHeight?: number;
  22156. size?: number;
  22157. width?: number;
  22158. height?: number;
  22159. alignHorizontal?: number;
  22160. alignVertical?: number;
  22161. sideOrientation?: number;
  22162. frontUVs?: Vector4;
  22163. backUVs?: Vector4;
  22164. }): VertexData;
  22165. /**
  22166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22168. * * segments sets the number of horizontal strips optional, default 32
  22169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22173. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22174. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22176. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22177. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22178. * @returns the VertexData of the ellipsoid
  22179. */
  22180. static CreateSphere(options: {
  22181. segments?: number;
  22182. diameter?: number;
  22183. diameterX?: number;
  22184. diameterY?: number;
  22185. diameterZ?: number;
  22186. arc?: number;
  22187. slice?: number;
  22188. sideOrientation?: number;
  22189. frontUVs?: Vector4;
  22190. backUVs?: Vector4;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a cylinder, cone or prism
  22194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22195. * * height sets the height (y direction) of the cylinder, optional, default 2
  22196. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22197. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22198. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22200. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22201. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22204. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22205. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22207. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22208. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22209. * @returns the VertexData of the cylinder, cone or prism
  22210. */
  22211. static CreateCylinder(options: {
  22212. height?: number;
  22213. diameterTop?: number;
  22214. diameterBottom?: number;
  22215. diameter?: number;
  22216. tessellation?: number;
  22217. subdivisions?: number;
  22218. arc?: number;
  22219. faceColors?: Color4[];
  22220. faceUV?: Vector4[];
  22221. hasRings?: boolean;
  22222. enclose?: boolean;
  22223. sideOrientation?: number;
  22224. frontUVs?: Vector4;
  22225. backUVs?: Vector4;
  22226. }): VertexData;
  22227. /**
  22228. * Creates the VertexData for a torus
  22229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22230. * * diameter the diameter of the torus, optional default 1
  22231. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22232. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22234. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22235. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22236. * @returns the VertexData of the torus
  22237. */
  22238. static CreateTorus(options: {
  22239. diameter?: number;
  22240. thickness?: number;
  22241. tessellation?: number;
  22242. sideOrientation?: number;
  22243. frontUVs?: Vector4;
  22244. backUVs?: Vector4;
  22245. }): VertexData;
  22246. /**
  22247. * Creates the VertexData of the LineSystem
  22248. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22249. * - lines an array of lines, each line being an array of successive Vector3
  22250. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22251. * @returns the VertexData of the LineSystem
  22252. */
  22253. static CreateLineSystem(options: {
  22254. lines: Vector3[][];
  22255. colors?: Nullable<Color4[][]>;
  22256. }): VertexData;
  22257. /**
  22258. * Create the VertexData for a DashedLines
  22259. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22260. * - points an array successive Vector3
  22261. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22262. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22263. * - dashNb the intended total number of dashes, optional, default 200
  22264. * @returns the VertexData for the DashedLines
  22265. */
  22266. static CreateDashedLines(options: {
  22267. points: Vector3[];
  22268. dashSize?: number;
  22269. gapSize?: number;
  22270. dashNb?: number;
  22271. }): VertexData;
  22272. /**
  22273. * Creates the VertexData for a Ground
  22274. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22275. * - width the width (x direction) of the ground, optional, default 1
  22276. * - height the height (z direction) of the ground, optional, default 1
  22277. * - subdivisions the number of subdivisions per side, optional, default 1
  22278. * @returns the VertexData of the Ground
  22279. */
  22280. static CreateGround(options: {
  22281. width?: number;
  22282. height?: number;
  22283. subdivisions?: number;
  22284. subdivisionsX?: number;
  22285. subdivisionsY?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22290. * * xmin the ground minimum X coordinate, optional, default -1
  22291. * * zmin the ground minimum Z coordinate, optional, default -1
  22292. * * xmax the ground maximum X coordinate, optional, default 1
  22293. * * zmax the ground maximum Z coordinate, optional, default 1
  22294. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22295. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22296. * @returns the VertexData of the TiledGround
  22297. */
  22298. static CreateTiledGround(options: {
  22299. xmin: number;
  22300. zmin: number;
  22301. xmax: number;
  22302. zmax: number;
  22303. subdivisions?: {
  22304. w: number;
  22305. h: number;
  22306. };
  22307. precision?: {
  22308. w: number;
  22309. h: number;
  22310. };
  22311. }): VertexData;
  22312. /**
  22313. * Creates the VertexData of the Ground designed from a heightmap
  22314. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22315. * * width the width (x direction) of the ground
  22316. * * height the height (z direction) of the ground
  22317. * * subdivisions the number of subdivisions per side
  22318. * * minHeight the minimum altitude on the ground, optional, default 0
  22319. * * maxHeight the maximum altitude on the ground, optional default 1
  22320. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22321. * * buffer the array holding the image color data
  22322. * * bufferWidth the width of image
  22323. * * bufferHeight the height of image
  22324. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22325. * @returns the VertexData of the Ground designed from a heightmap
  22326. */
  22327. static CreateGroundFromHeightMap(options: {
  22328. width: number;
  22329. height: number;
  22330. subdivisions: number;
  22331. minHeight: number;
  22332. maxHeight: number;
  22333. colorFilter: Color3;
  22334. buffer: Uint8Array;
  22335. bufferWidth: number;
  22336. bufferHeight: number;
  22337. alphaFilter: number;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a Plane
  22341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22342. * * size sets the width and height of the plane to the value of size, optional default 1
  22343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22347. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreatePlane(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. sideOrientation?: number;
  22355. frontUVs?: Vector4;
  22356. backUVs?: Vector4;
  22357. }): VertexData;
  22358. /**
  22359. * Creates the VertexData of the Disc or regular Polygon
  22360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22361. * * radius the radius of the disc, optional default 0.5
  22362. * * tessellation the number of polygon sides, optional, default 64
  22363. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22365. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22366. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22367. * @returns the VertexData of the box
  22368. */
  22369. static CreateDisc(options: {
  22370. radius?: number;
  22371. tessellation?: number;
  22372. arc?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22380. * @param polygon a mesh built from polygonTriangulation.build()
  22381. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22384. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22385. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22386. * @returns the VertexData of the Polygon
  22387. */
  22388. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22389. /**
  22390. * Creates the VertexData of the IcoSphere
  22391. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22392. * * radius the radius of the IcoSphere, optional default 1
  22393. * * radiusX allows stretching in the x direction, optional, default radius
  22394. * * radiusY allows stretching in the y direction, optional, default radius
  22395. * * radiusZ allows stretching in the z direction, optional, default radius
  22396. * * flat when true creates a flat shaded mesh, optional, default true
  22397. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22399. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22400. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22401. * @returns the VertexData of the IcoSphere
  22402. */
  22403. static CreateIcoSphere(options: {
  22404. radius?: number;
  22405. radiusX?: number;
  22406. radiusY?: number;
  22407. radiusZ?: number;
  22408. flat?: boolean;
  22409. subdivisions?: number;
  22410. sideOrientation?: number;
  22411. frontUVs?: Vector4;
  22412. backUVs?: Vector4;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for a Polyhedron
  22416. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22417. * * type provided types are:
  22418. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22419. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22420. * * size the size of the IcoSphere, optional default 1
  22421. * * sizeX allows stretching in the x direction, optional, default size
  22422. * * sizeY allows stretching in the y direction, optional, default size
  22423. * * sizeZ allows stretching in the z direction, optional, default size
  22424. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22426. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22427. * * flat when true creates a flat shaded mesh, optional, default true
  22428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22431. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22432. * @returns the VertexData of the Polyhedron
  22433. */
  22434. static CreatePolyhedron(options: {
  22435. type?: number;
  22436. size?: number;
  22437. sizeX?: number;
  22438. sizeY?: number;
  22439. sizeZ?: number;
  22440. custom?: any;
  22441. faceUV?: Vector4[];
  22442. faceColors?: Color4[];
  22443. flat?: boolean;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for a TorusKnot
  22450. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22451. * * radius the radius of the torus knot, optional, default 2
  22452. * * tube the thickness of the tube, optional, default 0.5
  22453. * * radialSegments the number of sides on each tube segments, optional, default 32
  22454. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22455. * * p the number of windings around the z axis, optional, default 2
  22456. * * q the number of windings around the x axis, optional, default 3
  22457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22458. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22459. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22460. * @returns the VertexData of the Torus Knot
  22461. */
  22462. static CreateTorusKnot(options: {
  22463. radius?: number;
  22464. tube?: number;
  22465. radialSegments?: number;
  22466. tubularSegments?: number;
  22467. p?: number;
  22468. q?: number;
  22469. sideOrientation?: number;
  22470. frontUVs?: Vector4;
  22471. backUVs?: Vector4;
  22472. }): VertexData;
  22473. /**
  22474. * Compute normals for given positions and indices
  22475. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22476. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22477. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22478. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22479. * * facetNormals : optional array of facet normals (vector3)
  22480. * * facetPositions : optional array of facet positions (vector3)
  22481. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22482. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22483. * * bInfo : optional bounding info, required for facetPartitioning computation
  22484. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22485. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22486. * * useRightHandedSystem: optional boolean to for right handed system computation
  22487. * * depthSort : optional boolean to enable the facet depth sort computation
  22488. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22489. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22490. */
  22491. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22492. facetNormals?: any;
  22493. facetPositions?: any;
  22494. facetPartitioning?: any;
  22495. ratio?: number;
  22496. bInfo?: any;
  22497. bbSize?: Vector3;
  22498. subDiv?: any;
  22499. useRightHandedSystem?: boolean;
  22500. depthSort?: boolean;
  22501. distanceTo?: Vector3;
  22502. depthSortedFacets?: any;
  22503. }): void;
  22504. /** @hidden */
  22505. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22506. /**
  22507. * Applies VertexData created from the imported parameters to the geometry
  22508. * @param parsedVertexData the parsed data from an imported file
  22509. * @param geometry the geometry to apply the VertexData to
  22510. */
  22511. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22512. }
  22513. }
  22514. declare module "babylonjs/Morph/morphTarget" {
  22515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22516. import { Observable } from "babylonjs/Misc/observable";
  22517. import { Nullable, FloatArray } from "babylonjs/types";
  22518. import { Scene } from "babylonjs/scene";
  22519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22520. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22521. /**
  22522. * Defines a target to use with MorphTargetManager
  22523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22524. */
  22525. export class MorphTarget implements IAnimatable {
  22526. /** defines the name of the target */
  22527. name: string;
  22528. /**
  22529. * Gets or sets the list of animations
  22530. */
  22531. animations: import("babylonjs/Animations/animation").Animation[];
  22532. private _scene;
  22533. private _positions;
  22534. private _normals;
  22535. private _tangents;
  22536. private _uvs;
  22537. private _influence;
  22538. /**
  22539. * Observable raised when the influence changes
  22540. */
  22541. onInfluenceChanged: Observable<boolean>;
  22542. /** @hidden */
  22543. _onDataLayoutChanged: Observable<void>;
  22544. /**
  22545. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22546. */
  22547. influence: number;
  22548. /**
  22549. * Gets or sets the id of the morph Target
  22550. */
  22551. id: string;
  22552. private _animationPropertiesOverride;
  22553. /**
  22554. * Gets or sets the animation properties override
  22555. */
  22556. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22557. /**
  22558. * Creates a new MorphTarget
  22559. * @param name defines the name of the target
  22560. * @param influence defines the influence to use
  22561. * @param scene defines the scene the morphtarget belongs to
  22562. */
  22563. constructor(
  22564. /** defines the name of the target */
  22565. name: string, influence?: number, scene?: Nullable<Scene>);
  22566. /**
  22567. * Gets a boolean defining if the target contains position data
  22568. */
  22569. readonly hasPositions: boolean;
  22570. /**
  22571. * Gets a boolean defining if the target contains normal data
  22572. */
  22573. readonly hasNormals: boolean;
  22574. /**
  22575. * Gets a boolean defining if the target contains tangent data
  22576. */
  22577. readonly hasTangents: boolean;
  22578. /**
  22579. * Gets a boolean defining if the target contains texture coordinates data
  22580. */
  22581. readonly hasUVs: boolean;
  22582. /**
  22583. * Affects position data to this target
  22584. * @param data defines the position data to use
  22585. */
  22586. setPositions(data: Nullable<FloatArray>): void;
  22587. /**
  22588. * Gets the position data stored in this target
  22589. * @returns a FloatArray containing the position data (or null if not present)
  22590. */
  22591. getPositions(): Nullable<FloatArray>;
  22592. /**
  22593. * Affects normal data to this target
  22594. * @param data defines the normal data to use
  22595. */
  22596. setNormals(data: Nullable<FloatArray>): void;
  22597. /**
  22598. * Gets the normal data stored in this target
  22599. * @returns a FloatArray containing the normal data (or null if not present)
  22600. */
  22601. getNormals(): Nullable<FloatArray>;
  22602. /**
  22603. * Affects tangent data to this target
  22604. * @param data defines the tangent data to use
  22605. */
  22606. setTangents(data: Nullable<FloatArray>): void;
  22607. /**
  22608. * Gets the tangent data stored in this target
  22609. * @returns a FloatArray containing the tangent data (or null if not present)
  22610. */
  22611. getTangents(): Nullable<FloatArray>;
  22612. /**
  22613. * Affects texture coordinates data to this target
  22614. * @param data defines the texture coordinates data to use
  22615. */
  22616. setUVs(data: Nullable<FloatArray>): void;
  22617. /**
  22618. * Gets the texture coordinates data stored in this target
  22619. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22620. */
  22621. getUVs(): Nullable<FloatArray>;
  22622. /**
  22623. * Serializes the current target into a Serialization object
  22624. * @returns the serialized object
  22625. */
  22626. serialize(): any;
  22627. /**
  22628. * Returns the string "MorphTarget"
  22629. * @returns "MorphTarget"
  22630. */
  22631. getClassName(): string;
  22632. /**
  22633. * Creates a new target from serialized data
  22634. * @param serializationObject defines the serialized data to use
  22635. * @returns a new MorphTarget
  22636. */
  22637. static Parse(serializationObject: any): MorphTarget;
  22638. /**
  22639. * Creates a MorphTarget from mesh data
  22640. * @param mesh defines the source mesh
  22641. * @param name defines the name to use for the new target
  22642. * @param influence defines the influence to attach to the target
  22643. * @returns a new MorphTarget
  22644. */
  22645. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22646. }
  22647. }
  22648. declare module "babylonjs/Morph/morphTargetManager" {
  22649. import { Nullable } from "babylonjs/types";
  22650. import { Scene } from "babylonjs/scene";
  22651. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22652. /**
  22653. * This class is used to deform meshes using morphing between different targets
  22654. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22655. */
  22656. export class MorphTargetManager {
  22657. private _targets;
  22658. private _targetInfluenceChangedObservers;
  22659. private _targetDataLayoutChangedObservers;
  22660. private _activeTargets;
  22661. private _scene;
  22662. private _influences;
  22663. private _supportsNormals;
  22664. private _supportsTangents;
  22665. private _supportsUVs;
  22666. private _vertexCount;
  22667. private _uniqueId;
  22668. private _tempInfluences;
  22669. /**
  22670. * Gets or sets a boolean indicating if normals must be morphed
  22671. */
  22672. enableNormalMorphing: boolean;
  22673. /**
  22674. * Gets or sets a boolean indicating if tangents must be morphed
  22675. */
  22676. enableTangentMorphing: boolean;
  22677. /**
  22678. * Gets or sets a boolean indicating if UV must be morphed
  22679. */
  22680. enableUVMorphing: boolean;
  22681. /**
  22682. * Creates a new MorphTargetManager
  22683. * @param scene defines the current scene
  22684. */
  22685. constructor(scene?: Nullable<Scene>);
  22686. /**
  22687. * Gets the unique ID of this manager
  22688. */
  22689. readonly uniqueId: number;
  22690. /**
  22691. * Gets the number of vertices handled by this manager
  22692. */
  22693. readonly vertexCount: number;
  22694. /**
  22695. * Gets a boolean indicating if this manager supports morphing of normals
  22696. */
  22697. readonly supportsNormals: boolean;
  22698. /**
  22699. * Gets a boolean indicating if this manager supports morphing of tangents
  22700. */
  22701. readonly supportsTangents: boolean;
  22702. /**
  22703. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22704. */
  22705. readonly supportsUVs: boolean;
  22706. /**
  22707. * Gets the number of targets stored in this manager
  22708. */
  22709. readonly numTargets: number;
  22710. /**
  22711. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22712. */
  22713. readonly numInfluencers: number;
  22714. /**
  22715. * Gets the list of influences (one per target)
  22716. */
  22717. readonly influences: Float32Array;
  22718. /**
  22719. * Gets the active target at specified index. An active target is a target with an influence > 0
  22720. * @param index defines the index to check
  22721. * @returns the requested target
  22722. */
  22723. getActiveTarget(index: number): MorphTarget;
  22724. /**
  22725. * Gets the target at specified index
  22726. * @param index defines the index to check
  22727. * @returns the requested target
  22728. */
  22729. getTarget(index: number): MorphTarget;
  22730. /**
  22731. * Add a new target to this manager
  22732. * @param target defines the target to add
  22733. */
  22734. addTarget(target: MorphTarget): void;
  22735. /**
  22736. * Removes a target from the manager
  22737. * @param target defines the target to remove
  22738. */
  22739. removeTarget(target: MorphTarget): void;
  22740. /**
  22741. * Serializes the current manager into a Serialization object
  22742. * @returns the serialized object
  22743. */
  22744. serialize(): any;
  22745. private _syncActiveTargets;
  22746. /**
  22747. * Syncrhonize the targets with all the meshes using this morph target manager
  22748. */
  22749. synchronize(): void;
  22750. /**
  22751. * Creates a new MorphTargetManager from serialized data
  22752. * @param serializationObject defines the serialized data
  22753. * @param scene defines the hosting scene
  22754. * @returns the new MorphTargetManager
  22755. */
  22756. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22757. }
  22758. }
  22759. declare module "babylonjs/Meshes/meshLODLevel" {
  22760. import { Mesh } from "babylonjs/Meshes/mesh";
  22761. import { Nullable } from "babylonjs/types";
  22762. /**
  22763. * Class used to represent a specific level of detail of a mesh
  22764. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22765. */
  22766. export class MeshLODLevel {
  22767. /** Defines the distance where this level should start being displayed */
  22768. distance: number;
  22769. /** Defines the mesh to use to render this level */
  22770. mesh: Nullable<Mesh>;
  22771. /**
  22772. * Creates a new LOD level
  22773. * @param distance defines the distance where this level should star being displayed
  22774. * @param mesh defines the mesh to use to render this level
  22775. */
  22776. constructor(
  22777. /** Defines the distance where this level should start being displayed */
  22778. distance: number,
  22779. /** Defines the mesh to use to render this level */
  22780. mesh: Nullable<Mesh>);
  22781. }
  22782. }
  22783. declare module "babylonjs/Meshes/groundMesh" {
  22784. import { Scene } from "babylonjs/scene";
  22785. import { Vector3 } from "babylonjs/Maths/math.vector";
  22786. import { Mesh } from "babylonjs/Meshes/mesh";
  22787. /**
  22788. * Mesh representing the gorund
  22789. */
  22790. export class GroundMesh extends Mesh {
  22791. /** If octree should be generated */
  22792. generateOctree: boolean;
  22793. private _heightQuads;
  22794. /** @hidden */
  22795. _subdivisionsX: number;
  22796. /** @hidden */
  22797. _subdivisionsY: number;
  22798. /** @hidden */
  22799. _width: number;
  22800. /** @hidden */
  22801. _height: number;
  22802. /** @hidden */
  22803. _minX: number;
  22804. /** @hidden */
  22805. _maxX: number;
  22806. /** @hidden */
  22807. _minZ: number;
  22808. /** @hidden */
  22809. _maxZ: number;
  22810. constructor(name: string, scene: Scene);
  22811. /**
  22812. * "GroundMesh"
  22813. * @returns "GroundMesh"
  22814. */
  22815. getClassName(): string;
  22816. /**
  22817. * The minimum of x and y subdivisions
  22818. */
  22819. readonly subdivisions: number;
  22820. /**
  22821. * X subdivisions
  22822. */
  22823. readonly subdivisionsX: number;
  22824. /**
  22825. * Y subdivisions
  22826. */
  22827. readonly subdivisionsY: number;
  22828. /**
  22829. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22830. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22831. * @param chunksCount the number of subdivisions for x and y
  22832. * @param octreeBlocksSize (Default: 32)
  22833. */
  22834. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22835. /**
  22836. * Returns a height (y) value in the Worl system :
  22837. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22838. * @param x x coordinate
  22839. * @param z z coordinate
  22840. * @returns the ground y position if (x, z) are outside the ground surface.
  22841. */
  22842. getHeightAtCoordinates(x: number, z: number): number;
  22843. /**
  22844. * Returns a normalized vector (Vector3) orthogonal to the ground
  22845. * at the ground coordinates (x, z) expressed in the World system.
  22846. * @param x x coordinate
  22847. * @param z z coordinate
  22848. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22849. */
  22850. getNormalAtCoordinates(x: number, z: number): Vector3;
  22851. /**
  22852. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22853. * at the ground coordinates (x, z) expressed in the World system.
  22854. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22855. * @param x x coordinate
  22856. * @param z z coordinate
  22857. * @param ref vector to store the result
  22858. * @returns the GroundMesh.
  22859. */
  22860. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22861. /**
  22862. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22863. * if the ground has been updated.
  22864. * This can be used in the render loop.
  22865. * @returns the GroundMesh.
  22866. */
  22867. updateCoordinateHeights(): GroundMesh;
  22868. private _getFacetAt;
  22869. private _initHeightQuads;
  22870. private _computeHeightQuads;
  22871. /**
  22872. * Serializes this ground mesh
  22873. * @param serializationObject object to write serialization to
  22874. */
  22875. serialize(serializationObject: any): void;
  22876. /**
  22877. * Parses a serialized ground mesh
  22878. * @param parsedMesh the serialized mesh
  22879. * @param scene the scene to create the ground mesh in
  22880. * @returns the created ground mesh
  22881. */
  22882. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22883. }
  22884. }
  22885. declare module "babylonjs/Physics/physicsJoint" {
  22886. import { Vector3 } from "babylonjs/Maths/math.vector";
  22887. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22888. /**
  22889. * Interface for Physics-Joint data
  22890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22891. */
  22892. export interface PhysicsJointData {
  22893. /**
  22894. * The main pivot of the joint
  22895. */
  22896. mainPivot?: Vector3;
  22897. /**
  22898. * The connected pivot of the joint
  22899. */
  22900. connectedPivot?: Vector3;
  22901. /**
  22902. * The main axis of the joint
  22903. */
  22904. mainAxis?: Vector3;
  22905. /**
  22906. * The connected axis of the joint
  22907. */
  22908. connectedAxis?: Vector3;
  22909. /**
  22910. * The collision of the joint
  22911. */
  22912. collision?: boolean;
  22913. /**
  22914. * Native Oimo/Cannon/Energy data
  22915. */
  22916. nativeParams?: any;
  22917. }
  22918. /**
  22919. * This is a holder class for the physics joint created by the physics plugin
  22920. * It holds a set of functions to control the underlying joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class PhysicsJoint {
  22924. /**
  22925. * The type of the physics joint
  22926. */
  22927. type: number;
  22928. /**
  22929. * The data for the physics joint
  22930. */
  22931. jointData: PhysicsJointData;
  22932. private _physicsJoint;
  22933. protected _physicsPlugin: IPhysicsEnginePlugin;
  22934. /**
  22935. * Initializes the physics joint
  22936. * @param type The type of the physics joint
  22937. * @param jointData The data for the physics joint
  22938. */
  22939. constructor(
  22940. /**
  22941. * The type of the physics joint
  22942. */
  22943. type: number,
  22944. /**
  22945. * The data for the physics joint
  22946. */
  22947. jointData: PhysicsJointData);
  22948. /**
  22949. * Gets the physics joint
  22950. */
  22951. /**
  22952. * Sets the physics joint
  22953. */
  22954. physicsJoint: any;
  22955. /**
  22956. * Sets the physics plugin
  22957. */
  22958. physicsPlugin: IPhysicsEnginePlugin;
  22959. /**
  22960. * Execute a function that is physics-plugin specific.
  22961. * @param {Function} func the function that will be executed.
  22962. * It accepts two parameters: the physics world and the physics joint
  22963. */
  22964. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22965. /**
  22966. * Distance-Joint type
  22967. */
  22968. static DistanceJoint: number;
  22969. /**
  22970. * Hinge-Joint type
  22971. */
  22972. static HingeJoint: number;
  22973. /**
  22974. * Ball-and-Socket joint type
  22975. */
  22976. static BallAndSocketJoint: number;
  22977. /**
  22978. * Wheel-Joint type
  22979. */
  22980. static WheelJoint: number;
  22981. /**
  22982. * Slider-Joint type
  22983. */
  22984. static SliderJoint: number;
  22985. /**
  22986. * Prismatic-Joint type
  22987. */
  22988. static PrismaticJoint: number;
  22989. /**
  22990. * Universal-Joint type
  22991. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22992. */
  22993. static UniversalJoint: number;
  22994. /**
  22995. * Hinge-Joint 2 type
  22996. */
  22997. static Hinge2Joint: number;
  22998. /**
  22999. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23000. */
  23001. static PointToPointJoint: number;
  23002. /**
  23003. * Spring-Joint type
  23004. */
  23005. static SpringJoint: number;
  23006. /**
  23007. * Lock-Joint type
  23008. */
  23009. static LockJoint: number;
  23010. }
  23011. /**
  23012. * A class representing a physics distance joint
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export class DistanceJoint extends PhysicsJoint {
  23016. /**
  23017. *
  23018. * @param jointData The data for the Distance-Joint
  23019. */
  23020. constructor(jointData: DistanceJointData);
  23021. /**
  23022. * Update the predefined distance.
  23023. * @param maxDistance The maximum preferred distance
  23024. * @param minDistance The minimum preferred distance
  23025. */
  23026. updateDistance(maxDistance: number, minDistance?: number): void;
  23027. }
  23028. /**
  23029. * Represents a Motor-Enabled Joint
  23030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23031. */
  23032. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23033. /**
  23034. * Initializes the Motor-Enabled Joint
  23035. * @param type The type of the joint
  23036. * @param jointData The physica joint data for the joint
  23037. */
  23038. constructor(type: number, jointData: PhysicsJointData);
  23039. /**
  23040. * Set the motor values.
  23041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23042. * @param force the force to apply
  23043. * @param maxForce max force for this motor.
  23044. */
  23045. setMotor(force?: number, maxForce?: number): void;
  23046. /**
  23047. * Set the motor's limits.
  23048. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23049. * @param upperLimit The upper limit of the motor
  23050. * @param lowerLimit The lower limit of the motor
  23051. */
  23052. setLimit(upperLimit: number, lowerLimit?: number): void;
  23053. }
  23054. /**
  23055. * This class represents a single physics Hinge-Joint
  23056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23057. */
  23058. export class HingeJoint extends MotorEnabledJoint {
  23059. /**
  23060. * Initializes the Hinge-Joint
  23061. * @param jointData The joint data for the Hinge-Joint
  23062. */
  23063. constructor(jointData: PhysicsJointData);
  23064. /**
  23065. * Set the motor values.
  23066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23067. * @param {number} force the force to apply
  23068. * @param {number} maxForce max force for this motor.
  23069. */
  23070. setMotor(force?: number, maxForce?: number): void;
  23071. /**
  23072. * Set the motor's limits.
  23073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23074. * @param upperLimit The upper limit of the motor
  23075. * @param lowerLimit The lower limit of the motor
  23076. */
  23077. setLimit(upperLimit: number, lowerLimit?: number): void;
  23078. }
  23079. /**
  23080. * This class represents a dual hinge physics joint (same as wheel joint)
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class Hinge2Joint extends MotorEnabledJoint {
  23084. /**
  23085. * Initializes the Hinge2-Joint
  23086. * @param jointData The joint data for the Hinge2-Joint
  23087. */
  23088. constructor(jointData: PhysicsJointData);
  23089. /**
  23090. * Set the motor values.
  23091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23092. * @param {number} targetSpeed the speed the motor is to reach
  23093. * @param {number} maxForce max force for this motor.
  23094. * @param {motorIndex} the motor's index, 0 or 1.
  23095. */
  23096. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23097. /**
  23098. * Set the motor limits.
  23099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23100. * @param {number} upperLimit the upper limit
  23101. * @param {number} lowerLimit lower limit
  23102. * @param {motorIndex} the motor's index, 0 or 1.
  23103. */
  23104. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23105. }
  23106. /**
  23107. * Interface for a motor enabled joint
  23108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export interface IMotorEnabledJoint {
  23111. /**
  23112. * Physics joint
  23113. */
  23114. physicsJoint: any;
  23115. /**
  23116. * Sets the motor of the motor-enabled joint
  23117. * @param force The force of the motor
  23118. * @param maxForce The maximum force of the motor
  23119. * @param motorIndex The index of the motor
  23120. */
  23121. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23122. /**
  23123. * Sets the limit of the motor
  23124. * @param upperLimit The upper limit of the motor
  23125. * @param lowerLimit The lower limit of the motor
  23126. * @param motorIndex The index of the motor
  23127. */
  23128. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23129. }
  23130. /**
  23131. * Joint data for a Distance-Joint
  23132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23133. */
  23134. export interface DistanceJointData extends PhysicsJointData {
  23135. /**
  23136. * Max distance the 2 joint objects can be apart
  23137. */
  23138. maxDistance: number;
  23139. }
  23140. /**
  23141. * Joint data from a spring joint
  23142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23143. */
  23144. export interface SpringJointData extends PhysicsJointData {
  23145. /**
  23146. * Length of the spring
  23147. */
  23148. length: number;
  23149. /**
  23150. * Stiffness of the spring
  23151. */
  23152. stiffness: number;
  23153. /**
  23154. * Damping of the spring
  23155. */
  23156. damping: number;
  23157. /** this callback will be called when applying the force to the impostors. */
  23158. forceApplicationCallback: () => void;
  23159. }
  23160. }
  23161. declare module "babylonjs/Physics/physicsRaycastResult" {
  23162. import { Vector3 } from "babylonjs/Maths/math.vector";
  23163. /**
  23164. * Holds the data for the raycast result
  23165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23166. */
  23167. export class PhysicsRaycastResult {
  23168. private _hasHit;
  23169. private _hitDistance;
  23170. private _hitNormalWorld;
  23171. private _hitPointWorld;
  23172. private _rayFromWorld;
  23173. private _rayToWorld;
  23174. /**
  23175. * Gets if there was a hit
  23176. */
  23177. readonly hasHit: boolean;
  23178. /**
  23179. * Gets the distance from the hit
  23180. */
  23181. readonly hitDistance: number;
  23182. /**
  23183. * Gets the hit normal/direction in the world
  23184. */
  23185. readonly hitNormalWorld: Vector3;
  23186. /**
  23187. * Gets the hit point in the world
  23188. */
  23189. readonly hitPointWorld: Vector3;
  23190. /**
  23191. * Gets the ray "start point" of the ray in the world
  23192. */
  23193. readonly rayFromWorld: Vector3;
  23194. /**
  23195. * Gets the ray "end point" of the ray in the world
  23196. */
  23197. readonly rayToWorld: Vector3;
  23198. /**
  23199. * Sets the hit data (normal & point in world space)
  23200. * @param hitNormalWorld defines the normal in world space
  23201. * @param hitPointWorld defines the point in world space
  23202. */
  23203. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23204. /**
  23205. * Sets the distance from the start point to the hit point
  23206. * @param distance
  23207. */
  23208. setHitDistance(distance: number): void;
  23209. /**
  23210. * Calculates the distance manually
  23211. */
  23212. calculateHitDistance(): void;
  23213. /**
  23214. * Resets all the values to default
  23215. * @param from The from point on world space
  23216. * @param to The to point on world space
  23217. */
  23218. reset(from?: Vector3, to?: Vector3): void;
  23219. }
  23220. /**
  23221. * Interface for the size containing width and height
  23222. */
  23223. interface IXYZ {
  23224. /**
  23225. * X
  23226. */
  23227. x: number;
  23228. /**
  23229. * Y
  23230. */
  23231. y: number;
  23232. /**
  23233. * Z
  23234. */
  23235. z: number;
  23236. }
  23237. }
  23238. declare module "babylonjs/Physics/IPhysicsEngine" {
  23239. import { Nullable } from "babylonjs/types";
  23240. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23242. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23243. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23244. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23245. /**
  23246. * Interface used to describe a physics joint
  23247. */
  23248. export interface PhysicsImpostorJoint {
  23249. /** Defines the main impostor to which the joint is linked */
  23250. mainImpostor: PhysicsImpostor;
  23251. /** Defines the impostor that is connected to the main impostor using this joint */
  23252. connectedImpostor: PhysicsImpostor;
  23253. /** Defines the joint itself */
  23254. joint: PhysicsJoint;
  23255. }
  23256. /** @hidden */
  23257. export interface IPhysicsEnginePlugin {
  23258. world: any;
  23259. name: string;
  23260. setGravity(gravity: Vector3): void;
  23261. setTimeStep(timeStep: number): void;
  23262. getTimeStep(): number;
  23263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23267. removePhysicsBody(impostor: PhysicsImpostor): void;
  23268. generateJoint(joint: PhysicsImpostorJoint): void;
  23269. removeJoint(joint: PhysicsImpostorJoint): void;
  23270. isSupported(): boolean;
  23271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23278. getBodyMass(impostor: PhysicsImpostor): number;
  23279. getBodyFriction(impostor: PhysicsImpostor): number;
  23280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23281. getBodyRestitution(impostor: PhysicsImpostor): number;
  23282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23283. getBodyPressure?(impostor: PhysicsImpostor): number;
  23284. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23285. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23286. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23287. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23288. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23289. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23290. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23291. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23292. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23293. sleepBody(impostor: PhysicsImpostor): void;
  23294. wakeUpBody(impostor: PhysicsImpostor): void;
  23295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23297. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23299. getRadius(impostor: PhysicsImpostor): number;
  23300. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23302. dispose(): void;
  23303. }
  23304. /**
  23305. * Interface used to define a physics engine
  23306. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23307. */
  23308. export interface IPhysicsEngine {
  23309. /**
  23310. * Gets the gravity vector used by the simulation
  23311. */
  23312. gravity: Vector3;
  23313. /**
  23314. * Sets the gravity vector used by the simulation
  23315. * @param gravity defines the gravity vector to use
  23316. */
  23317. setGravity(gravity: Vector3): void;
  23318. /**
  23319. * Set the time step of the physics engine.
  23320. * Default is 1/60.
  23321. * To slow it down, enter 1/600 for example.
  23322. * To speed it up, 1/30
  23323. * @param newTimeStep the new timestep to apply to this world.
  23324. */
  23325. setTimeStep(newTimeStep: number): void;
  23326. /**
  23327. * Get the time step of the physics engine.
  23328. * @returns the current time step
  23329. */
  23330. getTimeStep(): number;
  23331. /**
  23332. * Release all resources
  23333. */
  23334. dispose(): void;
  23335. /**
  23336. * Gets the name of the current physics plugin
  23337. * @returns the name of the plugin
  23338. */
  23339. getPhysicsPluginName(): string;
  23340. /**
  23341. * Adding a new impostor for the impostor tracking.
  23342. * This will be done by the impostor itself.
  23343. * @param impostor the impostor to add
  23344. */
  23345. addImpostor(impostor: PhysicsImpostor): void;
  23346. /**
  23347. * Remove an impostor from the engine.
  23348. * This impostor and its mesh will not longer be updated by the physics engine.
  23349. * @param impostor the impostor to remove
  23350. */
  23351. removeImpostor(impostor: PhysicsImpostor): void;
  23352. /**
  23353. * Add a joint to the physics engine
  23354. * @param mainImpostor defines the main impostor to which the joint is added.
  23355. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23356. * @param joint defines the joint that will connect both impostors.
  23357. */
  23358. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23359. /**
  23360. * Removes a joint from the simulation
  23361. * @param mainImpostor defines the impostor used with the joint
  23362. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23363. * @param joint defines the joint to remove
  23364. */
  23365. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23366. /**
  23367. * Gets the current plugin used to run the simulation
  23368. * @returns current plugin
  23369. */
  23370. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23371. /**
  23372. * Gets the list of physic impostors
  23373. * @returns an array of PhysicsImpostor
  23374. */
  23375. getImpostors(): Array<PhysicsImpostor>;
  23376. /**
  23377. * Gets the impostor for a physics enabled object
  23378. * @param object defines the object impersonated by the impostor
  23379. * @returns the PhysicsImpostor or null if not found
  23380. */
  23381. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23382. /**
  23383. * Gets the impostor for a physics body object
  23384. * @param body defines physics body used by the impostor
  23385. * @returns the PhysicsImpostor or null if not found
  23386. */
  23387. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23388. /**
  23389. * Does a raycast in the physics world
  23390. * @param from when should the ray start?
  23391. * @param to when should the ray end?
  23392. * @returns PhysicsRaycastResult
  23393. */
  23394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23395. /**
  23396. * Called by the scene. No need to call it.
  23397. * @param delta defines the timespam between frames
  23398. */
  23399. _step(delta: number): void;
  23400. }
  23401. }
  23402. declare module "babylonjs/Physics/physicsImpostor" {
  23403. import { Nullable, IndicesArray } from "babylonjs/types";
  23404. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23407. import { Scene } from "babylonjs/scene";
  23408. import { Bone } from "babylonjs/Bones/bone";
  23409. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23410. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23411. import { Space } from "babylonjs/Maths/math.axis";
  23412. /**
  23413. * The interface for the physics imposter parameters
  23414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23415. */
  23416. export interface PhysicsImpostorParameters {
  23417. /**
  23418. * The mass of the physics imposter
  23419. */
  23420. mass: number;
  23421. /**
  23422. * The friction of the physics imposter
  23423. */
  23424. friction?: number;
  23425. /**
  23426. * The coefficient of restitution of the physics imposter
  23427. */
  23428. restitution?: number;
  23429. /**
  23430. * The native options of the physics imposter
  23431. */
  23432. nativeOptions?: any;
  23433. /**
  23434. * Specifies if the parent should be ignored
  23435. */
  23436. ignoreParent?: boolean;
  23437. /**
  23438. * Specifies if bi-directional transformations should be disabled
  23439. */
  23440. disableBidirectionalTransformation?: boolean;
  23441. /**
  23442. * The pressure inside the physics imposter, soft object only
  23443. */
  23444. pressure?: number;
  23445. /**
  23446. * The stiffness the physics imposter, soft object only
  23447. */
  23448. stiffness?: number;
  23449. /**
  23450. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23451. */
  23452. velocityIterations?: number;
  23453. /**
  23454. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23455. */
  23456. positionIterations?: number;
  23457. /**
  23458. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23459. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23460. * Add to fix multiple points
  23461. */
  23462. fixedPoints?: number;
  23463. /**
  23464. * The collision margin around a soft object
  23465. */
  23466. margin?: number;
  23467. /**
  23468. * The collision margin around a soft object
  23469. */
  23470. damping?: number;
  23471. /**
  23472. * The path for a rope based on an extrusion
  23473. */
  23474. path?: any;
  23475. /**
  23476. * The shape of an extrusion used for a rope based on an extrusion
  23477. */
  23478. shape?: any;
  23479. }
  23480. /**
  23481. * Interface for a physics-enabled object
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface IPhysicsEnabledObject {
  23485. /**
  23486. * The position of the physics-enabled object
  23487. */
  23488. position: Vector3;
  23489. /**
  23490. * The rotation of the physics-enabled object
  23491. */
  23492. rotationQuaternion: Nullable<Quaternion>;
  23493. /**
  23494. * The scale of the physics-enabled object
  23495. */
  23496. scaling: Vector3;
  23497. /**
  23498. * The rotation of the physics-enabled object
  23499. */
  23500. rotation?: Vector3;
  23501. /**
  23502. * The parent of the physics-enabled object
  23503. */
  23504. parent?: any;
  23505. /**
  23506. * The bounding info of the physics-enabled object
  23507. * @returns The bounding info of the physics-enabled object
  23508. */
  23509. getBoundingInfo(): BoundingInfo;
  23510. /**
  23511. * Computes the world matrix
  23512. * @param force Specifies if the world matrix should be computed by force
  23513. * @returns A world matrix
  23514. */
  23515. computeWorldMatrix(force: boolean): Matrix;
  23516. /**
  23517. * Gets the world matrix
  23518. * @returns A world matrix
  23519. */
  23520. getWorldMatrix?(): Matrix;
  23521. /**
  23522. * Gets the child meshes
  23523. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23524. * @returns An array of abstract meshes
  23525. */
  23526. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23527. /**
  23528. * Gets the vertex data
  23529. * @param kind The type of vertex data
  23530. * @returns A nullable array of numbers, or a float32 array
  23531. */
  23532. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23533. /**
  23534. * Gets the indices from the mesh
  23535. * @returns A nullable array of index arrays
  23536. */
  23537. getIndices?(): Nullable<IndicesArray>;
  23538. /**
  23539. * Gets the scene from the mesh
  23540. * @returns the indices array or null
  23541. */
  23542. getScene?(): Scene;
  23543. /**
  23544. * Gets the absolute position from the mesh
  23545. * @returns the absolute position
  23546. */
  23547. getAbsolutePosition(): Vector3;
  23548. /**
  23549. * Gets the absolute pivot point from the mesh
  23550. * @returns the absolute pivot point
  23551. */
  23552. getAbsolutePivotPoint(): Vector3;
  23553. /**
  23554. * Rotates the mesh
  23555. * @param axis The axis of rotation
  23556. * @param amount The amount of rotation
  23557. * @param space The space of the rotation
  23558. * @returns The rotation transform node
  23559. */
  23560. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23561. /**
  23562. * Translates the mesh
  23563. * @param axis The axis of translation
  23564. * @param distance The distance of translation
  23565. * @param space The space of the translation
  23566. * @returns The transform node
  23567. */
  23568. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23569. /**
  23570. * Sets the absolute position of the mesh
  23571. * @param absolutePosition The absolute position of the mesh
  23572. * @returns The transform node
  23573. */
  23574. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23575. /**
  23576. * Gets the class name of the mesh
  23577. * @returns The class name
  23578. */
  23579. getClassName(): string;
  23580. }
  23581. /**
  23582. * Represents a physics imposter
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsImpostor {
  23586. /**
  23587. * The physics-enabled object used as the physics imposter
  23588. */
  23589. object: IPhysicsEnabledObject;
  23590. /**
  23591. * The type of the physics imposter
  23592. */
  23593. type: number;
  23594. private _options;
  23595. private _scene?;
  23596. /**
  23597. * The default object size of the imposter
  23598. */
  23599. static DEFAULT_OBJECT_SIZE: Vector3;
  23600. /**
  23601. * The identity quaternion of the imposter
  23602. */
  23603. static IDENTITY_QUATERNION: Quaternion;
  23604. /** @hidden */
  23605. _pluginData: any;
  23606. private _physicsEngine;
  23607. private _physicsBody;
  23608. private _bodyUpdateRequired;
  23609. private _onBeforePhysicsStepCallbacks;
  23610. private _onAfterPhysicsStepCallbacks;
  23611. /** @hidden */
  23612. _onPhysicsCollideCallbacks: Array<{
  23613. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23614. otherImpostors: Array<PhysicsImpostor>;
  23615. }>;
  23616. private _deltaPosition;
  23617. private _deltaRotation;
  23618. private _deltaRotationConjugated;
  23619. /** @hidden */
  23620. _isFromLine: boolean;
  23621. private _parent;
  23622. private _isDisposed;
  23623. private static _tmpVecs;
  23624. private static _tmpQuat;
  23625. /**
  23626. * Specifies if the physics imposter is disposed
  23627. */
  23628. readonly isDisposed: boolean;
  23629. /**
  23630. * Gets the mass of the physics imposter
  23631. */
  23632. mass: number;
  23633. /**
  23634. * Gets the coefficient of friction
  23635. */
  23636. /**
  23637. * Sets the coefficient of friction
  23638. */
  23639. friction: number;
  23640. /**
  23641. * Gets the coefficient of restitution
  23642. */
  23643. /**
  23644. * Sets the coefficient of restitution
  23645. */
  23646. restitution: number;
  23647. /**
  23648. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23649. */
  23650. /**
  23651. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23652. */
  23653. pressure: number;
  23654. /**
  23655. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23656. */
  23657. /**
  23658. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23659. */
  23660. stiffness: number;
  23661. /**
  23662. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23663. */
  23664. /**
  23665. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23666. */
  23667. velocityIterations: number;
  23668. /**
  23669. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23670. */
  23671. /**
  23672. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23673. */
  23674. positionIterations: number;
  23675. /**
  23676. * The unique id of the physics imposter
  23677. * set by the physics engine when adding this impostor to the array
  23678. */
  23679. uniqueId: number;
  23680. /**
  23681. * @hidden
  23682. */
  23683. soft: boolean;
  23684. /**
  23685. * @hidden
  23686. */
  23687. segments: number;
  23688. private _joints;
  23689. /**
  23690. * Initializes the physics imposter
  23691. * @param object The physics-enabled object used as the physics imposter
  23692. * @param type The type of the physics imposter
  23693. * @param _options The options for the physics imposter
  23694. * @param _scene The Babylon scene
  23695. */
  23696. constructor(
  23697. /**
  23698. * The physics-enabled object used as the physics imposter
  23699. */
  23700. object: IPhysicsEnabledObject,
  23701. /**
  23702. * The type of the physics imposter
  23703. */
  23704. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23705. /**
  23706. * This function will completly initialize this impostor.
  23707. * It will create a new body - but only if this mesh has no parent.
  23708. * If it has, this impostor will not be used other than to define the impostor
  23709. * of the child mesh.
  23710. * @hidden
  23711. */
  23712. _init(): void;
  23713. private _getPhysicsParent;
  23714. /**
  23715. * Should a new body be generated.
  23716. * @returns boolean specifying if body initialization is required
  23717. */
  23718. isBodyInitRequired(): boolean;
  23719. /**
  23720. * Sets the updated scaling
  23721. * @param updated Specifies if the scaling is updated
  23722. */
  23723. setScalingUpdated(): void;
  23724. /**
  23725. * Force a regeneration of this or the parent's impostor's body.
  23726. * Use under cautious - This will remove all joints already implemented.
  23727. */
  23728. forceUpdate(): void;
  23729. /**
  23730. * Gets the body that holds this impostor. Either its own, or its parent.
  23731. */
  23732. /**
  23733. * Set the physics body. Used mainly by the physics engine/plugin
  23734. */
  23735. physicsBody: any;
  23736. /**
  23737. * Get the parent of the physics imposter
  23738. * @returns Physics imposter or null
  23739. */
  23740. /**
  23741. * Sets the parent of the physics imposter
  23742. */
  23743. parent: Nullable<PhysicsImpostor>;
  23744. /**
  23745. * Resets the update flags
  23746. */
  23747. resetUpdateFlags(): void;
  23748. /**
  23749. * Gets the object extend size
  23750. * @returns the object extend size
  23751. */
  23752. getObjectExtendSize(): Vector3;
  23753. /**
  23754. * Gets the object center
  23755. * @returns The object center
  23756. */
  23757. getObjectCenter(): Vector3;
  23758. /**
  23759. * Get a specific parametes from the options parameter
  23760. * @param paramName The object parameter name
  23761. * @returns The object parameter
  23762. */
  23763. getParam(paramName: string): any;
  23764. /**
  23765. * Sets a specific parameter in the options given to the physics plugin
  23766. * @param paramName The parameter name
  23767. * @param value The value of the parameter
  23768. */
  23769. setParam(paramName: string, value: number): void;
  23770. /**
  23771. * Specifically change the body's mass option. Won't recreate the physics body object
  23772. * @param mass The mass of the physics imposter
  23773. */
  23774. setMass(mass: number): void;
  23775. /**
  23776. * Gets the linear velocity
  23777. * @returns linear velocity or null
  23778. */
  23779. getLinearVelocity(): Nullable<Vector3>;
  23780. /**
  23781. * Sets the linear velocity
  23782. * @param velocity linear velocity or null
  23783. */
  23784. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23785. /**
  23786. * Gets the angular velocity
  23787. * @returns angular velocity or null
  23788. */
  23789. getAngularVelocity(): Nullable<Vector3>;
  23790. /**
  23791. * Sets the angular velocity
  23792. * @param velocity The velocity or null
  23793. */
  23794. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23795. /**
  23796. * Execute a function with the physics plugin native code
  23797. * Provide a function the will have two variables - the world object and the physics body object
  23798. * @param func The function to execute with the physics plugin native code
  23799. */
  23800. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23801. /**
  23802. * Register a function that will be executed before the physics world is stepping forward
  23803. * @param func The function to execute before the physics world is stepped forward
  23804. */
  23805. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23806. /**
  23807. * Unregister a function that will be executed before the physics world is stepping forward
  23808. * @param func The function to execute before the physics world is stepped forward
  23809. */
  23810. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23811. /**
  23812. * Register a function that will be executed after the physics step
  23813. * @param func The function to execute after physics step
  23814. */
  23815. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23816. /**
  23817. * Unregisters a function that will be executed after the physics step
  23818. * @param func The function to execute after physics step
  23819. */
  23820. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23821. /**
  23822. * register a function that will be executed when this impostor collides against a different body
  23823. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23824. * @param func Callback that is executed on collision
  23825. */
  23826. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23827. /**
  23828. * Unregisters the physics imposter on contact
  23829. * @param collideAgainst The physics object to collide against
  23830. * @param func Callback to execute on collision
  23831. */
  23832. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23833. private _tmpQuat;
  23834. private _tmpQuat2;
  23835. /**
  23836. * Get the parent rotation
  23837. * @returns The parent rotation
  23838. */
  23839. getParentsRotation(): Quaternion;
  23840. /**
  23841. * this function is executed by the physics engine.
  23842. */
  23843. beforeStep: () => void;
  23844. /**
  23845. * this function is executed by the physics engine
  23846. */
  23847. afterStep: () => void;
  23848. /**
  23849. * Legacy collision detection event support
  23850. */
  23851. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23852. /**
  23853. * event and body object due to cannon's event-based architecture.
  23854. */
  23855. onCollide: (e: {
  23856. body: any;
  23857. }) => void;
  23858. /**
  23859. * Apply a force
  23860. * @param force The force to apply
  23861. * @param contactPoint The contact point for the force
  23862. * @returns The physics imposter
  23863. */
  23864. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23865. /**
  23866. * Apply an impulse
  23867. * @param force The impulse force
  23868. * @param contactPoint The contact point for the impulse force
  23869. * @returns The physics imposter
  23870. */
  23871. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23872. /**
  23873. * A help function to create a joint
  23874. * @param otherImpostor A physics imposter used to create a joint
  23875. * @param jointType The type of joint
  23876. * @param jointData The data for the joint
  23877. * @returns The physics imposter
  23878. */
  23879. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23880. /**
  23881. * Add a joint to this impostor with a different impostor
  23882. * @param otherImpostor A physics imposter used to add a joint
  23883. * @param joint The joint to add
  23884. * @returns The physics imposter
  23885. */
  23886. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23887. /**
  23888. * Add an anchor to a cloth impostor
  23889. * @param otherImpostor rigid impostor to anchor to
  23890. * @param width ratio across width from 0 to 1
  23891. * @param height ratio up height from 0 to 1
  23892. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23893. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23894. * @returns impostor the soft imposter
  23895. */
  23896. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23897. /**
  23898. * Add a hook to a rope impostor
  23899. * @param otherImpostor rigid impostor to anchor to
  23900. * @param length ratio across rope from 0 to 1
  23901. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23903. * @returns impostor the rope imposter
  23904. */
  23905. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23906. /**
  23907. * Will keep this body still, in a sleep mode.
  23908. * @returns the physics imposter
  23909. */
  23910. sleep(): PhysicsImpostor;
  23911. /**
  23912. * Wake the body up.
  23913. * @returns The physics imposter
  23914. */
  23915. wakeUp(): PhysicsImpostor;
  23916. /**
  23917. * Clones the physics imposter
  23918. * @param newObject The physics imposter clones to this physics-enabled object
  23919. * @returns A nullable physics imposter
  23920. */
  23921. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23922. /**
  23923. * Disposes the physics imposter
  23924. */
  23925. dispose(): void;
  23926. /**
  23927. * Sets the delta position
  23928. * @param position The delta position amount
  23929. */
  23930. setDeltaPosition(position: Vector3): void;
  23931. /**
  23932. * Sets the delta rotation
  23933. * @param rotation The delta rotation amount
  23934. */
  23935. setDeltaRotation(rotation: Quaternion): void;
  23936. /**
  23937. * Gets the box size of the physics imposter and stores the result in the input parameter
  23938. * @param result Stores the box size
  23939. * @returns The physics imposter
  23940. */
  23941. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23942. /**
  23943. * Gets the radius of the physics imposter
  23944. * @returns Radius of the physics imposter
  23945. */
  23946. getRadius(): number;
  23947. /**
  23948. * Sync a bone with this impostor
  23949. * @param bone The bone to sync to the impostor.
  23950. * @param boneMesh The mesh that the bone is influencing.
  23951. * @param jointPivot The pivot of the joint / bone in local space.
  23952. * @param distToJoint Optional distance from the impostor to the joint.
  23953. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23954. */
  23955. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23956. /**
  23957. * Sync impostor to a bone
  23958. * @param bone The bone that the impostor will be synced to.
  23959. * @param boneMesh The mesh that the bone is influencing.
  23960. * @param jointPivot The pivot of the joint / bone in local space.
  23961. * @param distToJoint Optional distance from the impostor to the joint.
  23962. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23963. * @param boneAxis Optional vector3 axis the bone is aligned with
  23964. */
  23965. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23966. /**
  23967. * No-Imposter type
  23968. */
  23969. static NoImpostor: number;
  23970. /**
  23971. * Sphere-Imposter type
  23972. */
  23973. static SphereImpostor: number;
  23974. /**
  23975. * Box-Imposter type
  23976. */
  23977. static BoxImpostor: number;
  23978. /**
  23979. * Plane-Imposter type
  23980. */
  23981. static PlaneImpostor: number;
  23982. /**
  23983. * Mesh-imposter type
  23984. */
  23985. static MeshImpostor: number;
  23986. /**
  23987. * Capsule-Impostor type (Ammo.js plugin only)
  23988. */
  23989. static CapsuleImpostor: number;
  23990. /**
  23991. * Cylinder-Imposter type
  23992. */
  23993. static CylinderImpostor: number;
  23994. /**
  23995. * Particle-Imposter type
  23996. */
  23997. static ParticleImpostor: number;
  23998. /**
  23999. * Heightmap-Imposter type
  24000. */
  24001. static HeightmapImpostor: number;
  24002. /**
  24003. * ConvexHull-Impostor type (Ammo.js plugin only)
  24004. */
  24005. static ConvexHullImpostor: number;
  24006. /**
  24007. * Rope-Imposter type
  24008. */
  24009. static RopeImpostor: number;
  24010. /**
  24011. * Cloth-Imposter type
  24012. */
  24013. static ClothImpostor: number;
  24014. /**
  24015. * Softbody-Imposter type
  24016. */
  24017. static SoftbodyImpostor: number;
  24018. }
  24019. }
  24020. declare module "babylonjs/Meshes/mesh" {
  24021. import { Observable } from "babylonjs/Misc/observable";
  24022. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24023. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24024. import { Camera } from "babylonjs/Cameras/camera";
  24025. import { Scene } from "babylonjs/scene";
  24026. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24027. import { Color4 } from "babylonjs/Maths/math.color";
  24028. import { Engine } from "babylonjs/Engines/engine";
  24029. import { Node } from "babylonjs/node";
  24030. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24031. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24032. import { Buffer } from "babylonjs/Meshes/buffer";
  24033. import { Geometry } from "babylonjs/Meshes/geometry";
  24034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24035. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24036. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24037. import { Effect } from "babylonjs/Materials/effect";
  24038. import { Material } from "babylonjs/Materials/material";
  24039. import { Skeleton } from "babylonjs/Bones/skeleton";
  24040. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24041. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24042. import { Path3D } from "babylonjs/Maths/math.path";
  24043. import { Plane } from "babylonjs/Maths/math.plane";
  24044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24045. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24046. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24047. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24048. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24049. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24050. /**
  24051. * @hidden
  24052. **/
  24053. export class _CreationDataStorage {
  24054. closePath?: boolean;
  24055. closeArray?: boolean;
  24056. idx: number[];
  24057. dashSize: number;
  24058. gapSize: number;
  24059. path3D: Path3D;
  24060. pathArray: Vector3[][];
  24061. arc: number;
  24062. radius: number;
  24063. cap: number;
  24064. tessellation: number;
  24065. }
  24066. /**
  24067. * @hidden
  24068. **/
  24069. class _InstanceDataStorage {
  24070. visibleInstances: any;
  24071. batchCache: _InstancesBatch;
  24072. instancesBufferSize: number;
  24073. instancesBuffer: Nullable<Buffer>;
  24074. instancesData: Float32Array;
  24075. overridenInstanceCount: number;
  24076. isFrozen: boolean;
  24077. previousBatch: Nullable<_InstancesBatch>;
  24078. hardwareInstancedRendering: boolean;
  24079. sideOrientation: number;
  24080. }
  24081. /**
  24082. * @hidden
  24083. **/
  24084. export class _InstancesBatch {
  24085. mustReturn: boolean;
  24086. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24087. renderSelf: boolean[];
  24088. hardwareInstancedRendering: boolean[];
  24089. }
  24090. /**
  24091. * Class used to represent renderable models
  24092. */
  24093. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24094. /**
  24095. * Mesh side orientation : usually the external or front surface
  24096. */
  24097. static readonly FRONTSIDE: number;
  24098. /**
  24099. * Mesh side orientation : usually the internal or back surface
  24100. */
  24101. static readonly BACKSIDE: number;
  24102. /**
  24103. * Mesh side orientation : both internal and external or front and back surfaces
  24104. */
  24105. static readonly DOUBLESIDE: number;
  24106. /**
  24107. * Mesh side orientation : by default, `FRONTSIDE`
  24108. */
  24109. static readonly DEFAULTSIDE: number;
  24110. /**
  24111. * Mesh cap setting : no cap
  24112. */
  24113. static readonly NO_CAP: number;
  24114. /**
  24115. * Mesh cap setting : one cap at the beginning of the mesh
  24116. */
  24117. static readonly CAP_START: number;
  24118. /**
  24119. * Mesh cap setting : one cap at the end of the mesh
  24120. */
  24121. static readonly CAP_END: number;
  24122. /**
  24123. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24124. */
  24125. static readonly CAP_ALL: number;
  24126. /**
  24127. * Mesh pattern setting : no flip or rotate
  24128. */
  24129. static readonly NO_FLIP: number;
  24130. /**
  24131. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24132. */
  24133. static readonly FLIP_TILE: number;
  24134. /**
  24135. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24136. */
  24137. static readonly ROTATE_TILE: number;
  24138. /**
  24139. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24140. */
  24141. static readonly FLIP_ROW: number;
  24142. /**
  24143. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24144. */
  24145. static readonly ROTATE_ROW: number;
  24146. /**
  24147. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24148. */
  24149. static readonly FLIP_N_ROTATE_TILE: number;
  24150. /**
  24151. * Mesh pattern setting : rotate pattern and rotate
  24152. */
  24153. static readonly FLIP_N_ROTATE_ROW: number;
  24154. /**
  24155. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24156. */
  24157. static readonly CENTER: number;
  24158. /**
  24159. * Mesh tile positioning : part tiles on left
  24160. */
  24161. static readonly LEFT: number;
  24162. /**
  24163. * Mesh tile positioning : part tiles on right
  24164. */
  24165. static readonly RIGHT: number;
  24166. /**
  24167. * Mesh tile positioning : part tiles on top
  24168. */
  24169. static readonly TOP: number;
  24170. /**
  24171. * Mesh tile positioning : part tiles on bottom
  24172. */
  24173. static readonly BOTTOM: number;
  24174. /**
  24175. * Gets the default side orientation.
  24176. * @param orientation the orientation to value to attempt to get
  24177. * @returns the default orientation
  24178. * @hidden
  24179. */
  24180. static _GetDefaultSideOrientation(orientation?: number): number;
  24181. private _internalMeshDataInfo;
  24182. /**
  24183. * An event triggered before rendering the mesh
  24184. */
  24185. readonly onBeforeRenderObservable: Observable<Mesh>;
  24186. /**
  24187. * An event triggered before binding the mesh
  24188. */
  24189. readonly onBeforeBindObservable: Observable<Mesh>;
  24190. /**
  24191. * An event triggered after rendering the mesh
  24192. */
  24193. readonly onAfterRenderObservable: Observable<Mesh>;
  24194. /**
  24195. * An event triggered before drawing the mesh
  24196. */
  24197. readonly onBeforeDrawObservable: Observable<Mesh>;
  24198. private _onBeforeDrawObserver;
  24199. /**
  24200. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24201. */
  24202. onBeforeDraw: () => void;
  24203. readonly hasInstances: boolean;
  24204. /**
  24205. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24206. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24207. */
  24208. delayLoadState: number;
  24209. /**
  24210. * Gets the list of instances created from this mesh
  24211. * it is not supposed to be modified manually.
  24212. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24214. */
  24215. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24216. /**
  24217. * Gets the file containing delay loading data for this mesh
  24218. */
  24219. delayLoadingFile: string;
  24220. /** @hidden */
  24221. _binaryInfo: any;
  24222. /**
  24223. * User defined function used to change how LOD level selection is done
  24224. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24225. */
  24226. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24227. /**
  24228. * Gets or sets the morph target manager
  24229. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24230. */
  24231. morphTargetManager: Nullable<MorphTargetManager>;
  24232. /** @hidden */
  24233. _creationDataStorage: Nullable<_CreationDataStorage>;
  24234. /** @hidden */
  24235. _geometry: Nullable<Geometry>;
  24236. /** @hidden */
  24237. _delayInfo: Array<string>;
  24238. /** @hidden */
  24239. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24240. /** @hidden */
  24241. _instanceDataStorage: _InstanceDataStorage;
  24242. private _effectiveMaterial;
  24243. /** @hidden */
  24244. _shouldGenerateFlatShading: boolean;
  24245. /** @hidden */
  24246. _originalBuilderSideOrientation: number;
  24247. /**
  24248. * Use this property to change the original side orientation defined at construction time
  24249. */
  24250. overrideMaterialSideOrientation: Nullable<number>;
  24251. /**
  24252. * Gets the source mesh (the one used to clone this one from)
  24253. */
  24254. readonly source: Nullable<Mesh>;
  24255. /**
  24256. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24257. */
  24258. isUnIndexed: boolean;
  24259. /**
  24260. * @constructor
  24261. * @param name The value used by scene.getMeshByName() to do a lookup.
  24262. * @param scene The scene to add this mesh to.
  24263. * @param parent The parent of this mesh, if it has one
  24264. * @param source An optional Mesh from which geometry is shared, cloned.
  24265. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24266. * When false, achieved by calling a clone(), also passing False.
  24267. * This will make creation of children, recursive.
  24268. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24269. */
  24270. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24271. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24272. /**
  24273. * Gets the class name
  24274. * @returns the string "Mesh".
  24275. */
  24276. getClassName(): string;
  24277. /** @hidden */
  24278. readonly _isMesh: boolean;
  24279. /**
  24280. * Returns a description of this mesh
  24281. * @param fullDetails define if full details about this mesh must be used
  24282. * @returns a descriptive string representing this mesh
  24283. */
  24284. toString(fullDetails?: boolean): string;
  24285. /** @hidden */
  24286. _unBindEffect(): void;
  24287. /**
  24288. * Gets a boolean indicating if this mesh has LOD
  24289. */
  24290. readonly hasLODLevels: boolean;
  24291. /**
  24292. * Gets the list of MeshLODLevel associated with the current mesh
  24293. * @returns an array of MeshLODLevel
  24294. */
  24295. getLODLevels(): MeshLODLevel[];
  24296. private _sortLODLevels;
  24297. /**
  24298. * Add a mesh as LOD level triggered at the given distance.
  24299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24300. * @param distance The distance from the center of the object to show this level
  24301. * @param mesh The mesh to be added as LOD level (can be null)
  24302. * @return This mesh (for chaining)
  24303. */
  24304. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24305. /**
  24306. * Returns the LOD level mesh at the passed distance or null if not found.
  24307. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24308. * @param distance The distance from the center of the object to show this level
  24309. * @returns a Mesh or `null`
  24310. */
  24311. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24312. /**
  24313. * Remove a mesh from the LOD array
  24314. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24315. * @param mesh defines the mesh to be removed
  24316. * @return This mesh (for chaining)
  24317. */
  24318. removeLODLevel(mesh: Mesh): Mesh;
  24319. /**
  24320. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24322. * @param camera defines the camera to use to compute distance
  24323. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24324. * @return This mesh (for chaining)
  24325. */
  24326. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24327. /**
  24328. * Gets the mesh internal Geometry object
  24329. */
  24330. readonly geometry: Nullable<Geometry>;
  24331. /**
  24332. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24333. * @returns the total number of vertices
  24334. */
  24335. getTotalVertices(): number;
  24336. /**
  24337. * Returns the content of an associated vertex buffer
  24338. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24339. * - VertexBuffer.PositionKind
  24340. * - VertexBuffer.UVKind
  24341. * - VertexBuffer.UV2Kind
  24342. * - VertexBuffer.UV3Kind
  24343. * - VertexBuffer.UV4Kind
  24344. * - VertexBuffer.UV5Kind
  24345. * - VertexBuffer.UV6Kind
  24346. * - VertexBuffer.ColorKind
  24347. * - VertexBuffer.MatricesIndicesKind
  24348. * - VertexBuffer.MatricesIndicesExtraKind
  24349. * - VertexBuffer.MatricesWeightsKind
  24350. * - VertexBuffer.MatricesWeightsExtraKind
  24351. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24352. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24353. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24354. */
  24355. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24356. /**
  24357. * Returns the mesh VertexBuffer object from the requested `kind`
  24358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24359. * - VertexBuffer.PositionKind
  24360. * - VertexBuffer.NormalKind
  24361. * - VertexBuffer.UVKind
  24362. * - VertexBuffer.UV2Kind
  24363. * - VertexBuffer.UV3Kind
  24364. * - VertexBuffer.UV4Kind
  24365. * - VertexBuffer.UV5Kind
  24366. * - VertexBuffer.UV6Kind
  24367. * - VertexBuffer.ColorKind
  24368. * - VertexBuffer.MatricesIndicesKind
  24369. * - VertexBuffer.MatricesIndicesExtraKind
  24370. * - VertexBuffer.MatricesWeightsKind
  24371. * - VertexBuffer.MatricesWeightsExtraKind
  24372. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24373. */
  24374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24375. /**
  24376. * Tests if a specific vertex buffer is associated with this mesh
  24377. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.NormalKind
  24380. * - VertexBuffer.UVKind
  24381. * - VertexBuffer.UV2Kind
  24382. * - VertexBuffer.UV3Kind
  24383. * - VertexBuffer.UV4Kind
  24384. * - VertexBuffer.UV5Kind
  24385. * - VertexBuffer.UV6Kind
  24386. * - VertexBuffer.ColorKind
  24387. * - VertexBuffer.MatricesIndicesKind
  24388. * - VertexBuffer.MatricesIndicesExtraKind
  24389. * - VertexBuffer.MatricesWeightsKind
  24390. * - VertexBuffer.MatricesWeightsExtraKind
  24391. * @returns a boolean
  24392. */
  24393. isVerticesDataPresent(kind: string): boolean;
  24394. /**
  24395. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24396. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24397. * - VertexBuffer.PositionKind
  24398. * - VertexBuffer.UVKind
  24399. * - VertexBuffer.UV2Kind
  24400. * - VertexBuffer.UV3Kind
  24401. * - VertexBuffer.UV4Kind
  24402. * - VertexBuffer.UV5Kind
  24403. * - VertexBuffer.UV6Kind
  24404. * - VertexBuffer.ColorKind
  24405. * - VertexBuffer.MatricesIndicesKind
  24406. * - VertexBuffer.MatricesIndicesExtraKind
  24407. * - VertexBuffer.MatricesWeightsKind
  24408. * - VertexBuffer.MatricesWeightsExtraKind
  24409. * @returns a boolean
  24410. */
  24411. isVertexBufferUpdatable(kind: string): boolean;
  24412. /**
  24413. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24414. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24415. * - VertexBuffer.PositionKind
  24416. * - VertexBuffer.NormalKind
  24417. * - VertexBuffer.UVKind
  24418. * - VertexBuffer.UV2Kind
  24419. * - VertexBuffer.UV3Kind
  24420. * - VertexBuffer.UV4Kind
  24421. * - VertexBuffer.UV5Kind
  24422. * - VertexBuffer.UV6Kind
  24423. * - VertexBuffer.ColorKind
  24424. * - VertexBuffer.MatricesIndicesKind
  24425. * - VertexBuffer.MatricesIndicesExtraKind
  24426. * - VertexBuffer.MatricesWeightsKind
  24427. * - VertexBuffer.MatricesWeightsExtraKind
  24428. * @returns an array of strings
  24429. */
  24430. getVerticesDataKinds(): string[];
  24431. /**
  24432. * Returns a positive integer : the total number of indices in this mesh geometry.
  24433. * @returns the numner of indices or zero if the mesh has no geometry.
  24434. */
  24435. getTotalIndices(): number;
  24436. /**
  24437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24438. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24439. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24440. * @returns the indices array or an empty array if the mesh has no geometry
  24441. */
  24442. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24443. readonly isBlocked: boolean;
  24444. /**
  24445. * Determine if the current mesh is ready to be rendered
  24446. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24447. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24448. * @returns true if all associated assets are ready (material, textures, shaders)
  24449. */
  24450. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24451. /**
  24452. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24453. */
  24454. readonly areNormalsFrozen: boolean;
  24455. /**
  24456. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24457. * @returns the current mesh
  24458. */
  24459. freezeNormals(): Mesh;
  24460. /**
  24461. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24462. * @returns the current mesh
  24463. */
  24464. unfreezeNormals(): Mesh;
  24465. /**
  24466. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24467. */
  24468. overridenInstanceCount: number;
  24469. /** @hidden */
  24470. _preActivate(): Mesh;
  24471. /** @hidden */
  24472. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24473. /** @hidden */
  24474. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24475. /**
  24476. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24477. * This means the mesh underlying bounding box and sphere are recomputed.
  24478. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24479. * @returns the current mesh
  24480. */
  24481. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24482. /** @hidden */
  24483. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24484. /**
  24485. * This function will subdivide the mesh into multiple submeshes
  24486. * @param count defines the expected number of submeshes
  24487. */
  24488. subdivide(count: number): void;
  24489. /**
  24490. * Copy a FloatArray into a specific associated vertex buffer
  24491. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.UVKind
  24494. * - VertexBuffer.UV2Kind
  24495. * - VertexBuffer.UV3Kind
  24496. * - VertexBuffer.UV4Kind
  24497. * - VertexBuffer.UV5Kind
  24498. * - VertexBuffer.UV6Kind
  24499. * - VertexBuffer.ColorKind
  24500. * - VertexBuffer.MatricesIndicesKind
  24501. * - VertexBuffer.MatricesIndicesExtraKind
  24502. * - VertexBuffer.MatricesWeightsKind
  24503. * - VertexBuffer.MatricesWeightsExtraKind
  24504. * @param data defines the data source
  24505. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24506. * @param stride defines the data stride size (can be null)
  24507. * @returns the current mesh
  24508. */
  24509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24510. /**
  24511. * Flags an associated vertex buffer as updatable
  24512. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24513. * - VertexBuffer.PositionKind
  24514. * - VertexBuffer.UVKind
  24515. * - VertexBuffer.UV2Kind
  24516. * - VertexBuffer.UV3Kind
  24517. * - VertexBuffer.UV4Kind
  24518. * - VertexBuffer.UV5Kind
  24519. * - VertexBuffer.UV6Kind
  24520. * - VertexBuffer.ColorKind
  24521. * - VertexBuffer.MatricesIndicesKind
  24522. * - VertexBuffer.MatricesIndicesExtraKind
  24523. * - VertexBuffer.MatricesWeightsKind
  24524. * - VertexBuffer.MatricesWeightsExtraKind
  24525. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24526. */
  24527. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24528. /**
  24529. * Sets the mesh global Vertex Buffer
  24530. * @param buffer defines the buffer to use
  24531. * @returns the current mesh
  24532. */
  24533. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24534. /**
  24535. * Update a specific associated vertex buffer
  24536. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @param data defines the data source
  24550. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24551. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24552. * @returns the current mesh
  24553. */
  24554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24555. /**
  24556. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24557. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24558. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24559. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24560. * @returns the current mesh
  24561. */
  24562. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24563. /**
  24564. * Creates a un-shared specific occurence of the geometry for the mesh.
  24565. * @returns the current mesh
  24566. */
  24567. makeGeometryUnique(): Mesh;
  24568. /**
  24569. * Set the index buffer of this mesh
  24570. * @param indices defines the source data
  24571. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24572. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24573. * @returns the current mesh
  24574. */
  24575. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24576. /**
  24577. * Update the current index buffer
  24578. * @param indices defines the source data
  24579. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24580. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24581. * @returns the current mesh
  24582. */
  24583. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24584. /**
  24585. * Invert the geometry to move from a right handed system to a left handed one.
  24586. * @returns the current mesh
  24587. */
  24588. toLeftHanded(): Mesh;
  24589. /** @hidden */
  24590. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24591. /** @hidden */
  24592. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24593. /**
  24594. * Registers for this mesh a javascript function called just before the rendering process
  24595. * @param func defines the function to call before rendering this mesh
  24596. * @returns the current mesh
  24597. */
  24598. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24599. /**
  24600. * Disposes a previously registered javascript function called before the rendering
  24601. * @param func defines the function to remove
  24602. * @returns the current mesh
  24603. */
  24604. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24605. /**
  24606. * Registers for this mesh a javascript function called just after the rendering is complete
  24607. * @param func defines the function to call after rendering this mesh
  24608. * @returns the current mesh
  24609. */
  24610. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24611. /**
  24612. * Disposes a previously registered javascript function called after the rendering.
  24613. * @param func defines the function to remove
  24614. * @returns the current mesh
  24615. */
  24616. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24617. /** @hidden */
  24618. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24619. /** @hidden */
  24620. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24621. /** @hidden */
  24622. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24623. /** @hidden */
  24624. _rebuild(): void;
  24625. /** @hidden */
  24626. _freeze(): void;
  24627. /** @hidden */
  24628. _unFreeze(): void;
  24629. /**
  24630. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  24631. * @param subMesh defines the subMesh to render
  24632. * @param enableAlphaMode defines if alpha mode can be changed
  24633. * @returns the current mesh
  24634. */
  24635. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24636. private _onBeforeDraw;
  24637. /**
  24638. * Renormalize the mesh and patch it up if there are no weights
  24639. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24640. * However in the case of zero weights then we set just a single influence to 1.
  24641. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24642. */
  24643. cleanMatrixWeights(): void;
  24644. private normalizeSkinFourWeights;
  24645. private normalizeSkinWeightsAndExtra;
  24646. /**
  24647. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24648. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24649. * the user know there was an issue with importing the mesh
  24650. * @returns a validation object with skinned, valid and report string
  24651. */
  24652. validateSkinning(): {
  24653. skinned: boolean;
  24654. valid: boolean;
  24655. report: string;
  24656. };
  24657. /** @hidden */
  24658. _checkDelayState(): Mesh;
  24659. private _queueLoad;
  24660. /**
  24661. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24662. * A mesh is in the frustum if its bounding box intersects the frustum
  24663. * @param frustumPlanes defines the frustum to test
  24664. * @returns true if the mesh is in the frustum planes
  24665. */
  24666. isInFrustum(frustumPlanes: Plane[]): boolean;
  24667. /**
  24668. * Sets the mesh material by the material or multiMaterial `id` property
  24669. * @param id is a string identifying the material or the multiMaterial
  24670. * @returns the current mesh
  24671. */
  24672. setMaterialByID(id: string): Mesh;
  24673. /**
  24674. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24675. * @returns an array of IAnimatable
  24676. */
  24677. getAnimatables(): IAnimatable[];
  24678. /**
  24679. * Modifies the mesh geometry according to the passed transformation matrix.
  24680. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24681. * The mesh normals are modified using the same transformation.
  24682. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24683. * @param transform defines the transform matrix to use
  24684. * @see http://doc.babylonjs.com/resources/baking_transformations
  24685. * @returns the current mesh
  24686. */
  24687. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24688. /**
  24689. * Modifies the mesh geometry according to its own current World Matrix.
  24690. * The mesh World Matrix is then reset.
  24691. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24692. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24693. * @see http://doc.babylonjs.com/resources/baking_transformations
  24694. * @returns the current mesh
  24695. */
  24696. bakeCurrentTransformIntoVertices(): Mesh;
  24697. /** @hidden */
  24698. readonly _positions: Nullable<Vector3[]>;
  24699. /** @hidden */
  24700. _resetPointsArrayCache(): Mesh;
  24701. /** @hidden */
  24702. _generatePointsArray(): boolean;
  24703. /**
  24704. * Returns a new Mesh object generated from the current mesh properties.
  24705. * This method must not get confused with createInstance()
  24706. * @param name is a string, the name given to the new mesh
  24707. * @param newParent can be any Node object (default `null`)
  24708. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24709. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24710. * @returns a new mesh
  24711. */
  24712. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24713. /**
  24714. * Releases resources associated with this mesh.
  24715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24717. */
  24718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24719. /**
  24720. * Modifies the mesh geometry according to a displacement map.
  24721. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24722. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24723. * @param url is a string, the URL from the image file is to be downloaded.
  24724. * @param minHeight is the lower limit of the displacement.
  24725. * @param maxHeight is the upper limit of the displacement.
  24726. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24727. * @param uvOffset is an optional vector2 used to offset UV.
  24728. * @param uvScale is an optional vector2 used to scale UV.
  24729. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24730. * @returns the Mesh.
  24731. */
  24732. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24733. /**
  24734. * Modifies the mesh geometry according to a displacementMap buffer.
  24735. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24736. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24737. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24738. * @param heightMapWidth is the width of the buffer image.
  24739. * @param heightMapHeight is the height of the buffer image.
  24740. * @param minHeight is the lower limit of the displacement.
  24741. * @param maxHeight is the upper limit of the displacement.
  24742. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24743. * @param uvOffset is an optional vector2 used to offset UV.
  24744. * @param uvScale is an optional vector2 used to scale UV.
  24745. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24746. * @returns the Mesh.
  24747. */
  24748. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24749. /**
  24750. * Modify the mesh to get a flat shading rendering.
  24751. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24752. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24753. * @returns current mesh
  24754. */
  24755. convertToFlatShadedMesh(): Mesh;
  24756. /**
  24757. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24758. * In other words, more vertices, no more indices and a single bigger VBO.
  24759. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24760. * @returns current mesh
  24761. */
  24762. convertToUnIndexedMesh(): Mesh;
  24763. /**
  24764. * Inverses facet orientations.
  24765. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24766. * @param flipNormals will also inverts the normals
  24767. * @returns current mesh
  24768. */
  24769. flipFaces(flipNormals?: boolean): Mesh;
  24770. /**
  24771. * Increase the number of facets and hence vertices in a mesh
  24772. * Vertex normals are interpolated from existing vertex normals
  24773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24774. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24775. */
  24776. increaseVertices(numberPerEdge: number): void;
  24777. /**
  24778. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24779. * This will undo any application of covertToFlatShadedMesh
  24780. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24781. */
  24782. forceSharedVertices(): void;
  24783. /** @hidden */
  24784. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24785. /** @hidden */
  24786. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24787. /**
  24788. * Creates a new InstancedMesh object from the mesh model.
  24789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24790. * @param name defines the name of the new instance
  24791. * @returns a new InstancedMesh
  24792. */
  24793. createInstance(name: string): InstancedMesh;
  24794. /**
  24795. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24796. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24797. * @returns the current mesh
  24798. */
  24799. synchronizeInstances(): Mesh;
  24800. /**
  24801. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24802. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24803. * This should be used together with the simplification to avoid disappearing triangles.
  24804. * @param successCallback an optional success callback to be called after the optimization finished.
  24805. * @returns the current mesh
  24806. */
  24807. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24808. /**
  24809. * Serialize current mesh
  24810. * @param serializationObject defines the object which will receive the serialization data
  24811. */
  24812. serialize(serializationObject: any): void;
  24813. /** @hidden */
  24814. _syncGeometryWithMorphTargetManager(): void;
  24815. /** @hidden */
  24816. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24817. /**
  24818. * Returns a new Mesh object parsed from the source provided.
  24819. * @param parsedMesh is the source
  24820. * @param scene defines the hosting scene
  24821. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24822. * @returns a new Mesh
  24823. */
  24824. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24825. /**
  24826. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24827. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24828. * @param name defines the name of the mesh to create
  24829. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24830. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24831. * @param closePath creates a seam between the first and the last points of each path of the path array
  24832. * @param offset is taken in account only if the `pathArray` is containing a single path
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24837. * @returns a new Mesh
  24838. */
  24839. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24840. /**
  24841. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24844. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24845. * @param scene defines the hosting scene
  24846. * @param updatable defines if the mesh must be flagged as updatable
  24847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24851. /**
  24852. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24853. * @param name defines the name of the mesh to create
  24854. * @param size sets the size (float) of each box side (default 1)
  24855. * @param scene defines the hosting scene
  24856. * @param updatable defines if the mesh must be flagged as updatable
  24857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24858. * @returns a new Mesh
  24859. */
  24860. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24861. /**
  24862. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24863. * @param name defines the name of the mesh to create
  24864. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24865. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24872. /**
  24873. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24874. * @param name defines the name of the mesh to create
  24875. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24876. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24877. * @param scene defines the hosting scene
  24878. * @returns a new Mesh
  24879. */
  24880. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24881. /**
  24882. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24883. * @param name defines the name of the mesh to create
  24884. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24885. * @param diameterTop set the top cap diameter (floats, default 1)
  24886. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24887. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24888. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24889. * @param scene defines the hosting scene
  24890. * @param updatable defines if the mesh must be flagged as updatable
  24891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24892. * @returns a new Mesh
  24893. */
  24894. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24895. /**
  24896. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24897. * @param name defines the name of the mesh to create
  24898. * @param diameter sets the diameter size (float) of the torus (default 1)
  24899. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24900. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24901. * @param scene defines the hosting scene
  24902. * @param updatable defines if the mesh must be flagged as updatable
  24903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24904. * @returns a new Mesh
  24905. */
  24906. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24907. /**
  24908. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24909. * @param name defines the name of the mesh to create
  24910. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24911. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24912. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24913. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24914. * @param p the number of windings on X axis (positive integers, default 2)
  24915. * @param q the number of windings on Y axis (positive integers, default 3)
  24916. * @param scene defines the hosting scene
  24917. * @param updatable defines if the mesh must be flagged as updatable
  24918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24919. * @returns a new Mesh
  24920. */
  24921. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24922. /**
  24923. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24924. * @param name defines the name of the mesh to create
  24925. * @param points is an array successive Vector3
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24932. /**
  24933. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param points is an array successive Vector3
  24936. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24937. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24938. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24945. /**
  24946. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24947. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24948. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  24949. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24951. * Remember you can only change the shape positions, not their number when updating a polygon.
  24952. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24953. * @param name defines the name of the mesh to create
  24954. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24955. * @param scene defines the hosting scene
  24956. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @param earcutInjection can be used to inject your own earcut reference
  24960. * @returns a new Mesh
  24961. */
  24962. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24963. /**
  24964. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24966. * @param name defines the name of the mesh to create
  24967. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24968. * @param depth defines the height of extrusion
  24969. * @param scene defines the hosting scene
  24970. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @param earcutInjection can be used to inject your own earcut reference
  24974. * @returns a new Mesh
  24975. */
  24976. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24977. /**
  24978. * Creates an extruded shape mesh.
  24979. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24980. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24981. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24982. * @param name defines the name of the mesh to create
  24983. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24984. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24985. * @param scale is the value to scale the shape
  24986. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  24987. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24991. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24992. * @returns a new Mesh
  24993. */
  24994. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24995. /**
  24996. * Creates an custom extruded shape mesh.
  24997. * The custom extrusion is a parametric shape.
  24998. * It has no predefined shape. Its final shape will depend on the input parameters.
  24999. * Please consider using the same method from the MeshBuilder class instead
  25000. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25001. * @param name defines the name of the mesh to create
  25002. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25003. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25004. * @param scaleFunction is a custom Javascript function called on each path point
  25005. * @param rotationFunction is a custom Javascript function called on each path point
  25006. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25007. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25008. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25009. * @param scene defines the hosting scene
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25013. * @returns a new Mesh
  25014. */
  25015. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25016. /**
  25017. * Creates lathe mesh.
  25018. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25019. * Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25022. * @param radius is the radius value of the lathe
  25023. * @param tessellation is the side number of the lathe.
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @returns a new Mesh
  25028. */
  25029. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25030. /**
  25031. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25032. * @param name defines the name of the mesh to create
  25033. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25034. * @param scene defines the hosting scene
  25035. * @param updatable defines if the mesh must be flagged as updatable
  25036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25037. * @returns a new Mesh
  25038. */
  25039. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25040. /**
  25041. * Creates a ground mesh.
  25042. * Please consider using the same method from the MeshBuilder class instead
  25043. * @param name defines the name of the mesh to create
  25044. * @param width set the width of the ground
  25045. * @param height set the height of the ground
  25046. * @param subdivisions sets the number of subdivisions per side
  25047. * @param scene defines the hosting scene
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @returns a new Mesh
  25050. */
  25051. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25052. /**
  25053. * Creates a tiled ground mesh.
  25054. * Please consider using the same method from the MeshBuilder class instead
  25055. * @param name defines the name of the mesh to create
  25056. * @param xmin set the ground minimum X coordinate
  25057. * @param zmin set the ground minimum Y coordinate
  25058. * @param xmax set the ground maximum X coordinate
  25059. * @param zmax set the ground maximum Z coordinate
  25060. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25061. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25067. w: number;
  25068. h: number;
  25069. }, precision: {
  25070. w: number;
  25071. h: number;
  25072. }, scene: Scene, updatable?: boolean): Mesh;
  25073. /**
  25074. * Creates a ground mesh from a height map.
  25075. * Please consider using the same method from the MeshBuilder class instead
  25076. * @see http://doc.babylonjs.com/babylon101/height_map
  25077. * @param name defines the name of the mesh to create
  25078. * @param url sets the URL of the height map image resource
  25079. * @param width set the ground width size
  25080. * @param height set the ground height size
  25081. * @param subdivisions sets the number of subdivision per side
  25082. * @param minHeight is the minimum altitude on the ground
  25083. * @param maxHeight is the maximum altitude on the ground
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25087. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25088. * @returns a new Mesh
  25089. */
  25090. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25091. /**
  25092. * Creates a tube mesh.
  25093. * The tube is a parametric shape.
  25094. * It has no predefined shape. Its final shape will depend on the input parameters.
  25095. * Please consider using the same method from the MeshBuilder class instead
  25096. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25097. * @param name defines the name of the mesh to create
  25098. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25099. * @param radius sets the tube radius size
  25100. * @param tessellation is the number of sides on the tubular surface
  25101. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25102. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25103. * @param scene defines the hosting scene
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25110. (i: number, distance: number): number;
  25111. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25112. /**
  25113. * Creates a polyhedron mesh.
  25114. * Please consider using the same method from the MeshBuilder class instead.
  25115. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25116. * * The parameter `size` (positive float, default 1) sets the polygon size
  25117. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25118. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25119. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25120. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25121. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25122. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25123. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25126. * @param name defines the name of the mesh to create
  25127. * @param options defines the options used to create the mesh
  25128. * @param scene defines the hosting scene
  25129. * @returns a new Mesh
  25130. */
  25131. static CreatePolyhedron(name: string, options: {
  25132. type?: number;
  25133. size?: number;
  25134. sizeX?: number;
  25135. sizeY?: number;
  25136. sizeZ?: number;
  25137. custom?: any;
  25138. faceUV?: Vector4[];
  25139. faceColors?: Color4[];
  25140. updatable?: boolean;
  25141. sideOrientation?: number;
  25142. }, scene: Scene): Mesh;
  25143. /**
  25144. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25145. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25146. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25147. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25148. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25149. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25152. * @param name defines the name of the mesh
  25153. * @param options defines the options used to create the mesh
  25154. * @param scene defines the hosting scene
  25155. * @returns a new Mesh
  25156. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25157. */
  25158. static CreateIcoSphere(name: string, options: {
  25159. radius?: number;
  25160. flat?: boolean;
  25161. subdivisions?: number;
  25162. sideOrientation?: number;
  25163. updatable?: boolean;
  25164. }, scene: Scene): Mesh;
  25165. /**
  25166. * Creates a decal mesh.
  25167. * Please consider using the same method from the MeshBuilder class instead.
  25168. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25169. * @param name defines the name of the mesh
  25170. * @param sourceMesh defines the mesh receiving the decal
  25171. * @param position sets the position of the decal in world coordinates
  25172. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25173. * @param size sets the decal scaling
  25174. * @param angle sets the angle to rotate the decal
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25178. /**
  25179. * Prepare internal position array for software CPU skinning
  25180. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25181. */
  25182. setPositionsForCPUSkinning(): Float32Array;
  25183. /**
  25184. * Prepare internal normal array for software CPU skinning
  25185. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25186. */
  25187. setNormalsForCPUSkinning(): Float32Array;
  25188. /**
  25189. * Updates the vertex buffer by applying transformation from the bones
  25190. * @param skeleton defines the skeleton to apply to current mesh
  25191. * @returns the current mesh
  25192. */
  25193. applySkeleton(skeleton: Skeleton): Mesh;
  25194. /**
  25195. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25196. * @param meshes defines the list of meshes to scan
  25197. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25198. */
  25199. static MinMax(meshes: AbstractMesh[]): {
  25200. min: Vector3;
  25201. max: Vector3;
  25202. };
  25203. /**
  25204. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25205. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25206. * @returns a vector3
  25207. */
  25208. static Center(meshesOrMinMaxVector: {
  25209. min: Vector3;
  25210. max: Vector3;
  25211. } | AbstractMesh[]): Vector3;
  25212. /**
  25213. * Merge the array of meshes into a single mesh for performance reasons.
  25214. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25215. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25216. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25217. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25218. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25219. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25220. * @returns a new mesh
  25221. */
  25222. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25223. /** @hidden */
  25224. addInstance(instance: InstancedMesh): void;
  25225. /** @hidden */
  25226. removeInstance(instance: InstancedMesh): void;
  25227. }
  25228. }
  25229. declare module "babylonjs/Cameras/camera" {
  25230. import { SmartArray } from "babylonjs/Misc/smartArray";
  25231. import { Observable } from "babylonjs/Misc/observable";
  25232. import { Nullable } from "babylonjs/types";
  25233. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25234. import { Scene } from "babylonjs/scene";
  25235. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25236. import { Node } from "babylonjs/node";
  25237. import { Mesh } from "babylonjs/Meshes/mesh";
  25238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25239. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25240. import { Viewport } from "babylonjs/Maths/math.viewport";
  25241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25244. import { Ray } from "babylonjs/Culling/ray";
  25245. /**
  25246. * This is the base class of all the camera used in the application.
  25247. * @see http://doc.babylonjs.com/features/cameras
  25248. */
  25249. export class Camera extends Node {
  25250. /** @hidden */
  25251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25252. /**
  25253. * This is the default projection mode used by the cameras.
  25254. * It helps recreating a feeling of perspective and better appreciate depth.
  25255. * This is the best way to simulate real life cameras.
  25256. */
  25257. static readonly PERSPECTIVE_CAMERA: number;
  25258. /**
  25259. * This helps creating camera with an orthographic mode.
  25260. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25261. */
  25262. static readonly ORTHOGRAPHIC_CAMERA: number;
  25263. /**
  25264. * This is the default FOV mode for perspective cameras.
  25265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25266. */
  25267. static readonly FOVMODE_VERTICAL_FIXED: number;
  25268. /**
  25269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25270. */
  25271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25272. /**
  25273. * This specifies ther is no need for a camera rig.
  25274. * Basically only one eye is rendered corresponding to the camera.
  25275. */
  25276. static readonly RIG_MODE_NONE: number;
  25277. /**
  25278. * Simulates a camera Rig with one blue eye and one red eye.
  25279. * This can be use with 3d blue and red glasses.
  25280. */
  25281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25282. /**
  25283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25284. */
  25285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25286. /**
  25287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25288. */
  25289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25290. /**
  25291. * Defines that both eyes of the camera will be rendered over under each other.
  25292. */
  25293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25294. /**
  25295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25296. */
  25297. static readonly RIG_MODE_VR: number;
  25298. /**
  25299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25300. */
  25301. static readonly RIG_MODE_WEBVR: number;
  25302. /**
  25303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25304. */
  25305. static readonly RIG_MODE_CUSTOM: number;
  25306. /**
  25307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25308. */
  25309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25310. /**
  25311. * Define the input manager associated with the camera.
  25312. */
  25313. inputs: CameraInputsManager<Camera>;
  25314. /** @hidden */
  25315. _position: Vector3;
  25316. /**
  25317. * Define the current local position of the camera in the scene
  25318. */
  25319. position: Vector3;
  25320. /**
  25321. * The vector the camera should consider as up.
  25322. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25323. */
  25324. upVector: Vector3;
  25325. /**
  25326. * Define the current limit on the left side for an orthographic camera
  25327. * In scene unit
  25328. */
  25329. orthoLeft: Nullable<number>;
  25330. /**
  25331. * Define the current limit on the right side for an orthographic camera
  25332. * In scene unit
  25333. */
  25334. orthoRight: Nullable<number>;
  25335. /**
  25336. * Define the current limit on the bottom side for an orthographic camera
  25337. * In scene unit
  25338. */
  25339. orthoBottom: Nullable<number>;
  25340. /**
  25341. * Define the current limit on the top side for an orthographic camera
  25342. * In scene unit
  25343. */
  25344. orthoTop: Nullable<number>;
  25345. /**
  25346. * Field Of View is set in Radians. (default is 0.8)
  25347. */
  25348. fov: number;
  25349. /**
  25350. * Define the minimum distance the camera can see from.
  25351. * This is important to note that the depth buffer are not infinite and the closer it starts
  25352. * the more your scene might encounter depth fighting issue.
  25353. */
  25354. minZ: number;
  25355. /**
  25356. * Define the maximum distance the camera can see to.
  25357. * This is important to note that the depth buffer are not infinite and the further it end
  25358. * the more your scene might encounter depth fighting issue.
  25359. */
  25360. maxZ: number;
  25361. /**
  25362. * Define the default inertia of the camera.
  25363. * This helps giving a smooth feeling to the camera movement.
  25364. */
  25365. inertia: number;
  25366. /**
  25367. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25368. */
  25369. mode: number;
  25370. /**
  25371. * Define wether the camera is intermediate.
  25372. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25373. */
  25374. isIntermediate: boolean;
  25375. /**
  25376. * Define the viewport of the camera.
  25377. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25378. */
  25379. viewport: Viewport;
  25380. /**
  25381. * Restricts the camera to viewing objects with the same layerMask.
  25382. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25383. */
  25384. layerMask: number;
  25385. /**
  25386. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25387. */
  25388. fovMode: number;
  25389. /**
  25390. * Rig mode of the camera.
  25391. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25392. * This is normally controlled byt the camera themselves as internal use.
  25393. */
  25394. cameraRigMode: number;
  25395. /**
  25396. * Defines the distance between both "eyes" in case of a RIG
  25397. */
  25398. interaxialDistance: number;
  25399. /**
  25400. * Defines if stereoscopic rendering is done side by side or over under.
  25401. */
  25402. isStereoscopicSideBySide: boolean;
  25403. /**
  25404. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25405. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25406. * else in the scene. (Eg. security camera)
  25407. *
  25408. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25409. */
  25410. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25411. /**
  25412. * When set, the camera will render to this render target instead of the default canvas
  25413. *
  25414. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25415. */
  25416. outputRenderTarget: Nullable<RenderTargetTexture>;
  25417. /**
  25418. * Observable triggered when the camera view matrix has changed.
  25419. */
  25420. onViewMatrixChangedObservable: Observable<Camera>;
  25421. /**
  25422. * Observable triggered when the camera Projection matrix has changed.
  25423. */
  25424. onProjectionMatrixChangedObservable: Observable<Camera>;
  25425. /**
  25426. * Observable triggered when the inputs have been processed.
  25427. */
  25428. onAfterCheckInputsObservable: Observable<Camera>;
  25429. /**
  25430. * Observable triggered when reset has been called and applied to the camera.
  25431. */
  25432. onRestoreStateObservable: Observable<Camera>;
  25433. /** @hidden */
  25434. _cameraRigParams: any;
  25435. /** @hidden */
  25436. _rigCameras: Camera[];
  25437. /** @hidden */
  25438. _rigPostProcess: Nullable<PostProcess>;
  25439. protected _webvrViewMatrix: Matrix;
  25440. /** @hidden */
  25441. _skipRendering: boolean;
  25442. /** @hidden */
  25443. _projectionMatrix: Matrix;
  25444. /** @hidden */
  25445. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25446. /** @hidden */
  25447. _activeMeshes: SmartArray<AbstractMesh>;
  25448. protected _globalPosition: Vector3;
  25449. /** @hidden */
  25450. _computedViewMatrix: Matrix;
  25451. private _doNotComputeProjectionMatrix;
  25452. private _transformMatrix;
  25453. private _frustumPlanes;
  25454. private _refreshFrustumPlanes;
  25455. private _storedFov;
  25456. private _stateStored;
  25457. /**
  25458. * Instantiates a new camera object.
  25459. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25460. * @see http://doc.babylonjs.com/features/cameras
  25461. * @param name Defines the name of the camera in the scene
  25462. * @param position Defines the position of the camera
  25463. * @param scene Defines the scene the camera belongs too
  25464. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25465. */
  25466. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25467. /**
  25468. * Store current camera state (fov, position, etc..)
  25469. * @returns the camera
  25470. */
  25471. storeState(): Camera;
  25472. /**
  25473. * Restores the camera state values if it has been stored. You must call storeState() first
  25474. */
  25475. protected _restoreStateValues(): boolean;
  25476. /**
  25477. * Restored camera state. You must call storeState() first.
  25478. * @returns true if restored and false otherwise
  25479. */
  25480. restoreState(): boolean;
  25481. /**
  25482. * Gets the class name of the camera.
  25483. * @returns the class name
  25484. */
  25485. getClassName(): string;
  25486. /** @hidden */
  25487. readonly _isCamera: boolean;
  25488. /**
  25489. * Gets a string representation of the camera useful for debug purpose.
  25490. * @param fullDetails Defines that a more verboe level of logging is required
  25491. * @returns the string representation
  25492. */
  25493. toString(fullDetails?: boolean): string;
  25494. /**
  25495. * Gets the current world space position of the camera.
  25496. */
  25497. readonly globalPosition: Vector3;
  25498. /**
  25499. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25500. * @returns the active meshe list
  25501. */
  25502. getActiveMeshes(): SmartArray<AbstractMesh>;
  25503. /**
  25504. * Check wether a mesh is part of the current active mesh list of the camera
  25505. * @param mesh Defines the mesh to check
  25506. * @returns true if active, false otherwise
  25507. */
  25508. isActiveMesh(mesh: Mesh): boolean;
  25509. /**
  25510. * Is this camera ready to be used/rendered
  25511. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25512. * @return true if the camera is ready
  25513. */
  25514. isReady(completeCheck?: boolean): boolean;
  25515. /** @hidden */
  25516. _initCache(): void;
  25517. /** @hidden */
  25518. _updateCache(ignoreParentClass?: boolean): void;
  25519. /** @hidden */
  25520. _isSynchronized(): boolean;
  25521. /** @hidden */
  25522. _isSynchronizedViewMatrix(): boolean;
  25523. /** @hidden */
  25524. _isSynchronizedProjectionMatrix(): boolean;
  25525. /**
  25526. * Attach the input controls to a specific dom element to get the input from.
  25527. * @param element Defines the element the controls should be listened from
  25528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25529. */
  25530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25531. /**
  25532. * Detach the current controls from the specified dom element.
  25533. * @param element Defines the element to stop listening the inputs from
  25534. */
  25535. detachControl(element: HTMLElement): void;
  25536. /**
  25537. * Update the camera state according to the different inputs gathered during the frame.
  25538. */
  25539. update(): void;
  25540. /** @hidden */
  25541. _checkInputs(): void;
  25542. /** @hidden */
  25543. readonly rigCameras: Camera[];
  25544. /**
  25545. * Gets the post process used by the rig cameras
  25546. */
  25547. readonly rigPostProcess: Nullable<PostProcess>;
  25548. /**
  25549. * Internal, gets the first post proces.
  25550. * @returns the first post process to be run on this camera.
  25551. */
  25552. _getFirstPostProcess(): Nullable<PostProcess>;
  25553. private _cascadePostProcessesToRigCams;
  25554. /**
  25555. * Attach a post process to the camera.
  25556. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25557. * @param postProcess The post process to attach to the camera
  25558. * @param insertAt The position of the post process in case several of them are in use in the scene
  25559. * @returns the position the post process has been inserted at
  25560. */
  25561. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25562. /**
  25563. * Detach a post process to the camera.
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25565. * @param postProcess The post process to detach from the camera
  25566. */
  25567. detachPostProcess(postProcess: PostProcess): void;
  25568. /**
  25569. * Gets the current world matrix of the camera
  25570. */
  25571. getWorldMatrix(): Matrix;
  25572. /** @hidden */
  25573. _getViewMatrix(): Matrix;
  25574. /**
  25575. * Gets the current view matrix of the camera.
  25576. * @param force forces the camera to recompute the matrix without looking at the cached state
  25577. * @returns the view matrix
  25578. */
  25579. getViewMatrix(force?: boolean): Matrix;
  25580. /**
  25581. * Freeze the projection matrix.
  25582. * It will prevent the cache check of the camera projection compute and can speed up perf
  25583. * if no parameter of the camera are meant to change
  25584. * @param projection Defines manually a projection if necessary
  25585. */
  25586. freezeProjectionMatrix(projection?: Matrix): void;
  25587. /**
  25588. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25589. */
  25590. unfreezeProjectionMatrix(): void;
  25591. /**
  25592. * Gets the current projection matrix of the camera.
  25593. * @param force forces the camera to recompute the matrix without looking at the cached state
  25594. * @returns the projection matrix
  25595. */
  25596. getProjectionMatrix(force?: boolean): Matrix;
  25597. /**
  25598. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25599. * @returns a Matrix
  25600. */
  25601. getTransformationMatrix(): Matrix;
  25602. private _updateFrustumPlanes;
  25603. /**
  25604. * Checks if a cullable object (mesh...) is in the camera frustum
  25605. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25606. * @param target The object to check
  25607. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25608. * @returns true if the object is in frustum otherwise false
  25609. */
  25610. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25611. /**
  25612. * Checks if a cullable object (mesh...) is in the camera frustum
  25613. * Unlike isInFrustum this cheks the full bounding box
  25614. * @param target The object to check
  25615. * @returns true if the object is in frustum otherwise false
  25616. */
  25617. isCompletelyInFrustum(target: ICullable): boolean;
  25618. /**
  25619. * Gets a ray in the forward direction from the camera.
  25620. * @param length Defines the length of the ray to create
  25621. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25622. * @param origin Defines the start point of the ray which defaults to the camera position
  25623. * @returns the forward ray
  25624. */
  25625. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25626. /**
  25627. * Releases resources associated with this node.
  25628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25630. */
  25631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25632. /** @hidden */
  25633. _isLeftCamera: boolean;
  25634. /**
  25635. * Gets the left camera of a rig setup in case of Rigged Camera
  25636. */
  25637. readonly isLeftCamera: boolean;
  25638. /** @hidden */
  25639. _isRightCamera: boolean;
  25640. /**
  25641. * Gets the right camera of a rig setup in case of Rigged Camera
  25642. */
  25643. readonly isRightCamera: boolean;
  25644. /**
  25645. * Gets the left camera of a rig setup in case of Rigged Camera
  25646. */
  25647. readonly leftCamera: Nullable<FreeCamera>;
  25648. /**
  25649. * Gets the right camera of a rig setup in case of Rigged Camera
  25650. */
  25651. readonly rightCamera: Nullable<FreeCamera>;
  25652. /**
  25653. * Gets the left camera target of a rig setup in case of Rigged Camera
  25654. * @returns the target position
  25655. */
  25656. getLeftTarget(): Nullable<Vector3>;
  25657. /**
  25658. * Gets the right camera target of a rig setup in case of Rigged Camera
  25659. * @returns the target position
  25660. */
  25661. getRightTarget(): Nullable<Vector3>;
  25662. /**
  25663. * @hidden
  25664. */
  25665. setCameraRigMode(mode: number, rigParams: any): void;
  25666. /** @hidden */
  25667. static _setStereoscopicRigMode(camera: Camera): void;
  25668. /** @hidden */
  25669. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25670. /** @hidden */
  25671. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25672. /** @hidden */
  25673. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25674. /** @hidden */
  25675. _getVRProjectionMatrix(): Matrix;
  25676. protected _updateCameraRotationMatrix(): void;
  25677. protected _updateWebVRCameraRotationMatrix(): void;
  25678. /**
  25679. * This function MUST be overwritten by the different WebVR cameras available.
  25680. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25681. * @hidden
  25682. */
  25683. _getWebVRProjectionMatrix(): Matrix;
  25684. /**
  25685. * This function MUST be overwritten by the different WebVR cameras available.
  25686. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25687. * @hidden
  25688. */
  25689. _getWebVRViewMatrix(): Matrix;
  25690. /** @hidden */
  25691. setCameraRigParameter(name: string, value: any): void;
  25692. /**
  25693. * needs to be overridden by children so sub has required properties to be copied
  25694. * @hidden
  25695. */
  25696. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25697. /**
  25698. * May need to be overridden by children
  25699. * @hidden
  25700. */
  25701. _updateRigCameras(): void;
  25702. /** @hidden */
  25703. _setupInputs(): void;
  25704. /**
  25705. * Serialiaze the camera setup to a json represention
  25706. * @returns the JSON representation
  25707. */
  25708. serialize(): any;
  25709. /**
  25710. * Clones the current camera.
  25711. * @param name The cloned camera name
  25712. * @returns the cloned camera
  25713. */
  25714. clone(name: string): Camera;
  25715. /**
  25716. * Gets the direction of the camera relative to a given local axis.
  25717. * @param localAxis Defines the reference axis to provide a relative direction.
  25718. * @return the direction
  25719. */
  25720. getDirection(localAxis: Vector3): Vector3;
  25721. /**
  25722. * Returns the current camera absolute rotation
  25723. */
  25724. readonly absoluteRotation: Quaternion;
  25725. /**
  25726. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25727. * @param localAxis Defines the reference axis to provide a relative direction.
  25728. * @param result Defines the vector to store the result in
  25729. */
  25730. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25731. /**
  25732. * Gets a camera constructor for a given camera type
  25733. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25734. * @param name The name of the camera the result will be able to instantiate
  25735. * @param scene The scene the result will construct the camera in
  25736. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25737. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25738. * @returns a factory method to construc the camera
  25739. */
  25740. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25741. /**
  25742. * Compute the world matrix of the camera.
  25743. * @returns the camera workd matrix
  25744. */
  25745. computeWorldMatrix(): Matrix;
  25746. /**
  25747. * Parse a JSON and creates the camera from the parsed information
  25748. * @param parsedCamera The JSON to parse
  25749. * @param scene The scene to instantiate the camera in
  25750. * @returns the newly constructed camera
  25751. */
  25752. static Parse(parsedCamera: any, scene: Scene): Camera;
  25753. }
  25754. }
  25755. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25756. import { Nullable } from "babylonjs/types";
  25757. import { Scene } from "babylonjs/scene";
  25758. import { Vector4 } from "babylonjs/Maths/math.vector";
  25759. import { Mesh } from "babylonjs/Meshes/mesh";
  25760. /**
  25761. * Class containing static functions to help procedurally build meshes
  25762. */
  25763. export class DiscBuilder {
  25764. /**
  25765. * Creates a plane polygonal mesh. By default, this is a disc
  25766. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25767. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25768. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  25769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25772. * @param name defines the name of the mesh
  25773. * @param options defines the options used to create the mesh
  25774. * @param scene defines the hosting scene
  25775. * @returns the plane polygonal mesh
  25776. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25777. */
  25778. static CreateDisc(name: string, options: {
  25779. radius?: number;
  25780. tessellation?: number;
  25781. arc?: number;
  25782. updatable?: boolean;
  25783. sideOrientation?: number;
  25784. frontUVs?: Vector4;
  25785. backUVs?: Vector4;
  25786. }, scene?: Nullable<Scene>): Mesh;
  25787. }
  25788. }
  25789. declare module "babylonjs/Particles/solidParticleSystem" {
  25790. import { Vector3 } from "babylonjs/Maths/math.vector";
  25791. import { Mesh } from "babylonjs/Meshes/mesh";
  25792. import { Scene, IDisposable } from "babylonjs/scene";
  25793. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25794. /**
  25795. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25796. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  25797. * The SPS is also a particle system. It provides some methods to manage the particles.
  25798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25799. *
  25800. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25801. */
  25802. export class SolidParticleSystem implements IDisposable {
  25803. /**
  25804. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25805. * Example : var p = SPS.particles[i];
  25806. */
  25807. particles: SolidParticle[];
  25808. /**
  25809. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25810. */
  25811. nbParticles: number;
  25812. /**
  25813. * If the particles must ever face the camera (default false). Useful for planar particles.
  25814. */
  25815. billboard: boolean;
  25816. /**
  25817. * Recompute normals when adding a shape
  25818. */
  25819. recomputeNormals: boolean;
  25820. /**
  25821. * This a counter ofr your own usage. It's not set by any SPS functions.
  25822. */
  25823. counter: number;
  25824. /**
  25825. * The SPS name. This name is also given to the underlying mesh.
  25826. */
  25827. name: string;
  25828. /**
  25829. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25830. */
  25831. mesh: Mesh;
  25832. /**
  25833. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25834. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25835. */
  25836. vars: any;
  25837. /**
  25838. * This array is populated when the SPS is set as 'pickable'.
  25839. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25840. * Each element of this array is an object `{idx: int, faceId: int}`.
  25841. * `idx` is the picked particle index in the `SPS.particles` array
  25842. * `faceId` is the picked face index counted within this particle.
  25843. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25844. */
  25845. pickedParticles: {
  25846. idx: number;
  25847. faceId: number;
  25848. }[];
  25849. /**
  25850. * This array is populated when `enableDepthSort` is set to true.
  25851. * Each element of this array is an instance of the class DepthSortedParticle.
  25852. */
  25853. depthSortedParticles: DepthSortedParticle[];
  25854. /**
  25855. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25856. * @hidden
  25857. */
  25858. _bSphereOnly: boolean;
  25859. /**
  25860. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25861. * @hidden
  25862. */
  25863. _bSphereRadiusFactor: number;
  25864. private _scene;
  25865. private _positions;
  25866. private _indices;
  25867. private _normals;
  25868. private _colors;
  25869. private _uvs;
  25870. private _indices32;
  25871. private _positions32;
  25872. private _normals32;
  25873. private _fixedNormal32;
  25874. private _colors32;
  25875. private _uvs32;
  25876. private _index;
  25877. private _updatable;
  25878. private _pickable;
  25879. private _isVisibilityBoxLocked;
  25880. private _alwaysVisible;
  25881. private _depthSort;
  25882. private _shapeCounter;
  25883. private _copy;
  25884. private _color;
  25885. private _computeParticleColor;
  25886. private _computeParticleTexture;
  25887. private _computeParticleRotation;
  25888. private _computeParticleVertex;
  25889. private _computeBoundingBox;
  25890. private _depthSortParticles;
  25891. private _camera;
  25892. private _mustUnrotateFixedNormals;
  25893. private _particlesIntersect;
  25894. private _needs32Bits;
  25895. /**
  25896. * Creates a SPS (Solid Particle System) object.
  25897. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25898. * @param scene (Scene) is the scene in which the SPS is added.
  25899. * @param options defines the options of the sps e.g.
  25900. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25901. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25902. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25903. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25904. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25905. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25906. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25907. */
  25908. constructor(name: string, scene: Scene, options?: {
  25909. updatable?: boolean;
  25910. isPickable?: boolean;
  25911. enableDepthSort?: boolean;
  25912. particleIntersection?: boolean;
  25913. boundingSphereOnly?: boolean;
  25914. bSphereRadiusFactor?: number;
  25915. });
  25916. /**
  25917. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25918. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25919. * @returns the created mesh
  25920. */
  25921. buildMesh(): Mesh;
  25922. /**
  25923. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25924. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25925. * Thus the particles generated from `digest()` have their property `position` set yet.
  25926. * @param mesh ( Mesh ) is the mesh to be digested
  25927. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  25928. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25929. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25930. * @returns the current SPS
  25931. */
  25932. digest(mesh: Mesh, options?: {
  25933. facetNb?: number;
  25934. number?: number;
  25935. delta?: number;
  25936. }): SolidParticleSystem;
  25937. private _unrotateFixedNormals;
  25938. private _resetCopy;
  25939. private _meshBuilder;
  25940. private _posToShape;
  25941. private _uvsToShapeUV;
  25942. private _addParticle;
  25943. /**
  25944. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25945. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25946. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25947. * @param nb (positive integer) the number of particles to be created from this model
  25948. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25949. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25950. * @returns the number of shapes in the system
  25951. */
  25952. addShape(mesh: Mesh, nb: number, options?: {
  25953. positionFunction?: any;
  25954. vertexFunction?: any;
  25955. }): number;
  25956. private _rebuildParticle;
  25957. /**
  25958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25959. * @returns the SPS.
  25960. */
  25961. rebuildMesh(): SolidParticleSystem;
  25962. /**
  25963. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25964. * This method calls `updateParticle()` for each particle of the SPS.
  25965. * For an animated SPS, it is usually called within the render loop.
  25966. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25967. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25968. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25969. * @returns the SPS.
  25970. */
  25971. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25972. /**
  25973. * Disposes the SPS.
  25974. */
  25975. dispose(): void;
  25976. /**
  25977. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25979. * @returns the SPS.
  25980. */
  25981. refreshVisibleSize(): SolidParticleSystem;
  25982. /**
  25983. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25984. * @param size the size (float) of the visibility box
  25985. * note : this doesn't lock the SPS mesh bounding box.
  25986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25987. */
  25988. setVisibilityBox(size: number): void;
  25989. /**
  25990. * Gets whether the SPS as always visible or not
  25991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25992. */
  25993. /**
  25994. * Sets the SPS as always visible or not
  25995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25996. */
  25997. isAlwaysVisible: boolean;
  25998. /**
  25999. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26001. */
  26002. /**
  26003. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26004. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26005. */
  26006. isVisibilityBoxLocked: boolean;
  26007. /**
  26008. * Tells to `setParticles()` to compute the particle rotations or not.
  26009. * Default value : true. The SPS is faster when it's set to false.
  26010. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26011. */
  26012. /**
  26013. * Gets if `setParticles()` computes the particle rotations or not.
  26014. * Default value : true. The SPS is faster when it's set to false.
  26015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26016. */
  26017. computeParticleRotation: boolean;
  26018. /**
  26019. * Tells to `setParticles()` to compute the particle colors or not.
  26020. * Default value : true. The SPS is faster when it's set to false.
  26021. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26022. */
  26023. /**
  26024. * Gets if `setParticles()` computes the particle colors or not.
  26025. * Default value : true. The SPS is faster when it's set to false.
  26026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26027. */
  26028. computeParticleColor: boolean;
  26029. /**
  26030. * Gets if `setParticles()` computes the particle textures or not.
  26031. * Default value : true. The SPS is faster when it's set to false.
  26032. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26033. */
  26034. computeParticleTexture: boolean;
  26035. /**
  26036. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26037. * Default value : false. The SPS is faster when it's set to false.
  26038. * Note : the particle custom vertex positions aren't stored values.
  26039. */
  26040. /**
  26041. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26042. * Default value : false. The SPS is faster when it's set to false.
  26043. * Note : the particle custom vertex positions aren't stored values.
  26044. */
  26045. computeParticleVertex: boolean;
  26046. /**
  26047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26048. */
  26049. /**
  26050. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26051. */
  26052. computeBoundingBox: boolean;
  26053. /**
  26054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26056. * Default : `true`
  26057. */
  26058. /**
  26059. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26061. * Default : `true`
  26062. */
  26063. depthSortParticles: boolean;
  26064. /**
  26065. * This function does nothing. It may be overwritten to set all the particle first values.
  26066. * The SPS doesn't call this function, you may have to call it by your own.
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26068. */
  26069. initParticles(): void;
  26070. /**
  26071. * This function does nothing. It may be overwritten to recycle a particle.
  26072. * The SPS doesn't call this function, you may have to call it by your own.
  26073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26074. * @param particle The particle to recycle
  26075. * @returns the recycled particle
  26076. */
  26077. recycleParticle(particle: SolidParticle): SolidParticle;
  26078. /**
  26079. * Updates a particle : this function should be overwritten by the user.
  26080. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26082. * @example : just set a particle position or velocity and recycle conditions
  26083. * @param particle The particle to update
  26084. * @returns the updated particle
  26085. */
  26086. updateParticle(particle: SolidParticle): SolidParticle;
  26087. /**
  26088. * Updates a vertex of a particle : it can be overwritten by the user.
  26089. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26090. * @param particle the current particle
  26091. * @param vertex the current index of the current particle
  26092. * @param pt the index of the current vertex in the particle shape
  26093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26094. * @example : just set a vertex particle position
  26095. * @returns the updated vertex
  26096. */
  26097. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26098. /**
  26099. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26100. * This does nothing and may be overwritten by the user.
  26101. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26102. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26103. * @param update the boolean update value actually passed to setParticles()
  26104. */
  26105. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26106. /**
  26107. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26108. * This will be passed three parameters.
  26109. * This does nothing and may be overwritten by the user.
  26110. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26111. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26112. * @param update the boolean update value actually passed to setParticles()
  26113. */
  26114. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26115. }
  26116. }
  26117. declare module "babylonjs/Particles/solidParticle" {
  26118. import { Nullable } from "babylonjs/types";
  26119. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26120. import { Color4 } from "babylonjs/Maths/math.color";
  26121. import { Mesh } from "babylonjs/Meshes/mesh";
  26122. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26123. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26124. import { Plane } from "babylonjs/Maths/math.plane";
  26125. /**
  26126. * Represents one particle of a solid particle system.
  26127. */
  26128. export class SolidParticle {
  26129. /**
  26130. * particle global index
  26131. */
  26132. idx: number;
  26133. /**
  26134. * The color of the particle
  26135. */
  26136. color: Nullable<Color4>;
  26137. /**
  26138. * The world space position of the particle.
  26139. */
  26140. position: Vector3;
  26141. /**
  26142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26143. */
  26144. rotation: Vector3;
  26145. /**
  26146. * The world space rotation quaternion of the particle.
  26147. */
  26148. rotationQuaternion: Nullable<Quaternion>;
  26149. /**
  26150. * The scaling of the particle.
  26151. */
  26152. scaling: Vector3;
  26153. /**
  26154. * The uvs of the particle.
  26155. */
  26156. uvs: Vector4;
  26157. /**
  26158. * The current speed of the particle.
  26159. */
  26160. velocity: Vector3;
  26161. /**
  26162. * The pivot point in the particle local space.
  26163. */
  26164. pivot: Vector3;
  26165. /**
  26166. * Must the particle be translated from its pivot point in its local space ?
  26167. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26168. * Default : false
  26169. */
  26170. translateFromPivot: boolean;
  26171. /**
  26172. * Is the particle active or not ?
  26173. */
  26174. alive: boolean;
  26175. /**
  26176. * Is the particle visible or not ?
  26177. */
  26178. isVisible: boolean;
  26179. /**
  26180. * Index of this particle in the global "positions" array (Internal use)
  26181. * @hidden
  26182. */
  26183. _pos: number;
  26184. /**
  26185. * @hidden Index of this particle in the global "indices" array (Internal use)
  26186. */
  26187. _ind: number;
  26188. /**
  26189. * @hidden ModelShape of this particle (Internal use)
  26190. */
  26191. _model: ModelShape;
  26192. /**
  26193. * ModelShape id of this particle
  26194. */
  26195. shapeId: number;
  26196. /**
  26197. * Index of the particle in its shape id
  26198. */
  26199. idxInShape: number;
  26200. /**
  26201. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26202. */
  26203. _modelBoundingInfo: BoundingInfo;
  26204. /**
  26205. * @hidden Particle BoundingInfo object (Internal use)
  26206. */
  26207. _boundingInfo: BoundingInfo;
  26208. /**
  26209. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26210. */
  26211. _sps: SolidParticleSystem;
  26212. /**
  26213. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26214. */
  26215. _stillInvisible: boolean;
  26216. /**
  26217. * @hidden Last computed particle rotation matrix
  26218. */
  26219. _rotationMatrix: number[];
  26220. /**
  26221. * Parent particle Id, if any.
  26222. * Default null.
  26223. */
  26224. parentId: Nullable<number>;
  26225. /**
  26226. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26227. * The possible values are :
  26228. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26229. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26232. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26233. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26234. * */
  26235. cullingStrategy: number;
  26236. /**
  26237. * @hidden Internal global position in the SPS.
  26238. */
  26239. _globalPosition: Vector3;
  26240. /**
  26241. * Creates a Solid Particle object.
  26242. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26243. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26244. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26245. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26246. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26247. * @param shapeId (integer) is the model shape identifier in the SPS.
  26248. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26249. * @param sps defines the sps it is associated to
  26250. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26251. */
  26252. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26253. /**
  26254. * Legacy support, changed scale to scaling
  26255. */
  26256. /**
  26257. * Legacy support, changed scale to scaling
  26258. */
  26259. scale: Vector3;
  26260. /**
  26261. * Legacy support, changed quaternion to rotationQuaternion
  26262. */
  26263. /**
  26264. * Legacy support, changed quaternion to rotationQuaternion
  26265. */
  26266. quaternion: Nullable<Quaternion>;
  26267. /**
  26268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26271. * @returns true if it intersects
  26272. */
  26273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26274. /**
  26275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26276. * A particle is in the frustum if its bounding box intersects the frustum
  26277. * @param frustumPlanes defines the frustum to test
  26278. * @returns true if the particle is in the frustum planes
  26279. */
  26280. isInFrustum(frustumPlanes: Plane[]): boolean;
  26281. /**
  26282. * get the rotation matrix of the particle
  26283. * @hidden
  26284. */
  26285. getRotationMatrix(m: Matrix): void;
  26286. }
  26287. /**
  26288. * Represents the shape of the model used by one particle of a solid particle system.
  26289. * SPS internal tool, don't use it manually.
  26290. */
  26291. export class ModelShape {
  26292. /**
  26293. * The shape id
  26294. * @hidden
  26295. */
  26296. shapeID: number;
  26297. /**
  26298. * flat array of model positions (internal use)
  26299. * @hidden
  26300. */
  26301. _shape: Vector3[];
  26302. /**
  26303. * flat array of model UVs (internal use)
  26304. * @hidden
  26305. */
  26306. _shapeUV: number[];
  26307. /**
  26308. * length of the shape in the model indices array (internal use)
  26309. * @hidden
  26310. */
  26311. _indicesLength: number;
  26312. /**
  26313. * Custom position function (internal use)
  26314. * @hidden
  26315. */
  26316. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26317. /**
  26318. * Custom vertex function (internal use)
  26319. * @hidden
  26320. */
  26321. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26322. /**
  26323. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  26324. * SPS internal tool, don't use it manually.
  26325. * @hidden
  26326. */
  26327. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26328. }
  26329. /**
  26330. * Represents a Depth Sorted Particle in the solid particle system.
  26331. */
  26332. export class DepthSortedParticle {
  26333. /**
  26334. * Index of the particle in the "indices" array
  26335. */
  26336. ind: number;
  26337. /**
  26338. * Length of the particle shape in the "indices" array
  26339. */
  26340. indicesLength: number;
  26341. /**
  26342. * Squared distance from the particle to the camera
  26343. */
  26344. sqDistance: number;
  26345. }
  26346. }
  26347. declare module "babylonjs/Collisions/meshCollisionData" {
  26348. import { Collider } from "babylonjs/Collisions/collider";
  26349. import { Vector3 } from "babylonjs/Maths/math.vector";
  26350. import { Nullable } from "babylonjs/types";
  26351. import { Observer } from "babylonjs/Misc/observable";
  26352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26353. /**
  26354. * @hidden
  26355. */
  26356. export class _MeshCollisionData {
  26357. _checkCollisions: boolean;
  26358. _collisionMask: number;
  26359. _collisionGroup: number;
  26360. _collider: Nullable<Collider>;
  26361. _oldPositionForCollisions: Vector3;
  26362. _diffPositionForCollisions: Vector3;
  26363. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26364. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26365. }
  26366. }
  26367. declare module "babylonjs/Meshes/abstractMesh" {
  26368. import { Observable } from "babylonjs/Misc/observable";
  26369. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26370. import { Camera } from "babylonjs/Cameras/camera";
  26371. import { Scene, IDisposable } from "babylonjs/scene";
  26372. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26373. import { Node } from "babylonjs/node";
  26374. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26377. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26378. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26379. import { Material } from "babylonjs/Materials/material";
  26380. import { Light } from "babylonjs/Lights/light";
  26381. import { Skeleton } from "babylonjs/Bones/skeleton";
  26382. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26383. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26384. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26386. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26387. import { Plane } from "babylonjs/Maths/math.plane";
  26388. import { Ray } from "babylonjs/Culling/ray";
  26389. import { Collider } from "babylonjs/Collisions/collider";
  26390. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26391. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26392. /** @hidden */
  26393. class _FacetDataStorage {
  26394. facetPositions: Vector3[];
  26395. facetNormals: Vector3[];
  26396. facetPartitioning: number[][];
  26397. facetNb: number;
  26398. partitioningSubdivisions: number;
  26399. partitioningBBoxRatio: number;
  26400. facetDataEnabled: boolean;
  26401. facetParameters: any;
  26402. bbSize: Vector3;
  26403. subDiv: {
  26404. max: number;
  26405. X: number;
  26406. Y: number;
  26407. Z: number;
  26408. };
  26409. facetDepthSort: boolean;
  26410. facetDepthSortEnabled: boolean;
  26411. depthSortedIndices: IndicesArray;
  26412. depthSortedFacets: {
  26413. ind: number;
  26414. sqDistance: number;
  26415. }[];
  26416. facetDepthSortFunction: (f1: {
  26417. ind: number;
  26418. sqDistance: number;
  26419. }, f2: {
  26420. ind: number;
  26421. sqDistance: number;
  26422. }) => number;
  26423. facetDepthSortFrom: Vector3;
  26424. facetDepthSortOrigin: Vector3;
  26425. invertedMatrix: Matrix;
  26426. }
  26427. /**
  26428. * @hidden
  26429. **/
  26430. class _InternalAbstractMeshDataInfo {
  26431. _hasVertexAlpha: boolean;
  26432. _useVertexColors: boolean;
  26433. _numBoneInfluencers: number;
  26434. _applyFog: boolean;
  26435. _receiveShadows: boolean;
  26436. _facetData: _FacetDataStorage;
  26437. _visibility: number;
  26438. _skeleton: Nullable<Skeleton>;
  26439. _layerMask: number;
  26440. _computeBonesUsingShaders: boolean;
  26441. _isActive: boolean;
  26442. _onlyForInstances: boolean;
  26443. _isActiveIntermediate: boolean;
  26444. _onlyForInstancesIntermediate: boolean;
  26445. }
  26446. /**
  26447. * Class used to store all common mesh properties
  26448. */
  26449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26450. /** No occlusion */
  26451. static OCCLUSION_TYPE_NONE: number;
  26452. /** Occlusion set to optimisitic */
  26453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26454. /** Occlusion set to strict */
  26455. static OCCLUSION_TYPE_STRICT: number;
  26456. /** Use an accurante occlusion algorithm */
  26457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26458. /** Use a conservative occlusion algorithm */
  26459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26461. * Test order :
  26462. * Is the bounding sphere outside the frustum ?
  26463. * If not, are the bounding box vertices outside the frustum ?
  26464. * It not, then the cullable object is in the frustum.
  26465. */
  26466. static readonly CULLINGSTRATEGY_STANDARD: number;
  26467. /** Culling strategy : Bounding Sphere Only.
  26468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26469. * It's also less accurate than the standard because some not visible objects can still be selected.
  26470. * Test : is the bounding sphere outside the frustum ?
  26471. * If not, then the cullable object is in the frustum.
  26472. */
  26473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26474. /** Culling strategy : Optimistic Inclusion.
  26475. * This in an inclusion test first, then the standard exclusion test.
  26476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26477. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  26478. * Anyway, it's as accurate as the standard strategy.
  26479. * Test :
  26480. * Is the cullable object bounding sphere center in the frustum ?
  26481. * If not, apply the default culling strategy.
  26482. */
  26483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26487. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  26488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26489. * Test :
  26490. * Is the cullable object bounding sphere center in the frustum ?
  26491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26492. */
  26493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26494. /**
  26495. * No billboard
  26496. */
  26497. static readonly BILLBOARDMODE_NONE: number;
  26498. /** Billboard on X axis */
  26499. static readonly BILLBOARDMODE_X: number;
  26500. /** Billboard on Y axis */
  26501. static readonly BILLBOARDMODE_Y: number;
  26502. /** Billboard on Z axis */
  26503. static readonly BILLBOARDMODE_Z: number;
  26504. /** Billboard on all axes */
  26505. static readonly BILLBOARDMODE_ALL: number;
  26506. /** Billboard on using position instead of orientation */
  26507. static readonly BILLBOARDMODE_USE_POSITION: number;
  26508. /** @hidden */
  26509. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26510. /**
  26511. * The culling strategy to use to check whether the mesh must be rendered or not.
  26512. * This value can be changed at any time and will be used on the next render mesh selection.
  26513. * The possible values are :
  26514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26518. * Please read each static variable documentation to get details about the culling process.
  26519. * */
  26520. cullingStrategy: number;
  26521. /**
  26522. * Gets the number of facets in the mesh
  26523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26524. */
  26525. readonly facetNb: number;
  26526. /**
  26527. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26529. */
  26530. partitioningSubdivisions: number;
  26531. /**
  26532. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26533. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26535. */
  26536. partitioningBBoxRatio: number;
  26537. /**
  26538. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26539. * Works only for updatable meshes.
  26540. * Doesn't work with multi-materials
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26542. */
  26543. mustDepthSortFacets: boolean;
  26544. /**
  26545. * The location (Vector3) where the facet depth sort must be computed from.
  26546. * By default, the active camera position.
  26547. * Used only when facet depth sort is enabled
  26548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26549. */
  26550. facetDepthSortFrom: Vector3;
  26551. /**
  26552. * gets a boolean indicating if facetData is enabled
  26553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26554. */
  26555. readonly isFacetDataEnabled: boolean;
  26556. /** @hidden */
  26557. _updateNonUniformScalingState(value: boolean): boolean;
  26558. /**
  26559. * An event triggered when this mesh collides with another one
  26560. */
  26561. onCollideObservable: Observable<AbstractMesh>;
  26562. /** Set a function to call when this mesh collides with another one */
  26563. onCollide: () => void;
  26564. /**
  26565. * An event triggered when the collision's position changes
  26566. */
  26567. onCollisionPositionChangeObservable: Observable<Vector3>;
  26568. /** Set a function to call when the collision's position changes */
  26569. onCollisionPositionChange: () => void;
  26570. /**
  26571. * An event triggered when material is changed
  26572. */
  26573. onMaterialChangedObservable: Observable<AbstractMesh>;
  26574. /**
  26575. * Gets or sets the orientation for POV movement & rotation
  26576. */
  26577. definedFacingForward: boolean;
  26578. /** @hidden */
  26579. _occlusionQuery: Nullable<WebGLQuery>;
  26580. /** @hidden */
  26581. _renderingGroup: Nullable<RenderingGroup>;
  26582. /**
  26583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26584. */
  26585. /**
  26586. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26587. */
  26588. visibility: number;
  26589. /** Gets or sets the alpha index used to sort transparent meshes
  26590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26591. */
  26592. alphaIndex: number;
  26593. /**
  26594. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26595. */
  26596. isVisible: boolean;
  26597. /**
  26598. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26599. */
  26600. isPickable: boolean;
  26601. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26602. showSubMeshesBoundingBox: boolean;
  26603. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26605. */
  26606. isBlocker: boolean;
  26607. /**
  26608. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26609. */
  26610. enablePointerMoveEvents: boolean;
  26611. /**
  26612. * Specifies the rendering group id for this mesh (0 by default)
  26613. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26614. */
  26615. renderingGroupId: number;
  26616. private _material;
  26617. /** Gets or sets current material */
  26618. material: Nullable<Material>;
  26619. /**
  26620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26621. * @see http://doc.babylonjs.com/babylon101/shadows
  26622. */
  26623. receiveShadows: boolean;
  26624. /** Defines color to use when rendering outline */
  26625. outlineColor: Color3;
  26626. /** Define width to use when rendering outline */
  26627. outlineWidth: number;
  26628. /** Defines color to use when rendering overlay */
  26629. overlayColor: Color3;
  26630. /** Defines alpha to use when rendering overlay */
  26631. overlayAlpha: number;
  26632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26633. hasVertexAlpha: boolean;
  26634. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  26635. useVertexColors: boolean;
  26636. /**
  26637. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26638. */
  26639. computeBonesUsingShaders: boolean;
  26640. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26641. numBoneInfluencers: number;
  26642. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26643. applyFog: boolean;
  26644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26645. useOctreeForRenderingSelection: boolean;
  26646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26647. useOctreeForPicking: boolean;
  26648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26649. useOctreeForCollisions: boolean;
  26650. /**
  26651. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26652. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26653. */
  26654. layerMask: number;
  26655. /**
  26656. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26657. */
  26658. alwaysSelectAsActiveMesh: boolean;
  26659. /**
  26660. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26661. */
  26662. doNotSyncBoundingInfo: boolean;
  26663. /**
  26664. * Gets or sets the current action manager
  26665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26666. */
  26667. actionManager: Nullable<AbstractActionManager>;
  26668. private _meshCollisionData;
  26669. /**
  26670. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26672. */
  26673. ellipsoid: Vector3;
  26674. /**
  26675. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26677. */
  26678. ellipsoidOffset: Vector3;
  26679. /**
  26680. * Gets or sets a collision mask used to mask collisions (default is -1).
  26681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26682. */
  26683. collisionMask: number;
  26684. /**
  26685. * Gets or sets the current collision group mask (-1 by default).
  26686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26687. */
  26688. collisionGroup: number;
  26689. /**
  26690. * Defines edge width used when edgesRenderer is enabled
  26691. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26692. */
  26693. edgesWidth: number;
  26694. /**
  26695. * Defines edge color used when edgesRenderer is enabled
  26696. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26697. */
  26698. edgesColor: Color4;
  26699. /** @hidden */
  26700. _edgesRenderer: Nullable<IEdgesRenderer>;
  26701. /** @hidden */
  26702. _masterMesh: Nullable<AbstractMesh>;
  26703. /** @hidden */
  26704. _boundingInfo: Nullable<BoundingInfo>;
  26705. /** @hidden */
  26706. _renderId: number;
  26707. /**
  26708. * Gets or sets the list of subMeshes
  26709. * @see http://doc.babylonjs.com/how_to/multi_materials
  26710. */
  26711. subMeshes: SubMesh[];
  26712. /** @hidden */
  26713. _intersectionsInProgress: AbstractMesh[];
  26714. /** @hidden */
  26715. _unIndexed: boolean;
  26716. /** @hidden */
  26717. _lightSources: Light[];
  26718. /** Gets the list of lights affecting that mesh */
  26719. readonly lightSources: Light[];
  26720. /** @hidden */
  26721. readonly _positions: Nullable<Vector3[]>;
  26722. /** @hidden */
  26723. _waitingData: {
  26724. lods: Nullable<any>;
  26725. actions: Nullable<any>;
  26726. freezeWorldMatrix: Nullable<boolean>;
  26727. };
  26728. /** @hidden */
  26729. _bonesTransformMatrices: Nullable<Float32Array>;
  26730. /** @hidden */
  26731. _transformMatrixTexture: Nullable<RawTexture>;
  26732. /**
  26733. * Gets or sets a skeleton to apply skining transformations
  26734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26735. */
  26736. skeleton: Nullable<Skeleton>;
  26737. /**
  26738. * An event triggered when the mesh is rebuilt.
  26739. */
  26740. onRebuildObservable: Observable<AbstractMesh>;
  26741. /**
  26742. * Creates a new AbstractMesh
  26743. * @param name defines the name of the mesh
  26744. * @param scene defines the hosting scene
  26745. */
  26746. constructor(name: string, scene?: Nullable<Scene>);
  26747. /**
  26748. * Returns the string "AbstractMesh"
  26749. * @returns "AbstractMesh"
  26750. */
  26751. getClassName(): string;
  26752. /**
  26753. * Gets a string representation of the current mesh
  26754. * @param fullDetails defines a boolean indicating if full details must be included
  26755. * @returns a string representation of the current mesh
  26756. */
  26757. toString(fullDetails?: boolean): string;
  26758. /**
  26759. * @hidden
  26760. */
  26761. protected _getEffectiveParent(): Nullable<Node>;
  26762. /** @hidden */
  26763. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26764. /** @hidden */
  26765. _rebuild(): void;
  26766. /** @hidden */
  26767. _resyncLightSources(): void;
  26768. /** @hidden */
  26769. _resyncLighSource(light: Light): void;
  26770. /** @hidden */
  26771. _unBindEffect(): void;
  26772. /** @hidden */
  26773. _removeLightSource(light: Light, dispose: boolean): void;
  26774. private _markSubMeshesAsDirty;
  26775. /** @hidden */
  26776. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26777. /** @hidden */
  26778. _markSubMeshesAsAttributesDirty(): void;
  26779. /** @hidden */
  26780. _markSubMeshesAsMiscDirty(): void;
  26781. /**
  26782. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26783. */
  26784. scaling: Vector3;
  26785. /**
  26786. * Returns true if the mesh is blocked. Implemented by child classes
  26787. */
  26788. readonly isBlocked: boolean;
  26789. /**
  26790. * Returns the mesh itself by default. Implemented by child classes
  26791. * @param camera defines the camera to use to pick the right LOD level
  26792. * @returns the currentAbstractMesh
  26793. */
  26794. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26795. /**
  26796. * Returns 0 by default. Implemented by child classes
  26797. * @returns an integer
  26798. */
  26799. getTotalVertices(): number;
  26800. /**
  26801. * Returns a positive integer : the total number of indices in this mesh geometry.
  26802. * @returns the numner of indices or zero if the mesh has no geometry.
  26803. */
  26804. getTotalIndices(): number;
  26805. /**
  26806. * Returns null by default. Implemented by child classes
  26807. * @returns null
  26808. */
  26809. getIndices(): Nullable<IndicesArray>;
  26810. /**
  26811. * Returns the array of the requested vertex data kind. Implemented by child classes
  26812. * @param kind defines the vertex data kind to use
  26813. * @returns null
  26814. */
  26815. getVerticesData(kind: string): Nullable<FloatArray>;
  26816. /**
  26817. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26818. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26819. * Note that a new underlying VertexBuffer object is created each call.
  26820. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26821. * @param kind defines vertex data kind:
  26822. * * VertexBuffer.PositionKind
  26823. * * VertexBuffer.UVKind
  26824. * * VertexBuffer.UV2Kind
  26825. * * VertexBuffer.UV3Kind
  26826. * * VertexBuffer.UV4Kind
  26827. * * VertexBuffer.UV5Kind
  26828. * * VertexBuffer.UV6Kind
  26829. * * VertexBuffer.ColorKind
  26830. * * VertexBuffer.MatricesIndicesKind
  26831. * * VertexBuffer.MatricesIndicesExtraKind
  26832. * * VertexBuffer.MatricesWeightsKind
  26833. * * VertexBuffer.MatricesWeightsExtraKind
  26834. * @param data defines the data source
  26835. * @param updatable defines if the data must be flagged as updatable (or static)
  26836. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  26837. * @returns the current mesh
  26838. */
  26839. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26840. /**
  26841. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26842. * If the mesh has no geometry, it is simply returned as it is.
  26843. * @param kind defines vertex data kind:
  26844. * * VertexBuffer.PositionKind
  26845. * * VertexBuffer.UVKind
  26846. * * VertexBuffer.UV2Kind
  26847. * * VertexBuffer.UV3Kind
  26848. * * VertexBuffer.UV4Kind
  26849. * * VertexBuffer.UV5Kind
  26850. * * VertexBuffer.UV6Kind
  26851. * * VertexBuffer.ColorKind
  26852. * * VertexBuffer.MatricesIndicesKind
  26853. * * VertexBuffer.MatricesIndicesExtraKind
  26854. * * VertexBuffer.MatricesWeightsKind
  26855. * * VertexBuffer.MatricesWeightsExtraKind
  26856. * @param data defines the data source
  26857. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  26858. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26859. * @returns the current mesh
  26860. */
  26861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26862. /**
  26863. * Sets the mesh indices,
  26864. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26865. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26866. * @param totalVertices Defines the total number of vertices
  26867. * @returns the current mesh
  26868. */
  26869. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26870. /**
  26871. * Gets a boolean indicating if specific vertex data is present
  26872. * @param kind defines the vertex data kind to use
  26873. * @returns true is data kind is present
  26874. */
  26875. isVerticesDataPresent(kind: string): boolean;
  26876. /**
  26877. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26878. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26879. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26880. * @returns a BoundingInfo
  26881. */
  26882. getBoundingInfo(): BoundingInfo;
  26883. /**
  26884. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26885. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26886. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26887. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26888. * @returns the current mesh
  26889. */
  26890. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26891. /**
  26892. * Overwrite the current bounding info
  26893. * @param boundingInfo defines the new bounding info
  26894. * @returns the current mesh
  26895. */
  26896. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26897. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26898. readonly useBones: boolean;
  26899. /** @hidden */
  26900. _preActivate(): void;
  26901. /** @hidden */
  26902. _preActivateForIntermediateRendering(renderId: number): void;
  26903. /** @hidden */
  26904. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26905. /** @hidden */
  26906. _postActivate(): void;
  26907. /** @hidden */
  26908. _freeze(): void;
  26909. /** @hidden */
  26910. _unFreeze(): void;
  26911. /**
  26912. * Gets the current world matrix
  26913. * @returns a Matrix
  26914. */
  26915. getWorldMatrix(): Matrix;
  26916. /** @hidden */
  26917. _getWorldMatrixDeterminant(): number;
  26918. /**
  26919. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26920. */
  26921. readonly isAnInstance: boolean;
  26922. /**
  26923. * Gets a boolean indicating if this mesh has instances
  26924. */
  26925. readonly hasInstances: boolean;
  26926. /**
  26927. * Perform relative position change from the point of view of behind the front of the mesh.
  26928. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26929. * Supports definition of mesh facing forward or backward
  26930. * @param amountRight defines the distance on the right axis
  26931. * @param amountUp defines the distance on the up axis
  26932. * @param amountForward defines the distance on the forward axis
  26933. * @returns the current mesh
  26934. */
  26935. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26936. /**
  26937. * Calculate relative position change from the point of view of behind the front of the mesh.
  26938. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26939. * Supports definition of mesh facing forward or backward
  26940. * @param amountRight defines the distance on the right axis
  26941. * @param amountUp defines the distance on the up axis
  26942. * @param amountForward defines the distance on the forward axis
  26943. * @returns the new displacement vector
  26944. */
  26945. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26946. /**
  26947. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26948. * Supports definition of mesh facing forward or backward
  26949. * @param flipBack defines the flip
  26950. * @param twirlClockwise defines the twirl
  26951. * @param tiltRight defines the tilt
  26952. * @returns the current mesh
  26953. */
  26954. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26955. /**
  26956. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26957. * Supports definition of mesh facing forward or backward.
  26958. * @param flipBack defines the flip
  26959. * @param twirlClockwise defines the twirl
  26960. * @param tiltRight defines the tilt
  26961. * @returns the new rotation vector
  26962. */
  26963. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26964. /**
  26965. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26966. * This means the mesh underlying bounding box and sphere are recomputed.
  26967. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26968. * @returns the current mesh
  26969. */
  26970. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26971. /** @hidden */
  26972. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26973. /** @hidden */
  26974. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26975. /** @hidden */
  26976. _updateBoundingInfo(): AbstractMesh;
  26977. /** @hidden */
  26978. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26979. /** @hidden */
  26980. protected _afterComputeWorldMatrix(): void;
  26981. /** @hidden */
  26982. readonly _effectiveMesh: AbstractMesh;
  26983. /**
  26984. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26985. * A mesh is in the frustum if its bounding box intersects the frustum
  26986. * @param frustumPlanes defines the frustum to test
  26987. * @returns true if the mesh is in the frustum planes
  26988. */
  26989. isInFrustum(frustumPlanes: Plane[]): boolean;
  26990. /**
  26991. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26992. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26993. * @param frustumPlanes defines the frustum to test
  26994. * @returns true if the mesh is completely in the frustum planes
  26995. */
  26996. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26997. /**
  26998. * True if the mesh intersects another mesh or a SolidParticle object
  26999. * @param mesh defines a target mesh or SolidParticle to test
  27000. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  27001. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27002. * @returns true if there is an intersection
  27003. */
  27004. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27005. /**
  27006. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27007. * @param point defines the point to test
  27008. * @returns true if there is an intersection
  27009. */
  27010. intersectsPoint(point: Vector3): boolean;
  27011. /**
  27012. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27014. */
  27015. checkCollisions: boolean;
  27016. /**
  27017. * Gets Collider object used to compute collisions (not physics)
  27018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27019. */
  27020. readonly collider: Nullable<Collider>;
  27021. /**
  27022. * Move the mesh using collision engine
  27023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27024. * @param displacement defines the requested displacement vector
  27025. * @returns the current mesh
  27026. */
  27027. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27028. private _onCollisionPositionChange;
  27029. /** @hidden */
  27030. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27031. /** @hidden */
  27032. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27033. /** @hidden */
  27034. _checkCollision(collider: Collider): AbstractMesh;
  27035. /** @hidden */
  27036. _generatePointsArray(): boolean;
  27037. /**
  27038. * Checks if the passed Ray intersects with the mesh
  27039. * @param ray defines the ray to use
  27040. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27042. * @returns the picking info
  27043. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27044. */
  27045. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27046. /**
  27047. * Clones the current mesh
  27048. * @param name defines the mesh name
  27049. * @param newParent defines the new mesh parent
  27050. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27051. * @returns the new mesh
  27052. */
  27053. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27054. /**
  27055. * Disposes all the submeshes of the current meshnp
  27056. * @returns the current mesh
  27057. */
  27058. releaseSubMeshes(): AbstractMesh;
  27059. /**
  27060. * Releases resources associated with this abstract mesh.
  27061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27063. */
  27064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27065. /**
  27066. * Adds the passed mesh as a child to the current mesh
  27067. * @param mesh defines the child mesh
  27068. * @returns the current mesh
  27069. */
  27070. addChild(mesh: AbstractMesh): AbstractMesh;
  27071. /**
  27072. * Removes the passed mesh from the current mesh children list
  27073. * @param mesh defines the child mesh
  27074. * @returns the current mesh
  27075. */
  27076. removeChild(mesh: AbstractMesh): AbstractMesh;
  27077. /** @hidden */
  27078. private _initFacetData;
  27079. /**
  27080. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27081. * This method can be called within the render loop.
  27082. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  27083. * @returns the current mesh
  27084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27085. */
  27086. updateFacetData(): AbstractMesh;
  27087. /**
  27088. * Returns the facetLocalNormals array.
  27089. * The normals are expressed in the mesh local spac
  27090. * @returns an array of Vector3
  27091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27092. */
  27093. getFacetLocalNormals(): Vector3[];
  27094. /**
  27095. * Returns the facetLocalPositions array.
  27096. * The facet positions are expressed in the mesh local space
  27097. * @returns an array of Vector3
  27098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27099. */
  27100. getFacetLocalPositions(): Vector3[];
  27101. /**
  27102. * Returns the facetLocalPartioning array
  27103. * @returns an array of array of numbers
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27105. */
  27106. getFacetLocalPartitioning(): number[][];
  27107. /**
  27108. * Returns the i-th facet position in the world system.
  27109. * This method allocates a new Vector3 per call
  27110. * @param i defines the facet index
  27111. * @returns a new Vector3
  27112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27113. */
  27114. getFacetPosition(i: number): Vector3;
  27115. /**
  27116. * Sets the reference Vector3 with the i-th facet position in the world system
  27117. * @param i defines the facet index
  27118. * @param ref defines the target vector
  27119. * @returns the current mesh
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27121. */
  27122. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27123. /**
  27124. * Returns the i-th facet normal in the world system.
  27125. * This method allocates a new Vector3 per call
  27126. * @param i defines the facet index
  27127. * @returns a new Vector3
  27128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27129. */
  27130. getFacetNormal(i: number): Vector3;
  27131. /**
  27132. * Sets the reference Vector3 with the i-th facet normal in the world system
  27133. * @param i defines the facet index
  27134. * @param ref defines the target vector
  27135. * @returns the current mesh
  27136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27137. */
  27138. getFacetNormalToRef(i: number, ref: Vector3): this;
  27139. /**
  27140. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  27141. * @param x defines x coordinate
  27142. * @param y defines y coordinate
  27143. * @param z defines z coordinate
  27144. * @returns the array of facet indexes
  27145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27146. */
  27147. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27148. /**
  27149. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27150. * @param projected sets as the (x,y,z) world projection on the facet
  27151. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27152. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27153. * @param x defines x coordinate
  27154. * @param y defines y coordinate
  27155. * @param z defines z coordinate
  27156. * @returns the face index if found (or null instead)
  27157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27158. */
  27159. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27160. /**
  27161. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27162. * @param projected sets as the (x,y,z) local projection on the facet
  27163. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27164. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27165. * @param x defines x coordinate
  27166. * @param y defines y coordinate
  27167. * @param z defines z coordinate
  27168. * @returns the face index if found (or null instead)
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27170. */
  27171. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27172. /**
  27173. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27174. * @returns the parameters
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27176. */
  27177. getFacetDataParameters(): any;
  27178. /**
  27179. * Disables the feature FacetData and frees the related memory
  27180. * @returns the current mesh
  27181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27182. */
  27183. disableFacetData(): AbstractMesh;
  27184. /**
  27185. * Updates the AbstractMesh indices array
  27186. * @param indices defines the data source
  27187. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27188. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  27189. * @returns the current mesh
  27190. */
  27191. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27192. /**
  27193. * Creates new normals data for the mesh
  27194. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27195. * @returns the current mesh
  27196. */
  27197. createNormals(updatable: boolean): AbstractMesh;
  27198. /**
  27199. * Align the mesh with a normal
  27200. * @param normal defines the normal to use
  27201. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27202. * @returns the current mesh
  27203. */
  27204. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27205. /** @hidden */
  27206. _checkOcclusionQuery(): boolean;
  27207. /**
  27208. * Disables the mesh edge rendering mode
  27209. * @returns the currentAbstractMesh
  27210. */
  27211. disableEdgesRendering(): AbstractMesh;
  27212. /**
  27213. * Enables the edge rendering mode on the mesh.
  27214. * This mode makes the mesh edges visible
  27215. * @param epsilon defines the maximal distance between two angles to detect a face
  27216. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27217. * @returns the currentAbstractMesh
  27218. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27219. */
  27220. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27221. }
  27222. }
  27223. declare module "babylonjs/Actions/actionEvent" {
  27224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27225. import { Nullable } from "babylonjs/types";
  27226. import { Sprite } from "babylonjs/Sprites/sprite";
  27227. import { Scene } from "babylonjs/scene";
  27228. import { Vector2 } from "babylonjs/Maths/math.vector";
  27229. /**
  27230. * Interface used to define ActionEvent
  27231. */
  27232. export interface IActionEvent {
  27233. /** The mesh or sprite that triggered the action */
  27234. source: any;
  27235. /** The X mouse cursor position at the time of the event */
  27236. pointerX: number;
  27237. /** The Y mouse cursor position at the time of the event */
  27238. pointerY: number;
  27239. /** The mesh that is currently pointed at (can be null) */
  27240. meshUnderPointer: Nullable<AbstractMesh>;
  27241. /** the original (browser) event that triggered the ActionEvent */
  27242. sourceEvent?: any;
  27243. /** additional data for the event */
  27244. additionalData?: any;
  27245. }
  27246. /**
  27247. * ActionEvent is the event being sent when an action is triggered.
  27248. */
  27249. export class ActionEvent implements IActionEvent {
  27250. /** The mesh or sprite that triggered the action */
  27251. source: any;
  27252. /** The X mouse cursor position at the time of the event */
  27253. pointerX: number;
  27254. /** The Y mouse cursor position at the time of the event */
  27255. pointerY: number;
  27256. /** The mesh that is currently pointed at (can be null) */
  27257. meshUnderPointer: Nullable<AbstractMesh>;
  27258. /** the original (browser) event that triggered the ActionEvent */
  27259. sourceEvent?: any;
  27260. /** additional data for the event */
  27261. additionalData?: any;
  27262. /**
  27263. * Creates a new ActionEvent
  27264. * @param source The mesh or sprite that triggered the action
  27265. * @param pointerX The X mouse cursor position at the time of the event
  27266. * @param pointerY The Y mouse cursor position at the time of the event
  27267. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27268. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27269. * @param additionalData additional data for the event
  27270. */
  27271. constructor(
  27272. /** The mesh or sprite that triggered the action */
  27273. source: any,
  27274. /** The X mouse cursor position at the time of the event */
  27275. pointerX: number,
  27276. /** The Y mouse cursor position at the time of the event */
  27277. pointerY: number,
  27278. /** The mesh that is currently pointed at (can be null) */
  27279. meshUnderPointer: Nullable<AbstractMesh>,
  27280. /** the original (browser) event that triggered the ActionEvent */
  27281. sourceEvent?: any,
  27282. /** additional data for the event */
  27283. additionalData?: any);
  27284. /**
  27285. * Helper function to auto-create an ActionEvent from a source mesh.
  27286. * @param source The source mesh that triggered the event
  27287. * @param evt The original (browser) event
  27288. * @param additionalData additional data for the event
  27289. * @returns the new ActionEvent
  27290. */
  27291. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27292. /**
  27293. * Helper function to auto-create an ActionEvent from a source sprite
  27294. * @param source The source sprite that triggered the event
  27295. * @param scene Scene associated with the sprite
  27296. * @param evt The original (browser) event
  27297. * @param additionalData additional data for the event
  27298. * @returns the new ActionEvent
  27299. */
  27300. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27301. /**
  27302. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27303. * @param scene the scene where the event occurred
  27304. * @param evt The original (browser) event
  27305. * @returns the new ActionEvent
  27306. */
  27307. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27308. /**
  27309. * Helper function to auto-create an ActionEvent from a primitive
  27310. * @param prim defines the target primitive
  27311. * @param pointerPos defines the pointer position
  27312. * @param evt The original (browser) event
  27313. * @param additionalData additional data for the event
  27314. * @returns the new ActionEvent
  27315. */
  27316. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27317. }
  27318. }
  27319. declare module "babylonjs/Actions/abstractActionManager" {
  27320. import { IDisposable } from "babylonjs/scene";
  27321. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27322. import { IAction } from "babylonjs/Actions/action";
  27323. import { Nullable } from "babylonjs/types";
  27324. /**
  27325. * Abstract class used to decouple action Manager from scene and meshes.
  27326. * Do not instantiate.
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27328. */
  27329. export abstract class AbstractActionManager implements IDisposable {
  27330. /** Gets the list of active triggers */
  27331. static Triggers: {
  27332. [key: string]: number;
  27333. };
  27334. /** Gets the cursor to use when hovering items */
  27335. hoverCursor: string;
  27336. /** Gets the list of actions */
  27337. actions: IAction[];
  27338. /**
  27339. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27340. */
  27341. isRecursive: boolean;
  27342. /**
  27343. * Releases all associated resources
  27344. */
  27345. abstract dispose(): void;
  27346. /**
  27347. * Does this action manager has pointer triggers
  27348. */
  27349. abstract readonly hasPointerTriggers: boolean;
  27350. /**
  27351. * Does this action manager has pick triggers
  27352. */
  27353. abstract readonly hasPickTriggers: boolean;
  27354. /**
  27355. * Process a specific trigger
  27356. * @param trigger defines the trigger to process
  27357. * @param evt defines the event details to be processed
  27358. */
  27359. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27360. /**
  27361. * Does this action manager handles actions of any of the given triggers
  27362. * @param triggers defines the triggers to be tested
  27363. * @return a boolean indicating whether one (or more) of the triggers is handled
  27364. */
  27365. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27366. /**
  27367. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27368. * speed.
  27369. * @param triggerA defines the trigger to be tested
  27370. * @param triggerB defines the trigger to be tested
  27371. * @return a boolean indicating whether one (or more) of the triggers is handled
  27372. */
  27373. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27374. /**
  27375. * Does this action manager handles actions of a given trigger
  27376. * @param trigger defines the trigger to be tested
  27377. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27378. * @return whether the trigger is handled
  27379. */
  27380. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27381. /**
  27382. * Serialize this manager to a JSON object
  27383. * @param name defines the property name to store this manager
  27384. * @returns a JSON representation of this manager
  27385. */
  27386. abstract serialize(name: string): any;
  27387. /**
  27388. * Registers an action to this action manager
  27389. * @param action defines the action to be registered
  27390. * @return the action amended (prepared) after registration
  27391. */
  27392. abstract registerAction(action: IAction): Nullable<IAction>;
  27393. /**
  27394. * Unregisters an action to this action manager
  27395. * @param action defines the action to be unregistered
  27396. * @return a boolean indicating whether the action has been unregistered
  27397. */
  27398. abstract unregisterAction(action: IAction): Boolean;
  27399. /**
  27400. * Does exist one action manager with at least one trigger
  27401. **/
  27402. static readonly HasTriggers: boolean;
  27403. /**
  27404. * Does exist one action manager with at least one pick trigger
  27405. **/
  27406. static readonly HasPickTriggers: boolean;
  27407. /**
  27408. * Does exist one action manager that handles actions of a given trigger
  27409. * @param trigger defines the trigger to be tested
  27410. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27411. **/
  27412. static HasSpecificTrigger(trigger: number): boolean;
  27413. }
  27414. }
  27415. declare module "babylonjs/node" {
  27416. import { Scene } from "babylonjs/scene";
  27417. import { Nullable } from "babylonjs/types";
  27418. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27419. import { Engine } from "babylonjs/Engines/engine";
  27420. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27421. import { Observable } from "babylonjs/Misc/observable";
  27422. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27423. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27424. import { Animatable } from "babylonjs/Animations/animatable";
  27425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27426. import { Animation } from "babylonjs/Animations/animation";
  27427. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27429. /**
  27430. * Defines how a node can be built from a string name.
  27431. */
  27432. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27433. /**
  27434. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27435. */
  27436. export class Node implements IBehaviorAware<Node> {
  27437. /** @hidden */
  27438. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27439. private static _NodeConstructors;
  27440. /**
  27441. * Add a new node constructor
  27442. * @param type defines the type name of the node to construct
  27443. * @param constructorFunc defines the constructor function
  27444. */
  27445. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27446. /**
  27447. * Returns a node constructor based on type name
  27448. * @param type defines the type name
  27449. * @param name defines the new node name
  27450. * @param scene defines the hosting scene
  27451. * @param options defines optional options to transmit to constructors
  27452. * @returns the new constructor or null
  27453. */
  27454. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27455. /**
  27456. * Gets or sets the name of the node
  27457. */
  27458. name: string;
  27459. /**
  27460. * Gets or sets the id of the node
  27461. */
  27462. id: string;
  27463. /**
  27464. * Gets or sets the unique id of the node
  27465. */
  27466. uniqueId: number;
  27467. /**
  27468. * Gets or sets a string used to store user defined state for the node
  27469. */
  27470. state: string;
  27471. /**
  27472. * Gets or sets an object used to store user defined information for the node
  27473. */
  27474. metadata: any;
  27475. /**
  27476. * For internal use only. Please do not use.
  27477. */
  27478. reservedDataStore: any;
  27479. /**
  27480. * List of inspectable custom properties (used by the Inspector)
  27481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27482. */
  27483. inspectableCustomProperties: IInspectable[];
  27484. /**
  27485. * Gets or sets a boolean used to define if the node must be serialized
  27486. */
  27487. doNotSerialize: boolean;
  27488. /** @hidden */
  27489. _isDisposed: boolean;
  27490. /**
  27491. * Gets a list of Animations associated with the node
  27492. */
  27493. animations: import("babylonjs/Animations/animation").Animation[];
  27494. protected _ranges: {
  27495. [name: string]: Nullable<AnimationRange>;
  27496. };
  27497. /**
  27498. * Callback raised when the node is ready to be used
  27499. */
  27500. onReady: Nullable<(node: Node) => void>;
  27501. private _isEnabled;
  27502. private _isParentEnabled;
  27503. private _isReady;
  27504. /** @hidden */
  27505. _currentRenderId: number;
  27506. private _parentUpdateId;
  27507. /** @hidden */
  27508. _childUpdateId: number;
  27509. /** @hidden */
  27510. _waitingParentId: Nullable<string>;
  27511. /** @hidden */
  27512. _scene: Scene;
  27513. /** @hidden */
  27514. _cache: any;
  27515. private _parentNode;
  27516. private _children;
  27517. /** @hidden */
  27518. _worldMatrix: Matrix;
  27519. /** @hidden */
  27520. _worldMatrixDeterminant: number;
  27521. /** @hidden */
  27522. _worldMatrixDeterminantIsDirty: boolean;
  27523. /** @hidden */
  27524. private _sceneRootNodesIndex;
  27525. /**
  27526. * Gets a boolean indicating if the node has been disposed
  27527. * @returns true if the node was disposed
  27528. */
  27529. isDisposed(): boolean;
  27530. /**
  27531. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27532. * @see https://doc.babylonjs.com/how_to/parenting
  27533. */
  27534. parent: Nullable<Node>;
  27535. private addToSceneRootNodes;
  27536. private removeFromSceneRootNodes;
  27537. private _animationPropertiesOverride;
  27538. /**
  27539. * Gets or sets the animation properties override
  27540. */
  27541. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27542. /**
  27543. * Gets a string idenfifying the name of the class
  27544. * @returns "Node" string
  27545. */
  27546. getClassName(): string;
  27547. /** @hidden */
  27548. readonly _isNode: boolean;
  27549. /**
  27550. * An event triggered when the mesh is disposed
  27551. */
  27552. onDisposeObservable: Observable<Node>;
  27553. private _onDisposeObserver;
  27554. /**
  27555. * Sets a callback that will be raised when the node will be disposed
  27556. */
  27557. onDispose: () => void;
  27558. /**
  27559. * Creates a new Node
  27560. * @param name the name and id to be given to this node
  27561. * @param scene the scene this node will be added to
  27562. * @param addToRootNodes the node will be added to scene.rootNodes
  27563. */
  27564. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27565. /**
  27566. * Gets the scene of the node
  27567. * @returns a scene
  27568. */
  27569. getScene(): Scene;
  27570. /**
  27571. * Gets the engine of the node
  27572. * @returns a Engine
  27573. */
  27574. getEngine(): Engine;
  27575. private _behaviors;
  27576. /**
  27577. * Attach a behavior to the node
  27578. * @see http://doc.babylonjs.com/features/behaviour
  27579. * @param behavior defines the behavior to attach
  27580. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27581. * @returns the current Node
  27582. */
  27583. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27584. /**
  27585. * Remove an attached behavior
  27586. * @see http://doc.babylonjs.com/features/behaviour
  27587. * @param behavior defines the behavior to attach
  27588. * @returns the current Node
  27589. */
  27590. removeBehavior(behavior: Behavior<Node>): Node;
  27591. /**
  27592. * Gets the list of attached behaviors
  27593. * @see http://doc.babylonjs.com/features/behaviour
  27594. */
  27595. readonly behaviors: Behavior<Node>[];
  27596. /**
  27597. * Gets an attached behavior by name
  27598. * @param name defines the name of the behavior to look for
  27599. * @see http://doc.babylonjs.com/features/behaviour
  27600. * @returns null if behavior was not found else the requested behavior
  27601. */
  27602. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27603. /**
  27604. * Returns the latest update of the World matrix
  27605. * @returns a Matrix
  27606. */
  27607. getWorldMatrix(): Matrix;
  27608. /** @hidden */
  27609. _getWorldMatrixDeterminant(): number;
  27610. /**
  27611. * Returns directly the latest state of the mesh World matrix.
  27612. * A Matrix is returned.
  27613. */
  27614. readonly worldMatrixFromCache: Matrix;
  27615. /** @hidden */
  27616. _initCache(): void;
  27617. /** @hidden */
  27618. updateCache(force?: boolean): void;
  27619. /** @hidden */
  27620. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27621. /** @hidden */
  27622. _updateCache(ignoreParentClass?: boolean): void;
  27623. /** @hidden */
  27624. _isSynchronized(): boolean;
  27625. /** @hidden */
  27626. _markSyncedWithParent(): void;
  27627. /** @hidden */
  27628. isSynchronizedWithParent(): boolean;
  27629. /** @hidden */
  27630. isSynchronized(): boolean;
  27631. /**
  27632. * Is this node ready to be used/rendered
  27633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27634. * @return true if the node is ready
  27635. */
  27636. isReady(completeCheck?: boolean): boolean;
  27637. /**
  27638. * Is this node enabled?
  27639. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  27640. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  27641. * @return whether this node (and its parent) is enabled
  27642. */
  27643. isEnabled(checkAncestors?: boolean): boolean;
  27644. /** @hidden */
  27645. protected _syncParentEnabledState(): void;
  27646. /**
  27647. * Set the enabled state of this node
  27648. * @param value defines the new enabled state
  27649. */
  27650. setEnabled(value: boolean): void;
  27651. /**
  27652. * Is this node a descendant of the given node?
  27653. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27654. * @param ancestor defines the parent node to inspect
  27655. * @returns a boolean indicating if this node is a descendant of the given node
  27656. */
  27657. isDescendantOf(ancestor: Node): boolean;
  27658. /** @hidden */
  27659. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27660. /**
  27661. * Will return all nodes that have this node as ascendant
  27662. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  27663. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27664. * @return all children nodes of all types
  27665. */
  27666. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27667. /**
  27668. * Get all child-meshes of this node
  27669. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  27670. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27671. * @returns an array of AbstractMesh
  27672. */
  27673. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27674. /**
  27675. * Get all direct children of this node
  27676. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27677. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  27678. * @returns an array of Node
  27679. */
  27680. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27681. /** @hidden */
  27682. _setReady(state: boolean): void;
  27683. /**
  27684. * Get an animation by name
  27685. * @param name defines the name of the animation to look for
  27686. * @returns null if not found else the requested animation
  27687. */
  27688. getAnimationByName(name: string): Nullable<Animation>;
  27689. /**
  27690. * Creates an animation range for this node
  27691. * @param name defines the name of the range
  27692. * @param from defines the starting key
  27693. * @param to defines the end key
  27694. */
  27695. createAnimationRange(name: string, from: number, to: number): void;
  27696. /**
  27697. * Delete a specific animation range
  27698. * @param name defines the name of the range to delete
  27699. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27700. */
  27701. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27702. /**
  27703. * Get an animation range by name
  27704. * @param name defines the name of the animation range to look for
  27705. * @returns null if not found else the requested animation range
  27706. */
  27707. getAnimationRange(name: string): Nullable<AnimationRange>;
  27708. /**
  27709. * Gets the list of all animation ranges defined on this node
  27710. * @returns an array
  27711. */
  27712. getAnimationRanges(): Nullable<AnimationRange>[];
  27713. /**
  27714. * Will start the animation sequence
  27715. * @param name defines the range frames for animation sequence
  27716. * @param loop defines if the animation should loop (false by default)
  27717. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27718. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27719. * @returns the object created for this animation. If range does not exist, it will return null
  27720. */
  27721. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27722. /**
  27723. * Serialize animation ranges into a JSON compatible object
  27724. * @returns serialization object
  27725. */
  27726. serializeAnimationRanges(): any;
  27727. /**
  27728. * Computes the world matrix of the node
  27729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27730. * @returns the world matrix
  27731. */
  27732. computeWorldMatrix(force?: boolean): Matrix;
  27733. /**
  27734. * Releases resources associated with this node.
  27735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27737. */
  27738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27739. /**
  27740. * Parse animation range data from a serialization object and store them into a given node
  27741. * @param node defines where to store the animation ranges
  27742. * @param parsedNode defines the serialization object to read data from
  27743. * @param scene defines the hosting scene
  27744. */
  27745. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27746. /**
  27747. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27748. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27749. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  27750. * @returns the new bounding vectors
  27751. */
  27752. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27753. min: Vector3;
  27754. max: Vector3;
  27755. };
  27756. }
  27757. }
  27758. declare module "babylonjs/Animations/animation" {
  27759. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27760. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27761. import { Color3 } from "babylonjs/Maths/math.color";
  27762. import { Nullable } from "babylonjs/types";
  27763. import { Scene } from "babylonjs/scene";
  27764. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27765. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27766. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27767. import { Node } from "babylonjs/node";
  27768. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27769. import { Size } from "babylonjs/Maths/math.size";
  27770. import { Animatable } from "babylonjs/Animations/animatable";
  27771. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27772. /**
  27773. * @hidden
  27774. */
  27775. export class _IAnimationState {
  27776. key: number;
  27777. repeatCount: number;
  27778. workValue?: any;
  27779. loopMode?: number;
  27780. offsetValue?: any;
  27781. highLimitValue?: any;
  27782. }
  27783. /**
  27784. * Class used to store any kind of animation
  27785. */
  27786. export class Animation {
  27787. /**Name of the animation */
  27788. name: string;
  27789. /**Property to animate */
  27790. targetProperty: string;
  27791. /**The frames per second of the animation */
  27792. framePerSecond: number;
  27793. /**The data type of the animation */
  27794. dataType: number;
  27795. /**The loop mode of the animation */
  27796. loopMode?: number | undefined;
  27797. /**Specifies if blending should be enabled */
  27798. enableBlending?: boolean | undefined;
  27799. /**
  27800. * Use matrix interpolation instead of using direct key value when animating matrices
  27801. */
  27802. static AllowMatricesInterpolation: boolean;
  27803. /**
  27804. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27805. */
  27806. static AllowMatrixDecomposeForInterpolation: boolean;
  27807. /**
  27808. * Stores the key frames of the animation
  27809. */
  27810. private _keys;
  27811. /**
  27812. * Stores the easing function of the animation
  27813. */
  27814. private _easingFunction;
  27815. /**
  27816. * @hidden Internal use only
  27817. */
  27818. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27819. /**
  27820. * The set of event that will be linked to this animation
  27821. */
  27822. private _events;
  27823. /**
  27824. * Stores an array of target property paths
  27825. */
  27826. targetPropertyPath: string[];
  27827. /**
  27828. * Stores the blending speed of the animation
  27829. */
  27830. blendingSpeed: number;
  27831. /**
  27832. * Stores the animation ranges for the animation
  27833. */
  27834. private _ranges;
  27835. /**
  27836. * @hidden Internal use
  27837. */
  27838. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27839. /**
  27840. * Sets up an animation
  27841. * @param property The property to animate
  27842. * @param animationType The animation type to apply
  27843. * @param framePerSecond The frames per second of the animation
  27844. * @param easingFunction The easing function used in the animation
  27845. * @returns The created animation
  27846. */
  27847. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27848. /**
  27849. * Create and start an animation on a node
  27850. * @param name defines the name of the global animation that will be run on all nodes
  27851. * @param node defines the root node where the animation will take place
  27852. * @param targetProperty defines property to animate
  27853. * @param framePerSecond defines the number of frame per second yo use
  27854. * @param totalFrame defines the number of frames in total
  27855. * @param from defines the initial value
  27856. * @param to defines the final value
  27857. * @param loopMode defines which loop mode you want to use (off by default)
  27858. * @param easingFunction defines the easing function to use (linear by default)
  27859. * @param onAnimationEnd defines the callback to call when animation end
  27860. * @returns the animatable created for this animation
  27861. */
  27862. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27863. /**
  27864. * Create and start an animation on a node and its descendants
  27865. * @param name defines the name of the global animation that will be run on all nodes
  27866. * @param node defines the root node where the animation will take place
  27867. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  27868. * @param targetProperty defines property to animate
  27869. * @param framePerSecond defines the number of frame per second to use
  27870. * @param totalFrame defines the number of frames in total
  27871. * @param from defines the initial value
  27872. * @param to defines the final value
  27873. * @param loopMode defines which loop mode you want to use (off by default)
  27874. * @param easingFunction defines the easing function to use (linear by default)
  27875. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27876. * @returns the list of animatables created for all nodes
  27877. * @example https://www.babylonjs-playground.com/#MH0VLI
  27878. */
  27879. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  27880. /**
  27881. * Creates a new animation, merges it with the existing animations and starts it
  27882. * @param name Name of the animation
  27883. * @param node Node which contains the scene that begins the animations
  27884. * @param targetProperty Specifies which property to animate
  27885. * @param framePerSecond The frames per second of the animation
  27886. * @param totalFrame The total number of frames
  27887. * @param from The frame at the beginning of the animation
  27888. * @param to The frame at the end of the animation
  27889. * @param loopMode Specifies the loop mode of the animation
  27890. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27891. * @param onAnimationEnd Callback to run once the animation is complete
  27892. * @returns Nullable animation
  27893. */
  27894. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27895. /**
  27896. * Transition property of an host to the target Value
  27897. * @param property The property to transition
  27898. * @param targetValue The target Value of the property
  27899. * @param host The object where the property to animate belongs
  27900. * @param scene Scene used to run the animation
  27901. * @param frameRate Framerate (in frame/s) to use
  27902. * @param transition The transition type we want to use
  27903. * @param duration The duration of the animation, in milliseconds
  27904. * @param onAnimationEnd Callback trigger at the end of the animation
  27905. * @returns Nullable animation
  27906. */
  27907. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27908. /**
  27909. * Return the array of runtime animations currently using this animation
  27910. */
  27911. readonly runtimeAnimations: RuntimeAnimation[];
  27912. /**
  27913. * Specifies if any of the runtime animations are currently running
  27914. */
  27915. readonly hasRunningRuntimeAnimations: boolean;
  27916. /**
  27917. * Initializes the animation
  27918. * @param name Name of the animation
  27919. * @param targetProperty Property to animate
  27920. * @param framePerSecond The frames per second of the animation
  27921. * @param dataType The data type of the animation
  27922. * @param loopMode The loop mode of the animation
  27923. * @param enableBlending Specifies if blending should be enabled
  27924. */
  27925. constructor(
  27926. /**Name of the animation */
  27927. name: string,
  27928. /**Property to animate */
  27929. targetProperty: string,
  27930. /**The frames per second of the animation */
  27931. framePerSecond: number,
  27932. /**The data type of the animation */
  27933. dataType: number,
  27934. /**The loop mode of the animation */
  27935. loopMode?: number | undefined,
  27936. /**Specifies if blending should be enabled */
  27937. enableBlending?: boolean | undefined);
  27938. /**
  27939. * Converts the animation to a string
  27940. * @param fullDetails support for multiple levels of logging within scene loading
  27941. * @returns String form of the animation
  27942. */
  27943. toString(fullDetails?: boolean): string;
  27944. /**
  27945. * Add an event to this animation
  27946. * @param event Event to add
  27947. */
  27948. addEvent(event: AnimationEvent): void;
  27949. /**
  27950. * Remove all events found at the given frame
  27951. * @param frame The frame to remove events from
  27952. */
  27953. removeEvents(frame: number): void;
  27954. /**
  27955. * Retrieves all the events from the animation
  27956. * @returns Events from the animation
  27957. */
  27958. getEvents(): AnimationEvent[];
  27959. /**
  27960. * Creates an animation range
  27961. * @param name Name of the animation range
  27962. * @param from Starting frame of the animation range
  27963. * @param to Ending frame of the animation
  27964. */
  27965. createRange(name: string, from: number, to: number): void;
  27966. /**
  27967. * Deletes an animation range by name
  27968. * @param name Name of the animation range to delete
  27969. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27970. */
  27971. deleteRange(name: string, deleteFrames?: boolean): void;
  27972. /**
  27973. * Gets the animation range by name, or null if not defined
  27974. * @param name Name of the animation range
  27975. * @returns Nullable animation range
  27976. */
  27977. getRange(name: string): Nullable<AnimationRange>;
  27978. /**
  27979. * Gets the key frames from the animation
  27980. * @returns The key frames of the animation
  27981. */
  27982. getKeys(): Array<IAnimationKey>;
  27983. /**
  27984. * Gets the highest frame rate of the animation
  27985. * @returns Highest frame rate of the animation
  27986. */
  27987. getHighestFrame(): number;
  27988. /**
  27989. * Gets the easing function of the animation
  27990. * @returns Easing function of the animation
  27991. */
  27992. getEasingFunction(): IEasingFunction;
  27993. /**
  27994. * Sets the easing function of the animation
  27995. * @param easingFunction A custom mathematical formula for animation
  27996. */
  27997. setEasingFunction(easingFunction: EasingFunction): void;
  27998. /**
  27999. * Interpolates a scalar linearly
  28000. * @param startValue Start value of the animation curve
  28001. * @param endValue End value of the animation curve
  28002. * @param gradient Scalar amount to interpolate
  28003. * @returns Interpolated scalar value
  28004. */
  28005. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28006. /**
  28007. * Interpolates a scalar cubically
  28008. * @param startValue Start value of the animation curve
  28009. * @param outTangent End tangent of the animation
  28010. * @param endValue End value of the animation curve
  28011. * @param inTangent Start tangent of the animation curve
  28012. * @param gradient Scalar amount to interpolate
  28013. * @returns Interpolated scalar value
  28014. */
  28015. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28016. /**
  28017. * Interpolates a quaternion using a spherical linear interpolation
  28018. * @param startValue Start value of the animation curve
  28019. * @param endValue End value of the animation curve
  28020. * @param gradient Scalar amount to interpolate
  28021. * @returns Interpolated quaternion value
  28022. */
  28023. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28024. /**
  28025. * Interpolates a quaternion cubically
  28026. * @param startValue Start value of the animation curve
  28027. * @param outTangent End tangent of the animation curve
  28028. * @param endValue End value of the animation curve
  28029. * @param inTangent Start tangent of the animation curve
  28030. * @param gradient Scalar amount to interpolate
  28031. * @returns Interpolated quaternion value
  28032. */
  28033. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28034. /**
  28035. * Interpolates a Vector3 linearl
  28036. * @param startValue Start value of the animation curve
  28037. * @param endValue End value of the animation curve
  28038. * @param gradient Scalar amount to interpolate
  28039. * @returns Interpolated scalar value
  28040. */
  28041. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28042. /**
  28043. * Interpolates a Vector3 cubically
  28044. * @param startValue Start value of the animation curve
  28045. * @param outTangent End tangent of the animation
  28046. * @param endValue End value of the animation curve
  28047. * @param inTangent Start tangent of the animation curve
  28048. * @param gradient Scalar amount to interpolate
  28049. * @returns InterpolatedVector3 value
  28050. */
  28051. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28052. /**
  28053. * Interpolates a Vector2 linearly
  28054. * @param startValue Start value of the animation curve
  28055. * @param endValue End value of the animation curve
  28056. * @param gradient Scalar amount to interpolate
  28057. * @returns Interpolated Vector2 value
  28058. */
  28059. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28060. /**
  28061. * Interpolates a Vector2 cubically
  28062. * @param startValue Start value of the animation curve
  28063. * @param outTangent End tangent of the animation
  28064. * @param endValue End value of the animation curve
  28065. * @param inTangent Start tangent of the animation curve
  28066. * @param gradient Scalar amount to interpolate
  28067. * @returns Interpolated Vector2 value
  28068. */
  28069. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28070. /**
  28071. * Interpolates a size linearly
  28072. * @param startValue Start value of the animation curve
  28073. * @param endValue End value of the animation curve
  28074. * @param gradient Scalar amount to interpolate
  28075. * @returns Interpolated Size value
  28076. */
  28077. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28078. /**
  28079. * Interpolates a Color3 linearly
  28080. * @param startValue Start value of the animation curve
  28081. * @param endValue End value of the animation curve
  28082. * @param gradient Scalar amount to interpolate
  28083. * @returns Interpolated Color3 value
  28084. */
  28085. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28086. /**
  28087. * @hidden Internal use only
  28088. */
  28089. _getKeyValue(value: any): any;
  28090. /**
  28091. * @hidden Internal use only
  28092. */
  28093. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28094. /**
  28095. * Defines the function to use to interpolate matrices
  28096. * @param startValue defines the start matrix
  28097. * @param endValue defines the end matrix
  28098. * @param gradient defines the gradient between both matrices
  28099. * @param result defines an optional target matrix where to store the interpolation
  28100. * @returns the interpolated matrix
  28101. */
  28102. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28103. /**
  28104. * Makes a copy of the animation
  28105. * @returns Cloned animation
  28106. */
  28107. clone(): Animation;
  28108. /**
  28109. * Sets the key frames of the animation
  28110. * @param values The animation key frames to set
  28111. */
  28112. setKeys(values: Array<IAnimationKey>): void;
  28113. /**
  28114. * Serializes the animation to an object
  28115. * @returns Serialized object
  28116. */
  28117. serialize(): any;
  28118. /**
  28119. * Float animation type
  28120. */
  28121. private static _ANIMATIONTYPE_FLOAT;
  28122. /**
  28123. * Vector3 animation type
  28124. */
  28125. private static _ANIMATIONTYPE_VECTOR3;
  28126. /**
  28127. * Quaternion animation type
  28128. */
  28129. private static _ANIMATIONTYPE_QUATERNION;
  28130. /**
  28131. * Matrix animation type
  28132. */
  28133. private static _ANIMATIONTYPE_MATRIX;
  28134. /**
  28135. * Color3 animation type
  28136. */
  28137. private static _ANIMATIONTYPE_COLOR3;
  28138. /**
  28139. * Vector2 animation type
  28140. */
  28141. private static _ANIMATIONTYPE_VECTOR2;
  28142. /**
  28143. * Size animation type
  28144. */
  28145. private static _ANIMATIONTYPE_SIZE;
  28146. /**
  28147. * Relative Loop Mode
  28148. */
  28149. private static _ANIMATIONLOOPMODE_RELATIVE;
  28150. /**
  28151. * Cycle Loop Mode
  28152. */
  28153. private static _ANIMATIONLOOPMODE_CYCLE;
  28154. /**
  28155. * Constant Loop Mode
  28156. */
  28157. private static _ANIMATIONLOOPMODE_CONSTANT;
  28158. /**
  28159. * Get the float animation type
  28160. */
  28161. static readonly ANIMATIONTYPE_FLOAT: number;
  28162. /**
  28163. * Get the Vector3 animation type
  28164. */
  28165. static readonly ANIMATIONTYPE_VECTOR3: number;
  28166. /**
  28167. * Get the Vector2 animation type
  28168. */
  28169. static readonly ANIMATIONTYPE_VECTOR2: number;
  28170. /**
  28171. * Get the Size animation type
  28172. */
  28173. static readonly ANIMATIONTYPE_SIZE: number;
  28174. /**
  28175. * Get the Quaternion animation type
  28176. */
  28177. static readonly ANIMATIONTYPE_QUATERNION: number;
  28178. /**
  28179. * Get the Matrix animation type
  28180. */
  28181. static readonly ANIMATIONTYPE_MATRIX: number;
  28182. /**
  28183. * Get the Color3 animation type
  28184. */
  28185. static readonly ANIMATIONTYPE_COLOR3: number;
  28186. /**
  28187. * Get the Relative Loop Mode
  28188. */
  28189. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28190. /**
  28191. * Get the Cycle Loop Mode
  28192. */
  28193. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28194. /**
  28195. * Get the Constant Loop Mode
  28196. */
  28197. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28198. /** @hidden */
  28199. static _UniversalLerp(left: any, right: any, amount: number): any;
  28200. /**
  28201. * Parses an animation object and creates an animation
  28202. * @param parsedAnimation Parsed animation object
  28203. * @returns Animation object
  28204. */
  28205. static Parse(parsedAnimation: any): Animation;
  28206. /**
  28207. * Appends the serialized animations from the source animations
  28208. * @param source Source containing the animations
  28209. * @param destination Target to store the animations
  28210. */
  28211. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28212. }
  28213. }
  28214. declare module "babylonjs/Animations/animatable.interface" {
  28215. import { Nullable } from "babylonjs/types";
  28216. import { Animation } from "babylonjs/Animations/animation";
  28217. /**
  28218. * Interface containing an array of animations
  28219. */
  28220. export interface IAnimatable {
  28221. /**
  28222. * Array of animations
  28223. */
  28224. animations: Nullable<Array<Animation>>;
  28225. }
  28226. }
  28227. declare module "babylonjs/Materials/fresnelParameters" {
  28228. import { Color3 } from "babylonjs/Maths/math.color";
  28229. /**
  28230. * This represents all the required information to add a fresnel effect on a material:
  28231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28232. */
  28233. export class FresnelParameters {
  28234. private _isEnabled;
  28235. /**
  28236. * Define if the fresnel effect is enable or not.
  28237. */
  28238. isEnabled: boolean;
  28239. /**
  28240. * Define the color used on edges (grazing angle)
  28241. */
  28242. leftColor: Color3;
  28243. /**
  28244. * Define the color used on center
  28245. */
  28246. rightColor: Color3;
  28247. /**
  28248. * Define bias applied to computed fresnel term
  28249. */
  28250. bias: number;
  28251. /**
  28252. * Defined the power exponent applied to fresnel term
  28253. */
  28254. power: number;
  28255. /**
  28256. * Clones the current fresnel and its valuues
  28257. * @returns a clone fresnel configuration
  28258. */
  28259. clone(): FresnelParameters;
  28260. /**
  28261. * Serializes the current fresnel parameters to a JSON representation.
  28262. * @return the JSON serialization
  28263. */
  28264. serialize(): any;
  28265. /**
  28266. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28267. * @param parsedFresnelParameters Define the JSON representation
  28268. * @returns the parsed parameters
  28269. */
  28270. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28271. }
  28272. }
  28273. declare module "babylonjs/Misc/decorators" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28276. import { Scene } from "babylonjs/scene";
  28277. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28278. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28279. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28280. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28281. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28282. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28283. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28284. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28285. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28286. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28287. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28288. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28289. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28290. /**
  28291. * Decorator used to define property that can be serialized as reference to a camera
  28292. * @param sourceName defines the name of the property to decorate
  28293. */
  28294. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28295. /**
  28296. * Class used to help serialization objects
  28297. */
  28298. export class SerializationHelper {
  28299. /** @hidden */
  28300. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28301. /** @hidden */
  28302. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28303. /** @hidden */
  28304. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28305. /** @hidden */
  28306. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28307. /**
  28308. * Appends the serialized animations from the source animations
  28309. * @param source Source containing the animations
  28310. * @param destination Target to store the animations
  28311. */
  28312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28313. /**
  28314. * Static function used to serialized a specific entity
  28315. * @param entity defines the entity to serialize
  28316. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28317. * @returns a JSON compatible object representing the serialization of the entity
  28318. */
  28319. static Serialize<T>(entity: T, serializationObject?: any): any;
  28320. /**
  28321. * Creates a new entity from a serialization data object
  28322. * @param creationFunction defines a function used to instanciated the new entity
  28323. * @param source defines the source serialization data
  28324. * @param scene defines the hosting scene
  28325. * @param rootUrl defines the root url for resources
  28326. * @returns a new entity
  28327. */
  28328. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28329. /**
  28330. * Clones an object
  28331. * @param creationFunction defines the function used to instanciate the new object
  28332. * @param source defines the source object
  28333. * @returns the cloned object
  28334. */
  28335. static Clone<T>(creationFunction: () => T, source: T): T;
  28336. /**
  28337. * Instanciates a new object based on a source one (some data will be shared between both object)
  28338. * @param creationFunction defines the function used to instanciate the new object
  28339. * @param source defines the source object
  28340. * @returns the new object
  28341. */
  28342. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28343. }
  28344. }
  28345. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28346. import { Nullable } from "babylonjs/types";
  28347. /**
  28348. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28349. */
  28350. export interface CubeMapInfo {
  28351. /**
  28352. * The pixel array for the front face.
  28353. * This is stored in format, left to right, up to down format.
  28354. */
  28355. front: Nullable<ArrayBufferView>;
  28356. /**
  28357. * The pixel array for the back face.
  28358. * This is stored in format, left to right, up to down format.
  28359. */
  28360. back: Nullable<ArrayBufferView>;
  28361. /**
  28362. * The pixel array for the left face.
  28363. * This is stored in format, left to right, up to down format.
  28364. */
  28365. left: Nullable<ArrayBufferView>;
  28366. /**
  28367. * The pixel array for the right face.
  28368. * This is stored in format, left to right, up to down format.
  28369. */
  28370. right: Nullable<ArrayBufferView>;
  28371. /**
  28372. * The pixel array for the up face.
  28373. * This is stored in format, left to right, up to down format.
  28374. */
  28375. up: Nullable<ArrayBufferView>;
  28376. /**
  28377. * The pixel array for the down face.
  28378. * This is stored in format, left to right, up to down format.
  28379. */
  28380. down: Nullable<ArrayBufferView>;
  28381. /**
  28382. * The size of the cubemap stored.
  28383. *
  28384. * Each faces will be size * size pixels.
  28385. */
  28386. size: number;
  28387. /**
  28388. * The format of the texture.
  28389. *
  28390. * RGBA, RGB.
  28391. */
  28392. format: number;
  28393. /**
  28394. * The type of the texture data.
  28395. *
  28396. * UNSIGNED_INT, FLOAT.
  28397. */
  28398. type: number;
  28399. /**
  28400. * Specifies whether the texture is in gamma space.
  28401. */
  28402. gammaSpace: boolean;
  28403. }
  28404. /**
  28405. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28406. */
  28407. export class PanoramaToCubeMapTools {
  28408. private static FACE_FRONT;
  28409. private static FACE_BACK;
  28410. private static FACE_RIGHT;
  28411. private static FACE_LEFT;
  28412. private static FACE_DOWN;
  28413. private static FACE_UP;
  28414. /**
  28415. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28416. *
  28417. * @param float32Array The source data.
  28418. * @param inputWidth The width of the input panorama.
  28419. * @param inputHeight The height of the input panorama.
  28420. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28421. * @return The cubemap data
  28422. */
  28423. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28424. private static CreateCubemapTexture;
  28425. private static CalcProjectionSpherical;
  28426. }
  28427. }
  28428. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28429. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28431. import { Nullable } from "babylonjs/types";
  28432. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28433. /**
  28434. * Helper class dealing with the extraction of spherical polynomial dataArray
  28435. * from a cube map.
  28436. */
  28437. export class CubeMapToSphericalPolynomialTools {
  28438. private static FileFaces;
  28439. /**
  28440. * Converts a texture to the according Spherical Polynomial data.
  28441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28442. *
  28443. * @param texture The texture to extract the information from.
  28444. * @return The Spherical Polynomial data.
  28445. */
  28446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28447. /**
  28448. * Converts a cubemap to the according Spherical Polynomial data.
  28449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28450. *
  28451. * @param cubeInfo The Cube map to extract the information from.
  28452. * @return The Spherical Polynomial data.
  28453. */
  28454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28455. }
  28456. }
  28457. declare module "babylonjs/Misc/guid" {
  28458. /**
  28459. * Class used to manipulate GUIDs
  28460. */
  28461. export class GUID {
  28462. /**
  28463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28464. * Be aware Math.random() could cause collisions, but:
  28465. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  28466. * @returns a pseudo random id
  28467. */
  28468. static RandomId(): string;
  28469. }
  28470. }
  28471. declare module "babylonjs/Materials/Textures/baseTexture" {
  28472. import { Observable } from "babylonjs/Misc/observable";
  28473. import { Nullable } from "babylonjs/types";
  28474. import { Scene } from "babylonjs/scene";
  28475. import { Matrix } from "babylonjs/Maths/math.vector";
  28476. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28478. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28479. import { ISize } from "babylonjs/Maths/math.size";
  28480. /**
  28481. * Base class of all the textures in babylon.
  28482. * It groups all the common properties the materials, post process, lights... might need
  28483. * in order to make a correct use of the texture.
  28484. */
  28485. export class BaseTexture implements IAnimatable {
  28486. /**
  28487. * Default anisotropic filtering level for the application.
  28488. * It is set to 4 as a good tradeoff between perf and quality.
  28489. */
  28490. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28491. /**
  28492. * Gets or sets the unique id of the texture
  28493. */
  28494. uniqueId: number;
  28495. /**
  28496. * Define the name of the texture.
  28497. */
  28498. name: string;
  28499. /**
  28500. * Gets or sets an object used to store user defined information.
  28501. */
  28502. metadata: any;
  28503. /**
  28504. * For internal use only. Please do not use.
  28505. */
  28506. reservedDataStore: any;
  28507. private _hasAlpha;
  28508. /**
  28509. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28510. */
  28511. hasAlpha: boolean;
  28512. /**
  28513. * Defines if the alpha value should be determined via the rgb values.
  28514. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28515. */
  28516. getAlphaFromRGB: boolean;
  28517. /**
  28518. * Intensity or strength of the texture.
  28519. * It is commonly used by materials to fine tune the intensity of the texture
  28520. */
  28521. level: number;
  28522. /**
  28523. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28524. * This is part of the texture as textures usually maps to one uv set.
  28525. */
  28526. coordinatesIndex: number;
  28527. private _coordinatesMode;
  28528. /**
  28529. * How a texture is mapped.
  28530. *
  28531. * | Value | Type | Description |
  28532. * | ----- | ----------------------------------- | ----------- |
  28533. * | 0 | EXPLICIT_MODE | |
  28534. * | 1 | SPHERICAL_MODE | |
  28535. * | 2 | PLANAR_MODE | |
  28536. * | 3 | CUBIC_MODE | |
  28537. * | 4 | PROJECTION_MODE | |
  28538. * | 5 | SKYBOX_MODE | |
  28539. * | 6 | INVCUBIC_MODE | |
  28540. * | 7 | EQUIRECTANGULAR_MODE | |
  28541. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28542. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28543. */
  28544. coordinatesMode: number;
  28545. /**
  28546. * | Value | Type | Description |
  28547. * | ----- | ------------------ | ----------- |
  28548. * | 0 | CLAMP_ADDRESSMODE | |
  28549. * | 1 | WRAP_ADDRESSMODE | |
  28550. * | 2 | MIRROR_ADDRESSMODE | |
  28551. */
  28552. wrapU: number;
  28553. /**
  28554. * | Value | Type | Description |
  28555. * | ----- | ------------------ | ----------- |
  28556. * | 0 | CLAMP_ADDRESSMODE | |
  28557. * | 1 | WRAP_ADDRESSMODE | |
  28558. * | 2 | MIRROR_ADDRESSMODE | |
  28559. */
  28560. wrapV: number;
  28561. /**
  28562. * | Value | Type | Description |
  28563. * | ----- | ------------------ | ----------- |
  28564. * | 0 | CLAMP_ADDRESSMODE | |
  28565. * | 1 | WRAP_ADDRESSMODE | |
  28566. * | 2 | MIRROR_ADDRESSMODE | |
  28567. */
  28568. wrapR: number;
  28569. /**
  28570. * With compliant hardware and browser (supporting anisotropic filtering)
  28571. * this defines the level of anisotropic filtering in the texture.
  28572. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28573. */
  28574. anisotropicFilteringLevel: number;
  28575. /**
  28576. * Define if the texture is a cube texture or if false a 2d texture.
  28577. */
  28578. isCube: boolean;
  28579. /**
  28580. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28581. */
  28582. is3D: boolean;
  28583. /**
  28584. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28585. * HDR texture are usually stored in linear space.
  28586. * This only impacts the PBR and Background materials
  28587. */
  28588. gammaSpace: boolean;
  28589. /**
  28590. * Gets or sets whether or not the texture contains RGBD data.
  28591. */
  28592. isRGBD: boolean;
  28593. /**
  28594. * Is Z inverted in the texture (useful in a cube texture).
  28595. */
  28596. invertZ: boolean;
  28597. /**
  28598. * Are mip maps generated for this texture or not.
  28599. */
  28600. readonly noMipmap: boolean;
  28601. /**
  28602. * @hidden
  28603. */
  28604. lodLevelInAlpha: boolean;
  28605. /**
  28606. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28607. */
  28608. lodGenerationOffset: number;
  28609. /**
  28610. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28611. */
  28612. lodGenerationScale: number;
  28613. /**
  28614. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28615. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28616. * average roughness values.
  28617. */
  28618. linearSpecularLOD: boolean;
  28619. /**
  28620. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28621. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28622. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28623. */
  28624. irradianceTexture: Nullable<BaseTexture>;
  28625. /**
  28626. * Define if the texture is a render target.
  28627. */
  28628. isRenderTarget: boolean;
  28629. /**
  28630. * Define the unique id of the texture in the scene.
  28631. */
  28632. readonly uid: string;
  28633. /**
  28634. * Return a string representation of the texture.
  28635. * @returns the texture as a string
  28636. */
  28637. toString(): string;
  28638. /**
  28639. * Get the class name of the texture.
  28640. * @returns "BaseTexture"
  28641. */
  28642. getClassName(): string;
  28643. /**
  28644. * Define the list of animation attached to the texture.
  28645. */
  28646. animations: import("babylonjs/Animations/animation").Animation[];
  28647. /**
  28648. * An event triggered when the texture is disposed.
  28649. */
  28650. onDisposeObservable: Observable<BaseTexture>;
  28651. private _onDisposeObserver;
  28652. /**
  28653. * Callback triggered when the texture has been disposed.
  28654. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28655. */
  28656. onDispose: () => void;
  28657. /**
  28658. * Define the current state of the loading sequence when in delayed load mode.
  28659. */
  28660. delayLoadState: number;
  28661. private _scene;
  28662. /** @hidden */
  28663. _texture: Nullable<InternalTexture>;
  28664. private _uid;
  28665. /**
  28666. * Define if the texture is preventinga material to render or not.
  28667. * If not and the texture is not ready, the engine will use a default black texture instead.
  28668. */
  28669. readonly isBlocking: boolean;
  28670. /**
  28671. * Instantiates a new BaseTexture.
  28672. * Base class of all the textures in babylon.
  28673. * It groups all the common properties the materials, post process, lights... might need
  28674. * in order to make a correct use of the texture.
  28675. * @param scene Define the scene the texture blongs to
  28676. */
  28677. constructor(scene: Nullable<Scene>);
  28678. /**
  28679. * Get the scene the texture belongs to.
  28680. * @returns the scene or null if undefined
  28681. */
  28682. getScene(): Nullable<Scene>;
  28683. /**
  28684. * Get the texture transform matrix used to offset tile the texture for istance.
  28685. * @returns the transformation matrix
  28686. */
  28687. getTextureMatrix(): Matrix;
  28688. /**
  28689. * Get the texture reflection matrix used to rotate/transform the reflection.
  28690. * @returns the reflection matrix
  28691. */
  28692. getReflectionTextureMatrix(): Matrix;
  28693. /**
  28694. * Get the underlying lower level texture from Babylon.
  28695. * @returns the insternal texture
  28696. */
  28697. getInternalTexture(): Nullable<InternalTexture>;
  28698. /**
  28699. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28700. * @returns true if ready or not blocking
  28701. */
  28702. isReadyOrNotBlocking(): boolean;
  28703. /**
  28704. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28705. * @returns true if fully ready
  28706. */
  28707. isReady(): boolean;
  28708. private _cachedSize;
  28709. /**
  28710. * Get the size of the texture.
  28711. * @returns the texture size.
  28712. */
  28713. getSize(): ISize;
  28714. /**
  28715. * Get the base size of the texture.
  28716. * It can be different from the size if the texture has been resized for POT for instance
  28717. * @returns the base size
  28718. */
  28719. getBaseSize(): ISize;
  28720. /**
  28721. * Update the sampling mode of the texture.
  28722. * Default is Trilinear mode.
  28723. *
  28724. * | Value | Type | Description |
  28725. * | ----- | ------------------ | ----------- |
  28726. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28727. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28728. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28729. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28730. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28731. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28732. * | 7 | NEAREST_LINEAR | |
  28733. * | 8 | NEAREST_NEAREST | |
  28734. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28735. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28736. * | 11 | LINEAR_LINEAR | |
  28737. * | 12 | LINEAR_NEAREST | |
  28738. *
  28739. * > _mag_: magnification filter (close to the viewer)
  28740. * > _min_: minification filter (far from the viewer)
  28741. * > _mip_: filter used between mip map levels
  28742. *@param samplingMode Define the new sampling mode of the texture
  28743. */
  28744. updateSamplingMode(samplingMode: number): void;
  28745. /**
  28746. * Scales the texture if is `canRescale()`
  28747. * @param ratio the resize factor we want to use to rescale
  28748. */
  28749. scale(ratio: number): void;
  28750. /**
  28751. * Get if the texture can rescale.
  28752. */
  28753. readonly canRescale: boolean;
  28754. /** @hidden */
  28755. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28756. /** @hidden */
  28757. _rebuild(): void;
  28758. /**
  28759. * Triggers the load sequence in delayed load mode.
  28760. */
  28761. delayLoad(): void;
  28762. /**
  28763. * Clones the texture.
  28764. * @returns the cloned texture
  28765. */
  28766. clone(): Nullable<BaseTexture>;
  28767. /**
  28768. * Get the texture underlying type (INT, FLOAT...)
  28769. */
  28770. readonly textureType: number;
  28771. /**
  28772. * Get the texture underlying format (RGB, RGBA...)
  28773. */
  28774. readonly textureFormat: number;
  28775. /**
  28776. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28777. * This will returns an RGBA array buffer containing either in values (0-255) or
  28778. * float values (0-1) depending of the underlying buffer type.
  28779. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28780. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28781. * @param buffer defines a user defined buffer to fill with data (can be null)
  28782. * @returns The Array buffer containing the pixels data.
  28783. */
  28784. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28785. /**
  28786. * Release and destroy the underlying lower level texture aka internalTexture.
  28787. */
  28788. releaseInternalTexture(): void;
  28789. /**
  28790. * Get the polynomial representation of the texture data.
  28791. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28792. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28793. */
  28794. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28795. /** @hidden */
  28796. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28797. /** @hidden */
  28798. readonly _lodTextureMid: Nullable<BaseTexture>;
  28799. /** @hidden */
  28800. readonly _lodTextureLow: Nullable<BaseTexture>;
  28801. /**
  28802. * Dispose the texture and release its associated resources.
  28803. */
  28804. dispose(): void;
  28805. /**
  28806. * Serialize the texture into a JSON representation that can be parsed later on.
  28807. * @returns the JSON representation of the texture
  28808. */
  28809. serialize(): any;
  28810. /**
  28811. * Helper function to be called back once a list of texture contains only ready textures.
  28812. * @param textures Define the list of textures to wait for
  28813. * @param callback Define the callback triggered once the entire list will be ready
  28814. */
  28815. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28816. }
  28817. }
  28818. declare module "babylonjs/Materials/Textures/internalTexture" {
  28819. import { Observable } from "babylonjs/Misc/observable";
  28820. import { Nullable, int } from "babylonjs/types";
  28821. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28822. import { Engine } from "babylonjs/Engines/engine";
  28823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28824. /**
  28825. * Class used to store data associated with WebGL texture data for the engine
  28826. * This class should not be used directly
  28827. */
  28828. export class InternalTexture {
  28829. /** @hidden */
  28830. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28831. /**
  28832. * The source of the texture data is unknown
  28833. */
  28834. static DATASOURCE_UNKNOWN: number;
  28835. /**
  28836. * Texture data comes from an URL
  28837. */
  28838. static DATASOURCE_URL: number;
  28839. /**
  28840. * Texture data is only used for temporary storage
  28841. */
  28842. static DATASOURCE_TEMP: number;
  28843. /**
  28844. * Texture data comes from raw data (ArrayBuffer)
  28845. */
  28846. static DATASOURCE_RAW: number;
  28847. /**
  28848. * Texture content is dynamic (video or dynamic texture)
  28849. */
  28850. static DATASOURCE_DYNAMIC: number;
  28851. /**
  28852. * Texture content is generated by rendering to it
  28853. */
  28854. static DATASOURCE_RENDERTARGET: number;
  28855. /**
  28856. * Texture content is part of a multi render target process
  28857. */
  28858. static DATASOURCE_MULTIRENDERTARGET: number;
  28859. /**
  28860. * Texture data comes from a cube data file
  28861. */
  28862. static DATASOURCE_CUBE: number;
  28863. /**
  28864. * Texture data comes from a raw cube data
  28865. */
  28866. static DATASOURCE_CUBERAW: number;
  28867. /**
  28868. * Texture data come from a prefiltered cube data file
  28869. */
  28870. static DATASOURCE_CUBEPREFILTERED: number;
  28871. /**
  28872. * Texture content is raw 3D data
  28873. */
  28874. static DATASOURCE_RAW3D: number;
  28875. /**
  28876. * Texture content is a depth texture
  28877. */
  28878. static DATASOURCE_DEPTHTEXTURE: number;
  28879. /**
  28880. * Texture data comes from a raw cube data encoded with RGBD
  28881. */
  28882. static DATASOURCE_CUBERAW_RGBD: number;
  28883. /**
  28884. * Defines if the texture is ready
  28885. */
  28886. isReady: boolean;
  28887. /**
  28888. * Defines if the texture is a cube texture
  28889. */
  28890. isCube: boolean;
  28891. /**
  28892. * Defines if the texture contains 3D data
  28893. */
  28894. is3D: boolean;
  28895. /**
  28896. * Defines if the texture contains multiview data
  28897. */
  28898. isMultiview: boolean;
  28899. /**
  28900. * Gets the URL used to load this texture
  28901. */
  28902. url: string;
  28903. /**
  28904. * Gets the sampling mode of the texture
  28905. */
  28906. samplingMode: number;
  28907. /**
  28908. * Gets a boolean indicating if the texture needs mipmaps generation
  28909. */
  28910. generateMipMaps: boolean;
  28911. /**
  28912. * Gets the number of samples used by the texture (WebGL2+ only)
  28913. */
  28914. samples: number;
  28915. /**
  28916. * Gets the type of the texture (int, float...)
  28917. */
  28918. type: number;
  28919. /**
  28920. * Gets the format of the texture (RGB, RGBA...)
  28921. */
  28922. format: number;
  28923. /**
  28924. * Observable called when the texture is loaded
  28925. */
  28926. onLoadedObservable: Observable<InternalTexture>;
  28927. /**
  28928. * Gets the width of the texture
  28929. */
  28930. width: number;
  28931. /**
  28932. * Gets the height of the texture
  28933. */
  28934. height: number;
  28935. /**
  28936. * Gets the depth of the texture
  28937. */
  28938. depth: number;
  28939. /**
  28940. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28941. */
  28942. baseWidth: number;
  28943. /**
  28944. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28945. */
  28946. baseHeight: number;
  28947. /**
  28948. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28949. */
  28950. baseDepth: number;
  28951. /**
  28952. * Gets a boolean indicating if the texture is inverted on Y axis
  28953. */
  28954. invertY: boolean;
  28955. /** @hidden */
  28956. _invertVScale: boolean;
  28957. /** @hidden */
  28958. _associatedChannel: number;
  28959. /** @hidden */
  28960. _dataSource: number;
  28961. /** @hidden */
  28962. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28963. /** @hidden */
  28964. _bufferView: Nullable<ArrayBufferView>;
  28965. /** @hidden */
  28966. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28967. /** @hidden */
  28968. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28969. /** @hidden */
  28970. _size: number;
  28971. /** @hidden */
  28972. _extension: string;
  28973. /** @hidden */
  28974. _files: Nullable<string[]>;
  28975. /** @hidden */
  28976. _workingCanvas: Nullable<HTMLCanvasElement>;
  28977. /** @hidden */
  28978. _workingContext: Nullable<CanvasRenderingContext2D>;
  28979. /** @hidden */
  28980. _framebuffer: Nullable<WebGLFramebuffer>;
  28981. /** @hidden */
  28982. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28983. /** @hidden */
  28984. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28985. /** @hidden */
  28986. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28987. /** @hidden */
  28988. _attachments: Nullable<number[]>;
  28989. /** @hidden */
  28990. _cachedCoordinatesMode: Nullable<number>;
  28991. /** @hidden */
  28992. _cachedWrapU: Nullable<number>;
  28993. /** @hidden */
  28994. _cachedWrapV: Nullable<number>;
  28995. /** @hidden */
  28996. _cachedWrapR: Nullable<number>;
  28997. /** @hidden */
  28998. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28999. /** @hidden */
  29000. _isDisabled: boolean;
  29001. /** @hidden */
  29002. _compression: Nullable<string>;
  29003. /** @hidden */
  29004. _generateStencilBuffer: boolean;
  29005. /** @hidden */
  29006. _generateDepthBuffer: boolean;
  29007. /** @hidden */
  29008. _comparisonFunction: number;
  29009. /** @hidden */
  29010. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29011. /** @hidden */
  29012. _lodGenerationScale: number;
  29013. /** @hidden */
  29014. _lodGenerationOffset: number;
  29015. /** @hidden */
  29016. _colorTextureArray: Nullable<WebGLTexture>;
  29017. /** @hidden */
  29018. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29019. /** @hidden */
  29020. _lodTextureHigh: Nullable<BaseTexture>;
  29021. /** @hidden */
  29022. _lodTextureMid: Nullable<BaseTexture>;
  29023. /** @hidden */
  29024. _lodTextureLow: Nullable<BaseTexture>;
  29025. /** @hidden */
  29026. _isRGBD: boolean;
  29027. /** @hidden */
  29028. _linearSpecularLOD: boolean;
  29029. /** @hidden */
  29030. _irradianceTexture: Nullable<BaseTexture>;
  29031. /** @hidden */
  29032. _webGLTexture: Nullable<WebGLTexture>;
  29033. /** @hidden */
  29034. _references: number;
  29035. private _engine;
  29036. /**
  29037. * Gets the Engine the texture belongs to.
  29038. * @returns The babylon engine
  29039. */
  29040. getEngine(): Engine;
  29041. /**
  29042. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29043. */
  29044. readonly dataSource: number;
  29045. /**
  29046. * Creates a new InternalTexture
  29047. * @param engine defines the engine to use
  29048. * @param dataSource defines the type of data that will be used
  29049. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29050. */
  29051. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29052. /**
  29053. * Increments the number of references (ie. the number of Texture that point to it)
  29054. */
  29055. incrementReferences(): void;
  29056. /**
  29057. * Change the size of the texture (not the size of the content)
  29058. * @param width defines the new width
  29059. * @param height defines the new height
  29060. * @param depth defines the new depth (1 by default)
  29061. */
  29062. updateSize(width: int, height: int, depth?: int): void;
  29063. /** @hidden */
  29064. _rebuild(): void;
  29065. /** @hidden */
  29066. _swapAndDie(target: InternalTexture): void;
  29067. /**
  29068. * Dispose the current allocated resources
  29069. */
  29070. dispose(): void;
  29071. }
  29072. }
  29073. declare module "babylonjs/Materials/effect" {
  29074. import { Observable } from "babylonjs/Misc/observable";
  29075. import { Nullable } from "babylonjs/types";
  29076. import { IDisposable } from "babylonjs/scene";
  29077. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29078. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29079. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29080. import { Engine } from "babylonjs/Engines/engine";
  29081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29084. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29086. /**
  29087. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29088. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29089. */
  29090. export class EffectFallbacks {
  29091. private _defines;
  29092. private _currentRank;
  29093. private _maxRank;
  29094. private _mesh;
  29095. /**
  29096. * Removes the fallback from the bound mesh.
  29097. */
  29098. unBindMesh(): void;
  29099. /**
  29100. * Adds a fallback on the specified property.
  29101. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29102. * @param define The name of the define in the shader
  29103. */
  29104. addFallback(rank: number, define: string): void;
  29105. /**
  29106. * Sets the mesh to use CPU skinning when needing to fallback.
  29107. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29108. * @param mesh The mesh to use the fallbacks.
  29109. */
  29110. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29111. /**
  29112. * Checks to see if more fallbacks are still availible.
  29113. */
  29114. readonly hasMoreFallbacks: boolean;
  29115. /**
  29116. * Removes the defines that should be removed when falling back.
  29117. * @param currentDefines defines the current define statements for the shader.
  29118. * @param effect defines the current effect we try to compile
  29119. * @returns The resulting defines with defines of the current rank removed.
  29120. */
  29121. reduce(currentDefines: string, effect: Effect): string;
  29122. }
  29123. /**
  29124. * Options to be used when creating an effect.
  29125. */
  29126. export class EffectCreationOptions {
  29127. /**
  29128. * Atrributes that will be used in the shader.
  29129. */
  29130. attributes: string[];
  29131. /**
  29132. * Uniform varible names that will be set in the shader.
  29133. */
  29134. uniformsNames: string[];
  29135. /**
  29136. * Uniform buffer varible names that will be set in the shader.
  29137. */
  29138. uniformBuffersNames: string[];
  29139. /**
  29140. * Sampler texture variable names that will be set in the shader.
  29141. */
  29142. samplers: string[];
  29143. /**
  29144. * Define statements that will be set in the shader.
  29145. */
  29146. defines: any;
  29147. /**
  29148. * Possible fallbacks for this effect to improve performance when needed.
  29149. */
  29150. fallbacks: Nullable<EffectFallbacks>;
  29151. /**
  29152. * Callback that will be called when the shader is compiled.
  29153. */
  29154. onCompiled: Nullable<(effect: Effect) => void>;
  29155. /**
  29156. * Callback that will be called if an error occurs during shader compilation.
  29157. */
  29158. onError: Nullable<(effect: Effect, errors: string) => void>;
  29159. /**
  29160. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29161. */
  29162. indexParameters: any;
  29163. /**
  29164. * Max number of lights that can be used in the shader.
  29165. */
  29166. maxSimultaneousLights: number;
  29167. /**
  29168. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29169. */
  29170. transformFeedbackVaryings: Nullable<string[]>;
  29171. }
  29172. /**
  29173. * Effect containing vertex and fragment shader that can be executed on an object.
  29174. */
  29175. export class Effect implements IDisposable {
  29176. /**
  29177. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29178. */
  29179. static ShadersRepository: string;
  29180. /**
  29181. * Name of the effect.
  29182. */
  29183. name: any;
  29184. /**
  29185. * String container all the define statements that should be set on the shader.
  29186. */
  29187. defines: string;
  29188. /**
  29189. * Callback that will be called when the shader is compiled.
  29190. */
  29191. onCompiled: Nullable<(effect: Effect) => void>;
  29192. /**
  29193. * Callback that will be called if an error occurs during shader compilation.
  29194. */
  29195. onError: Nullable<(effect: Effect, errors: string) => void>;
  29196. /**
  29197. * Callback that will be called when effect is bound.
  29198. */
  29199. onBind: Nullable<(effect: Effect) => void>;
  29200. /**
  29201. * Unique ID of the effect.
  29202. */
  29203. uniqueId: number;
  29204. /**
  29205. * Observable that will be called when the shader is compiled.
  29206. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29207. */
  29208. onCompileObservable: Observable<Effect>;
  29209. /**
  29210. * Observable that will be called if an error occurs during shader compilation.
  29211. */
  29212. onErrorObservable: Observable<Effect>;
  29213. /** @hidden */
  29214. _onBindObservable: Nullable<Observable<Effect>>;
  29215. /**
  29216. * Observable that will be called when effect is bound.
  29217. */
  29218. readonly onBindObservable: Observable<Effect>;
  29219. /** @hidden */
  29220. _bonesComputationForcedToCPU: boolean;
  29221. private static _uniqueIdSeed;
  29222. private _engine;
  29223. private _uniformBuffersNames;
  29224. private _uniformsNames;
  29225. private _samplerList;
  29226. private _samplers;
  29227. private _isReady;
  29228. private _compilationError;
  29229. private _attributesNames;
  29230. private _attributes;
  29231. private _uniforms;
  29232. /**
  29233. * Key for the effect.
  29234. * @hidden
  29235. */
  29236. _key: string;
  29237. private _indexParameters;
  29238. private _fallbacks;
  29239. private _vertexSourceCode;
  29240. private _fragmentSourceCode;
  29241. private _vertexSourceCodeOverride;
  29242. private _fragmentSourceCodeOverride;
  29243. private _transformFeedbackVaryings;
  29244. /**
  29245. * Compiled shader to webGL program.
  29246. * @hidden
  29247. */
  29248. _pipelineContext: Nullable<IPipelineContext>;
  29249. private _valueCache;
  29250. private static _baseCache;
  29251. /**
  29252. * Instantiates an effect.
  29253. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29254. * @param baseName Name of the effect.
  29255. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29256. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29257. * @param samplers List of sampler variables that will be passed to the shader.
  29258. * @param engine Engine to be used to render the effect
  29259. * @param defines Define statements to be added to the shader.
  29260. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29261. * @param onCompiled Callback that will be called when the shader is compiled.
  29262. * @param onError Callback that will be called if an error occurs during shader compilation.
  29263. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29264. */
  29265. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29266. private _useFinalCode;
  29267. /**
  29268. * Unique key for this effect
  29269. */
  29270. readonly key: string;
  29271. /**
  29272. * If the effect has been compiled and prepared.
  29273. * @returns if the effect is compiled and prepared.
  29274. */
  29275. isReady(): boolean;
  29276. private _isReadyInternal;
  29277. /**
  29278. * The engine the effect was initialized with.
  29279. * @returns the engine.
  29280. */
  29281. getEngine(): Engine;
  29282. /**
  29283. * The pipeline context for this effect
  29284. * @returns the associated pipeline context
  29285. */
  29286. getPipelineContext(): Nullable<IPipelineContext>;
  29287. /**
  29288. * The set of names of attribute variables for the shader.
  29289. * @returns An array of attribute names.
  29290. */
  29291. getAttributesNames(): string[];
  29292. /**
  29293. * Returns the attribute at the given index.
  29294. * @param index The index of the attribute.
  29295. * @returns The location of the attribute.
  29296. */
  29297. getAttributeLocation(index: number): number;
  29298. /**
  29299. * Returns the attribute based on the name of the variable.
  29300. * @param name of the attribute to look up.
  29301. * @returns the attribute location.
  29302. */
  29303. getAttributeLocationByName(name: string): number;
  29304. /**
  29305. * The number of attributes.
  29306. * @returns the numnber of attributes.
  29307. */
  29308. getAttributesCount(): number;
  29309. /**
  29310. * Gets the index of a uniform variable.
  29311. * @param uniformName of the uniform to look up.
  29312. * @returns the index.
  29313. */
  29314. getUniformIndex(uniformName: string): number;
  29315. /**
  29316. * Returns the attribute based on the name of the variable.
  29317. * @param uniformName of the uniform to look up.
  29318. * @returns the location of the uniform.
  29319. */
  29320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29321. /**
  29322. * Returns an array of sampler variable names
  29323. * @returns The array of sampler variable neames.
  29324. */
  29325. getSamplers(): string[];
  29326. /**
  29327. * The error from the last compilation.
  29328. * @returns the error string.
  29329. */
  29330. getCompilationError(): string;
  29331. /**
  29332. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29333. * @param func The callback to be used.
  29334. */
  29335. executeWhenCompiled(func: (effect: Effect) => void): void;
  29336. private _checkIsReady;
  29337. /** @hidden */
  29338. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29339. /** @hidden */
  29340. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29341. /** @hidden */
  29342. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29343. /**
  29344. * Recompiles the webGL program
  29345. * @param vertexSourceCode The source code for the vertex shader.
  29346. * @param fragmentSourceCode The source code for the fragment shader.
  29347. * @param onCompiled Callback called when completed.
  29348. * @param onError Callback called on error.
  29349. * @hidden
  29350. */
  29351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29352. /**
  29353. * Prepares the effect
  29354. * @hidden
  29355. */
  29356. _prepareEffect(): void;
  29357. private _processCompilationErrors;
  29358. /**
  29359. * Checks if the effect is supported. (Must be called after compilation)
  29360. */
  29361. readonly isSupported: boolean;
  29362. /**
  29363. * Binds a texture to the engine to be used as output of the shader.
  29364. * @param channel Name of the output variable.
  29365. * @param texture Texture to bind.
  29366. * @hidden
  29367. */
  29368. _bindTexture(channel: string, texture: InternalTexture): void;
  29369. /**
  29370. * Sets a texture on the engine to be used in the shader.
  29371. * @param channel Name of the sampler variable.
  29372. * @param texture Texture to set.
  29373. */
  29374. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29375. /**
  29376. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29377. * @param channel Name of the sampler variable.
  29378. * @param texture Texture to set.
  29379. */
  29380. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29381. /**
  29382. * Sets an array of textures on the engine to be used in the shader.
  29383. * @param channel Name of the variable.
  29384. * @param textures Textures to set.
  29385. */
  29386. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29387. /**
  29388. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  29389. * @param channel Name of the sampler variable.
  29390. * @param postProcess Post process to get the input texture from.
  29391. */
  29392. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29393. /**
  29394. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29395. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  29396. * @param channel Name of the sampler variable.
  29397. * @param postProcess Post process to get the output texture from.
  29398. */
  29399. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29400. /** @hidden */
  29401. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29402. /** @hidden */
  29403. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29404. /** @hidden */
  29405. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29406. /** @hidden */
  29407. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29408. /**
  29409. * Binds a buffer to a uniform.
  29410. * @param buffer Buffer to bind.
  29411. * @param name Name of the uniform variable to bind to.
  29412. */
  29413. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29414. /**
  29415. * Binds block to a uniform.
  29416. * @param blockName Name of the block to bind.
  29417. * @param index Index to bind.
  29418. */
  29419. bindUniformBlock(blockName: string, index: number): void;
  29420. /**
  29421. * Sets an interger value on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param value Value to be set.
  29424. * @returns this effect.
  29425. */
  29426. setInt(uniformName: string, value: number): Effect;
  29427. /**
  29428. * Sets an int array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setIntArray(uniformName: string, array: Int32Array): Effect;
  29434. /**
  29435. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29441. /**
  29442. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29448. /**
  29449. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29455. /**
  29456. * Sets an float array on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param array array to be set.
  29459. * @returns this effect.
  29460. */
  29461. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29462. /**
  29463. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29464. * @param uniformName Name of the variable.
  29465. * @param array array to be set.
  29466. * @returns this effect.
  29467. */
  29468. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29469. /**
  29470. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29471. * @param uniformName Name of the variable.
  29472. * @param array array to be set.
  29473. * @returns this effect.
  29474. */
  29475. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29476. /**
  29477. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29478. * @param uniformName Name of the variable.
  29479. * @param array array to be set.
  29480. * @returns this effect.
  29481. */
  29482. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29483. /**
  29484. * Sets an array on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param array array to be set.
  29487. * @returns this effect.
  29488. */
  29489. setArray(uniformName: string, array: number[]): Effect;
  29490. /**
  29491. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29492. * @param uniformName Name of the variable.
  29493. * @param array array to be set.
  29494. * @returns this effect.
  29495. */
  29496. setArray2(uniformName: string, array: number[]): Effect;
  29497. /**
  29498. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29499. * @param uniformName Name of the variable.
  29500. * @param array array to be set.
  29501. * @returns this effect.
  29502. */
  29503. setArray3(uniformName: string, array: number[]): Effect;
  29504. /**
  29505. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29506. * @param uniformName Name of the variable.
  29507. * @param array array to be set.
  29508. * @returns this effect.
  29509. */
  29510. setArray4(uniformName: string, array: number[]): Effect;
  29511. /**
  29512. * Sets matrices on a uniform variable.
  29513. * @param uniformName Name of the variable.
  29514. * @param matrices matrices to be set.
  29515. * @returns this effect.
  29516. */
  29517. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29518. /**
  29519. * Sets matrix on a uniform variable.
  29520. * @param uniformName Name of the variable.
  29521. * @param matrix matrix to be set.
  29522. * @returns this effect.
  29523. */
  29524. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29525. /**
  29526. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  29527. * @param uniformName Name of the variable.
  29528. * @param matrix matrix to be set.
  29529. * @returns this effect.
  29530. */
  29531. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29532. /**
  29533. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29534. * @param uniformName Name of the variable.
  29535. * @param matrix matrix to be set.
  29536. * @returns this effect.
  29537. */
  29538. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29539. /**
  29540. * Sets a float on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param value value to be set.
  29543. * @returns this effect.
  29544. */
  29545. setFloat(uniformName: string, value: number): Effect;
  29546. /**
  29547. * Sets a boolean on a uniform variable.
  29548. * @param uniformName Name of the variable.
  29549. * @param bool value to be set.
  29550. * @returns this effect.
  29551. */
  29552. setBool(uniformName: string, bool: boolean): Effect;
  29553. /**
  29554. * Sets a Vector2 on a uniform variable.
  29555. * @param uniformName Name of the variable.
  29556. * @param vector2 vector2 to be set.
  29557. * @returns this effect.
  29558. */
  29559. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29560. /**
  29561. * Sets a float2 on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param x First float in float2.
  29564. * @param y Second float in float2.
  29565. * @returns this effect.
  29566. */
  29567. setFloat2(uniformName: string, x: number, y: number): Effect;
  29568. /**
  29569. * Sets a Vector3 on a uniform variable.
  29570. * @param uniformName Name of the variable.
  29571. * @param vector3 Value to be set.
  29572. * @returns this effect.
  29573. */
  29574. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29575. /**
  29576. * Sets a float3 on a uniform variable.
  29577. * @param uniformName Name of the variable.
  29578. * @param x First float in float3.
  29579. * @param y Second float in float3.
  29580. * @param z Third float in float3.
  29581. * @returns this effect.
  29582. */
  29583. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29584. /**
  29585. * Sets a Vector4 on a uniform variable.
  29586. * @param uniformName Name of the variable.
  29587. * @param vector4 Value to be set.
  29588. * @returns this effect.
  29589. */
  29590. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29591. /**
  29592. * Sets a float4 on a uniform variable.
  29593. * @param uniformName Name of the variable.
  29594. * @param x First float in float4.
  29595. * @param y Second float in float4.
  29596. * @param z Third float in float4.
  29597. * @param w Fourth float in float4.
  29598. * @returns this effect.
  29599. */
  29600. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29601. /**
  29602. * Sets a Color3 on a uniform variable.
  29603. * @param uniformName Name of the variable.
  29604. * @param color3 Value to be set.
  29605. * @returns this effect.
  29606. */
  29607. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29608. /**
  29609. * Sets a Color4 on a uniform variable.
  29610. * @param uniformName Name of the variable.
  29611. * @param color3 Value to be set.
  29612. * @param alpha Alpha value to be set.
  29613. * @returns this effect.
  29614. */
  29615. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniformName defines the name of the variable
  29619. * @param color4 defines the value to be set
  29620. * @returns this effect.
  29621. */
  29622. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29623. /** Release all associated resources */
  29624. dispose(): void;
  29625. /**
  29626. * This function will add a new shader to the shader store
  29627. * @param name the name of the shader
  29628. * @param pixelShader optional pixel shader content
  29629. * @param vertexShader optional vertex shader content
  29630. */
  29631. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29632. /**
  29633. * Store of each shader (The can be looked up using effect.key)
  29634. */
  29635. static ShadersStore: {
  29636. [key: string]: string;
  29637. };
  29638. /**
  29639. * Store of each included file for a shader (The can be looked up using effect.key)
  29640. */
  29641. static IncludesShadersStore: {
  29642. [key: string]: string;
  29643. };
  29644. /**
  29645. * Resets the cache of effects.
  29646. */
  29647. static ResetCache(): void;
  29648. }
  29649. }
  29650. declare module "babylonjs/Materials/uniformBuffer" {
  29651. import { Nullable, FloatArray } from "babylonjs/types";
  29652. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29653. import { Engine } from "babylonjs/Engines/engine";
  29654. import { Effect } from "babylonjs/Materials/effect";
  29655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29656. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29657. import { Color3 } from "babylonjs/Maths/math.color";
  29658. /**
  29659. * Uniform buffer objects.
  29660. *
  29661. * Handles blocks of uniform on the GPU.
  29662. *
  29663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29664. *
  29665. * For more information, please refer to :
  29666. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29667. */
  29668. export class UniformBuffer {
  29669. private _engine;
  29670. private _buffer;
  29671. private _data;
  29672. private _bufferData;
  29673. private _dynamic?;
  29674. private _uniformLocations;
  29675. private _uniformSizes;
  29676. private _uniformLocationPointer;
  29677. private _needSync;
  29678. private _noUBO;
  29679. private _currentEffect;
  29680. private static _MAX_UNIFORM_SIZE;
  29681. private static _tempBuffer;
  29682. /**
  29683. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29684. * This is dynamic to allow compat with webgl 1 and 2.
  29685. * You will need to pass the name of the uniform as well as the value.
  29686. */
  29687. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29688. /**
  29689. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29690. * This is dynamic to allow compat with webgl 1 and 2.
  29691. * You will need to pass the name of the uniform as well as the value.
  29692. */
  29693. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29694. /**
  29695. * Lambda to Update a single float in a uniform buffer.
  29696. * This is dynamic to allow compat with webgl 1 and 2.
  29697. * You will need to pass the name of the uniform as well as the value.
  29698. */
  29699. updateFloat: (name: string, x: number) => void;
  29700. /**
  29701. * Lambda to Update a vec2 of float in a uniform buffer.
  29702. * This is dynamic to allow compat with webgl 1 and 2.
  29703. * You will need to pass the name of the uniform as well as the value.
  29704. */
  29705. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29706. /**
  29707. * Lambda to Update a vec3 of float in a uniform buffer.
  29708. * This is dynamic to allow compat with webgl 1 and 2.
  29709. * You will need to pass the name of the uniform as well as the value.
  29710. */
  29711. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29712. /**
  29713. * Lambda to Update a vec4 of float in a uniform buffer.
  29714. * This is dynamic to allow compat with webgl 1 and 2.
  29715. * You will need to pass the name of the uniform as well as the value.
  29716. */
  29717. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29718. /**
  29719. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29720. * This is dynamic to allow compat with webgl 1 and 2.
  29721. * You will need to pass the name of the uniform as well as the value.
  29722. */
  29723. updateMatrix: (name: string, mat: Matrix) => void;
  29724. /**
  29725. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29726. * This is dynamic to allow compat with webgl 1 and 2.
  29727. * You will need to pass the name of the uniform as well as the value.
  29728. */
  29729. updateVector3: (name: string, vector: Vector3) => void;
  29730. /**
  29731. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29732. * This is dynamic to allow compat with webgl 1 and 2.
  29733. * You will need to pass the name of the uniform as well as the value.
  29734. */
  29735. updateVector4: (name: string, vector: Vector4) => void;
  29736. /**
  29737. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29738. * This is dynamic to allow compat with webgl 1 and 2.
  29739. * You will need to pass the name of the uniform as well as the value.
  29740. */
  29741. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29742. /**
  29743. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29744. * This is dynamic to allow compat with webgl 1 and 2.
  29745. * You will need to pass the name of the uniform as well as the value.
  29746. */
  29747. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29748. /**
  29749. * Instantiates a new Uniform buffer objects.
  29750. *
  29751. * Handles blocks of uniform on the GPU.
  29752. *
  29753. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29754. *
  29755. * For more information, please refer to :
  29756. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29757. * @param engine Define the engine the buffer is associated with
  29758. * @param data Define the data contained in the buffer
  29759. * @param dynamic Define if the buffer is updatable
  29760. */
  29761. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29762. /**
  29763. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29764. * or just falling back on setUniformXXX calls.
  29765. */
  29766. readonly useUbo: boolean;
  29767. /**
  29768. * Indicates if the WebGL underlying uniform buffer is in sync
  29769. * with the javascript cache data.
  29770. */
  29771. readonly isSync: boolean;
  29772. /**
  29773. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29774. * Also, a dynamic UniformBuffer will disable cache verification and always
  29775. * update the underlying WebGL uniform buffer to the GPU.
  29776. * @returns if Dynamic, otherwise false
  29777. */
  29778. isDynamic(): boolean;
  29779. /**
  29780. * The data cache on JS side.
  29781. * @returns the underlying data as a float array
  29782. */
  29783. getData(): Float32Array;
  29784. /**
  29785. * The underlying WebGL Uniform buffer.
  29786. * @returns the webgl buffer
  29787. */
  29788. getBuffer(): Nullable<DataBuffer>;
  29789. /**
  29790. * std140 layout specifies how to align data within an UBO structure.
  29791. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29792. * for specs.
  29793. */
  29794. private _fillAlignment;
  29795. /**
  29796. * Adds an uniform in the buffer.
  29797. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29798. * for the layout to be correct !
  29799. * @param name Name of the uniform, as used in the uniform block in the shader.
  29800. * @param size Data size, or data directly.
  29801. */
  29802. addUniform(name: string, size: number | number[]): void;
  29803. /**
  29804. * Adds a Matrix 4x4 to the uniform buffer.
  29805. * @param name Name of the uniform, as used in the uniform block in the shader.
  29806. * @param mat A 4x4 matrix.
  29807. */
  29808. addMatrix(name: string, mat: Matrix): void;
  29809. /**
  29810. * Adds a vec2 to the uniform buffer.
  29811. * @param name Name of the uniform, as used in the uniform block in the shader.
  29812. * @param x Define the x component value of the vec2
  29813. * @param y Define the y component value of the vec2
  29814. */
  29815. addFloat2(name: string, x: number, y: number): void;
  29816. /**
  29817. * Adds a vec3 to the uniform buffer.
  29818. * @param name Name of the uniform, as used in the uniform block in the shader.
  29819. * @param x Define the x component value of the vec3
  29820. * @param y Define the y component value of the vec3
  29821. * @param z Define the z component value of the vec3
  29822. */
  29823. addFloat3(name: string, x: number, y: number, z: number): void;
  29824. /**
  29825. * Adds a vec3 to the uniform buffer.
  29826. * @param name Name of the uniform, as used in the uniform block in the shader.
  29827. * @param color Define the vec3 from a Color
  29828. */
  29829. addColor3(name: string, color: Color3): void;
  29830. /**
  29831. * Adds a vec4 to the uniform buffer.
  29832. * @param name Name of the uniform, as used in the uniform block in the shader.
  29833. * @param color Define the rgb components from a Color
  29834. * @param alpha Define the a component of the vec4
  29835. */
  29836. addColor4(name: string, color: Color3, alpha: number): void;
  29837. /**
  29838. * Adds a vec3 to the uniform buffer.
  29839. * @param name Name of the uniform, as used in the uniform block in the shader.
  29840. * @param vector Define the vec3 components from a Vector
  29841. */
  29842. addVector3(name: string, vector: Vector3): void;
  29843. /**
  29844. * Adds a Matrix 3x3 to the uniform buffer.
  29845. * @param name Name of the uniform, as used in the uniform block in the shader.
  29846. */
  29847. addMatrix3x3(name: string): void;
  29848. /**
  29849. * Adds a Matrix 2x2 to the uniform buffer.
  29850. * @param name Name of the uniform, as used in the uniform block in the shader.
  29851. */
  29852. addMatrix2x2(name: string): void;
  29853. /**
  29854. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29855. */
  29856. create(): void;
  29857. /** @hidden */
  29858. _rebuild(): void;
  29859. /**
  29860. * Updates the WebGL Uniform Buffer on the GPU.
  29861. * If the `dynamic` flag is set to true, no cache comparison is done.
  29862. * Otherwise, the buffer will be updated only if the cache differs.
  29863. */
  29864. update(): void;
  29865. /**
  29866. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29867. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29868. * @param data Define the flattened data
  29869. * @param size Define the size of the data.
  29870. */
  29871. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29872. private _valueCache;
  29873. private _cacheMatrix;
  29874. private _updateMatrix3x3ForUniform;
  29875. private _updateMatrix3x3ForEffect;
  29876. private _updateMatrix2x2ForEffect;
  29877. private _updateMatrix2x2ForUniform;
  29878. private _updateFloatForEffect;
  29879. private _updateFloatForUniform;
  29880. private _updateFloat2ForEffect;
  29881. private _updateFloat2ForUniform;
  29882. private _updateFloat3ForEffect;
  29883. private _updateFloat3ForUniform;
  29884. private _updateFloat4ForEffect;
  29885. private _updateFloat4ForUniform;
  29886. private _updateMatrixForEffect;
  29887. private _updateMatrixForUniform;
  29888. private _updateVector3ForEffect;
  29889. private _updateVector3ForUniform;
  29890. private _updateVector4ForEffect;
  29891. private _updateVector4ForUniform;
  29892. private _updateColor3ForEffect;
  29893. private _updateColor3ForUniform;
  29894. private _updateColor4ForEffect;
  29895. private _updateColor4ForUniform;
  29896. /**
  29897. * Sets a sampler uniform on the effect.
  29898. * @param name Define the name of the sampler.
  29899. * @param texture Define the texture to set in the sampler
  29900. */
  29901. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29902. /**
  29903. * Directly updates the value of the uniform in the cache AND on the GPU.
  29904. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29905. * @param data Define the flattened data
  29906. */
  29907. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29908. /**
  29909. * Binds this uniform buffer to an effect.
  29910. * @param effect Define the effect to bind the buffer to
  29911. * @param name Name of the uniform block in the shader.
  29912. */
  29913. bindToEffect(effect: Effect, name: string): void;
  29914. /**
  29915. * Disposes the uniform buffer.
  29916. */
  29917. dispose(): void;
  29918. }
  29919. }
  29920. declare module "babylonjs/Audio/analyser" {
  29921. import { Scene } from "babylonjs/scene";
  29922. /**
  29923. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29925. */
  29926. export class Analyser {
  29927. /**
  29928. * Gets or sets the smoothing
  29929. * @ignorenaming
  29930. */
  29931. SMOOTHING: number;
  29932. /**
  29933. * Gets or sets the FFT table size
  29934. * @ignorenaming
  29935. */
  29936. FFT_SIZE: number;
  29937. /**
  29938. * Gets or sets the bar graph amplitude
  29939. * @ignorenaming
  29940. */
  29941. BARGRAPHAMPLITUDE: number;
  29942. /**
  29943. * Gets or sets the position of the debug canvas
  29944. * @ignorenaming
  29945. */
  29946. DEBUGCANVASPOS: {
  29947. x: number;
  29948. y: number;
  29949. };
  29950. /**
  29951. * Gets or sets the debug canvas size
  29952. * @ignorenaming
  29953. */
  29954. DEBUGCANVASSIZE: {
  29955. width: number;
  29956. height: number;
  29957. };
  29958. private _byteFreqs;
  29959. private _byteTime;
  29960. private _floatFreqs;
  29961. private _webAudioAnalyser;
  29962. private _debugCanvas;
  29963. private _debugCanvasContext;
  29964. private _scene;
  29965. private _registerFunc;
  29966. private _audioEngine;
  29967. /**
  29968. * Creates a new analyser
  29969. * @param scene defines hosting scene
  29970. */
  29971. constructor(scene: Scene);
  29972. /**
  29973. * Get the number of data values you will have to play with for the visualization
  29974. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29975. * @returns a number
  29976. */
  29977. getFrequencyBinCount(): number;
  29978. /**
  29979. * Gets the current frequency data as a byte array
  29980. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29981. * @returns a Uint8Array
  29982. */
  29983. getByteFrequencyData(): Uint8Array;
  29984. /**
  29985. * Gets the current waveform as a byte array
  29986. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29987. * @returns a Uint8Array
  29988. */
  29989. getByteTimeDomainData(): Uint8Array;
  29990. /**
  29991. * Gets the current frequency data as a float array
  29992. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29993. * @returns a Float32Array
  29994. */
  29995. getFloatFrequencyData(): Float32Array;
  29996. /**
  29997. * Renders the debug canvas
  29998. */
  29999. drawDebugCanvas(): void;
  30000. /**
  30001. * Stops rendering the debug canvas and removes it
  30002. */
  30003. stopDebugCanvas(): void;
  30004. /**
  30005. * Connects two audio nodes
  30006. * @param inputAudioNode defines first node to connect
  30007. * @param outputAudioNode defines second node to connect
  30008. */
  30009. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30010. /**
  30011. * Releases all associated resources
  30012. */
  30013. dispose(): void;
  30014. }
  30015. }
  30016. declare module "babylonjs/Audio/audioEngine" {
  30017. import { IDisposable } from "babylonjs/scene";
  30018. import { Analyser } from "babylonjs/Audio/analyser";
  30019. import { Nullable } from "babylonjs/types";
  30020. import { Observable } from "babylonjs/Misc/observable";
  30021. /**
  30022. * This represents an audio engine and it is responsible
  30023. * to play, synchronize and analyse sounds throughout the application.
  30024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30025. */
  30026. export interface IAudioEngine extends IDisposable {
  30027. /**
  30028. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30029. */
  30030. readonly canUseWebAudio: boolean;
  30031. /**
  30032. * Gets the current AudioContext if available.
  30033. */
  30034. readonly audioContext: Nullable<AudioContext>;
  30035. /**
  30036. * The master gain node defines the global audio volume of your audio engine.
  30037. */
  30038. readonly masterGain: GainNode;
  30039. /**
  30040. * Gets whether or not mp3 are supported by your browser.
  30041. */
  30042. readonly isMP3supported: boolean;
  30043. /**
  30044. * Gets whether or not ogg are supported by your browser.
  30045. */
  30046. readonly isOGGsupported: boolean;
  30047. /**
  30048. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30049. * @ignoreNaming
  30050. */
  30051. WarnedWebAudioUnsupported: boolean;
  30052. /**
  30053. * Defines if the audio engine relies on a custom unlocked button.
  30054. * In this case, the embedded button will not be displayed.
  30055. */
  30056. useCustomUnlockedButton: boolean;
  30057. /**
  30058. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30059. */
  30060. readonly unlocked: boolean;
  30061. /**
  30062. * Event raised when audio has been unlocked on the browser.
  30063. */
  30064. onAudioUnlockedObservable: Observable<AudioEngine>;
  30065. /**
  30066. * Event raised when audio has been locked on the browser.
  30067. */
  30068. onAudioLockedObservable: Observable<AudioEngine>;
  30069. /**
  30070. * Flags the audio engine in Locked state.
  30071. * This happens due to new browser policies preventing audio to autoplay.
  30072. */
  30073. lock(): void;
  30074. /**
  30075. * Unlocks the audio engine once a user action has been done on the dom.
  30076. * This is helpful to resume play once browser policies have been satisfied.
  30077. */
  30078. unlock(): void;
  30079. }
  30080. /**
  30081. * This represents the default audio engine used in babylon.
  30082. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30084. */
  30085. export class AudioEngine implements IAudioEngine {
  30086. private _audioContext;
  30087. private _audioContextInitialized;
  30088. private _muteButton;
  30089. private _hostElement;
  30090. /**
  30091. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30092. */
  30093. canUseWebAudio: boolean;
  30094. /**
  30095. * The master gain node defines the global audio volume of your audio engine.
  30096. */
  30097. masterGain: GainNode;
  30098. /**
  30099. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30100. * @ignoreNaming
  30101. */
  30102. WarnedWebAudioUnsupported: boolean;
  30103. /**
  30104. * Gets whether or not mp3 are supported by your browser.
  30105. */
  30106. isMP3supported: boolean;
  30107. /**
  30108. * Gets whether or not ogg are supported by your browser.
  30109. */
  30110. isOGGsupported: boolean;
  30111. /**
  30112. * Gets whether audio has been unlocked on the device.
  30113. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30114. * a user interaction has happened.
  30115. */
  30116. unlocked: boolean;
  30117. /**
  30118. * Defines if the audio engine relies on a custom unlocked button.
  30119. * In this case, the embedded button will not be displayed.
  30120. */
  30121. useCustomUnlockedButton: boolean;
  30122. /**
  30123. * Event raised when audio has been unlocked on the browser.
  30124. */
  30125. onAudioUnlockedObservable: Observable<AudioEngine>;
  30126. /**
  30127. * Event raised when audio has been locked on the browser.
  30128. */
  30129. onAudioLockedObservable: Observable<AudioEngine>;
  30130. /**
  30131. * Gets the current AudioContext if available.
  30132. */
  30133. readonly audioContext: Nullable<AudioContext>;
  30134. private _connectedAnalyser;
  30135. /**
  30136. * Instantiates a new audio engine.
  30137. *
  30138. * There should be only one per page as some browsers restrict the number
  30139. * of audio contexts you can create.
  30140. * @param hostElement defines the host element where to display the mute icon if necessary
  30141. */
  30142. constructor(hostElement?: Nullable<HTMLElement>);
  30143. /**
  30144. * Flags the audio engine in Locked state.
  30145. * This happens due to new browser policies preventing audio to autoplay.
  30146. */
  30147. lock(): void;
  30148. /**
  30149. * Unlocks the audio engine once a user action has been done on the dom.
  30150. * This is helpful to resume play once browser policies have been satisfied.
  30151. */
  30152. unlock(): void;
  30153. private _resumeAudioContext;
  30154. private _initializeAudioContext;
  30155. private _tryToRun;
  30156. private _triggerRunningState;
  30157. private _triggerSuspendedState;
  30158. private _displayMuteButton;
  30159. private _moveButtonToTopLeft;
  30160. private _onResize;
  30161. private _hideMuteButton;
  30162. /**
  30163. * Destroy and release the resources associated with the audio ccontext.
  30164. */
  30165. dispose(): void;
  30166. /**
  30167. * Gets the global volume sets on the master gain.
  30168. * @returns the global volume if set or -1 otherwise
  30169. */
  30170. getGlobalVolume(): number;
  30171. /**
  30172. * Sets the global volume of your experience (sets on the master gain).
  30173. * @param newVolume Defines the new global volume of the application
  30174. */
  30175. setGlobalVolume(newVolume: number): void;
  30176. /**
  30177. * Connect the audio engine to an audio analyser allowing some amazing
  30178. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30180. * @param analyser The analyser to connect to the engine
  30181. */
  30182. connectToAnalyser(analyser: Analyser): void;
  30183. }
  30184. }
  30185. declare module "babylonjs/Loading/loadingScreen" {
  30186. /**
  30187. * Interface used to present a loading screen while loading a scene
  30188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30189. */
  30190. export interface ILoadingScreen {
  30191. /**
  30192. * Function called to display the loading screen
  30193. */
  30194. displayLoadingUI: () => void;
  30195. /**
  30196. * Function called to hide the loading screen
  30197. */
  30198. hideLoadingUI: () => void;
  30199. /**
  30200. * Gets or sets the color to use for the background
  30201. */
  30202. loadingUIBackgroundColor: string;
  30203. /**
  30204. * Gets or sets the text to display while loading
  30205. */
  30206. loadingUIText: string;
  30207. }
  30208. /**
  30209. * Class used for the default loading screen
  30210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30211. */
  30212. export class DefaultLoadingScreen implements ILoadingScreen {
  30213. private _renderingCanvas;
  30214. private _loadingText;
  30215. private _loadingDivBackgroundColor;
  30216. private _loadingDiv;
  30217. private _loadingTextDiv;
  30218. /** Gets or sets the logo url to use for the default loading screen */
  30219. static DefaultLogoUrl: string;
  30220. /** Gets or sets the spinner url to use for the default loading screen */
  30221. static DefaultSpinnerUrl: string;
  30222. /**
  30223. * Creates a new default loading screen
  30224. * @param _renderingCanvas defines the canvas used to render the scene
  30225. * @param _loadingText defines the default text to display
  30226. * @param _loadingDivBackgroundColor defines the default background color
  30227. */
  30228. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30229. /**
  30230. * Function called to display the loading screen
  30231. */
  30232. displayLoadingUI(): void;
  30233. /**
  30234. * Function called to hide the loading screen
  30235. */
  30236. hideLoadingUI(): void;
  30237. /**
  30238. * Gets or sets the text to display while loading
  30239. */
  30240. loadingUIText: string;
  30241. /**
  30242. * Gets or sets the color to use for the background
  30243. */
  30244. loadingUIBackgroundColor: string;
  30245. private _resizeLoadingUI;
  30246. }
  30247. }
  30248. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30250. import { Engine } from "babylonjs/Engines/engine";
  30251. import { Nullable } from "babylonjs/types";
  30252. /** @hidden */
  30253. export class WebGLPipelineContext implements IPipelineContext {
  30254. engine: Engine;
  30255. program: Nullable<WebGLProgram>;
  30256. context?: WebGLRenderingContext;
  30257. vertexShader?: WebGLShader;
  30258. fragmentShader?: WebGLShader;
  30259. isParallelCompiled: boolean;
  30260. onCompiled?: () => void;
  30261. transformFeedback?: WebGLTransformFeedback | null;
  30262. readonly isAsync: boolean;
  30263. readonly isReady: boolean;
  30264. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30265. }
  30266. }
  30267. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30269. /** @hidden */
  30270. export class WebGLDataBuffer extends DataBuffer {
  30271. private _buffer;
  30272. constructor(resource: WebGLBuffer);
  30273. readonly underlyingResource: any;
  30274. }
  30275. }
  30276. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30277. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30278. /** @hidden */
  30279. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30280. attributeProcessor(attribute: string): string;
  30281. varyingProcessor(varying: string, isFragment: boolean): string;
  30282. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30283. }
  30284. }
  30285. declare module "babylonjs/Misc/perfCounter" {
  30286. /**
  30287. * This class is used to track a performance counter which is number based.
  30288. * The user has access to many properties which give statistics of different nature.
  30289. *
  30290. * The implementer can track two kinds of Performance Counter: time and count.
  30291. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  30292. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  30293. */
  30294. export class PerfCounter {
  30295. /**
  30296. * Gets or sets a global boolean to turn on and off all the counters
  30297. */
  30298. static Enabled: boolean;
  30299. /**
  30300. * Returns the smallest value ever
  30301. */
  30302. readonly min: number;
  30303. /**
  30304. * Returns the biggest value ever
  30305. */
  30306. readonly max: number;
  30307. /**
  30308. * Returns the average value since the performance counter is running
  30309. */
  30310. readonly average: number;
  30311. /**
  30312. * Returns the average value of the last second the counter was monitored
  30313. */
  30314. readonly lastSecAverage: number;
  30315. /**
  30316. * Returns the current value
  30317. */
  30318. readonly current: number;
  30319. /**
  30320. * Gets the accumulated total
  30321. */
  30322. readonly total: number;
  30323. /**
  30324. * Gets the total value count
  30325. */
  30326. readonly count: number;
  30327. /**
  30328. * Creates a new counter
  30329. */
  30330. constructor();
  30331. /**
  30332. * Call this method to start monitoring a new frame.
  30333. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  30334. */
  30335. fetchNewFrame(): void;
  30336. /**
  30337. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30338. * @param newCount the count value to add to the monitored count
  30339. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  30340. */
  30341. addCount(newCount: number, fetchResult: boolean): void;
  30342. /**
  30343. * Start monitoring this performance counter
  30344. */
  30345. beginMonitoring(): void;
  30346. /**
  30347. * Compute the time lapsed since the previous beginMonitoring() call.
  30348. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  30349. */
  30350. endMonitoring(newFrame?: boolean): void;
  30351. private _fetchResult;
  30352. private _startMonitoringTime;
  30353. private _min;
  30354. private _max;
  30355. private _average;
  30356. private _current;
  30357. private _totalValueCount;
  30358. private _totalAccumulated;
  30359. private _lastSecAverage;
  30360. private _lastSecAccumulated;
  30361. private _lastSecTime;
  30362. private _lastSecValueCount;
  30363. }
  30364. }
  30365. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30366. /**
  30367. * Interface for any object that can request an animation frame
  30368. */
  30369. export interface ICustomAnimationFrameRequester {
  30370. /**
  30371. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30372. */
  30373. renderFunction?: Function;
  30374. /**
  30375. * Called to request the next frame to render to
  30376. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30377. */
  30378. requestAnimationFrame: Function;
  30379. /**
  30380. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30381. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30382. */
  30383. requestID?: number;
  30384. }
  30385. }
  30386. declare module "babylonjs/Materials/Textures/videoTexture" {
  30387. import { Observable } from "babylonjs/Misc/observable";
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Scene } from "babylonjs/scene";
  30390. import { Texture } from "babylonjs/Materials/Textures/texture";
  30391. /**
  30392. * Settings for finer control over video usage
  30393. */
  30394. export interface VideoTextureSettings {
  30395. /**
  30396. * Applies `autoplay` to video, if specified
  30397. */
  30398. autoPlay?: boolean;
  30399. /**
  30400. * Applies `loop` to video, if specified
  30401. */
  30402. loop?: boolean;
  30403. /**
  30404. * Automatically updates internal texture from video at every frame in the render loop
  30405. */
  30406. autoUpdateTexture: boolean;
  30407. /**
  30408. * Image src displayed during the video loading or until the user interacts with the video.
  30409. */
  30410. poster?: string;
  30411. }
  30412. /**
  30413. * If you want to display a video in your scene, this is the special texture for that.
  30414. * This special texture works similar to other textures, with the exception of a few parameters.
  30415. * @see https://doc.babylonjs.com/how_to/video_texture
  30416. */
  30417. export class VideoTexture extends Texture {
  30418. /**
  30419. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30420. */
  30421. readonly autoUpdateTexture: boolean;
  30422. /**
  30423. * The video instance used by the texture internally
  30424. */
  30425. readonly video: HTMLVideoElement;
  30426. private _onUserActionRequestedObservable;
  30427. /**
  30428. * Event triggerd when a dom action is required by the user to play the video.
  30429. * This happens due to recent changes in browser policies preventing video to auto start.
  30430. */
  30431. readonly onUserActionRequestedObservable: Observable<Texture>;
  30432. private _generateMipMaps;
  30433. private _engine;
  30434. private _stillImageCaptured;
  30435. private _displayingPosterTexture;
  30436. private _settings;
  30437. private _createInternalTextureOnEvent;
  30438. private _frameId;
  30439. /**
  30440. * Creates a video texture.
  30441. * If you want to display a video in your scene, this is the special texture for that.
  30442. * This special texture works similar to other textures, with the exception of a few parameters.
  30443. * @see https://doc.babylonjs.com/how_to/video_texture
  30444. * @param name optional name, will detect from video source, if not defined
  30445. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30446. * @param scene is obviously the current scene.
  30447. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30448. * @param invertY is false by default but can be used to invert video on Y axis
  30449. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30450. * @param settings allows finer control over video usage
  30451. */
  30452. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30453. private _getName;
  30454. private _getVideo;
  30455. private _createInternalTexture;
  30456. private reset;
  30457. /**
  30458. * @hidden Internal method to initiate `update`.
  30459. */
  30460. _rebuild(): void;
  30461. /**
  30462. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30463. */
  30464. update(): void;
  30465. /**
  30466. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30467. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30468. */
  30469. updateTexture(isVisible: boolean): void;
  30470. protected _updateInternalTexture: () => void;
  30471. /**
  30472. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30473. * @param url New url.
  30474. */
  30475. updateURL(url: string): void;
  30476. /**
  30477. * Dispose the texture and release its associated resources.
  30478. */
  30479. dispose(): void;
  30480. /**
  30481. * Creates a video texture straight from a stream.
  30482. * @param scene Define the scene the texture should be created in
  30483. * @param stream Define the stream the texture should be created from
  30484. * @returns The created video texture as a promise
  30485. */
  30486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30487. /**
  30488. * Creates a video texture straight from your WebCam video feed.
  30489. * @param scene Define the scene the texture should be created in
  30490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30492. * @returns The created video texture as a promise
  30493. */
  30494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30495. minWidth: number;
  30496. maxWidth: number;
  30497. minHeight: number;
  30498. maxHeight: number;
  30499. deviceId: string;
  30500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30501. /**
  30502. * Creates a video texture straight from your WebCam video feed.
  30503. * @param scene Define the scene the texture should be created in
  30504. * @param onReady Define a callback to triggered once the texture will be ready
  30505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30507. */
  30508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30509. minWidth: number;
  30510. maxWidth: number;
  30511. minHeight: number;
  30512. maxHeight: number;
  30513. deviceId: string;
  30514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30515. }
  30516. }
  30517. declare module "babylonjs/Engines/engine" {
  30518. import { Observable } from "babylonjs/Misc/observable";
  30519. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30520. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30521. import { Scene } from "babylonjs/scene";
  30522. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30523. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30524. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30528. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30529. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30530. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30531. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30532. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30533. import { WebRequest } from "babylonjs/Misc/webRequest";
  30534. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30536. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30537. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30538. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30539. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30540. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30541. import { Material } from "babylonjs/Materials/material";
  30542. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30544. /**
  30545. * Defines the interface used by objects containing a viewport (like a camera)
  30546. */
  30547. interface IViewportOwnerLike {
  30548. /**
  30549. * Gets or sets the viewport
  30550. */
  30551. viewport: IViewportLike;
  30552. }
  30553. /**
  30554. * Interface for attribute information associated with buffer instanciation
  30555. */
  30556. export class InstancingAttributeInfo {
  30557. /**
  30558. * Index/offset of the attribute in the vertex shader
  30559. */
  30560. index: number;
  30561. /**
  30562. * size of the attribute, 1, 2, 3 or 4
  30563. */
  30564. attributeSize: number;
  30565. /**
  30566. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30567. * default is FLOAT
  30568. */
  30569. attribyteType: number;
  30570. /**
  30571. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30572. */
  30573. normalized: boolean;
  30574. /**
  30575. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30576. */
  30577. offset: number;
  30578. /**
  30579. * Name of the GLSL attribute, for debugging purpose only
  30580. */
  30581. attributeName: string;
  30582. }
  30583. /**
  30584. * Define options used to create a depth texture
  30585. */
  30586. export class DepthTextureCreationOptions {
  30587. /** Specifies whether or not a stencil should be allocated in the texture */
  30588. generateStencil?: boolean;
  30589. /** Specifies whether or not bilinear filtering is enable on the texture */
  30590. bilinearFiltering?: boolean;
  30591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30592. comparisonFunction?: number;
  30593. /** Specifies if the created texture is a cube texture */
  30594. isCube?: boolean;
  30595. }
  30596. /**
  30597. * Class used to describe the capabilities of the engine relatively to the current browser
  30598. */
  30599. export class EngineCapabilities {
  30600. /** Maximum textures units per fragment shader */
  30601. maxTexturesImageUnits: number;
  30602. /** Maximum texture units per vertex shader */
  30603. maxVertexTextureImageUnits: number;
  30604. /** Maximum textures units in the entire pipeline */
  30605. maxCombinedTexturesImageUnits: number;
  30606. /** Maximum texture size */
  30607. maxTextureSize: number;
  30608. /** Maximum cube texture size */
  30609. maxCubemapTextureSize: number;
  30610. /** Maximum render texture size */
  30611. maxRenderTextureSize: number;
  30612. /** Maximum number of vertex attributes */
  30613. maxVertexAttribs: number;
  30614. /** Maximum number of varyings */
  30615. maxVaryingVectors: number;
  30616. /** Maximum number of uniforms per vertex shader */
  30617. maxVertexUniformVectors: number;
  30618. /** Maximum number of uniforms per fragment shader */
  30619. maxFragmentUniformVectors: number;
  30620. /** Defines if standard derivates (dx/dy) are supported */
  30621. standardDerivatives: boolean;
  30622. /** Defines if s3tc texture compression is supported */
  30623. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30624. /** Defines if pvrtc texture compression is supported */
  30625. pvrtc: any;
  30626. /** Defines if etc1 texture compression is supported */
  30627. etc1: any;
  30628. /** Defines if etc2 texture compression is supported */
  30629. etc2: any;
  30630. /** Defines if astc texture compression is supported */
  30631. astc: any;
  30632. /** Defines if float textures are supported */
  30633. textureFloat: boolean;
  30634. /** Defines if vertex array objects are supported */
  30635. vertexArrayObject: boolean;
  30636. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30637. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30638. /** Gets the maximum level of anisotropy supported */
  30639. maxAnisotropy: number;
  30640. /** Defines if instancing is supported */
  30641. instancedArrays: boolean;
  30642. /** Defines if 32 bits indices are supported */
  30643. uintIndices: boolean;
  30644. /** Defines if high precision shaders are supported */
  30645. highPrecisionShaderSupported: boolean;
  30646. /** Defines if depth reading in the fragment shader is supported */
  30647. fragmentDepthSupported: boolean;
  30648. /** Defines if float texture linear filtering is supported*/
  30649. textureFloatLinearFiltering: boolean;
  30650. /** Defines if rendering to float textures is supported */
  30651. textureFloatRender: boolean;
  30652. /** Defines if half float textures are supported*/
  30653. textureHalfFloat: boolean;
  30654. /** Defines if half float texture linear filtering is supported*/
  30655. textureHalfFloatLinearFiltering: boolean;
  30656. /** Defines if rendering to half float textures is supported */
  30657. textureHalfFloatRender: boolean;
  30658. /** Defines if textureLOD shader command is supported */
  30659. textureLOD: boolean;
  30660. /** Defines if draw buffers extension is supported */
  30661. drawBuffersExtension: boolean;
  30662. /** Defines if depth textures are supported */
  30663. depthTextureExtension: boolean;
  30664. /** Defines if float color buffer are supported */
  30665. colorBufferFloat: boolean;
  30666. /** Gets disjoint timer query extension (null if not supported) */
  30667. timerQuery: EXT_disjoint_timer_query;
  30668. /** Defines if timestamp can be used with timer query */
  30669. canUseTimestampForTimerQuery: boolean;
  30670. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30671. multiview: any;
  30672. /** Function used to let the system compiles shaders in background */
  30673. parallelShaderCompile: {
  30674. COMPLETION_STATUS_KHR: number;
  30675. };
  30676. /** Max number of texture samples for MSAA */
  30677. maxMSAASamples: number;
  30678. }
  30679. /** Interface defining initialization parameters for Engine class */
  30680. export interface EngineOptions extends WebGLContextAttributes {
  30681. /**
  30682. * Defines if the engine should no exceed a specified device ratio
  30683. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30684. */
  30685. limitDeviceRatio?: number;
  30686. /**
  30687. * Defines if webvr should be enabled automatically
  30688. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30689. */
  30690. autoEnableWebVR?: boolean;
  30691. /**
  30692. * Defines if webgl2 should be turned off even if supported
  30693. * @see http://doc.babylonjs.com/features/webgl2
  30694. */
  30695. disableWebGL2Support?: boolean;
  30696. /**
  30697. * Defines if webaudio should be initialized as well
  30698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30699. */
  30700. audioEngine?: boolean;
  30701. /**
  30702. * Defines if animations should run using a deterministic lock step
  30703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30704. */
  30705. deterministicLockstep?: boolean;
  30706. /** Defines the maximum steps to use with deterministic lock step mode */
  30707. lockstepMaxSteps?: number;
  30708. /**
  30709. * Defines that engine should ignore context lost events
  30710. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30711. */
  30712. doNotHandleContextLost?: boolean;
  30713. /**
  30714. * Defines that engine should ignore modifying touch action attribute and style
  30715. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30716. */
  30717. doNotHandleTouchAction?: boolean;
  30718. /**
  30719. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30720. */
  30721. useHighPrecisionFloats?: boolean;
  30722. }
  30723. /**
  30724. * Defines the interface used by display changed events
  30725. */
  30726. export interface IDisplayChangedEventArgs {
  30727. /** Gets the vrDisplay object (if any) */
  30728. vrDisplay: Nullable<any>;
  30729. /** Gets a boolean indicating if webVR is supported */
  30730. vrSupported: boolean;
  30731. }
  30732. /**
  30733. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30734. */
  30735. export class Engine {
  30736. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30737. static ExceptionList: ({
  30738. key: string;
  30739. capture: string;
  30740. captureConstraint: number;
  30741. targets: string[];
  30742. } | {
  30743. key: string;
  30744. capture: null;
  30745. captureConstraint: null;
  30746. targets: string[];
  30747. })[];
  30748. /** Gets the list of created engines */
  30749. static readonly Instances: Engine[];
  30750. /**
  30751. * Gets the latest created engine
  30752. */
  30753. static readonly LastCreatedEngine: Nullable<Engine>;
  30754. /**
  30755. * Gets the latest created scene
  30756. */
  30757. static readonly LastCreatedScene: Nullable<Scene>;
  30758. /**
  30759. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30760. * @param flag defines which part of the materials must be marked as dirty
  30761. * @param predicate defines a predicate used to filter which materials should be affected
  30762. */
  30763. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30764. /** @hidden */
  30765. static _TextureLoaders: IInternalTextureLoader[];
  30766. /** Defines that alpha blending is disabled */
  30767. static readonly ALPHA_DISABLE: number;
  30768. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30769. static readonly ALPHA_ADD: number;
  30770. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30771. static readonly ALPHA_COMBINE: number;
  30772. /** Defines that alpha blending to DEST - SRC * DEST */
  30773. static readonly ALPHA_SUBTRACT: number;
  30774. /** Defines that alpha blending to SRC * DEST */
  30775. static readonly ALPHA_MULTIPLY: number;
  30776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30777. static readonly ALPHA_MAXIMIZED: number;
  30778. /** Defines that alpha blending to SRC + DEST */
  30779. static readonly ALPHA_ONEONE: number;
  30780. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30781. static readonly ALPHA_PREMULTIPLIED: number;
  30782. /**
  30783. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30784. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30785. */
  30786. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30787. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30788. static readonly ALPHA_INTERPOLATE: number;
  30789. /**
  30790. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30791. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30792. */
  30793. static readonly ALPHA_SCREENMODE: number;
  30794. /** Defines that the ressource is not delayed*/
  30795. static readonly DELAYLOADSTATE_NONE: number;
  30796. /** Defines that the ressource was successfully delay loaded */
  30797. static readonly DELAYLOADSTATE_LOADED: number;
  30798. /** Defines that the ressource is currently delay loading */
  30799. static readonly DELAYLOADSTATE_LOADING: number;
  30800. /** Defines that the ressource is delayed and has not started loading */
  30801. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30803. static readonly NEVER: number;
  30804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  30805. static readonly ALWAYS: number;
  30806. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30807. static readonly LESS: number;
  30808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30809. static readonly EQUAL: number;
  30810. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  30811. static readonly LEQUAL: number;
  30812. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30813. static readonly GREATER: number;
  30814. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  30815. static readonly GEQUAL: number;
  30816. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  30817. static readonly NOTEQUAL: number;
  30818. /** Passed to stencilOperation to specify that stencil value must be kept */
  30819. static readonly KEEP: number;
  30820. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30821. static readonly REPLACE: number;
  30822. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30823. static readonly INCR: number;
  30824. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30825. static readonly DECR: number;
  30826. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30827. static readonly INVERT: number;
  30828. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30829. static readonly INCR_WRAP: number;
  30830. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30831. static readonly DECR_WRAP: number;
  30832. /** Texture is not repeating outside of 0..1 UVs */
  30833. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30834. /** Texture is repeating outside of 0..1 UVs */
  30835. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30836. /** Texture is repeating and mirrored */
  30837. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30838. /** ALPHA */
  30839. static readonly TEXTUREFORMAT_ALPHA: number;
  30840. /** LUMINANCE */
  30841. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30842. /** LUMINANCE_ALPHA */
  30843. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30844. /** RGB */
  30845. static readonly TEXTUREFORMAT_RGB: number;
  30846. /** RGBA */
  30847. static readonly TEXTUREFORMAT_RGBA: number;
  30848. /** RED */
  30849. static readonly TEXTUREFORMAT_RED: number;
  30850. /** RED (2nd reference) */
  30851. static readonly TEXTUREFORMAT_R: number;
  30852. /** RG */
  30853. static readonly TEXTUREFORMAT_RG: number;
  30854. /** RED_INTEGER */
  30855. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30856. /** RED_INTEGER (2nd reference) */
  30857. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30858. /** RG_INTEGER */
  30859. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30860. /** RGB_INTEGER */
  30861. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30862. /** RGBA_INTEGER */
  30863. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30864. /** UNSIGNED_BYTE */
  30865. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30866. /** UNSIGNED_BYTE (2nd reference) */
  30867. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30868. /** FLOAT */
  30869. static readonly TEXTURETYPE_FLOAT: number;
  30870. /** HALF_FLOAT */
  30871. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30872. /** BYTE */
  30873. static readonly TEXTURETYPE_BYTE: number;
  30874. /** SHORT */
  30875. static readonly TEXTURETYPE_SHORT: number;
  30876. /** UNSIGNED_SHORT */
  30877. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30878. /** INT */
  30879. static readonly TEXTURETYPE_INT: number;
  30880. /** UNSIGNED_INT */
  30881. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30882. /** UNSIGNED_SHORT_4_4_4_4 */
  30883. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30884. /** UNSIGNED_SHORT_5_5_5_1 */
  30885. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30886. /** UNSIGNED_SHORT_5_6_5 */
  30887. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30888. /** UNSIGNED_INT_2_10_10_10_REV */
  30889. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30890. /** UNSIGNED_INT_24_8 */
  30891. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30892. /** UNSIGNED_INT_10F_11F_11F_REV */
  30893. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30894. /** UNSIGNED_INT_5_9_9_9_REV */
  30895. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30896. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30897. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30898. /** nearest is mag = nearest and min = nearest and mip = linear */
  30899. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30900. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30901. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30902. /** Trilinear is mag = linear and min = linear and mip = linear */
  30903. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30904. /** nearest is mag = nearest and min = nearest and mip = linear */
  30905. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30906. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30907. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30908. /** Trilinear is mag = linear and min = linear and mip = linear */
  30909. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30910. /** mag = nearest and min = nearest and mip = nearest */
  30911. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30912. /** mag = nearest and min = linear and mip = nearest */
  30913. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30914. /** mag = nearest and min = linear and mip = linear */
  30915. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30916. /** mag = nearest and min = linear and mip = none */
  30917. static readonly TEXTURE_NEAREST_LINEAR: number;
  30918. /** mag = nearest and min = nearest and mip = none */
  30919. static readonly TEXTURE_NEAREST_NEAREST: number;
  30920. /** mag = linear and min = nearest and mip = nearest */
  30921. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30922. /** mag = linear and min = nearest and mip = linear */
  30923. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30924. /** mag = linear and min = linear and mip = none */
  30925. static readonly TEXTURE_LINEAR_LINEAR: number;
  30926. /** mag = linear and min = nearest and mip = none */
  30927. static readonly TEXTURE_LINEAR_NEAREST: number;
  30928. /** Explicit coordinates mode */
  30929. static readonly TEXTURE_EXPLICIT_MODE: number;
  30930. /** Spherical coordinates mode */
  30931. static readonly TEXTURE_SPHERICAL_MODE: number;
  30932. /** Planar coordinates mode */
  30933. static readonly TEXTURE_PLANAR_MODE: number;
  30934. /** Cubic coordinates mode */
  30935. static readonly TEXTURE_CUBIC_MODE: number;
  30936. /** Projection coordinates mode */
  30937. static readonly TEXTURE_PROJECTION_MODE: number;
  30938. /** Skybox coordinates mode */
  30939. static readonly TEXTURE_SKYBOX_MODE: number;
  30940. /** Inverse Cubic coordinates mode */
  30941. static readonly TEXTURE_INVCUBIC_MODE: number;
  30942. /** Equirectangular coordinates mode */
  30943. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30944. /** Equirectangular Fixed coordinates mode */
  30945. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30946. /** Equirectangular Fixed Mirrored coordinates mode */
  30947. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30948. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30949. static readonly SCALEMODE_FLOOR: number;
  30950. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30951. static readonly SCALEMODE_NEAREST: number;
  30952. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30953. static readonly SCALEMODE_CEILING: number;
  30954. /**
  30955. * Returns the current npm package of the sdk
  30956. */
  30957. static readonly NpmPackage: string;
  30958. /**
  30959. * Returns the current version of the framework
  30960. */
  30961. static readonly Version: string;
  30962. /**
  30963. * Returns a string describing the current engine
  30964. */
  30965. readonly description: string;
  30966. /**
  30967. * Gets or sets the epsilon value used by collision engine
  30968. */
  30969. static CollisionsEpsilon: number;
  30970. /**
  30971. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30972. */
  30973. static ShadersRepository: string;
  30974. /**
  30975. * Method called to create the default loading screen.
  30976. * This can be overriden in your own app.
  30977. * @param canvas The rendering canvas element
  30978. * @returns The loading screen
  30979. */
  30980. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30981. /**
  30982. * Method called to create the default rescale post process on each engine.
  30983. */
  30984. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30985. /** @hidden */
  30986. _shaderProcessor: IShaderProcessor;
  30987. /**
  30988. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30989. */
  30990. forcePOTTextures: boolean;
  30991. /**
  30992. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30993. */
  30994. isFullscreen: boolean;
  30995. /**
  30996. * Gets a boolean indicating if the pointer is currently locked
  30997. */
  30998. isPointerLock: boolean;
  30999. /**
  31000. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31001. */
  31002. cullBackFaces: boolean;
  31003. /**
  31004. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31005. */
  31006. renderEvenInBackground: boolean;
  31007. /**
  31008. * Gets or sets a boolean indicating that cache can be kept between frames
  31009. */
  31010. preventCacheWipeBetweenFrames: boolean;
  31011. /**
  31012. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31013. **/
  31014. enableOfflineSupport: boolean;
  31015. /**
  31016. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  31017. **/
  31018. disableManifestCheck: boolean;
  31019. /**
  31020. * Gets the list of created scenes
  31021. */
  31022. scenes: Scene[];
  31023. /**
  31024. * Event raised when a new scene is created
  31025. */
  31026. onNewSceneAddedObservable: Observable<Scene>;
  31027. /**
  31028. * Gets the list of created postprocesses
  31029. */
  31030. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31031. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31032. validateShaderPrograms: boolean;
  31033. /**
  31034. * Observable event triggered each time the rendering canvas is resized
  31035. */
  31036. onResizeObservable: Observable<Engine>;
  31037. /**
  31038. * Observable event triggered each time the canvas loses focus
  31039. */
  31040. onCanvasBlurObservable: Observable<Engine>;
  31041. /**
  31042. * Observable event triggered each time the canvas gains focus
  31043. */
  31044. onCanvasFocusObservable: Observable<Engine>;
  31045. /**
  31046. * Observable event triggered each time the canvas receives pointerout event
  31047. */
  31048. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31049. /**
  31050. * Observable event triggered before each texture is initialized
  31051. */
  31052. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31053. /**
  31054. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31055. */
  31056. disableUniformBuffers: boolean;
  31057. /** @hidden */
  31058. _uniformBuffers: UniformBuffer[];
  31059. /**
  31060. * Gets a boolean indicating that the engine supports uniform buffers
  31061. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31062. */
  31063. readonly supportsUniformBuffers: boolean;
  31064. /**
  31065. * Observable raised when the engine begins a new frame
  31066. */
  31067. onBeginFrameObservable: Observable<Engine>;
  31068. /**
  31069. * If set, will be used to request the next animation frame for the render loop
  31070. */
  31071. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31072. /**
  31073. * Observable raised when the engine ends the current frame
  31074. */
  31075. onEndFrameObservable: Observable<Engine>;
  31076. /**
  31077. * Observable raised when the engine is about to compile a shader
  31078. */
  31079. onBeforeShaderCompilationObservable: Observable<Engine>;
  31080. /**
  31081. * Observable raised when the engine has jsut compiled a shader
  31082. */
  31083. onAfterShaderCompilationObservable: Observable<Engine>;
  31084. /** @hidden */
  31085. _gl: WebGLRenderingContext;
  31086. private _renderingCanvas;
  31087. private _windowIsBackground;
  31088. protected _webGLVersion: number;
  31089. protected _highPrecisionShadersAllowed: boolean;
  31090. /** @hidden */
  31091. readonly _shouldUseHighPrecisionShader: boolean;
  31092. /**
  31093. * Gets a boolean indicating that only power of 2 textures are supported
  31094. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31095. */
  31096. readonly needPOTTextures: boolean;
  31097. /** @hidden */
  31098. _badOS: boolean;
  31099. /** @hidden */
  31100. _badDesktopOS: boolean;
  31101. /**
  31102. * Gets the audio engine
  31103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31104. * @ignorenaming
  31105. */
  31106. static audioEngine: IAudioEngine;
  31107. /**
  31108. * Default AudioEngine factory responsible of creating the Audio Engine.
  31109. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31110. */
  31111. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31112. /**
  31113. * Default offline support factory responsible of creating a tool used to store data locally.
  31114. * By default, this will create a Database object if the workload has been embedded.
  31115. */
  31116. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31117. private _onFocus;
  31118. private _onBlur;
  31119. private _onCanvasPointerOut;
  31120. private _onCanvasBlur;
  31121. private _onCanvasFocus;
  31122. private _onFullscreenChange;
  31123. private _onPointerLockChange;
  31124. private _hardwareScalingLevel;
  31125. /** @hidden */
  31126. _caps: EngineCapabilities;
  31127. private _pointerLockRequested;
  31128. private _isStencilEnable;
  31129. protected _colorWrite: boolean;
  31130. private _loadingScreen;
  31131. /** @hidden */
  31132. _drawCalls: PerfCounter;
  31133. private _glVersion;
  31134. private _glRenderer;
  31135. private _glVendor;
  31136. private _videoTextureSupported;
  31137. private _renderingQueueLaunched;
  31138. private _activeRenderLoops;
  31139. private _deterministicLockstep;
  31140. private _lockstepMaxSteps;
  31141. /**
  31142. * Observable signaled when a context lost event is raised
  31143. */
  31144. onContextLostObservable: Observable<Engine>;
  31145. /**
  31146. * Observable signaled when a context restored event is raised
  31147. */
  31148. onContextRestoredObservable: Observable<Engine>;
  31149. private _onContextLost;
  31150. private _onContextRestored;
  31151. private _contextWasLost;
  31152. /** @hidden */
  31153. _doNotHandleContextLost: boolean;
  31154. /**
  31155. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31157. */
  31158. doNotHandleContextLost: boolean;
  31159. private _performanceMonitor;
  31160. private _fps;
  31161. private _deltaTime;
  31162. /**
  31163. * Turn this value on if you want to pause FPS computation when in background
  31164. */
  31165. disablePerformanceMonitorInBackground: boolean;
  31166. /**
  31167. * Gets the performance monitor attached to this engine
  31168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31169. */
  31170. readonly performanceMonitor: PerformanceMonitor;
  31171. /**
  31172. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31173. */
  31174. disableVertexArrayObjects: boolean;
  31175. /** @hidden */
  31176. protected _depthCullingState: _DepthCullingState;
  31177. /** @hidden */
  31178. protected _stencilState: _StencilState;
  31179. /** @hidden */
  31180. protected _alphaState: _AlphaState;
  31181. /** @hidden */
  31182. protected _alphaMode: number;
  31183. /** @hidden */
  31184. _internalTexturesCache: InternalTexture[];
  31185. /** @hidden */
  31186. protected _activeChannel: number;
  31187. private _currentTextureChannel;
  31188. /** @hidden */
  31189. protected _boundTexturesCache: {
  31190. [key: string]: Nullable<InternalTexture>;
  31191. };
  31192. /** @hidden */
  31193. protected _currentEffect: Nullable<Effect>;
  31194. /** @hidden */
  31195. protected _currentProgram: Nullable<WebGLProgram>;
  31196. private _compiledEffects;
  31197. private _vertexAttribArraysEnabled;
  31198. /** @hidden */
  31199. protected _cachedViewport: Nullable<IViewportLike>;
  31200. private _cachedVertexArrayObject;
  31201. /** @hidden */
  31202. protected _cachedVertexBuffers: any;
  31203. /** @hidden */
  31204. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31205. /** @hidden */
  31206. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31207. /** @hidden */
  31208. _currentRenderTarget: Nullable<InternalTexture>;
  31209. private _uintIndicesCurrentlySet;
  31210. private _currentBoundBuffer;
  31211. /** @hidden */
  31212. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31213. private _currentBufferPointers;
  31214. private _currentInstanceLocations;
  31215. private _currentInstanceBuffers;
  31216. private _textureUnits;
  31217. /** @hidden */
  31218. _workingCanvas: Nullable<HTMLCanvasElement>;
  31219. /** @hidden */
  31220. _workingContext: Nullable<CanvasRenderingContext2D>;
  31221. private _rescalePostProcess;
  31222. private _dummyFramebuffer;
  31223. private _externalData;
  31224. /** @hidden */
  31225. _bindedRenderFunction: any;
  31226. private _vaoRecordInProgress;
  31227. private _mustWipeVertexAttributes;
  31228. private _emptyTexture;
  31229. private _emptyCubeTexture;
  31230. private _emptyTexture3D;
  31231. /** @hidden */
  31232. _frameHandler: number;
  31233. private _nextFreeTextureSlots;
  31234. private _maxSimultaneousTextures;
  31235. private _activeRequests;
  31236. private _texturesSupported;
  31237. /** @hidden */
  31238. _textureFormatInUse: Nullable<string>;
  31239. /**
  31240. * Gets the list of texture formats supported
  31241. */
  31242. readonly texturesSupported: Array<string>;
  31243. /**
  31244. * Gets the list of texture formats in use
  31245. */
  31246. readonly textureFormatInUse: Nullable<string>;
  31247. /**
  31248. * Gets the current viewport
  31249. */
  31250. readonly currentViewport: Nullable<IViewportLike>;
  31251. /**
  31252. * Gets the default empty texture
  31253. */
  31254. readonly emptyTexture: InternalTexture;
  31255. /**
  31256. * Gets the default empty 3D texture
  31257. */
  31258. readonly emptyTexture3D: InternalTexture;
  31259. /**
  31260. * Gets the default empty cube texture
  31261. */
  31262. readonly emptyCubeTexture: InternalTexture;
  31263. /**
  31264. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31265. */
  31266. readonly premultipliedAlpha: boolean;
  31267. /**
  31268. * Creates a new engine
  31269. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  31270. * @param antialias defines enable antialiasing (default: false)
  31271. * @param options defines further options to be sent to the getContext() function
  31272. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31273. */
  31274. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31275. /**
  31276. * Initializes a webVR display and starts listening to display change events
  31277. * The onVRDisplayChangedObservable will be notified upon these changes
  31278. * @returns The onVRDisplayChangedObservable
  31279. */
  31280. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31281. /** @hidden */
  31282. _prepareVRComponent(): void;
  31283. /** @hidden */
  31284. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31285. /** @hidden */
  31286. _submitVRFrame(): void;
  31287. /**
  31288. * Call this function to leave webVR mode
  31289. * Will do nothing if webVR is not supported or if there is no webVR device
  31290. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31291. */
  31292. disableVR(): void;
  31293. /**
  31294. * Gets a boolean indicating that the system is in VR mode and is presenting
  31295. * @returns true if VR mode is engaged
  31296. */
  31297. isVRPresenting(): boolean;
  31298. /** @hidden */
  31299. _requestVRFrame(): void;
  31300. private _disableTouchAction;
  31301. private _rebuildInternalTextures;
  31302. private _rebuildEffects;
  31303. /**
  31304. * Gets a boolean indicating if all created effects are ready
  31305. * @returns true if all effects are ready
  31306. */
  31307. areAllEffectsReady(): boolean;
  31308. private _rebuildBuffers;
  31309. private _initGLContext;
  31310. /**
  31311. * Gets version of the current webGL context
  31312. */
  31313. readonly webGLVersion: number;
  31314. /**
  31315. * Gets a string idenfifying the name of the class
  31316. * @returns "Engine" string
  31317. */
  31318. getClassName(): string;
  31319. /**
  31320. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31321. */
  31322. readonly isStencilEnable: boolean;
  31323. /** @hidden */
  31324. _prepareWorkingCanvas(): void;
  31325. /**
  31326. * Reset the texture cache to empty state
  31327. */
  31328. resetTextureCache(): void;
  31329. /**
  31330. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31332. * @returns true if engine is in deterministic lock step mode
  31333. */
  31334. isDeterministicLockStep(): boolean;
  31335. /**
  31336. * Gets the max steps when engine is running in deterministic lock step
  31337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31338. * @returns the max steps
  31339. */
  31340. getLockstepMaxSteps(): number;
  31341. /**
  31342. * Gets an object containing information about the current webGL context
  31343. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31344. */
  31345. getGlInfo(): {
  31346. vendor: string;
  31347. renderer: string;
  31348. version: string;
  31349. };
  31350. /**
  31351. * Gets current aspect ratio
  31352. * @param viewportOwner defines the camera to use to get the aspect ratio
  31353. * @param useScreen defines if screen size must be used (or the current render target if any)
  31354. * @returns a number defining the aspect ratio
  31355. */
  31356. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31357. /**
  31358. * Gets current screen aspect ratio
  31359. * @returns a number defining the aspect ratio
  31360. */
  31361. getScreenAspectRatio(): number;
  31362. /**
  31363. * Gets the current render width
  31364. * @param useScreen defines if screen size must be used (or the current render target if any)
  31365. * @returns a number defining the current render width
  31366. */
  31367. getRenderWidth(useScreen?: boolean): number;
  31368. /**
  31369. * Gets the current render height
  31370. * @param useScreen defines if screen size must be used (or the current render target if any)
  31371. * @returns a number defining the current render height
  31372. */
  31373. getRenderHeight(useScreen?: boolean): number;
  31374. /**
  31375. * Gets the HTML canvas attached with the current webGL context
  31376. * @returns a HTML canvas
  31377. */
  31378. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31379. /**
  31380. * Gets host window
  31381. * @returns the host window object
  31382. */
  31383. getHostWindow(): Window;
  31384. /**
  31385. * Gets host document
  31386. * @returns the host document object
  31387. */
  31388. getHostDocument(): Document;
  31389. /**
  31390. * Gets the client rect of the HTML canvas attached with the current webGL context
  31391. * @returns a client rectanglee
  31392. */
  31393. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31394. /**
  31395. * Defines the hardware scaling level.
  31396. * By default the hardware scaling level is computed from the window device ratio.
  31397. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31398. * @param level defines the level to use
  31399. */
  31400. setHardwareScalingLevel(level: number): void;
  31401. /**
  31402. * Gets the current hardware scaling level.
  31403. * By default the hardware scaling level is computed from the window device ratio.
  31404. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31405. * @returns a number indicating the current hardware scaling level
  31406. */
  31407. getHardwareScalingLevel(): number;
  31408. /**
  31409. * Gets the list of loaded textures
  31410. * @returns an array containing all loaded textures
  31411. */
  31412. getLoadedTexturesCache(): InternalTexture[];
  31413. /**
  31414. * Gets the object containing all engine capabilities
  31415. * @returns the EngineCapabilities object
  31416. */
  31417. getCaps(): EngineCapabilities;
  31418. /**
  31419. * Gets the current depth function
  31420. * @returns a number defining the depth function
  31421. */
  31422. getDepthFunction(): Nullable<number>;
  31423. /**
  31424. * Sets the current depth function
  31425. * @param depthFunc defines the function to use
  31426. */
  31427. setDepthFunction(depthFunc: number): void;
  31428. /**
  31429. * Sets the current depth function to GREATER
  31430. */
  31431. setDepthFunctionToGreater(): void;
  31432. /**
  31433. * Sets the current depth function to GEQUAL
  31434. */
  31435. setDepthFunctionToGreaterOrEqual(): void;
  31436. /**
  31437. * Sets the current depth function to LESS
  31438. */
  31439. setDepthFunctionToLess(): void;
  31440. private _cachedStencilBuffer;
  31441. private _cachedStencilFunction;
  31442. private _cachedStencilMask;
  31443. private _cachedStencilOperationPass;
  31444. private _cachedStencilOperationFail;
  31445. private _cachedStencilOperationDepthFail;
  31446. private _cachedStencilReference;
  31447. /**
  31448. * Caches the the state of the stencil buffer
  31449. */
  31450. cacheStencilState(): void;
  31451. /**
  31452. * Restores the state of the stencil buffer
  31453. */
  31454. restoreStencilState(): void;
  31455. /**
  31456. * Sets the current depth function to LEQUAL
  31457. */
  31458. setDepthFunctionToLessOrEqual(): void;
  31459. /**
  31460. * Gets a boolean indicating if stencil buffer is enabled
  31461. * @returns the current stencil buffer state
  31462. */
  31463. getStencilBuffer(): boolean;
  31464. /**
  31465. * Enable or disable the stencil buffer
  31466. * @param enable defines if the stencil buffer must be enabled or disabled
  31467. */
  31468. setStencilBuffer(enable: boolean): void;
  31469. /**
  31470. * Gets the current stencil mask
  31471. * @returns a number defining the new stencil mask to use
  31472. */
  31473. getStencilMask(): number;
  31474. /**
  31475. * Sets the current stencil mask
  31476. * @param mask defines the new stencil mask to use
  31477. */
  31478. setStencilMask(mask: number): void;
  31479. /**
  31480. * Gets the current stencil function
  31481. * @returns a number defining the stencil function to use
  31482. */
  31483. getStencilFunction(): number;
  31484. /**
  31485. * Gets the current stencil reference value
  31486. * @returns a number defining the stencil reference value to use
  31487. */
  31488. getStencilFunctionReference(): number;
  31489. /**
  31490. * Gets the current stencil mask
  31491. * @returns a number defining the stencil mask to use
  31492. */
  31493. getStencilFunctionMask(): number;
  31494. /**
  31495. * Sets the current stencil function
  31496. * @param stencilFunc defines the new stencil function to use
  31497. */
  31498. setStencilFunction(stencilFunc: number): void;
  31499. /**
  31500. * Sets the current stencil reference
  31501. * @param reference defines the new stencil reference to use
  31502. */
  31503. setStencilFunctionReference(reference: number): void;
  31504. /**
  31505. * Sets the current stencil mask
  31506. * @param mask defines the new stencil mask to use
  31507. */
  31508. setStencilFunctionMask(mask: number): void;
  31509. /**
  31510. * Gets the current stencil operation when stencil fails
  31511. * @returns a number defining stencil operation to use when stencil fails
  31512. */
  31513. getStencilOperationFail(): number;
  31514. /**
  31515. * Gets the current stencil operation when depth fails
  31516. * @returns a number defining stencil operation to use when depth fails
  31517. */
  31518. getStencilOperationDepthFail(): number;
  31519. /**
  31520. * Gets the current stencil operation when stencil passes
  31521. * @returns a number defining stencil operation to use when stencil passes
  31522. */
  31523. getStencilOperationPass(): number;
  31524. /**
  31525. * Sets the stencil operation to use when stencil fails
  31526. * @param operation defines the stencil operation to use when stencil fails
  31527. */
  31528. setStencilOperationFail(operation: number): void;
  31529. /**
  31530. * Sets the stencil operation to use when depth fails
  31531. * @param operation defines the stencil operation to use when depth fails
  31532. */
  31533. setStencilOperationDepthFail(operation: number): void;
  31534. /**
  31535. * Sets the stencil operation to use when stencil passes
  31536. * @param operation defines the stencil operation to use when stencil passes
  31537. */
  31538. setStencilOperationPass(operation: number): void;
  31539. /**
  31540. * Sets a boolean indicating if the dithering state is enabled or disabled
  31541. * @param value defines the dithering state
  31542. */
  31543. setDitheringState(value: boolean): void;
  31544. /**
  31545. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31546. * @param value defines the rasterizer state
  31547. */
  31548. setRasterizerState(value: boolean): void;
  31549. /**
  31550. * stop executing a render loop function and remove it from the execution array
  31551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31552. */
  31553. stopRenderLoop(renderFunction?: () => void): void;
  31554. /** @hidden */
  31555. _renderLoop(): void;
  31556. /**
  31557. * Can be used to override the current requestAnimationFrame requester.
  31558. * @hidden
  31559. */
  31560. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31561. /**
  31562. * Register and execute a render loop. The engine can have more than one render function
  31563. * @param renderFunction defines the function to continuously execute
  31564. */
  31565. runRenderLoop(renderFunction: () => void): void;
  31566. /**
  31567. * Toggle full screen mode
  31568. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31569. */
  31570. switchFullscreen(requestPointerLock: boolean): void;
  31571. /**
  31572. * Enters full screen mode
  31573. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31574. */
  31575. enterFullscreen(requestPointerLock: boolean): void;
  31576. /**
  31577. * Exits full screen mode
  31578. */
  31579. exitFullscreen(): void;
  31580. /**
  31581. * Enters Pointerlock mode
  31582. */
  31583. enterPointerlock(): void;
  31584. /**
  31585. * Exits Pointerlock mode
  31586. */
  31587. exitPointerlock(): void;
  31588. /**
  31589. * Clear the current render buffer or the current render target (if any is set up)
  31590. * @param color defines the color to use
  31591. * @param backBuffer defines if the back buffer must be cleared
  31592. * @param depth defines if the depth buffer must be cleared
  31593. * @param stencil defines if the stencil buffer must be cleared
  31594. */
  31595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31596. /**
  31597. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31598. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31599. * @param y defines the y-coordinate of the corner of the clear rectangle
  31600. * @param width defines the width of the clear rectangle
  31601. * @param height defines the height of the clear rectangle
  31602. * @param clearColor defines the clear color
  31603. */
  31604. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31605. /**
  31606. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31607. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31608. * @param y defines the y-coordinate of the corner of the clear rectangle
  31609. * @param width defines the width of the clear rectangle
  31610. * @param height defines the height of the clear rectangle
  31611. */
  31612. enableScissor(x: number, y: number, width: number, height: number): void;
  31613. /**
  31614. * Disable previously set scissor test rectangle
  31615. */
  31616. disableScissor(): void;
  31617. private _viewportCached;
  31618. /** @hidden */
  31619. _viewport(x: number, y: number, width: number, height: number): void;
  31620. /**
  31621. * Set the WebGL's viewport
  31622. * @param viewport defines the viewport element to be used
  31623. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31624. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31625. */
  31626. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31627. /**
  31628. * Directly set the WebGL Viewport
  31629. * @param x defines the x coordinate of the viewport (in screen space)
  31630. * @param y defines the y coordinate of the viewport (in screen space)
  31631. * @param width defines the width of the viewport (in screen space)
  31632. * @param height defines the height of the viewport (in screen space)
  31633. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  31634. */
  31635. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31636. /**
  31637. * Begin a new frame
  31638. */
  31639. beginFrame(): void;
  31640. /**
  31641. * Enf the current frame
  31642. */
  31643. endFrame(): void;
  31644. /**
  31645. * Resize the view according to the canvas' size
  31646. */
  31647. resize(): void;
  31648. /**
  31649. * Force a specific size of the canvas
  31650. * @param width defines the new canvas' width
  31651. * @param height defines the new canvas' height
  31652. */
  31653. setSize(width: number, height: number): void;
  31654. /**
  31655. * Binds the frame buffer to the specified texture.
  31656. * @param texture The texture to render to or null for the default canvas
  31657. * @param faceIndex The face of the texture to render to in case of cube texture
  31658. * @param requiredWidth The width of the target to render to
  31659. * @param requiredHeight The height of the target to render to
  31660. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31661. * @param depthStencilTexture The depth stencil texture to use to render
  31662. * @param lodLevel defines le lod level to bind to the frame buffer
  31663. */
  31664. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31665. /** @hidden */
  31666. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31667. /**
  31668. * Unbind the current render target texture from the webGL context
  31669. * @param texture defines the render target texture to unbind
  31670. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31671. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31672. */
  31673. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31674. /**
  31675. * Force the mipmap generation for the given render target texture
  31676. * @param texture defines the render target texture to use
  31677. */
  31678. generateMipMapsForCubemap(texture: InternalTexture): void;
  31679. /**
  31680. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31681. */
  31682. flushFramebuffer(): void;
  31683. /**
  31684. * Unbind the current render target and bind the default framebuffer
  31685. */
  31686. restoreDefaultFramebuffer(): void;
  31687. /**
  31688. * Create an uniform buffer
  31689. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31690. * @param elements defines the content of the uniform buffer
  31691. * @returns the webGL uniform buffer
  31692. */
  31693. createUniformBuffer(elements: FloatArray): DataBuffer;
  31694. /**
  31695. * Create a dynamic uniform buffer
  31696. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31697. * @param elements defines the content of the uniform buffer
  31698. * @returns the webGL uniform buffer
  31699. */
  31700. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31701. /**
  31702. * Update an existing uniform buffer
  31703. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31704. * @param uniformBuffer defines the target uniform buffer
  31705. * @param elements defines the content to update
  31706. * @param offset defines the offset in the uniform buffer where update should start
  31707. * @param count defines the size of the data to update
  31708. */
  31709. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31710. private _resetVertexBufferBinding;
  31711. /**
  31712. * Creates a vertex buffer
  31713. * @param data the data for the vertex buffer
  31714. * @returns the new WebGL static buffer
  31715. */
  31716. createVertexBuffer(data: DataArray): DataBuffer;
  31717. /**
  31718. * Creates a dynamic vertex buffer
  31719. * @param data the data for the dynamic vertex buffer
  31720. * @returns the new WebGL dynamic buffer
  31721. */
  31722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31723. /**
  31724. * Update a dynamic index buffer
  31725. * @param indexBuffer defines the target index buffer
  31726. * @param indices defines the data to update
  31727. * @param offset defines the offset in the target index buffer where update should start
  31728. */
  31729. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31730. /**
  31731. * Updates a dynamic vertex buffer.
  31732. * @param vertexBuffer the vertex buffer to update
  31733. * @param data the data used to update the vertex buffer
  31734. * @param byteOffset the byte offset of the data
  31735. * @param byteLength the byte length of the data
  31736. */
  31737. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31738. private _resetIndexBufferBinding;
  31739. /**
  31740. * Creates a new index buffer
  31741. * @param indices defines the content of the index buffer
  31742. * @param updatable defines if the index buffer must be updatable
  31743. * @returns a new webGL buffer
  31744. */
  31745. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31746. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31747. /**
  31748. * Bind a webGL buffer to the webGL context
  31749. * @param buffer defines the buffer to bind
  31750. */
  31751. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31752. /**
  31753. * Bind an uniform buffer to the current webGL context
  31754. * @param buffer defines the buffer to bind
  31755. */
  31756. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31757. /**
  31758. * Bind a buffer to the current webGL context at a given location
  31759. * @param buffer defines the buffer to bind
  31760. * @param location defines the index where to bind the buffer
  31761. */
  31762. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31763. /**
  31764. * Bind a specific block at a given index in a specific shader program
  31765. * @param pipelineContext defines the pipeline context to use
  31766. * @param blockName defines the block name
  31767. * @param index defines the index where to bind the block
  31768. */
  31769. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31770. private bindIndexBuffer;
  31771. private bindBuffer;
  31772. /**
  31773. * update the bound buffer with the given data
  31774. * @param data defines the data to update
  31775. */
  31776. updateArrayBuffer(data: Float32Array): void;
  31777. private _vertexAttribPointer;
  31778. private _bindIndexBufferWithCache;
  31779. private _bindVertexBuffersAttributes;
  31780. /**
  31781. * Records a vertex array object
  31782. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31783. * @param vertexBuffers defines the list of vertex buffers to store
  31784. * @param indexBuffer defines the index buffer to store
  31785. * @param effect defines the effect to store
  31786. * @returns the new vertex array object
  31787. */
  31788. recordVertexArrayObject(vertexBuffers: {
  31789. [key: string]: VertexBuffer;
  31790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31791. /**
  31792. * Bind a specific vertex array object
  31793. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31794. * @param vertexArrayObject defines the vertex array object to bind
  31795. * @param indexBuffer defines the index buffer to bind
  31796. */
  31797. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31798. /**
  31799. * Bind webGl buffers directly to the webGL context
  31800. * @param vertexBuffer defines the vertex buffer to bind
  31801. * @param indexBuffer defines the index buffer to bind
  31802. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31803. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31804. * @param effect defines the effect associated with the vertex buffer
  31805. */
  31806. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31807. private _unbindVertexArrayObject;
  31808. /**
  31809. * Bind a list of vertex buffers to the webGL context
  31810. * @param vertexBuffers defines the list of vertex buffers to bind
  31811. * @param indexBuffer defines the index buffer to bind
  31812. * @param effect defines the effect associated with the vertex buffers
  31813. */
  31814. bindBuffers(vertexBuffers: {
  31815. [key: string]: Nullable<VertexBuffer>;
  31816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31817. /**
  31818. * Unbind all instance attributes
  31819. */
  31820. unbindInstanceAttributes(): void;
  31821. /**
  31822. * Release and free the memory of a vertex array object
  31823. * @param vao defines the vertex array object to delete
  31824. */
  31825. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31826. /** @hidden */
  31827. _releaseBuffer(buffer: DataBuffer): boolean;
  31828. protected _deleteBuffer(buffer: DataBuffer): void;
  31829. /**
  31830. * Creates a webGL buffer to use with instanciation
  31831. * @param capacity defines the size of the buffer
  31832. * @returns the webGL buffer
  31833. */
  31834. createInstancesBuffer(capacity: number): DataBuffer;
  31835. /**
  31836. * Delete a webGL buffer used with instanciation
  31837. * @param buffer defines the webGL buffer to delete
  31838. */
  31839. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31840. /**
  31841. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31842. * @param instancesBuffer defines the webGL buffer to update and bind
  31843. * @param data defines the data to store in the buffer
  31844. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31845. */
  31846. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31847. /**
  31848. * Apply all cached states (depth, culling, stencil and alpha)
  31849. */
  31850. applyStates(): void;
  31851. /**
  31852. * Send a draw order
  31853. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31854. * @param indexStart defines the starting index
  31855. * @param indexCount defines the number of index to draw
  31856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31857. */
  31858. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31859. /**
  31860. * Draw a list of points
  31861. * @param verticesStart defines the index of first vertex to draw
  31862. * @param verticesCount defines the count of vertices to draw
  31863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31864. */
  31865. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31866. /**
  31867. * Draw a list of unindexed primitives
  31868. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31869. * @param verticesStart defines the index of first vertex to draw
  31870. * @param verticesCount defines the count of vertices to draw
  31871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31872. */
  31873. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31874. /**
  31875. * Draw a list of indexed primitives
  31876. * @param fillMode defines the primitive to use
  31877. * @param indexStart defines the starting index
  31878. * @param indexCount defines the number of index to draw
  31879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31880. */
  31881. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31882. /**
  31883. * Draw a list of unindexed primitives
  31884. * @param fillMode defines the primitive to use
  31885. * @param verticesStart defines the index of first vertex to draw
  31886. * @param verticesCount defines the count of vertices to draw
  31887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31888. */
  31889. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31890. private _drawMode;
  31891. /** @hidden */
  31892. _releaseEffect(effect: Effect): void;
  31893. /** @hidden */
  31894. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31895. /**
  31896. * Create a new effect (used to store vertex/fragment shaders)
  31897. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31898. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31899. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31900. * @param samplers defines an array of string used to represent textures
  31901. * @param defines defines the string containing the defines to use to compile the shaders
  31902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31903. * @param onCompiled defines a function to call when the effect creation is successful
  31904. * @param onError defines a function to call when the effect creation has failed
  31905. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31906. * @returns the new Effect
  31907. */
  31908. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31909. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31910. private _compileShader;
  31911. private _compileRawShader;
  31912. /**
  31913. * Directly creates a webGL program
  31914. * @param pipelineContext defines the pipeline context to attach to
  31915. * @param vertexCode defines the vertex shader code to use
  31916. * @param fragmentCode defines the fragment shader code to use
  31917. * @param context defines the webGL context to use (if not set, the current one will be used)
  31918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31919. * @returns the new webGL program
  31920. */
  31921. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31922. /**
  31923. * Creates a webGL program
  31924. * @param pipelineContext defines the pipeline context to attach to
  31925. * @param vertexCode defines the vertex shader code to use
  31926. * @param fragmentCode defines the fragment shader code to use
  31927. * @param defines defines the string containing the defines to use to compile the shaders
  31928. * @param context defines the webGL context to use (if not set, the current one will be used)
  31929. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31930. * @returns the new webGL program
  31931. */
  31932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31933. /**
  31934. * Creates a new pipeline context
  31935. * @returns the new pipeline
  31936. */
  31937. createPipelineContext(): IPipelineContext;
  31938. private _createShaderProgram;
  31939. private _finalizePipelineContext;
  31940. /** @hidden */
  31941. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31942. /** @hidden */
  31943. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31944. /** @hidden */
  31945. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31946. /**
  31947. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31948. * @param pipelineContext defines the pipeline context to use
  31949. * @param uniformsNames defines the list of uniform names
  31950. * @returns an array of webGL uniform locations
  31951. */
  31952. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31953. /**
  31954. * Gets the lsit of active attributes for a given webGL program
  31955. * @param pipelineContext defines the pipeline context to use
  31956. * @param attributesNames defines the list of attribute names to get
  31957. * @returns an array of indices indicating the offset of each attribute
  31958. */
  31959. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31960. /**
  31961. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31962. * @param effect defines the effect to activate
  31963. */
  31964. enableEffect(effect: Nullable<Effect>): void;
  31965. /**
  31966. * Set the value of an uniform to an array of int32
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param array defines the array of int32 to store
  31969. */
  31970. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31971. /**
  31972. * Set the value of an uniform to an array of int32 (stored as vec2)
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param array defines the array of int32 to store
  31975. */
  31976. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31977. /**
  31978. * Set the value of an uniform to an array of int32 (stored as vec3)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param array defines the array of int32 to store
  31981. */
  31982. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31983. /**
  31984. * Set the value of an uniform to an array of int32 (stored as vec4)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param array defines the array of int32 to store
  31987. */
  31988. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31989. /**
  31990. * Set the value of an uniform to an array of float32
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param array defines the array of float32 to store
  31993. */
  31994. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31995. /**
  31996. * Set the value of an uniform to an array of float32 (stored as vec2)
  31997. * @param uniform defines the webGL uniform location where to store the value
  31998. * @param array defines the array of float32 to store
  31999. */
  32000. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32001. /**
  32002. * Set the value of an uniform to an array of float32 (stored as vec3)
  32003. * @param uniform defines the webGL uniform location where to store the value
  32004. * @param array defines the array of float32 to store
  32005. */
  32006. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32007. /**
  32008. * Set the value of an uniform to an array of float32 (stored as vec4)
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param array defines the array of float32 to store
  32011. */
  32012. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32013. /**
  32014. * Set the value of an uniform to an array of number
  32015. * @param uniform defines the webGL uniform location where to store the value
  32016. * @param array defines the array of number to store
  32017. */
  32018. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32019. /**
  32020. * Set the value of an uniform to an array of number (stored as vec2)
  32021. * @param uniform defines the webGL uniform location where to store the value
  32022. * @param array defines the array of number to store
  32023. */
  32024. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32025. /**
  32026. * Set the value of an uniform to an array of number (stored as vec3)
  32027. * @param uniform defines the webGL uniform location where to store the value
  32028. * @param array defines the array of number to store
  32029. */
  32030. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32031. /**
  32032. * Set the value of an uniform to an array of number (stored as vec4)
  32033. * @param uniform defines the webGL uniform location where to store the value
  32034. * @param array defines the array of number to store
  32035. */
  32036. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32037. /**
  32038. * Set the value of an uniform to an array of float32 (stored as matrices)
  32039. * @param uniform defines the webGL uniform location where to store the value
  32040. * @param matrices defines the array of float32 to store
  32041. */
  32042. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32043. /**
  32044. * Set the value of an uniform to a matrix (3x3)
  32045. * @param uniform defines the webGL uniform location where to store the value
  32046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32047. */
  32048. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32049. /**
  32050. * Set the value of an uniform to a matrix (2x2)
  32051. * @param uniform defines the webGL uniform location where to store the value
  32052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32053. */
  32054. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32055. /**
  32056. * Set the value of an uniform to a number (int)
  32057. * @param uniform defines the webGL uniform location where to store the value
  32058. * @param value defines the int number to store
  32059. */
  32060. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32061. /**
  32062. * Set the value of an uniform to a number (float)
  32063. * @param uniform defines the webGL uniform location where to store the value
  32064. * @param value defines the float number to store
  32065. */
  32066. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32067. /**
  32068. * Set the value of an uniform to a vec2
  32069. * @param uniform defines the webGL uniform location where to store the value
  32070. * @param x defines the 1st component of the value
  32071. * @param y defines the 2nd component of the value
  32072. */
  32073. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32074. /**
  32075. * Set the value of an uniform to a vec3
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param x defines the 1st component of the value
  32078. * @param y defines the 2nd component of the value
  32079. * @param z defines the 3rd component of the value
  32080. */
  32081. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32082. /**
  32083. * Set the value of an uniform to a boolean
  32084. * @param uniform defines the webGL uniform location where to store the value
  32085. * @param bool defines the boolean to store
  32086. */
  32087. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32088. /**
  32089. * Set the value of an uniform to a vec4
  32090. * @param uniform defines the webGL uniform location where to store the value
  32091. * @param x defines the 1st component of the value
  32092. * @param y defines the 2nd component of the value
  32093. * @param z defines the 3rd component of the value
  32094. * @param w defines the 4th component of the value
  32095. */
  32096. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32097. /**
  32098. * Sets a Color4 on a uniform variable
  32099. * @param uniform defines the uniform location
  32100. * @param color4 defines the value to be set
  32101. */
  32102. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32103. /**
  32104. * Set various states to the webGL context
  32105. * @param culling defines backface culling state
  32106. * @param zOffset defines the value to apply to zOffset (0 by default)
  32107. * @param force defines if states must be applied even if cache is up to date
  32108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32109. */
  32110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32111. /**
  32112. * Set the z offset to apply to current rendering
  32113. * @param value defines the offset to apply
  32114. */
  32115. setZOffset(value: number): void;
  32116. /**
  32117. * Gets the current value of the zOffset
  32118. * @returns the current zOffset state
  32119. */
  32120. getZOffset(): number;
  32121. /**
  32122. * Enable or disable depth buffering
  32123. * @param enable defines the state to set
  32124. */
  32125. setDepthBuffer(enable: boolean): void;
  32126. /**
  32127. * Gets a boolean indicating if depth writing is enabled
  32128. * @returns the current depth writing state
  32129. */
  32130. getDepthWrite(): boolean;
  32131. /**
  32132. * Enable or disable depth writing
  32133. * @param enable defines the state to set
  32134. */
  32135. setDepthWrite(enable: boolean): void;
  32136. /**
  32137. * Enable or disable color writing
  32138. * @param enable defines the state to set
  32139. */
  32140. setColorWrite(enable: boolean): void;
  32141. /**
  32142. * Gets a boolean indicating if color writing is enabled
  32143. * @returns the current color writing state
  32144. */
  32145. getColorWrite(): boolean;
  32146. /**
  32147. * Sets alpha constants used by some alpha blending modes
  32148. * @param r defines the red component
  32149. * @param g defines the green component
  32150. * @param b defines the blue component
  32151. * @param a defines the alpha component
  32152. */
  32153. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32154. /**
  32155. * Sets the current alpha mode
  32156. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32159. */
  32160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32161. /**
  32162. * Gets the current alpha mode
  32163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32164. * @returns the current alpha mode
  32165. */
  32166. getAlphaMode(): number;
  32167. /**
  32168. * Clears the list of texture accessible through engine.
  32169. * This can help preventing texture load conflict due to name collision.
  32170. */
  32171. clearInternalTexturesCache(): void;
  32172. /**
  32173. * Force the entire cache to be cleared
  32174. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32175. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32176. */
  32177. wipeCaches(bruteForce?: boolean): void;
  32178. /**
  32179. * Set the compressed texture format to use, based on the formats you have, and the formats
  32180. * supported by the hardware / browser.
  32181. *
  32182. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32183. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32184. * to API arguments needed to compressed textures. This puts the burden on the container
  32185. * generator to house the arcane code for determining these for current & future formats.
  32186. *
  32187. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32188. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32189. *
  32190. * Note: The result of this call is not taken into account when a texture is base64.
  32191. *
  32192. * @param formatsAvailable defines the list of those format families you have created
  32193. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32194. *
  32195. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32196. * @returns The extension selected.
  32197. */
  32198. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32199. /** @hidden */
  32200. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32201. min: number;
  32202. mag: number;
  32203. };
  32204. /** @hidden */
  32205. _createTexture(): WebGLTexture;
  32206. /**
  32207. * Usually called from Texture.ts.
  32208. * Passed information to create a WebGLTexture
  32209. * @param urlArg defines a value which contains one of the following:
  32210. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32211. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32212. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32214. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  32215. * @param scene needed for loading to the correct scene
  32216. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32217. * @param onLoad optional callback to be called upon successful completion
  32218. * @param onError optional callback to be called upon failure
  32219. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  32220. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32221. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32222. * @param forcedExtension defines the extension to use to pick the right loader
  32223. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32224. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32225. */
  32226. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32227. /**
  32228. * @hidden
  32229. * Rescales a texture
  32230. * @param source input texutre
  32231. * @param destination destination texture
  32232. * @param scene scene to use to render the resize
  32233. * @param internalFormat format to use when resizing
  32234. * @param onComplete callback to be called when resize has completed
  32235. */
  32236. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32237. private _unpackFlipYCached;
  32238. /**
  32239. * In case you are sharing the context with other applications, it might
  32240. * be interested to not cache the unpack flip y state to ensure a consistent
  32241. * value would be set.
  32242. */
  32243. enableUnpackFlipYCached: boolean;
  32244. /** @hidden */
  32245. _unpackFlipY(value: boolean): void;
  32246. /** @hidden */
  32247. _getUnpackAlignement(): number;
  32248. /**
  32249. * Creates a dynamic texture
  32250. * @param width defines the width of the texture
  32251. * @param height defines the height of the texture
  32252. * @param generateMipMaps defines if the engine should generate the mip levels
  32253. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32254. * @returns the dynamic texture inside an InternalTexture
  32255. */
  32256. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32257. /**
  32258. * Update the sampling mode of a given texture
  32259. * @param samplingMode defines the required sampling mode
  32260. * @param texture defines the texture to update
  32261. */
  32262. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32263. /**
  32264. * Update the content of a dynamic texture
  32265. * @param texture defines the texture to update
  32266. * @param canvas defines the canvas containing the source
  32267. * @param invertY defines if data must be stored with Y axis inverted
  32268. * @param premulAlpha defines if alpha is stored as premultiplied
  32269. * @param format defines the format of the data
  32270. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32271. */
  32272. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32273. /**
  32274. * Update a video texture
  32275. * @param texture defines the texture to update
  32276. * @param video defines the video element to use
  32277. * @param invertY defines if data must be stored with Y axis inverted
  32278. */
  32279. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32280. /**
  32281. * Updates a depth texture Comparison Mode and Function.
  32282. * If the comparison Function is equal to 0, the mode will be set to none.
  32283. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32284. * @param texture The texture to set the comparison function for
  32285. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32286. */
  32287. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32288. /** @hidden */
  32289. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32290. width: number;
  32291. height: number;
  32292. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32293. /**
  32294. * Creates a depth stencil texture.
  32295. * This is only available in WebGL 2 or with the depth texture extension available.
  32296. * @param size The size of face edge in the texture.
  32297. * @param options The options defining the texture.
  32298. * @returns The texture
  32299. */
  32300. createDepthStencilTexture(size: number | {
  32301. width: number;
  32302. height: number;
  32303. }, options: DepthTextureCreationOptions): InternalTexture;
  32304. /**
  32305. * Creates a depth stencil texture.
  32306. * This is only available in WebGL 2 or with the depth texture extension available.
  32307. * @param size The size of face edge in the texture.
  32308. * @param options The options defining the texture.
  32309. * @returns The texture
  32310. */
  32311. private _createDepthStencilTexture;
  32312. /**
  32313. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32314. * @param renderTarget The render target to set the frame buffer for
  32315. */
  32316. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32317. /**
  32318. * Creates a new render target texture
  32319. * @param size defines the size of the texture
  32320. * @param options defines the options used to create the texture
  32321. * @returns a new render target texture stored in an InternalTexture
  32322. */
  32323. createRenderTargetTexture(size: number | {
  32324. width: number;
  32325. height: number;
  32326. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32327. /** @hidden */
  32328. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32329. /**
  32330. * Updates the sample count of a render target texture
  32331. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32332. * @param texture defines the texture to update
  32333. * @param samples defines the sample count to set
  32334. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32335. */
  32336. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32337. /** @hidden */
  32338. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32339. /** @hidden */
  32340. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32341. /** @hidden */
  32342. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32343. /** @hidden */
  32344. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32345. /**
  32346. * @hidden
  32347. */
  32348. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32349. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32350. private _prepareWebGLTexture;
  32351. /** @hidden */
  32352. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32353. /** @hidden */
  32354. _releaseFramebufferObjects(texture: InternalTexture): void;
  32355. /** @hidden */
  32356. _releaseTexture(texture: InternalTexture): void;
  32357. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32358. protected _setProgram(program: WebGLProgram): void;
  32359. protected _boundUniforms: {
  32360. [key: number]: WebGLUniformLocation;
  32361. };
  32362. /**
  32363. * Binds an effect to the webGL context
  32364. * @param effect defines the effect to bind
  32365. */
  32366. bindSamplers(effect: Effect): void;
  32367. private _activateCurrentTexture;
  32368. /** @hidden */
  32369. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32370. /** @hidden */
  32371. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32372. /**
  32373. * Sets a texture to the webGL context from a postprocess
  32374. * @param channel defines the channel to use
  32375. * @param postProcess defines the source postprocess
  32376. */
  32377. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32378. /**
  32379. * Binds the output of the passed in post process to the texture channel specified
  32380. * @param channel The channel the texture should be bound to
  32381. * @param postProcess The post process which's output should be bound
  32382. */
  32383. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32384. /**
  32385. * Unbind all textures from the webGL context
  32386. */
  32387. unbindAllTextures(): void;
  32388. /**
  32389. * Sets a texture to the according uniform.
  32390. * @param channel The texture channel
  32391. * @param uniform The uniform to set
  32392. * @param texture The texture to apply
  32393. */
  32394. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32395. /**
  32396. * Sets a depth stencil texture from a render target to the according uniform.
  32397. * @param channel The texture channel
  32398. * @param uniform The uniform to set
  32399. * @param texture The render target texture containing the depth stencil texture to apply
  32400. */
  32401. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32402. private _bindSamplerUniformToChannel;
  32403. private _getTextureWrapMode;
  32404. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32405. /**
  32406. * Sets an array of texture to the webGL context
  32407. * @param channel defines the channel where the texture array must be set
  32408. * @param uniform defines the associated uniform location
  32409. * @param textures defines the array of textures to bind
  32410. */
  32411. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32412. /** @hidden */
  32413. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32414. private _setTextureParameterFloat;
  32415. private _setTextureParameterInteger;
  32416. /**
  32417. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32418. * @param x defines the x coordinate of the rectangle where pixels must be read
  32419. * @param y defines the y coordinate of the rectangle where pixels must be read
  32420. * @param width defines the width of the rectangle where pixels must be read
  32421. * @param height defines the height of the rectangle where pixels must be read
  32422. * @returns a Uint8Array containing RGBA colors
  32423. */
  32424. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32425. /**
  32426. * Add an externaly attached data from its key.
  32427. * This method call will fail and return false, if such key already exists.
  32428. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32429. * @param key the unique key that identifies the data
  32430. * @param data the data object to associate to the key for this Engine instance
  32431. * @return true if no such key were already present and the data was added successfully, false otherwise
  32432. */
  32433. addExternalData<T>(key: string, data: T): boolean;
  32434. /**
  32435. * Get an externaly attached data from its key
  32436. * @param key the unique key that identifies the data
  32437. * @return the associated data, if present (can be null), or undefined if not present
  32438. */
  32439. getExternalData<T>(key: string): T;
  32440. /**
  32441. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32442. * @param key the unique key that identifies the data
  32443. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32444. * @return the associated data, can be null if the factory returned null.
  32445. */
  32446. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32447. /**
  32448. * Remove an externaly attached data from the Engine instance
  32449. * @param key the unique key that identifies the data
  32450. * @return true if the data was successfully removed, false if it doesn't exist
  32451. */
  32452. removeExternalData(key: string): boolean;
  32453. /**
  32454. * Unbind all vertex attributes from the webGL context
  32455. */
  32456. unbindAllAttributes(): void;
  32457. /**
  32458. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  32459. */
  32460. releaseEffects(): void;
  32461. /**
  32462. * Dispose and release all associated resources
  32463. */
  32464. dispose(): void;
  32465. /**
  32466. * Display the loading screen
  32467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32468. */
  32469. displayLoadingUI(): void;
  32470. /**
  32471. * Hide the loading screen
  32472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32473. */
  32474. hideLoadingUI(): void;
  32475. /**
  32476. * Gets the current loading screen object
  32477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32478. */
  32479. /**
  32480. * Sets the current loading screen object
  32481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32482. */
  32483. loadingScreen: ILoadingScreen;
  32484. /**
  32485. * Sets the current loading screen text
  32486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32487. */
  32488. loadingUIText: string;
  32489. /**
  32490. * Sets the current loading screen background color
  32491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32492. */
  32493. loadingUIBackgroundColor: string;
  32494. /**
  32495. * Attach a new callback raised when context lost event is fired
  32496. * @param callback defines the callback to call
  32497. */
  32498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32499. /**
  32500. * Attach a new callback raised when context restored event is fired
  32501. * @param callback defines the callback to call
  32502. */
  32503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32504. /**
  32505. * Gets the source code of the vertex shader associated with a specific webGL program
  32506. * @param program defines the program to use
  32507. * @returns a string containing the source code of the vertex shader associated with the program
  32508. */
  32509. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32510. /**
  32511. * Gets the source code of the fragment shader associated with a specific webGL program
  32512. * @param program defines the program to use
  32513. * @returns a string containing the source code of the fragment shader associated with the program
  32514. */
  32515. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32516. /**
  32517. * Get the current error code of the webGL context
  32518. * @returns the error code
  32519. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32520. */
  32521. getError(): number;
  32522. /**
  32523. * Gets the current framerate
  32524. * @returns a number representing the framerate
  32525. */
  32526. getFps(): number;
  32527. /**
  32528. * Gets the time spent between current and previous frame
  32529. * @returns a number representing the delta time in ms
  32530. */
  32531. getDeltaTime(): number;
  32532. private _measureFps;
  32533. /** @hidden */
  32534. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32535. private _canRenderToFloatFramebuffer;
  32536. private _canRenderToHalfFloatFramebuffer;
  32537. private _canRenderToFramebuffer;
  32538. /** @hidden */
  32539. _getWebGLTextureType(type: number): number;
  32540. /** @hidden */
  32541. _getInternalFormat(format: number): number;
  32542. /** @hidden */
  32543. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32544. /** @hidden */
  32545. _getRGBAMultiSampleBufferFormat(type: number): number;
  32546. /** @hidden */
  32547. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32548. /** @hidden */
  32549. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32550. /**
  32551. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32552. * @returns true if the engine can be created
  32553. * @ignorenaming
  32554. */
  32555. static isSupported(): boolean;
  32556. /**
  32557. * Find the next highest power of two.
  32558. * @param x Number to start search from.
  32559. * @return Next highest power of two.
  32560. */
  32561. static CeilingPOT(x: number): number;
  32562. /**
  32563. * Find the next lowest power of two.
  32564. * @param x Number to start search from.
  32565. * @return Next lowest power of two.
  32566. */
  32567. static FloorPOT(x: number): number;
  32568. /**
  32569. * Find the nearest power of two.
  32570. * @param x Number to start search from.
  32571. * @return Next nearest power of two.
  32572. */
  32573. static NearestPOT(x: number): number;
  32574. /**
  32575. * Get the closest exponent of two
  32576. * @param value defines the value to approximate
  32577. * @param max defines the maximum value to return
  32578. * @param mode defines how to define the closest value
  32579. * @returns closest exponent of two of the given value
  32580. */
  32581. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32582. /**
  32583. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32584. * @param func - the function to be called
  32585. * @param requester - the object that will request the next frame. Falls back to window.
  32586. * @returns frame number
  32587. */
  32588. static QueueNewFrame(func: () => void, requester?: any): number;
  32589. /**
  32590. * Ask the browser to promote the current element to pointerlock mode
  32591. * @param element defines the DOM element to promote
  32592. */
  32593. static _RequestPointerlock(element: HTMLElement): void;
  32594. /**
  32595. * Asks the browser to exit pointerlock mode
  32596. */
  32597. static _ExitPointerlock(): void;
  32598. /**
  32599. * Ask the browser to promote the current element to fullscreen rendering mode
  32600. * @param element defines the DOM element to promote
  32601. */
  32602. static _RequestFullscreen(element: HTMLElement): void;
  32603. /**
  32604. * Asks the browser to exit fullscreen mode
  32605. */
  32606. static _ExitFullscreen(): void;
  32607. }
  32608. }
  32609. declare module "babylonjs/Engines/engineStore" {
  32610. import { Nullable } from "babylonjs/types";
  32611. import { Engine } from "babylonjs/Engines/engine";
  32612. import { Scene } from "babylonjs/scene";
  32613. /**
  32614. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32615. * during the life time of the application.
  32616. */
  32617. export class EngineStore {
  32618. /** Gets the list of created engines */
  32619. static Instances: import("babylonjs/Engines/engine").Engine[];
  32620. /** @hidden */
  32621. static _LastCreatedScene: Nullable<Scene>;
  32622. /**
  32623. * Gets the latest created engine
  32624. */
  32625. static readonly LastCreatedEngine: Nullable<Engine>;
  32626. /**
  32627. * Gets the latest created scene
  32628. */
  32629. static readonly LastCreatedScene: Nullable<Scene>;
  32630. /**
  32631. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32632. * @ignorenaming
  32633. */
  32634. static UseFallbackTexture: boolean;
  32635. /**
  32636. * Texture content used if a texture cannot loaded
  32637. * @ignorenaming
  32638. */
  32639. static FallbackTexture: string;
  32640. }
  32641. }
  32642. declare module "babylonjs/Misc/promise" {
  32643. /**
  32644. * Helper class that provides a small promise polyfill
  32645. */
  32646. export class PromisePolyfill {
  32647. /**
  32648. * Static function used to check if the polyfill is required
  32649. * If this is the case then the function will inject the polyfill to window.Promise
  32650. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32651. */
  32652. static Apply(force?: boolean): void;
  32653. }
  32654. }
  32655. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32656. /**
  32657. * Interface for screenshot methods with describe argument called `size` as object with options
  32658. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32659. */
  32660. export interface IScreenshotSize {
  32661. /**
  32662. * number in pixels for canvas height
  32663. */
  32664. height?: number;
  32665. /**
  32666. * multiplier allowing render at a higher or lower resolution
  32667. * If value is defined then height and width will be ignored and taken from camera
  32668. */
  32669. precision?: number;
  32670. /**
  32671. * number in pixels for canvas width
  32672. */
  32673. width?: number;
  32674. }
  32675. }
  32676. declare module "babylonjs/Misc/tools" {
  32677. import { Nullable, float } from "babylonjs/types";
  32678. import { DomManagement } from "babylonjs/Misc/domManagement";
  32679. import { WebRequest } from "babylonjs/Misc/webRequest";
  32680. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32681. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32682. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32683. import { Camera } from "babylonjs/Cameras/camera";
  32684. import { Engine } from "babylonjs/Engines/engine";
  32685. interface IColor4Like {
  32686. r: float;
  32687. g: float;
  32688. b: float;
  32689. a: float;
  32690. }
  32691. /**
  32692. * Class containing a set of static utilities functions
  32693. */
  32694. export class Tools {
  32695. /**
  32696. * Gets or sets the base URL to use to load assets
  32697. */
  32698. static BaseUrl: string;
  32699. /**
  32700. * Enable/Disable Custom HTTP Request Headers globally.
  32701. * default = false
  32702. * @see CustomRequestHeaders
  32703. */
  32704. static UseCustomRequestHeaders: boolean;
  32705. /**
  32706. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32707. * i.e. when loading files, where the server/service expects an Authorization header
  32708. */
  32709. static CustomRequestHeaders: {
  32710. [key: string]: string;
  32711. };
  32712. /**
  32713. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32714. */
  32715. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32716. /**
  32717. * Default behaviour for cors in the application.
  32718. * It can be a string if the expected behavior is identical in the entire app.
  32719. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32720. */
  32721. static CorsBehavior: string | ((url: string | string[]) => string);
  32722. /**
  32723. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32724. * @ignorenaming
  32725. */
  32726. static UseFallbackTexture: boolean;
  32727. /**
  32728. * Use this object to register external classes like custom textures or material
  32729. * to allow the laoders to instantiate them
  32730. */
  32731. static RegisteredExternalClasses: {
  32732. [key: string]: Object;
  32733. };
  32734. /**
  32735. * Texture content used if a texture cannot loaded
  32736. * @ignorenaming
  32737. */
  32738. static fallbackTexture: string;
  32739. /**
  32740. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32741. * @param u defines the coordinate on X axis
  32742. * @param v defines the coordinate on Y axis
  32743. * @param width defines the width of the source data
  32744. * @param height defines the height of the source data
  32745. * @param pixels defines the source byte array
  32746. * @param color defines the output color
  32747. */
  32748. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32749. /**
  32750. * Interpolates between a and b via alpha
  32751. * @param a The lower value (returned when alpha = 0)
  32752. * @param b The upper value (returned when alpha = 1)
  32753. * @param alpha The interpolation-factor
  32754. * @return The mixed value
  32755. */
  32756. static Mix(a: number, b: number, alpha: number): number;
  32757. /**
  32758. * Tries to instantiate a new object from a given class name
  32759. * @param className defines the class name to instantiate
  32760. * @returns the new object or null if the system was not able to do the instantiation
  32761. */
  32762. static Instantiate(className: string): any;
  32763. /**
  32764. * Provides a slice function that will work even on IE
  32765. * @param data defines the array to slice
  32766. * @param start defines the start of the data (optional)
  32767. * @param end defines the end of the data (optional)
  32768. * @returns the new sliced array
  32769. */
  32770. static Slice<T>(data: T, start?: number, end?: number): T;
  32771. /**
  32772. * Polyfill for setImmediate
  32773. * @param action defines the action to execute after the current execution block
  32774. */
  32775. static SetImmediate(action: () => void): void;
  32776. /**
  32777. * Function indicating if a number is an exponent of 2
  32778. * @param value defines the value to test
  32779. * @returns true if the value is an exponent of 2
  32780. */
  32781. static IsExponentOfTwo(value: number): boolean;
  32782. private static _tmpFloatArray;
  32783. /**
  32784. * Returns the nearest 32-bit single precision float representation of a Number
  32785. * @param value A Number. If the parameter is of a different type, it will get converted
  32786. * to a number or to NaN if it cannot be converted
  32787. * @returns number
  32788. */
  32789. static FloatRound(value: number): number;
  32790. /**
  32791. * Extracts the filename from a path
  32792. * @param path defines the path to use
  32793. * @returns the filename
  32794. */
  32795. static GetFilename(path: string): string;
  32796. /**
  32797. * Extracts the "folder" part of a path (everything before the filename).
  32798. * @param uri The URI to extract the info from
  32799. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32800. * @returns The "folder" part of the path
  32801. */
  32802. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32803. /**
  32804. * Extracts text content from a DOM element hierarchy
  32805. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32806. */
  32807. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32808. /**
  32809. * Convert an angle in radians to degrees
  32810. * @param angle defines the angle to convert
  32811. * @returns the angle in degrees
  32812. */
  32813. static ToDegrees(angle: number): number;
  32814. /**
  32815. * Convert an angle in degrees to radians
  32816. * @param angle defines the angle to convert
  32817. * @returns the angle in radians
  32818. */
  32819. static ToRadians(angle: number): number;
  32820. /**
  32821. * Encode a buffer to a base64 string
  32822. * @param buffer defines the buffer to encode
  32823. * @returns the encoded string
  32824. */
  32825. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32826. /**
  32827. * Returns an array if obj is not an array
  32828. * @param obj defines the object to evaluate as an array
  32829. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32830. * @returns either obj directly if obj is an array or a new array containing obj
  32831. */
  32832. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32833. /**
  32834. * Gets the pointer prefix to use
  32835. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32836. */
  32837. static GetPointerPrefix(): string;
  32838. /**
  32839. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32840. * @param url define the url we are trying
  32841. * @param element define the dom element where to configure the cors policy
  32842. */
  32843. static SetCorsBehavior(url: string | string[], element: {
  32844. crossOrigin: string | null;
  32845. }): void;
  32846. /**
  32847. * Removes unwanted characters from an url
  32848. * @param url defines the url to clean
  32849. * @returns the cleaned url
  32850. */
  32851. static CleanUrl(url: string): string;
  32852. /**
  32853. * Gets or sets a function used to pre-process url before using them to load assets
  32854. */
  32855. static PreprocessUrl: (url: string) => string;
  32856. /**
  32857. * Loads an image as an HTMLImageElement.
  32858. * @param input url string, ArrayBuffer, or Blob to load
  32859. * @param onLoad callback called when the image successfully loads
  32860. * @param onError callback called when the image fails to load
  32861. * @param offlineProvider offline provider for caching
  32862. * @returns the HTMLImageElement of the loaded image
  32863. */
  32864. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32865. /**
  32866. * Loads a file
  32867. * @param url url string, ArrayBuffer, or Blob to load
  32868. * @param onSuccess callback called when the file successfully loads
  32869. * @param onProgress callback called while file is loading (if the server supports this mode)
  32870. * @param offlineProvider defines the offline provider for caching
  32871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32872. * @param onError callback called when the file fails to load
  32873. * @returns a file request object
  32874. */
  32875. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32876. /**
  32877. * Loads a file from a url
  32878. * @param url the file url to load
  32879. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32880. */
  32881. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32882. /**
  32883. * Load a script (identified by an url). When the url returns, the
  32884. * content of this file is added into a new script element, attached to the DOM (body element)
  32885. * @param scriptUrl defines the url of the script to laod
  32886. * @param onSuccess defines the callback called when the script is loaded
  32887. * @param onError defines the callback to call if an error occurs
  32888. * @param scriptId defines the id of the script element
  32889. */
  32890. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32891. /**
  32892. * Load an asynchronous script (identified by an url). When the url returns, the
  32893. * content of this file is added into a new script element, attached to the DOM (body element)
  32894. * @param scriptUrl defines the url of the script to laod
  32895. * @param scriptId defines the id of the script element
  32896. * @returns a promise request object
  32897. */
  32898. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32899. /**
  32900. * Loads a file from a blob
  32901. * @param fileToLoad defines the blob to use
  32902. * @param callback defines the callback to call when data is loaded
  32903. * @param progressCallback defines the callback to call during loading process
  32904. * @returns a file request object
  32905. */
  32906. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32907. /**
  32908. * Loads a file
  32909. * @param fileToLoad defines the file to load
  32910. * @param callback defines the callback to call when data is loaded
  32911. * @param progressCallBack defines the callback to call during loading process
  32912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32913. * @returns a file request object
  32914. */
  32915. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32916. /**
  32917. * Creates a data url from a given string content
  32918. * @param content defines the content to convert
  32919. * @returns the new data url link
  32920. */
  32921. static FileAsURL(content: string): string;
  32922. /**
  32923. * Format the given number to a specific decimal format
  32924. * @param value defines the number to format
  32925. * @param decimals defines the number of decimals to use
  32926. * @returns the formatted string
  32927. */
  32928. static Format(value: number, decimals?: number): string;
  32929. /**
  32930. * Tries to copy an object by duplicating every property
  32931. * @param source defines the source object
  32932. * @param destination defines the target object
  32933. * @param doNotCopyList defines a list of properties to avoid
  32934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32935. */
  32936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32937. /**
  32938. * Gets a boolean indicating if the given object has no own property
  32939. * @param obj defines the object to test
  32940. * @returns true if object has no own property
  32941. */
  32942. static IsEmpty(obj: any): boolean;
  32943. /**
  32944. * Function used to register events at window level
  32945. * @param windowElement defines the Window object to use
  32946. * @param events defines the events to register
  32947. */
  32948. static RegisterTopRootEvents(windowElement: Window, events: {
  32949. name: string;
  32950. handler: Nullable<(e: FocusEvent) => any>;
  32951. }[]): void;
  32952. /**
  32953. * Function used to unregister events from window level
  32954. * @param windowElement defines the Window object to use
  32955. * @param events defines the events to unregister
  32956. */
  32957. static UnregisterTopRootEvents(windowElement: Window, events: {
  32958. name: string;
  32959. handler: Nullable<(e: FocusEvent) => any>;
  32960. }[]): void;
  32961. /**
  32962. * @ignore
  32963. */
  32964. static _ScreenshotCanvas: HTMLCanvasElement;
  32965. /**
  32966. * Dumps the current bound framebuffer
  32967. * @param width defines the rendering width
  32968. * @param height defines the rendering height
  32969. * @param engine defines the hosting engine
  32970. * @param successCallback defines the callback triggered once the data are available
  32971. * @param mimeType defines the mime type of the result
  32972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32973. */
  32974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32975. /**
  32976. * Converts the canvas data to blob.
  32977. * This acts as a polyfill for browsers not supporting the to blob function.
  32978. * @param canvas Defines the canvas to extract the data from
  32979. * @param successCallback Defines the callback triggered once the data are available
  32980. * @param mimeType Defines the mime type of the result
  32981. */
  32982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32983. /**
  32984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32985. * @param successCallback defines the callback triggered once the data are available
  32986. * @param mimeType defines the mime type of the result
  32987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32988. */
  32989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32990. /**
  32991. * Downloads a blob in the browser
  32992. * @param blob defines the blob to download
  32993. * @param fileName defines the name of the downloaded file
  32994. */
  32995. static Download(blob: Blob, fileName: string): void;
  32996. /**
  32997. * Captures a screenshot of the current rendering
  32998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32999. * @param engine defines the rendering engine
  33000. * @param camera defines the source camera
  33001. * @param size This parameter can be set to a single number or to an object with the
  33002. * following (optional) properties: precision, width, height. If a single number is passed,
  33003. * it will be used for both width and height. If an object is passed, the screenshot size
  33004. * will be derived from the parameters. The precision property is a multiplier allowing
  33005. * rendering at a higher or lower resolution
  33006. * @param successCallback defines the callback receives a single parameter which contains the
  33007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33008. * src parameter of an <img> to display it
  33009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33010. * Check your browser for supported MIME types
  33011. */
  33012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33013. /**
  33014. * Captures a screenshot of the current rendering
  33015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33016. * @param engine defines the rendering engine
  33017. * @param camera defines the source camera
  33018. * @param size This parameter can be set to a single number or to an object with the
  33019. * following (optional) properties: precision, width, height. If a single number is passed,
  33020. * it will be used for both width and height. If an object is passed, the screenshot size
  33021. * will be derived from the parameters. The precision property is a multiplier allowing
  33022. * rendering at a higher or lower resolution
  33023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33024. * Check your browser for supported MIME types
  33025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33026. * to the src parameter of an <img> to display it
  33027. */
  33028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33029. /**
  33030. * Generates an image screenshot from the specified camera.
  33031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33032. * @param engine The engine to use for rendering
  33033. * @param camera The camera to use for rendering
  33034. * @param size This parameter can be set to a single number or to an object with the
  33035. * following (optional) properties: precision, width, height. If a single number is passed,
  33036. * it will be used for both width and height. If an object is passed, the screenshot size
  33037. * will be derived from the parameters. The precision property is a multiplier allowing
  33038. * rendering at a higher or lower resolution
  33039. * @param successCallback The callback receives a single parameter which contains the
  33040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33041. * src parameter of an <img> to display it
  33042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33043. * Check your browser for supported MIME types
  33044. * @param samples Texture samples (default: 1)
  33045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33046. * @param fileName A name for for the downloaded file.
  33047. */
  33048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33049. /**
  33050. * Generates an image screenshot from the specified camera.
  33051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33052. * @param engine The engine to use for rendering
  33053. * @param camera The camera to use for rendering
  33054. * @param size This parameter can be set to a single number or to an object with the
  33055. * following (optional) properties: precision, width, height. If a single number is passed,
  33056. * it will be used for both width and height. If an object is passed, the screenshot size
  33057. * will be derived from the parameters. The precision property is a multiplier allowing
  33058. * rendering at a higher or lower resolution
  33059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33060. * Check your browser for supported MIME types
  33061. * @param samples Texture samples (default: 1)
  33062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33063. * @param fileName A name for for the downloaded file.
  33064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33065. * to the src parameter of an <img> to display it
  33066. */
  33067. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33068. /**
  33069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33070. * Be aware Math.random() could cause collisions, but:
  33071. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  33072. * @returns a pseudo random id
  33073. */
  33074. static RandomId(): string;
  33075. /**
  33076. * Test if the given uri is a base64 string
  33077. * @param uri The uri to test
  33078. * @return True if the uri is a base64 string or false otherwise
  33079. */
  33080. static IsBase64(uri: string): boolean;
  33081. /**
  33082. * Decode the given base64 uri.
  33083. * @param uri The uri to decode
  33084. * @return The decoded base64 data.
  33085. */
  33086. static DecodeBase64(uri: string): ArrayBuffer;
  33087. /**
  33088. * Gets the absolute url.
  33089. * @param url the input url
  33090. * @return the absolute url
  33091. */
  33092. static GetAbsoluteUrl(url: string): string;
  33093. /**
  33094. * No log
  33095. */
  33096. static readonly NoneLogLevel: number;
  33097. /**
  33098. * Only message logs
  33099. */
  33100. static readonly MessageLogLevel: number;
  33101. /**
  33102. * Only warning logs
  33103. */
  33104. static readonly WarningLogLevel: number;
  33105. /**
  33106. * Only error logs
  33107. */
  33108. static readonly ErrorLogLevel: number;
  33109. /**
  33110. * All logs
  33111. */
  33112. static readonly AllLogLevel: number;
  33113. /**
  33114. * Gets a value indicating the number of loading errors
  33115. * @ignorenaming
  33116. */
  33117. static readonly errorsCount: number;
  33118. /**
  33119. * Callback called when a new log is added
  33120. */
  33121. static OnNewCacheEntry: (entry: string) => void;
  33122. /**
  33123. * Log a message to the console
  33124. * @param message defines the message to log
  33125. */
  33126. static Log(message: string): void;
  33127. /**
  33128. * Write a warning message to the console
  33129. * @param message defines the message to log
  33130. */
  33131. static Warn(message: string): void;
  33132. /**
  33133. * Write an error message to the console
  33134. * @param message defines the message to log
  33135. */
  33136. static Error(message: string): void;
  33137. /**
  33138. * Gets current log cache (list of logs)
  33139. */
  33140. static readonly LogCache: string;
  33141. /**
  33142. * Clears the log cache
  33143. */
  33144. static ClearLogCache(): void;
  33145. /**
  33146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33147. */
  33148. static LogLevels: number;
  33149. /**
  33150. * Checks if the window object exists
  33151. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33152. */
  33153. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33154. /**
  33155. * No performance log
  33156. */
  33157. static readonly PerformanceNoneLogLevel: number;
  33158. /**
  33159. * Use user marks to log performance
  33160. */
  33161. static readonly PerformanceUserMarkLogLevel: number;
  33162. /**
  33163. * Log performance to the console
  33164. */
  33165. static readonly PerformanceConsoleLogLevel: number;
  33166. private static _performance;
  33167. /**
  33168. * Sets the current performance log level
  33169. */
  33170. static PerformanceLogLevel: number;
  33171. private static _StartPerformanceCounterDisabled;
  33172. private static _EndPerformanceCounterDisabled;
  33173. private static _StartUserMark;
  33174. private static _EndUserMark;
  33175. private static _StartPerformanceConsole;
  33176. private static _EndPerformanceConsole;
  33177. /**
  33178. * Starts a performance counter
  33179. */
  33180. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33181. /**
  33182. * Ends a specific performance coutner
  33183. */
  33184. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33185. /**
  33186. * Gets either window.performance.now() if supported or Date.now() else
  33187. */
  33188. static readonly Now: number;
  33189. /**
  33190. * This method will return the name of the class used to create the instance of the given object.
  33191. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33192. * @param object the object to get the class name from
  33193. * @param isType defines if the object is actually a type
  33194. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33195. */
  33196. static GetClassName(object: any, isType?: boolean): string;
  33197. /**
  33198. * Gets the first element of an array satisfying a given predicate
  33199. * @param array defines the array to browse
  33200. * @param predicate defines the predicate to use
  33201. * @returns null if not found or the element
  33202. */
  33203. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33204. /**
  33205. * This method will return the name of the full name of the class, including its owning module (if any).
  33206. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  33207. * @param object the object to get the class name from
  33208. * @param isType defines if the object is actually a type
  33209. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  33210. * @ignorenaming
  33211. */
  33212. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33213. /**
  33214. * Returns a promise that resolves after the given amount of time.
  33215. * @param delay Number of milliseconds to delay
  33216. * @returns Promise that resolves after the given amount of time
  33217. */
  33218. static DelayAsync(delay: number): Promise<void>;
  33219. }
  33220. /**
  33221. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33222. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33223. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33224. * @param name The name of the class, case should be preserved
  33225. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33226. */
  33227. export function className(name: string, module?: string): (target: Object) => void;
  33228. /**
  33229. * An implementation of a loop for asynchronous functions.
  33230. */
  33231. export class AsyncLoop {
  33232. /**
  33233. * Defines the number of iterations for the loop
  33234. */
  33235. iterations: number;
  33236. /**
  33237. * Defines the current index of the loop.
  33238. */
  33239. index: number;
  33240. private _done;
  33241. private _fn;
  33242. private _successCallback;
  33243. /**
  33244. * Constructor.
  33245. * @param iterations the number of iterations.
  33246. * @param func the function to run each iteration
  33247. * @param successCallback the callback that will be called upon succesful execution
  33248. * @param offset starting offset.
  33249. */
  33250. constructor(
  33251. /**
  33252. * Defines the number of iterations for the loop
  33253. */
  33254. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33255. /**
  33256. * Execute the next iteration. Must be called after the last iteration was finished.
  33257. */
  33258. executeNext(): void;
  33259. /**
  33260. * Break the loop and run the success callback.
  33261. */
  33262. breakLoop(): void;
  33263. /**
  33264. * Create and run an async loop.
  33265. * @param iterations the number of iterations.
  33266. * @param fn the function to run each iteration
  33267. * @param successCallback the callback that will be called upon succesful execution
  33268. * @param offset starting offset.
  33269. * @returns the created async loop object
  33270. */
  33271. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33272. /**
  33273. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33274. * @param iterations total number of iterations
  33275. * @param syncedIterations number of synchronous iterations in each async iteration.
  33276. * @param fn the function to call each iteration.
  33277. * @param callback a success call back that will be called when iterating stops.
  33278. * @param breakFunction a break condition (optional)
  33279. * @param timeout timeout settings for the setTimeout function. default - 0.
  33280. * @returns the created async loop object
  33281. */
  33282. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33283. }
  33284. }
  33285. declare module "babylonjs/Collisions/collisionCoordinator" {
  33286. import { Nullable } from "babylonjs/types";
  33287. import { Scene } from "babylonjs/scene";
  33288. import { Vector3 } from "babylonjs/Maths/math.vector";
  33289. import { Collider } from "babylonjs/Collisions/collider";
  33290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33291. /** @hidden */
  33292. export interface ICollisionCoordinator {
  33293. createCollider(): Collider;
  33294. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33295. init(scene: Scene): void;
  33296. }
  33297. /** @hidden */
  33298. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33299. private _scene;
  33300. private _scaledPosition;
  33301. private _scaledVelocity;
  33302. private _finalPosition;
  33303. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33304. createCollider(): Collider;
  33305. init(scene: Scene): void;
  33306. private _collideWithWorld;
  33307. }
  33308. }
  33309. declare module "babylonjs/Inputs/scene.inputManager" {
  33310. import { Nullable } from "babylonjs/types";
  33311. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33312. import { Vector2 } from "babylonjs/Maths/math.vector";
  33313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33314. import { Scene } from "babylonjs/scene";
  33315. /**
  33316. * Class used to manage all inputs for the scene.
  33317. */
  33318. export class InputManager {
  33319. /** The distance in pixel that you have to move to prevent some events */
  33320. static DragMovementThreshold: number;
  33321. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33322. static LongPressDelay: number;
  33323. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33324. static DoubleClickDelay: number;
  33325. /** If you need to check double click without raising a single click at first click, enable this flag */
  33326. static ExclusiveDoubleClickMode: boolean;
  33327. private _wheelEventName;
  33328. private _onPointerMove;
  33329. private _onPointerDown;
  33330. private _onPointerUp;
  33331. private _initClickEvent;
  33332. private _initActionManager;
  33333. private _delayedSimpleClick;
  33334. private _delayedSimpleClickTimeout;
  33335. private _previousDelayedSimpleClickTimeout;
  33336. private _meshPickProceed;
  33337. private _previousButtonPressed;
  33338. private _currentPickResult;
  33339. private _previousPickResult;
  33340. private _totalPointersPressed;
  33341. private _doubleClickOccured;
  33342. private _pointerOverMesh;
  33343. private _pickedDownMesh;
  33344. private _pickedUpMesh;
  33345. private _pointerX;
  33346. private _pointerY;
  33347. private _unTranslatedPointerX;
  33348. private _unTranslatedPointerY;
  33349. private _startingPointerPosition;
  33350. private _previousStartingPointerPosition;
  33351. private _startingPointerTime;
  33352. private _previousStartingPointerTime;
  33353. private _pointerCaptures;
  33354. private _onKeyDown;
  33355. private _onKeyUp;
  33356. private _onCanvasFocusObserver;
  33357. private _onCanvasBlurObserver;
  33358. private _scene;
  33359. /**
  33360. * Creates a new InputManager
  33361. * @param scene defines the hosting scene
  33362. */
  33363. constructor(scene: Scene);
  33364. /**
  33365. * Gets the mesh that is currently under the pointer
  33366. */
  33367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33368. /**
  33369. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33370. */
  33371. readonly unTranslatedPointer: Vector2;
  33372. /**
  33373. * Gets or sets the current on-screen X position of the pointer
  33374. */
  33375. pointerX: number;
  33376. /**
  33377. * Gets or sets the current on-screen Y position of the pointer
  33378. */
  33379. pointerY: number;
  33380. private _updatePointerPosition;
  33381. private _processPointerMove;
  33382. private _setRayOnPointerInfo;
  33383. private _checkPrePointerObservable;
  33384. /**
  33385. * Use this method to simulate a pointer move on a mesh
  33386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33389. */
  33390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33391. /**
  33392. * Use this method to simulate a pointer down on a mesh
  33393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33396. */
  33397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33398. private _processPointerDown;
  33399. /** @hidden */
  33400. _isPointerSwiping(): boolean;
  33401. /**
  33402. * Use this method to simulate a pointer up on a mesh
  33403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33407. */
  33408. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33409. private _processPointerUp;
  33410. /**
  33411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33413. * @returns true if the pointer was captured
  33414. */
  33415. isPointerCaptured(pointerId?: number): boolean;
  33416. /**
  33417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33418. * @param attachUp defines if you want to attach events to pointerup
  33419. * @param attachDown defines if you want to attach events to pointerdown
  33420. * @param attachMove defines if you want to attach events to pointermove
  33421. */
  33422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33423. /**
  33424. * Detaches all event handlers
  33425. */
  33426. detachControl(): void;
  33427. /**
  33428. * Force the value of meshUnderPointer
  33429. * @param mesh defines the mesh to use
  33430. */
  33431. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33432. /**
  33433. * Gets the mesh under the pointer
  33434. * @returns a Mesh or null if no mesh is under the pointer
  33435. */
  33436. getPointerOverMesh(): Nullable<AbstractMesh>;
  33437. }
  33438. }
  33439. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33440. /**
  33441. * Helper class used to generate session unique ID
  33442. */
  33443. export class UniqueIdGenerator {
  33444. private static _UniqueIdCounter;
  33445. /**
  33446. * Gets an unique (relatively to the current scene) Id
  33447. */
  33448. static readonly UniqueId: number;
  33449. }
  33450. }
  33451. declare module "babylonjs/Animations/animationGroup" {
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { Animation } from "babylonjs/Animations/animation";
  33454. import { Scene, IDisposable } from "babylonjs/scene";
  33455. import { Observable } from "babylonjs/Misc/observable";
  33456. import { Nullable } from "babylonjs/types";
  33457. import "babylonjs/Animations/animatable";
  33458. /**
  33459. * This class defines the direct association between an animation and a target
  33460. */
  33461. export class TargetedAnimation {
  33462. /**
  33463. * Animation to perform
  33464. */
  33465. animation: Animation;
  33466. /**
  33467. * Target to animate
  33468. */
  33469. target: any;
  33470. /**
  33471. * Serialize the object
  33472. * @returns the JSON object representing the current entity
  33473. */
  33474. serialize(): any;
  33475. }
  33476. /**
  33477. * Use this class to create coordinated animations on multiple targets
  33478. */
  33479. export class AnimationGroup implements IDisposable {
  33480. /** The name of the animation group */
  33481. name: string;
  33482. private _scene;
  33483. private _targetedAnimations;
  33484. private _animatables;
  33485. private _from;
  33486. private _to;
  33487. private _isStarted;
  33488. private _isPaused;
  33489. private _speedRatio;
  33490. private _loopAnimation;
  33491. /**
  33492. * Gets or sets the unique id of the node
  33493. */
  33494. uniqueId: number;
  33495. /**
  33496. * This observable will notify when one animation have ended
  33497. */
  33498. onAnimationEndObservable: Observable<TargetedAnimation>;
  33499. /**
  33500. * Observer raised when one animation loops
  33501. */
  33502. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33503. /**
  33504. * This observable will notify when all animations have ended.
  33505. */
  33506. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33507. /**
  33508. * This observable will notify when all animations have paused.
  33509. */
  33510. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33511. /**
  33512. * This observable will notify when all animations are playing.
  33513. */
  33514. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33515. /**
  33516. * Gets the first frame
  33517. */
  33518. readonly from: number;
  33519. /**
  33520. * Gets the last frame
  33521. */
  33522. readonly to: number;
  33523. /**
  33524. * Define if the animations are started
  33525. */
  33526. readonly isStarted: boolean;
  33527. /**
  33528. * Gets a value indicating that the current group is playing
  33529. */
  33530. readonly isPlaying: boolean;
  33531. /**
  33532. * Gets or sets the speed ratio to use for all animations
  33533. */
  33534. /**
  33535. * Gets or sets the speed ratio to use for all animations
  33536. */
  33537. speedRatio: number;
  33538. /**
  33539. * Gets or sets if all animations should loop or not
  33540. */
  33541. loopAnimation: boolean;
  33542. /**
  33543. * Gets the targeted animations for this animation group
  33544. */
  33545. readonly targetedAnimations: Array<TargetedAnimation>;
  33546. /**
  33547. * returning the list of animatables controlled by this animation group.
  33548. */
  33549. readonly animatables: Array<Animatable>;
  33550. /**
  33551. * Instantiates a new Animation Group.
  33552. * This helps managing several animations at once.
  33553. * @see http://doc.babylonjs.com/how_to/group
  33554. * @param name Defines the name of the group
  33555. * @param scene Defines the scene the group belongs to
  33556. */
  33557. constructor(
  33558. /** The name of the animation group */
  33559. name: string, scene?: Nullable<Scene>);
  33560. /**
  33561. * Add an animation (with its target) in the group
  33562. * @param animation defines the animation we want to add
  33563. * @param target defines the target of the animation
  33564. * @returns the TargetedAnimation object
  33565. */
  33566. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33567. /**
  33568. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33569. * It can add constant keys at begin or end
  33570. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33571. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33572. * @returns the animation group
  33573. */
  33574. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33575. /**
  33576. * Start all animations on given targets
  33577. * @param loop defines if animations must loop
  33578. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33579. * @param from defines the from key (optional)
  33580. * @param to defines the to key (optional)
  33581. * @returns the current animation group
  33582. */
  33583. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33584. /**
  33585. * Pause all animations
  33586. * @returns the animation group
  33587. */
  33588. pause(): AnimationGroup;
  33589. /**
  33590. * Play all animations to initial state
  33591. * This function will start() the animations if they were not started or will restart() them if they were paused
  33592. * @param loop defines if animations must loop
  33593. * @returns the animation group
  33594. */
  33595. play(loop?: boolean): AnimationGroup;
  33596. /**
  33597. * Reset all animations to initial state
  33598. * @returns the animation group
  33599. */
  33600. reset(): AnimationGroup;
  33601. /**
  33602. * Restart animations from key 0
  33603. * @returns the animation group
  33604. */
  33605. restart(): AnimationGroup;
  33606. /**
  33607. * Stop all animations
  33608. * @returns the animation group
  33609. */
  33610. stop(): AnimationGroup;
  33611. /**
  33612. * Set animation weight for all animatables
  33613. * @param weight defines the weight to use
  33614. * @return the animationGroup
  33615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33616. */
  33617. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33618. /**
  33619. * Synchronize and normalize all animatables with a source animatable
  33620. * @param root defines the root animatable to synchronize with
  33621. * @return the animationGroup
  33622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33623. */
  33624. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33625. /**
  33626. * Goes to a specific frame in this animation group
  33627. * @param frame the frame number to go to
  33628. * @return the animationGroup
  33629. */
  33630. goToFrame(frame: number): AnimationGroup;
  33631. /**
  33632. * Dispose all associated resources
  33633. */
  33634. dispose(): void;
  33635. private _checkAnimationGroupEnded;
  33636. /**
  33637. * Clone the current animation group and returns a copy
  33638. * @param newName defines the name of the new group
  33639. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33640. * @returns the new aniamtion group
  33641. */
  33642. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33643. /**
  33644. * Serializes the animationGroup to an object
  33645. * @returns Serialized object
  33646. */
  33647. serialize(): any;
  33648. /**
  33649. * Returns a new AnimationGroup object parsed from the source provided.
  33650. * @param parsedAnimationGroup defines the source
  33651. * @param scene defines the scene that will receive the animationGroup
  33652. * @returns a new AnimationGroup
  33653. */
  33654. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33655. /**
  33656. * Returns the string "AnimationGroup"
  33657. * @returns "AnimationGroup"
  33658. */
  33659. getClassName(): string;
  33660. /**
  33661. * Creates a detailled string about the object
  33662. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33663. * @returns a string representing the object
  33664. */
  33665. toString(fullDetails?: boolean): string;
  33666. }
  33667. }
  33668. declare module "babylonjs/scene" {
  33669. import { Nullable } from "babylonjs/types";
  33670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33671. import { Observable } from "babylonjs/Misc/observable";
  33672. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33673. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33674. import { Geometry } from "babylonjs/Meshes/geometry";
  33675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33678. import { Mesh } from "babylonjs/Meshes/mesh";
  33679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33680. import { Bone } from "babylonjs/Bones/bone";
  33681. import { Skeleton } from "babylonjs/Bones/skeleton";
  33682. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33683. import { Camera } from "babylonjs/Cameras/camera";
  33684. import { AbstractScene } from "babylonjs/abstractScene";
  33685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33686. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33687. import { Material } from "babylonjs/Materials/material";
  33688. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33689. import { Effect } from "babylonjs/Materials/effect";
  33690. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33691. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33692. import { Light } from "babylonjs/Lights/light";
  33693. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33694. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33695. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33696. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33698. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33699. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33700. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33701. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33702. import { Engine } from "babylonjs/Engines/engine";
  33703. import { Node } from "babylonjs/node";
  33704. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33705. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33706. import { WebRequest } from "babylonjs/Misc/webRequest";
  33707. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33708. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33709. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33710. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33711. import { Plane } from "babylonjs/Maths/math.plane";
  33712. import { Ray } from "babylonjs/Culling/ray";
  33713. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33714. import { Animation } from "babylonjs/Animations/animation";
  33715. import { Animatable } from "babylonjs/Animations/animatable";
  33716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33718. import { Collider } from "babylonjs/Collisions/collider";
  33719. /**
  33720. * Define an interface for all classes that will hold resources
  33721. */
  33722. export interface IDisposable {
  33723. /**
  33724. * Releases all held resources
  33725. */
  33726. dispose(): void;
  33727. }
  33728. /** Interface defining initialization parameters for Scene class */
  33729. export interface SceneOptions {
  33730. /**
  33731. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33732. * It will improve performance when the number of geometries becomes important.
  33733. */
  33734. useGeometryUniqueIdsMap?: boolean;
  33735. /**
  33736. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33738. */
  33739. useMaterialMeshMap?: boolean;
  33740. /**
  33741. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33743. */
  33744. useClonedMeshhMap?: boolean;
  33745. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33746. virtual?: boolean;
  33747. }
  33748. /**
  33749. * Represents a scene to be rendered by the engine.
  33750. * @see http://doc.babylonjs.com/features/scene
  33751. */
  33752. export class Scene extends AbstractScene implements IAnimatable {
  33753. /** The fog is deactivated */
  33754. static readonly FOGMODE_NONE: number;
  33755. /** The fog density is following an exponential function */
  33756. static readonly FOGMODE_EXP: number;
  33757. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33758. static readonly FOGMODE_EXP2: number;
  33759. /** The fog density is following a linear function. */
  33760. static readonly FOGMODE_LINEAR: number;
  33761. /**
  33762. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33764. */
  33765. static MinDeltaTime: number;
  33766. /**
  33767. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33769. */
  33770. static MaxDeltaTime: number;
  33771. /**
  33772. * Factory used to create the default material.
  33773. * @param name The name of the material to create
  33774. * @param scene The scene to create the material for
  33775. * @returns The default material
  33776. */
  33777. static DefaultMaterialFactory(scene: Scene): Material;
  33778. /**
  33779. * Factory used to create the a collision coordinator.
  33780. * @returns The collision coordinator
  33781. */
  33782. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33783. /** @hidden */
  33784. _inputManager: InputManager;
  33785. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33786. cameraToUseForPointers: Nullable<Camera>;
  33787. /** @hidden */
  33788. readonly _isScene: boolean;
  33789. /**
  33790. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33791. */
  33792. autoClear: boolean;
  33793. /**
  33794. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33795. */
  33796. autoClearDepthAndStencil: boolean;
  33797. /**
  33798. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33799. */
  33800. clearColor: Color4;
  33801. /**
  33802. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33803. */
  33804. ambientColor: Color3;
  33805. /**
  33806. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33807. * It should only be one of the following (if not the default embedded one):
  33808. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33809. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33810. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33811. * The material properties need to be setup according to the type of texture in use.
  33812. */
  33813. environmentBRDFTexture: BaseTexture;
  33814. /** @hidden */
  33815. protected _environmentTexture: Nullable<BaseTexture>;
  33816. /**
  33817. * Texture used in all pbr material as the reflection texture.
  33818. * As in the majority of the scene they are the same (exception for multi room and so on),
  33819. * this is easier to reference from here than from all the materials.
  33820. */
  33821. /**
  33822. * Texture used in all pbr material as the reflection texture.
  33823. * As in the majority of the scene they are the same (exception for multi room and so on),
  33824. * this is easier to set here than in all the materials.
  33825. */
  33826. environmentTexture: Nullable<BaseTexture>;
  33827. /** @hidden */
  33828. protected _environmentIntensity: number;
  33829. /**
  33830. * Intensity of the environment in all pbr material.
  33831. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33832. * As in the majority of the scene they are the same (exception for multi room and so on),
  33833. * this is easier to reference from here than from all the materials.
  33834. */
  33835. /**
  33836. * Intensity of the environment in all pbr material.
  33837. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33838. * As in the majority of the scene they are the same (exception for multi room and so on),
  33839. * this is easier to set here than in all the materials.
  33840. */
  33841. environmentIntensity: number;
  33842. /** @hidden */
  33843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33844. /**
  33845. * Default image processing configuration used either in the rendering
  33846. * Forward main pass or through the imageProcessingPostProcess if present.
  33847. * As in the majority of the scene they are the same (exception for multi camera),
  33848. * this is easier to reference from here than from all the materials and post process.
  33849. *
  33850. * No setter as we it is a shared configuration, you can set the values instead.
  33851. */
  33852. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33853. private _forceWireframe;
  33854. /**
  33855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33856. */
  33857. forceWireframe: boolean;
  33858. private _forcePointsCloud;
  33859. /**
  33860. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33861. */
  33862. forcePointsCloud: boolean;
  33863. /**
  33864. * Gets or sets the active clipplane 1
  33865. */
  33866. clipPlane: Nullable<Plane>;
  33867. /**
  33868. * Gets or sets the active clipplane 2
  33869. */
  33870. clipPlane2: Nullable<Plane>;
  33871. /**
  33872. * Gets or sets the active clipplane 3
  33873. */
  33874. clipPlane3: Nullable<Plane>;
  33875. /**
  33876. * Gets or sets the active clipplane 4
  33877. */
  33878. clipPlane4: Nullable<Plane>;
  33879. /**
  33880. * Gets or sets a boolean indicating if animations are enabled
  33881. */
  33882. animationsEnabled: boolean;
  33883. private _animationPropertiesOverride;
  33884. /**
  33885. * Gets or sets the animation properties override
  33886. */
  33887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33888. /**
  33889. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33890. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33891. */
  33892. useConstantAnimationDeltaTime: boolean;
  33893. /**
  33894. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33895. * Please note that it requires to run a ray cast through the scene on every frame
  33896. */
  33897. constantlyUpdateMeshUnderPointer: boolean;
  33898. /**
  33899. * Defines the HTML cursor to use when hovering over interactive elements
  33900. */
  33901. hoverCursor: string;
  33902. /**
  33903. * Defines the HTML default cursor to use (empty by default)
  33904. */
  33905. defaultCursor: string;
  33906. /**
  33907. * This is used to call preventDefault() on pointer down
  33908. * in order to block unwanted artifacts like system double clicks
  33909. */
  33910. preventDefaultOnPointerDown: boolean;
  33911. /**
  33912. * This is used to call preventDefault() on pointer up
  33913. * in order to block unwanted artifacts like system double clicks
  33914. */
  33915. preventDefaultOnPointerUp: boolean;
  33916. /**
  33917. * Gets or sets user defined metadata
  33918. */
  33919. metadata: any;
  33920. /**
  33921. * For internal use only. Please do not use.
  33922. */
  33923. reservedDataStore: any;
  33924. /**
  33925. * Gets the name of the plugin used to load this scene (null by default)
  33926. */
  33927. loadingPluginName: string;
  33928. /**
  33929. * Use this array to add regular expressions used to disable offline support for specific urls
  33930. */
  33931. disableOfflineSupportExceptionRules: RegExp[];
  33932. /**
  33933. * An event triggered when the scene is disposed.
  33934. */
  33935. onDisposeObservable: Observable<Scene>;
  33936. private _onDisposeObserver;
  33937. /** Sets a function to be executed when this scene is disposed. */
  33938. onDispose: () => void;
  33939. /**
  33940. * An event triggered before rendering the scene (right after animations and physics)
  33941. */
  33942. onBeforeRenderObservable: Observable<Scene>;
  33943. private _onBeforeRenderObserver;
  33944. /** Sets a function to be executed before rendering this scene */
  33945. beforeRender: Nullable<() => void>;
  33946. /**
  33947. * An event triggered after rendering the scene
  33948. */
  33949. onAfterRenderObservable: Observable<Scene>;
  33950. /**
  33951. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33952. */
  33953. onAfterRenderCameraObservable: Observable<Camera>;
  33954. private _onAfterRenderObserver;
  33955. /** Sets a function to be executed after rendering this scene */
  33956. afterRender: Nullable<() => void>;
  33957. /**
  33958. * An event triggered before animating the scene
  33959. */
  33960. onBeforeAnimationsObservable: Observable<Scene>;
  33961. /**
  33962. * An event triggered after animations processing
  33963. */
  33964. onAfterAnimationsObservable: Observable<Scene>;
  33965. /**
  33966. * An event triggered before draw calls are ready to be sent
  33967. */
  33968. onBeforeDrawPhaseObservable: Observable<Scene>;
  33969. /**
  33970. * An event triggered after draw calls have been sent
  33971. */
  33972. onAfterDrawPhaseObservable: Observable<Scene>;
  33973. /**
  33974. * An event triggered when the scene is ready
  33975. */
  33976. onReadyObservable: Observable<Scene>;
  33977. /**
  33978. * An event triggered before rendering a camera
  33979. */
  33980. onBeforeCameraRenderObservable: Observable<Camera>;
  33981. private _onBeforeCameraRenderObserver;
  33982. /** Sets a function to be executed before rendering a camera*/
  33983. beforeCameraRender: () => void;
  33984. /**
  33985. * An event triggered after rendering a camera
  33986. */
  33987. onAfterCameraRenderObservable: Observable<Camera>;
  33988. private _onAfterCameraRenderObserver;
  33989. /** Sets a function to be executed after rendering a camera*/
  33990. afterCameraRender: () => void;
  33991. /**
  33992. * An event triggered when active meshes evaluation is about to start
  33993. */
  33994. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33995. /**
  33996. * An event triggered when active meshes evaluation is done
  33997. */
  33998. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33999. /**
  34000. * An event triggered when particles rendering is about to start
  34001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34002. */
  34003. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34004. /**
  34005. * An event triggered when particles rendering is done
  34006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34007. */
  34008. onAfterParticlesRenderingObservable: Observable<Scene>;
  34009. /**
  34010. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34011. */
  34012. onDataLoadedObservable: Observable<Scene>;
  34013. /**
  34014. * An event triggered when a camera is created
  34015. */
  34016. onNewCameraAddedObservable: Observable<Camera>;
  34017. /**
  34018. * An event triggered when a camera is removed
  34019. */
  34020. onCameraRemovedObservable: Observable<Camera>;
  34021. /**
  34022. * An event triggered when a light is created
  34023. */
  34024. onNewLightAddedObservable: Observable<Light>;
  34025. /**
  34026. * An event triggered when a light is removed
  34027. */
  34028. onLightRemovedObservable: Observable<Light>;
  34029. /**
  34030. * An event triggered when a geometry is created
  34031. */
  34032. onNewGeometryAddedObservable: Observable<Geometry>;
  34033. /**
  34034. * An event triggered when a geometry is removed
  34035. */
  34036. onGeometryRemovedObservable: Observable<Geometry>;
  34037. /**
  34038. * An event triggered when a transform node is created
  34039. */
  34040. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34041. /**
  34042. * An event triggered when a transform node is removed
  34043. */
  34044. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34045. /**
  34046. * An event triggered when a mesh is created
  34047. */
  34048. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34049. /**
  34050. * An event triggered when a mesh is removed
  34051. */
  34052. onMeshRemovedObservable: Observable<AbstractMesh>;
  34053. /**
  34054. * An event triggered when a skeleton is created
  34055. */
  34056. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34057. /**
  34058. * An event triggered when a skeleton is removed
  34059. */
  34060. onSkeletonRemovedObservable: Observable<Skeleton>;
  34061. /**
  34062. * An event triggered when a material is created
  34063. */
  34064. onNewMaterialAddedObservable: Observable<Material>;
  34065. /**
  34066. * An event triggered when a material is removed
  34067. */
  34068. onMaterialRemovedObservable: Observable<Material>;
  34069. /**
  34070. * An event triggered when a texture is created
  34071. */
  34072. onNewTextureAddedObservable: Observable<BaseTexture>;
  34073. /**
  34074. * An event triggered when a texture is removed
  34075. */
  34076. onTextureRemovedObservable: Observable<BaseTexture>;
  34077. /**
  34078. * An event triggered when render targets are about to be rendered
  34079. * Can happen multiple times per frame.
  34080. */
  34081. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34082. /**
  34083. * An event triggered when render targets were rendered.
  34084. * Can happen multiple times per frame.
  34085. */
  34086. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34087. /**
  34088. * An event triggered before calculating deterministic simulation step
  34089. */
  34090. onBeforeStepObservable: Observable<Scene>;
  34091. /**
  34092. * An event triggered after calculating deterministic simulation step
  34093. */
  34094. onAfterStepObservable: Observable<Scene>;
  34095. /**
  34096. * An event triggered when the activeCamera property is updated
  34097. */
  34098. onActiveCameraChanged: Observable<Scene>;
  34099. /**
  34100. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34102. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34103. */
  34104. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34105. /**
  34106. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34108. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34109. */
  34110. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34111. /**
  34112. * This Observable will when a mesh has been imported into the scene.
  34113. */
  34114. onMeshImportedObservable: Observable<AbstractMesh>;
  34115. /**
  34116. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34117. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34118. */
  34119. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34120. /** @hidden */
  34121. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34122. /**
  34123. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34124. */
  34125. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34126. /**
  34127. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34128. */
  34129. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34130. /**
  34131. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34132. */
  34133. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34134. /** Callback called when a pointer move is detected */
  34135. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34136. /** Callback called when a pointer down is detected */
  34137. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34138. /** Callback called when a pointer up is detected */
  34139. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34140. /** Callback called when a pointer pick is detected */
  34141. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34142. /**
  34143. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  34144. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34145. */
  34146. onPrePointerObservable: Observable<PointerInfoPre>;
  34147. /**
  34148. * Observable event triggered each time an input event is received from the rendering canvas
  34149. */
  34150. onPointerObservable: Observable<PointerInfo>;
  34151. /**
  34152. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34153. */
  34154. readonly unTranslatedPointer: Vector2;
  34155. /**
  34156. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34157. */
  34158. static DragMovementThreshold: number;
  34159. /**
  34160. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34161. */
  34162. static LongPressDelay: number;
  34163. /**
  34164. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34165. */
  34166. static DoubleClickDelay: number;
  34167. /** If you need to check double click without raising a single click at first click, enable this flag */
  34168. static ExclusiveDoubleClickMode: boolean;
  34169. /** @hidden */
  34170. _mirroredCameraPosition: Nullable<Vector3>;
  34171. /**
  34172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34174. */
  34175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34176. /**
  34177. * Observable event triggered each time an keyboard event is received from the hosting window
  34178. */
  34179. onKeyboardObservable: Observable<KeyboardInfo>;
  34180. private _useRightHandedSystem;
  34181. /**
  34182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34183. */
  34184. useRightHandedSystem: boolean;
  34185. private _timeAccumulator;
  34186. private _currentStepId;
  34187. private _currentInternalStep;
  34188. /**
  34189. * Sets the step Id used by deterministic lock step
  34190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34191. * @param newStepId defines the step Id
  34192. */
  34193. setStepId(newStepId: number): void;
  34194. /**
  34195. * Gets the step Id used by deterministic lock step
  34196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34197. * @returns the step Id
  34198. */
  34199. getStepId(): number;
  34200. /**
  34201. * Gets the internal step used by deterministic lock step
  34202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34203. * @returns the internal step
  34204. */
  34205. getInternalStep(): number;
  34206. private _fogEnabled;
  34207. /**
  34208. * Gets or sets a boolean indicating if fog is enabled on this scene
  34209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34210. * (Default is true)
  34211. */
  34212. fogEnabled: boolean;
  34213. private _fogMode;
  34214. /**
  34215. * Gets or sets the fog mode to use
  34216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34217. * | mode | value |
  34218. * | --- | --- |
  34219. * | FOGMODE_NONE | 0 |
  34220. * | FOGMODE_EXP | 1 |
  34221. * | FOGMODE_EXP2 | 2 |
  34222. * | FOGMODE_LINEAR | 3 |
  34223. */
  34224. fogMode: number;
  34225. /**
  34226. * Gets or sets the fog color to use
  34227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34228. * (Default is Color3(0.2, 0.2, 0.3))
  34229. */
  34230. fogColor: Color3;
  34231. /**
  34232. * Gets or sets the fog density to use
  34233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34234. * (Default is 0.1)
  34235. */
  34236. fogDensity: number;
  34237. /**
  34238. * Gets or sets the fog start distance to use
  34239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34240. * (Default is 0)
  34241. */
  34242. fogStart: number;
  34243. /**
  34244. * Gets or sets the fog end distance to use
  34245. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34246. * (Default is 1000)
  34247. */
  34248. fogEnd: number;
  34249. private _shadowsEnabled;
  34250. /**
  34251. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34252. */
  34253. shadowsEnabled: boolean;
  34254. private _lightsEnabled;
  34255. /**
  34256. * Gets or sets a boolean indicating if lights are enabled on this scene
  34257. */
  34258. lightsEnabled: boolean;
  34259. /** All of the active cameras added to this scene. */
  34260. activeCameras: Camera[];
  34261. /** @hidden */
  34262. _activeCamera: Nullable<Camera>;
  34263. /** Gets or sets the current active camera */
  34264. activeCamera: Nullable<Camera>;
  34265. private _defaultMaterial;
  34266. /** The default material used on meshes when no material is affected */
  34267. /** The default material used on meshes when no material is affected */
  34268. defaultMaterial: Material;
  34269. private _texturesEnabled;
  34270. /**
  34271. * Gets or sets a boolean indicating if textures are enabled on this scene
  34272. */
  34273. texturesEnabled: boolean;
  34274. /**
  34275. * Gets or sets a boolean indicating if particles are enabled on this scene
  34276. */
  34277. particlesEnabled: boolean;
  34278. /**
  34279. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34280. */
  34281. spritesEnabled: boolean;
  34282. private _skeletonsEnabled;
  34283. /**
  34284. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34285. */
  34286. skeletonsEnabled: boolean;
  34287. /**
  34288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34289. */
  34290. lensFlaresEnabled: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34294. */
  34295. collisionsEnabled: boolean;
  34296. private _collisionCoordinator;
  34297. /** @hidden */
  34298. readonly collisionCoordinator: ICollisionCoordinator;
  34299. /**
  34300. * Defines the gravity applied to this scene (used only for collisions)
  34301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34302. */
  34303. gravity: Vector3;
  34304. /**
  34305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34306. */
  34307. postProcessesEnabled: boolean;
  34308. /**
  34309. * The list of postprocesses added to the scene
  34310. */
  34311. postProcesses: PostProcess[];
  34312. /**
  34313. * Gets the current postprocess manager
  34314. */
  34315. postProcessManager: PostProcessManager;
  34316. /**
  34317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34318. */
  34319. renderTargetsEnabled: boolean;
  34320. /**
  34321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34323. */
  34324. dumpNextRenderTargets: boolean;
  34325. /**
  34326. * The list of user defined render targets added to the scene
  34327. */
  34328. customRenderTargets: RenderTargetTexture[];
  34329. /**
  34330. * Defines if texture loading must be delayed
  34331. * If true, textures will only be loaded when they need to be rendered
  34332. */
  34333. useDelayedTextureLoading: boolean;
  34334. /**
  34335. * Gets the list of meshes imported to the scene through SceneLoader
  34336. */
  34337. importedMeshesFiles: String[];
  34338. /**
  34339. * Gets or sets a boolean indicating if probes are enabled on this scene
  34340. */
  34341. probesEnabled: boolean;
  34342. /**
  34343. * Gets or sets the current offline provider to use to store scene data
  34344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34345. */
  34346. offlineProvider: IOfflineProvider;
  34347. /**
  34348. * Gets or sets the action manager associated with the scene
  34349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34350. */
  34351. actionManager: AbstractActionManager;
  34352. private _meshesForIntersections;
  34353. /**
  34354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34355. */
  34356. proceduralTexturesEnabled: boolean;
  34357. private _engine;
  34358. private _totalVertices;
  34359. /** @hidden */
  34360. _activeIndices: PerfCounter;
  34361. /** @hidden */
  34362. _activeParticles: PerfCounter;
  34363. /** @hidden */
  34364. _activeBones: PerfCounter;
  34365. private _animationRatio;
  34366. /** @hidden */
  34367. _animationTimeLast: number;
  34368. /** @hidden */
  34369. _animationTime: number;
  34370. /**
  34371. * Gets or sets a general scale for animation speed
  34372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34373. */
  34374. animationTimeScale: number;
  34375. /** @hidden */
  34376. _cachedMaterial: Nullable<Material>;
  34377. /** @hidden */
  34378. _cachedEffect: Nullable<Effect>;
  34379. /** @hidden */
  34380. _cachedVisibility: Nullable<number>;
  34381. private _renderId;
  34382. private _frameId;
  34383. private _executeWhenReadyTimeoutId;
  34384. private _intermediateRendering;
  34385. private _viewUpdateFlag;
  34386. private _projectionUpdateFlag;
  34387. /** @hidden */
  34388. _toBeDisposed: Nullable<IDisposable>[];
  34389. private _activeRequests;
  34390. /** @hidden */
  34391. _pendingData: any[];
  34392. private _isDisposed;
  34393. /**
  34394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34396. */
  34397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34398. private _activeMeshes;
  34399. private _processedMaterials;
  34400. private _renderTargets;
  34401. /** @hidden */
  34402. _activeParticleSystems: SmartArray<IParticleSystem>;
  34403. private _activeSkeletons;
  34404. private _softwareSkinnedMeshes;
  34405. private _renderingManager;
  34406. /** @hidden */
  34407. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34408. private _transformMatrix;
  34409. private _sceneUbo;
  34410. /** @hidden */
  34411. _viewMatrix: Matrix;
  34412. private _projectionMatrix;
  34413. /** @hidden */
  34414. _forcedViewPosition: Nullable<Vector3>;
  34415. /** @hidden */
  34416. _frustumPlanes: Plane[];
  34417. /**
  34418. * Gets the list of frustum planes (built from the active camera)
  34419. */
  34420. readonly frustumPlanes: Plane[];
  34421. /**
  34422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34423. * This is useful if there are more lights that the maximum simulteanous authorized
  34424. */
  34425. requireLightSorting: boolean;
  34426. /** @hidden */
  34427. readonly useMaterialMeshMap: boolean;
  34428. /** @hidden */
  34429. readonly useClonedMeshhMap: boolean;
  34430. private _externalData;
  34431. private _uid;
  34432. /**
  34433. * @hidden
  34434. * Backing store of defined scene components.
  34435. */
  34436. _components: ISceneComponent[];
  34437. /**
  34438. * @hidden
  34439. * Backing store of defined scene components.
  34440. */
  34441. _serializableComponents: ISceneSerializableComponent[];
  34442. /**
  34443. * List of components to register on the next registration step.
  34444. */
  34445. private _transientComponents;
  34446. /**
  34447. * Registers the transient components if needed.
  34448. */
  34449. private _registerTransientComponents;
  34450. /**
  34451. * @hidden
  34452. * Add a component to the scene.
  34453. * Note that the ccomponent could be registered on th next frame if this is called after
  34454. * the register component stage.
  34455. * @param component Defines the component to add to the scene
  34456. */
  34457. _addComponent(component: ISceneComponent): void;
  34458. /**
  34459. * @hidden
  34460. * Gets a component from the scene.
  34461. * @param name defines the name of the component to retrieve
  34462. * @returns the component or null if not present
  34463. */
  34464. _getComponent(name: string): Nullable<ISceneComponent>;
  34465. /**
  34466. * @hidden
  34467. * Defines the actions happening before camera updates.
  34468. */
  34469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34470. /**
  34471. * @hidden
  34472. * Defines the actions happening before clear the canvas.
  34473. */
  34474. _beforeClearStage: Stage<SimpleStageAction>;
  34475. /**
  34476. * @hidden
  34477. * Defines the actions when collecting render targets for the frame.
  34478. */
  34479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34480. /**
  34481. * @hidden
  34482. * Defines the actions happening for one camera in the frame.
  34483. */
  34484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34485. /**
  34486. * @hidden
  34487. * Defines the actions happening during the per mesh ready checks.
  34488. */
  34489. _isReadyForMeshStage: Stage<MeshStageAction>;
  34490. /**
  34491. * @hidden
  34492. * Defines the actions happening before evaluate active mesh checks.
  34493. */
  34494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34495. /**
  34496. * @hidden
  34497. * Defines the actions happening during the evaluate sub mesh checks.
  34498. */
  34499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34500. /**
  34501. * @hidden
  34502. * Defines the actions happening during the active mesh stage.
  34503. */
  34504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34505. /**
  34506. * @hidden
  34507. * Defines the actions happening during the per camera render target step.
  34508. */
  34509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34510. /**
  34511. * @hidden
  34512. * Defines the actions happening just before the active camera is drawing.
  34513. */
  34514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34515. /**
  34516. * @hidden
  34517. * Defines the actions happening just before a render target is drawing.
  34518. */
  34519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34520. /**
  34521. * @hidden
  34522. * Defines the actions happening just before a rendering group is drawing.
  34523. */
  34524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34525. /**
  34526. * @hidden
  34527. * Defines the actions happening just before a mesh is drawing.
  34528. */
  34529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34530. /**
  34531. * @hidden
  34532. * Defines the actions happening just after a mesh has been drawn.
  34533. */
  34534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34535. /**
  34536. * @hidden
  34537. * Defines the actions happening just after a rendering group has been drawn.
  34538. */
  34539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34540. /**
  34541. * @hidden
  34542. * Defines the actions happening just after the active camera has been drawn.
  34543. */
  34544. _afterCameraDrawStage: Stage<CameraStageAction>;
  34545. /**
  34546. * @hidden
  34547. * Defines the actions happening just after a render target has been drawn.
  34548. */
  34549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34550. /**
  34551. * @hidden
  34552. * Defines the actions happening just after rendering all cameras and computing intersections.
  34553. */
  34554. _afterRenderStage: Stage<SimpleStageAction>;
  34555. /**
  34556. * @hidden
  34557. * Defines the actions happening when a pointer move event happens.
  34558. */
  34559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34560. /**
  34561. * @hidden
  34562. * Defines the actions happening when a pointer down event happens.
  34563. */
  34564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34565. /**
  34566. * @hidden
  34567. * Defines the actions happening when a pointer up event happens.
  34568. */
  34569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34570. /**
  34571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34572. */
  34573. private geometriesByUniqueId;
  34574. /**
  34575. * Creates a new Scene
  34576. * @param engine defines the engine to use to render this scene
  34577. * @param options defines the scene options
  34578. */
  34579. constructor(engine: Engine, options?: SceneOptions);
  34580. /**
  34581. * Gets a string idenfifying the name of the class
  34582. * @returns "Scene" string
  34583. */
  34584. getClassName(): string;
  34585. private _defaultMeshCandidates;
  34586. /**
  34587. * @hidden
  34588. */
  34589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34590. private _defaultSubMeshCandidates;
  34591. /**
  34592. * @hidden
  34593. */
  34594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34595. /**
  34596. * Sets the default candidate providers for the scene.
  34597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34598. * and getCollidingSubMeshCandidates to their default function
  34599. */
  34600. setDefaultCandidateProviders(): void;
  34601. /**
  34602. * Gets the mesh that is currently under the pointer
  34603. */
  34604. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34605. /**
  34606. * Gets or sets the current on-screen X position of the pointer
  34607. */
  34608. pointerX: number;
  34609. /**
  34610. * Gets or sets the current on-screen Y position of the pointer
  34611. */
  34612. pointerY: number;
  34613. /**
  34614. * Gets the cached material (ie. the latest rendered one)
  34615. * @returns the cached material
  34616. */
  34617. getCachedMaterial(): Nullable<Material>;
  34618. /**
  34619. * Gets the cached effect (ie. the latest rendered one)
  34620. * @returns the cached effect
  34621. */
  34622. getCachedEffect(): Nullable<Effect>;
  34623. /**
  34624. * Gets the cached visibility state (ie. the latest rendered one)
  34625. * @returns the cached visibility state
  34626. */
  34627. getCachedVisibility(): Nullable<number>;
  34628. /**
  34629. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34630. * @param material defines the current material
  34631. * @param effect defines the current effect
  34632. * @param visibility defines the current visibility state
  34633. * @returns true if one parameter is not cached
  34634. */
  34635. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34636. /**
  34637. * Gets the engine associated with the scene
  34638. * @returns an Engine
  34639. */
  34640. getEngine(): Engine;
  34641. /**
  34642. * Gets the total number of vertices rendered per frame
  34643. * @returns the total number of vertices rendered per frame
  34644. */
  34645. getTotalVertices(): number;
  34646. /**
  34647. * Gets the performance counter for total vertices
  34648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34649. */
  34650. readonly totalVerticesPerfCounter: PerfCounter;
  34651. /**
  34652. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34653. * @returns the total number of active indices rendered per frame
  34654. */
  34655. getActiveIndices(): number;
  34656. /**
  34657. * Gets the performance counter for active indices
  34658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34659. */
  34660. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34661. /**
  34662. * Gets the total number of active particles rendered per frame
  34663. * @returns the total number of active particles rendered per frame
  34664. */
  34665. getActiveParticles(): number;
  34666. /**
  34667. * Gets the performance counter for active particles
  34668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34669. */
  34670. readonly activeParticlesPerfCounter: PerfCounter;
  34671. /**
  34672. * Gets the total number of active bones rendered per frame
  34673. * @returns the total number of active bones rendered per frame
  34674. */
  34675. getActiveBones(): number;
  34676. /**
  34677. * Gets the performance counter for active bones
  34678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34679. */
  34680. readonly activeBonesPerfCounter: PerfCounter;
  34681. /**
  34682. * Gets the array of active meshes
  34683. * @returns an array of AbstractMesh
  34684. */
  34685. getActiveMeshes(): SmartArray<AbstractMesh>;
  34686. /**
  34687. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34688. * @returns a number
  34689. */
  34690. getAnimationRatio(): number;
  34691. /**
  34692. * Gets an unique Id for the current render phase
  34693. * @returns a number
  34694. */
  34695. getRenderId(): number;
  34696. /**
  34697. * Gets an unique Id for the current frame
  34698. * @returns a number
  34699. */
  34700. getFrameId(): number;
  34701. /** Call this function if you want to manually increment the render Id*/
  34702. incrementRenderId(): void;
  34703. private _createUbo;
  34704. /**
  34705. * Use this method to simulate a pointer move on a mesh
  34706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34709. * @returns the current scene
  34710. */
  34711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34712. /**
  34713. * Use this method to simulate a pointer down on a mesh
  34714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34717. * @returns the current scene
  34718. */
  34719. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34720. /**
  34721. * Use this method to simulate a pointer up on a mesh
  34722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34725. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34726. * @returns the current scene
  34727. */
  34728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34729. /**
  34730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34732. * @returns true if the pointer was captured
  34733. */
  34734. isPointerCaptured(pointerId?: number): boolean;
  34735. /**
  34736. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34737. * @param attachUp defines if you want to attach events to pointerup
  34738. * @param attachDown defines if you want to attach events to pointerdown
  34739. * @param attachMove defines if you want to attach events to pointermove
  34740. */
  34741. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34742. /** Detaches all event handlers*/
  34743. detachControl(): void;
  34744. /**
  34745. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34746. * Delay loaded resources are not taking in account
  34747. * @return true if all required resources are ready
  34748. */
  34749. isReady(): boolean;
  34750. /** Resets all cached information relative to material (including effect and visibility) */
  34751. resetCachedMaterial(): void;
  34752. /**
  34753. * Registers a function to be called before every frame render
  34754. * @param func defines the function to register
  34755. */
  34756. registerBeforeRender(func: () => void): void;
  34757. /**
  34758. * Unregisters a function called before every frame render
  34759. * @param func defines the function to unregister
  34760. */
  34761. unregisterBeforeRender(func: () => void): void;
  34762. /**
  34763. * Registers a function to be called after every frame render
  34764. * @param func defines the function to register
  34765. */
  34766. registerAfterRender(func: () => void): void;
  34767. /**
  34768. * Unregisters a function called after every frame render
  34769. * @param func defines the function to unregister
  34770. */
  34771. unregisterAfterRender(func: () => void): void;
  34772. private _executeOnceBeforeRender;
  34773. /**
  34774. * The provided function will run before render once and will be disposed afterwards.
  34775. * A timeout delay can be provided so that the function will be executed in N ms.
  34776. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34777. * @param func The function to be executed.
  34778. * @param timeout optional delay in ms
  34779. */
  34780. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34781. /** @hidden */
  34782. _addPendingData(data: any): void;
  34783. /** @hidden */
  34784. _removePendingData(data: any): void;
  34785. /**
  34786. * Returns the number of items waiting to be loaded
  34787. * @returns the number of items waiting to be loaded
  34788. */
  34789. getWaitingItemsCount(): number;
  34790. /**
  34791. * Returns a boolean indicating if the scene is still loading data
  34792. */
  34793. readonly isLoading: boolean;
  34794. /**
  34795. * Registers a function to be executed when the scene is ready
  34796. * @param {Function} func - the function to be executed
  34797. */
  34798. executeWhenReady(func: () => void): void;
  34799. /**
  34800. * Returns a promise that resolves when the scene is ready
  34801. * @returns A promise that resolves when the scene is ready
  34802. */
  34803. whenReadyAsync(): Promise<void>;
  34804. /** @hidden */
  34805. _checkIsReady(): void;
  34806. /**
  34807. * Gets all animatable attached to the scene
  34808. */
  34809. readonly animatables: Animatable[];
  34810. /**
  34811. * Resets the last animation time frame.
  34812. * Useful to override when animations start running when loading a scene for the first time.
  34813. */
  34814. resetLastAnimationTimeFrame(): void;
  34815. /**
  34816. * Gets the current view matrix
  34817. * @returns a Matrix
  34818. */
  34819. getViewMatrix(): Matrix;
  34820. /**
  34821. * Gets the current projection matrix
  34822. * @returns a Matrix
  34823. */
  34824. getProjectionMatrix(): Matrix;
  34825. /**
  34826. * Gets the current transform matrix
  34827. * @returns a Matrix made of View * Projection
  34828. */
  34829. getTransformMatrix(): Matrix;
  34830. /**
  34831. * Sets the current transform matrix
  34832. * @param viewL defines the View matrix to use
  34833. * @param projectionL defines the Projection matrix to use
  34834. * @param viewR defines the right View matrix to use (if provided)
  34835. * @param projectionR defines the right Projection matrix to use (if provided)
  34836. */
  34837. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34838. /**
  34839. * Gets the uniform buffer used to store scene data
  34840. * @returns a UniformBuffer
  34841. */
  34842. getSceneUniformBuffer(): UniformBuffer;
  34843. /**
  34844. * Gets an unique (relatively to the current scene) Id
  34845. * @returns an unique number for the scene
  34846. */
  34847. getUniqueId(): number;
  34848. /**
  34849. * Add a mesh to the list of scene's meshes
  34850. * @param newMesh defines the mesh to add
  34851. * @param recursive if all child meshes should also be added to the scene
  34852. */
  34853. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34854. /**
  34855. * Remove a mesh for the list of scene's meshes
  34856. * @param toRemove defines the mesh to remove
  34857. * @param recursive if all child meshes should also be removed from the scene
  34858. * @returns the index where the mesh was in the mesh list
  34859. */
  34860. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34861. /**
  34862. * Add a transform node to the list of scene's transform nodes
  34863. * @param newTransformNode defines the transform node to add
  34864. */
  34865. addTransformNode(newTransformNode: TransformNode): void;
  34866. /**
  34867. * Remove a transform node for the list of scene's transform nodes
  34868. * @param toRemove defines the transform node to remove
  34869. * @returns the index where the transform node was in the transform node list
  34870. */
  34871. removeTransformNode(toRemove: TransformNode): number;
  34872. /**
  34873. * Remove a skeleton for the list of scene's skeletons
  34874. * @param toRemove defines the skeleton to remove
  34875. * @returns the index where the skeleton was in the skeleton list
  34876. */
  34877. removeSkeleton(toRemove: Skeleton): number;
  34878. /**
  34879. * Remove a morph target for the list of scene's morph targets
  34880. * @param toRemove defines the morph target to remove
  34881. * @returns the index where the morph target was in the morph target list
  34882. */
  34883. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34884. /**
  34885. * Remove a light for the list of scene's lights
  34886. * @param toRemove defines the light to remove
  34887. * @returns the index where the light was in the light list
  34888. */
  34889. removeLight(toRemove: Light): number;
  34890. /**
  34891. * Remove a camera for the list of scene's cameras
  34892. * @param toRemove defines the camera to remove
  34893. * @returns the index where the camera was in the camera list
  34894. */
  34895. removeCamera(toRemove: Camera): number;
  34896. /**
  34897. * Remove a particle system for the list of scene's particle systems
  34898. * @param toRemove defines the particle system to remove
  34899. * @returns the index where the particle system was in the particle system list
  34900. */
  34901. removeParticleSystem(toRemove: IParticleSystem): number;
  34902. /**
  34903. * Remove a animation for the list of scene's animations
  34904. * @param toRemove defines the animation to remove
  34905. * @returns the index where the animation was in the animation list
  34906. */
  34907. removeAnimation(toRemove: Animation): number;
  34908. /**
  34909. * Will stop the animation of the given target
  34910. * @param target - the target
  34911. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34912. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  34913. */
  34914. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34915. /**
  34916. * Removes the given animation group from this scene.
  34917. * @param toRemove The animation group to remove
  34918. * @returns The index of the removed animation group
  34919. */
  34920. removeAnimationGroup(toRemove: AnimationGroup): number;
  34921. /**
  34922. * Removes the given multi-material from this scene.
  34923. * @param toRemove The multi-material to remove
  34924. * @returns The index of the removed multi-material
  34925. */
  34926. removeMultiMaterial(toRemove: MultiMaterial): number;
  34927. /**
  34928. * Removes the given material from this scene.
  34929. * @param toRemove The material to remove
  34930. * @returns The index of the removed material
  34931. */
  34932. removeMaterial(toRemove: Material): number;
  34933. /**
  34934. * Removes the given action manager from this scene.
  34935. * @param toRemove The action manager to remove
  34936. * @returns The index of the removed action manager
  34937. */
  34938. removeActionManager(toRemove: AbstractActionManager): number;
  34939. /**
  34940. * Removes the given texture from this scene.
  34941. * @param toRemove The texture to remove
  34942. * @returns The index of the removed texture
  34943. */
  34944. removeTexture(toRemove: BaseTexture): number;
  34945. /**
  34946. * Adds the given light to this scene
  34947. * @param newLight The light to add
  34948. */
  34949. addLight(newLight: Light): void;
  34950. /**
  34951. * Sorts the list list based on light priorities
  34952. */
  34953. sortLightsByPriority(): void;
  34954. /**
  34955. * Adds the given camera to this scene
  34956. * @param newCamera The camera to add
  34957. */
  34958. addCamera(newCamera: Camera): void;
  34959. /**
  34960. * Adds the given skeleton to this scene
  34961. * @param newSkeleton The skeleton to add
  34962. */
  34963. addSkeleton(newSkeleton: Skeleton): void;
  34964. /**
  34965. * Adds the given particle system to this scene
  34966. * @param newParticleSystem The particle system to add
  34967. */
  34968. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34969. /**
  34970. * Adds the given animation to this scene
  34971. * @param newAnimation The animation to add
  34972. */
  34973. addAnimation(newAnimation: Animation): void;
  34974. /**
  34975. * Adds the given animation group to this scene.
  34976. * @param newAnimationGroup The animation group to add
  34977. */
  34978. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34979. /**
  34980. * Adds the given multi-material to this scene
  34981. * @param newMultiMaterial The multi-material to add
  34982. */
  34983. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34984. /**
  34985. * Adds the given material to this scene
  34986. * @param newMaterial The material to add
  34987. */
  34988. addMaterial(newMaterial: Material): void;
  34989. /**
  34990. * Adds the given morph target to this scene
  34991. * @param newMorphTargetManager The morph target to add
  34992. */
  34993. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34994. /**
  34995. * Adds the given geometry to this scene
  34996. * @param newGeometry The geometry to add
  34997. */
  34998. addGeometry(newGeometry: Geometry): void;
  34999. /**
  35000. * Adds the given action manager to this scene
  35001. * @param newActionManager The action manager to add
  35002. */
  35003. addActionManager(newActionManager: AbstractActionManager): void;
  35004. /**
  35005. * Adds the given texture to this scene.
  35006. * @param newTexture The texture to add
  35007. */
  35008. addTexture(newTexture: BaseTexture): void;
  35009. /**
  35010. * Switch active camera
  35011. * @param newCamera defines the new active camera
  35012. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35013. */
  35014. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35015. /**
  35016. * sets the active camera of the scene using its ID
  35017. * @param id defines the camera's ID
  35018. * @return the new active camera or null if none found.
  35019. */
  35020. setActiveCameraByID(id: string): Nullable<Camera>;
  35021. /**
  35022. * sets the active camera of the scene using its name
  35023. * @param name defines the camera's name
  35024. * @returns the new active camera or null if none found.
  35025. */
  35026. setActiveCameraByName(name: string): Nullable<Camera>;
  35027. /**
  35028. * get an animation group using its name
  35029. * @param name defines the material's name
  35030. * @return the animation group or null if none found.
  35031. */
  35032. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35033. /**
  35034. * Get a material using its unique id
  35035. * @param uniqueId defines the material's unique id
  35036. * @return the material or null if none found.
  35037. */
  35038. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35039. /**
  35040. * get a material using its id
  35041. * @param id defines the material's ID
  35042. * @return the material or null if none found.
  35043. */
  35044. getMaterialByID(id: string): Nullable<Material>;
  35045. /**
  35046. * Gets a the last added material using a given id
  35047. * @param id defines the material's ID
  35048. * @return the last material with the given id or null if none found.
  35049. */
  35050. getLastMaterialByID(id: string): Nullable<Material>;
  35051. /**
  35052. * Gets a material using its name
  35053. * @param name defines the material's name
  35054. * @return the material or null if none found.
  35055. */
  35056. getMaterialByName(name: string): Nullable<Material>;
  35057. /**
  35058. * Get a texture using its unique id
  35059. * @param uniqueId defines the texture's unique id
  35060. * @return the texture or null if none found.
  35061. */
  35062. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35063. /**
  35064. * Gets a camera using its id
  35065. * @param id defines the id to look for
  35066. * @returns the camera or null if not found
  35067. */
  35068. getCameraByID(id: string): Nullable<Camera>;
  35069. /**
  35070. * Gets a camera using its unique id
  35071. * @param uniqueId defines the unique id to look for
  35072. * @returns the camera or null if not found
  35073. */
  35074. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35075. /**
  35076. * Gets a camera using its name
  35077. * @param name defines the camera's name
  35078. * @return the camera or null if none found.
  35079. */
  35080. getCameraByName(name: string): Nullable<Camera>;
  35081. /**
  35082. * Gets a bone using its id
  35083. * @param id defines the bone's id
  35084. * @return the bone or null if not found
  35085. */
  35086. getBoneByID(id: string): Nullable<Bone>;
  35087. /**
  35088. * Gets a bone using its id
  35089. * @param name defines the bone's name
  35090. * @return the bone or null if not found
  35091. */
  35092. getBoneByName(name: string): Nullable<Bone>;
  35093. /**
  35094. * Gets a light node using its name
  35095. * @param name defines the the light's name
  35096. * @return the light or null if none found.
  35097. */
  35098. getLightByName(name: string): Nullable<Light>;
  35099. /**
  35100. * Gets a light node using its id
  35101. * @param id defines the light's id
  35102. * @return the light or null if none found.
  35103. */
  35104. getLightByID(id: string): Nullable<Light>;
  35105. /**
  35106. * Gets a light node using its scene-generated unique ID
  35107. * @param uniqueId defines the light's unique id
  35108. * @return the light or null if none found.
  35109. */
  35110. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35111. /**
  35112. * Gets a particle system by id
  35113. * @param id defines the particle system id
  35114. * @return the corresponding system or null if none found
  35115. */
  35116. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35117. /**
  35118. * Gets a geometry using its ID
  35119. * @param id defines the geometry's id
  35120. * @return the geometry or null if none found.
  35121. */
  35122. getGeometryByID(id: string): Nullable<Geometry>;
  35123. private _getGeometryByUniqueID;
  35124. /**
  35125. * Add a new geometry to this scene
  35126. * @param geometry defines the geometry to be added to the scene.
  35127. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35128. * @return a boolean defining if the geometry was added or not
  35129. */
  35130. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35131. /**
  35132. * Removes an existing geometry
  35133. * @param geometry defines the geometry to be removed from the scene
  35134. * @return a boolean defining if the geometry was removed or not
  35135. */
  35136. removeGeometry(geometry: Geometry): boolean;
  35137. /**
  35138. * Gets the list of geometries attached to the scene
  35139. * @returns an array of Geometry
  35140. */
  35141. getGeometries(): Geometry[];
  35142. /**
  35143. * Gets the first added mesh found of a given ID
  35144. * @param id defines the id to search for
  35145. * @return the mesh found or null if not found at all
  35146. */
  35147. getMeshByID(id: string): Nullable<AbstractMesh>;
  35148. /**
  35149. * Gets a list of meshes using their id
  35150. * @param id defines the id to search for
  35151. * @returns a list of meshes
  35152. */
  35153. getMeshesByID(id: string): Array<AbstractMesh>;
  35154. /**
  35155. * Gets the first added transform node found of a given ID
  35156. * @param id defines the id to search for
  35157. * @return the found transform node or null if not found at all.
  35158. */
  35159. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35160. /**
  35161. * Gets a transform node with its auto-generated unique id
  35162. * @param uniqueId efines the unique id to search for
  35163. * @return the found transform node or null if not found at all.
  35164. */
  35165. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35166. /**
  35167. * Gets a list of transform nodes using their id
  35168. * @param id defines the id to search for
  35169. * @returns a list of transform nodes
  35170. */
  35171. getTransformNodesByID(id: string): Array<TransformNode>;
  35172. /**
  35173. * Gets a mesh with its auto-generated unique id
  35174. * @param uniqueId defines the unique id to search for
  35175. * @return the found mesh or null if not found at all.
  35176. */
  35177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35178. /**
  35179. * Gets a the last added mesh using a given id
  35180. * @param id defines the id to search for
  35181. * @return the found mesh or null if not found at all.
  35182. */
  35183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35184. /**
  35185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35186. * @param id defines the id to search for
  35187. * @return the found node or null if not found at all
  35188. */
  35189. getLastEntryByID(id: string): Nullable<Node>;
  35190. /**
  35191. * Gets a node (Mesh, Camera, Light) using a given id
  35192. * @param id defines the id to search for
  35193. * @return the found node or null if not found at all
  35194. */
  35195. getNodeByID(id: string): Nullable<Node>;
  35196. /**
  35197. * Gets a node (Mesh, Camera, Light) using a given name
  35198. * @param name defines the name to search for
  35199. * @return the found node or null if not found at all.
  35200. */
  35201. getNodeByName(name: string): Nullable<Node>;
  35202. /**
  35203. * Gets a mesh using a given name
  35204. * @param name defines the name to search for
  35205. * @return the found mesh or null if not found at all.
  35206. */
  35207. getMeshByName(name: string): Nullable<AbstractMesh>;
  35208. /**
  35209. * Gets a transform node using a given name
  35210. * @param name defines the name to search for
  35211. * @return the found transform node or null if not found at all.
  35212. */
  35213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35214. /**
  35215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35216. * @param id defines the id to search for
  35217. * @return the found skeleton or null if not found at all.
  35218. */
  35219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35220. /**
  35221. * Gets a skeleton using a given auto generated unique id
  35222. * @param uniqueId defines the unique id to search for
  35223. * @return the found skeleton or null if not found at all.
  35224. */
  35225. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35226. /**
  35227. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35228. * @param id defines the id to search for
  35229. * @return the found skeleton or null if not found at all.
  35230. */
  35231. getSkeletonById(id: string): Nullable<Skeleton>;
  35232. /**
  35233. * Gets a skeleton using a given name
  35234. * @param name defines the name to search for
  35235. * @return the found skeleton or null if not found at all.
  35236. */
  35237. getSkeletonByName(name: string): Nullable<Skeleton>;
  35238. /**
  35239. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35240. * @param id defines the id to search for
  35241. * @return the found morph target manager or null if not found at all.
  35242. */
  35243. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35244. /**
  35245. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35246. * @param id defines the id to search for
  35247. * @return the found morph target or null if not found at all.
  35248. */
  35249. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35250. /**
  35251. * Gets a boolean indicating if the given mesh is active
  35252. * @param mesh defines the mesh to look for
  35253. * @returns true if the mesh is in the active list
  35254. */
  35255. isActiveMesh(mesh: AbstractMesh): boolean;
  35256. /**
  35257. * Return a unique id as a string which can serve as an identifier for the scene
  35258. */
  35259. readonly uid: string;
  35260. /**
  35261. * Add an externaly attached data from its key.
  35262. * This method call will fail and return false, if such key already exists.
  35263. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35264. * @param key the unique key that identifies the data
  35265. * @param data the data object to associate to the key for this Engine instance
  35266. * @return true if no such key were already present and the data was added successfully, false otherwise
  35267. */
  35268. addExternalData<T>(key: string, data: T): boolean;
  35269. /**
  35270. * Get an externaly attached data from its key
  35271. * @param key the unique key that identifies the data
  35272. * @return the associated data, if present (can be null), or undefined if not present
  35273. */
  35274. getExternalData<T>(key: string): Nullable<T>;
  35275. /**
  35276. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35277. * @param key the unique key that identifies the data
  35278. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35279. * @return the associated data, can be null if the factory returned null.
  35280. */
  35281. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35282. /**
  35283. * Remove an externaly attached data from the Engine instance
  35284. * @param key the unique key that identifies the data
  35285. * @return true if the data was successfully removed, false if it doesn't exist
  35286. */
  35287. removeExternalData(key: string): boolean;
  35288. private _evaluateSubMesh;
  35289. /**
  35290. * Clear the processed materials smart array preventing retention point in material dispose.
  35291. */
  35292. freeProcessedMaterials(): void;
  35293. private _preventFreeActiveMeshesAndRenderingGroups;
  35294. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35295. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35296. * when disposing several meshes in a row or a hierarchy of meshes.
  35297. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35298. */
  35299. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35300. /**
  35301. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35302. */
  35303. freeActiveMeshes(): void;
  35304. /**
  35305. * Clear the info related to rendering groups preventing retention points during dispose.
  35306. */
  35307. freeRenderingGroups(): void;
  35308. /** @hidden */
  35309. _isInIntermediateRendering(): boolean;
  35310. /**
  35311. * Lambda returning the list of potentially active meshes.
  35312. */
  35313. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35314. /**
  35315. * Lambda returning the list of potentially active sub meshes.
  35316. */
  35317. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35318. /**
  35319. * Lambda returning the list of potentially intersecting sub meshes.
  35320. */
  35321. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35322. /**
  35323. * Lambda returning the list of potentially colliding sub meshes.
  35324. */
  35325. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35326. private _activeMeshesFrozen;
  35327. /**
  35328. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35329. * @returns the current scene
  35330. */
  35331. freezeActiveMeshes(): Scene;
  35332. /**
  35333. * Use this function to restart evaluating active meshes on every frame
  35334. * @returns the current scene
  35335. */
  35336. unfreezeActiveMeshes(): Scene;
  35337. private _evaluateActiveMeshes;
  35338. private _activeMesh;
  35339. /**
  35340. * Update the transform matrix to update from the current active camera
  35341. * @param force defines a boolean used to force the update even if cache is up to date
  35342. */
  35343. updateTransformMatrix(force?: boolean): void;
  35344. private _bindFrameBuffer;
  35345. /** @hidden */
  35346. _allowPostProcessClearColor: boolean;
  35347. /** @hidden */
  35348. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35349. private _processSubCameras;
  35350. private _checkIntersections;
  35351. /** @hidden */
  35352. _advancePhysicsEngineStep(step: number): void;
  35353. /**
  35354. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35355. */
  35356. getDeterministicFrameTime: () => number;
  35357. /** @hidden */
  35358. _animate(): void;
  35359. /** Execute all animations (for a frame) */
  35360. animate(): void;
  35361. /**
  35362. * Render the scene
  35363. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35364. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35365. */
  35366. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35367. /**
  35368. * Freeze all materials
  35369. * A frozen material will not be updatable but should be faster to render
  35370. */
  35371. freezeMaterials(): void;
  35372. /**
  35373. * Unfreeze all materials
  35374. * A frozen material will not be updatable but should be faster to render
  35375. */
  35376. unfreezeMaterials(): void;
  35377. /**
  35378. * Releases all held ressources
  35379. */
  35380. dispose(): void;
  35381. /**
  35382. * Gets if the scene is already disposed
  35383. */
  35384. readonly isDisposed: boolean;
  35385. /**
  35386. * Call this function to reduce memory footprint of the scene.
  35387. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35388. */
  35389. clearCachedVertexData(): void;
  35390. /**
  35391. * This function will remove the local cached buffer data from texture.
  35392. * It will save memory but will prevent the texture from being rebuilt
  35393. */
  35394. cleanCachedTextureBuffer(): void;
  35395. /**
  35396. * Get the world extend vectors with an optional filter
  35397. *
  35398. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35399. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35400. */
  35401. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35402. min: Vector3;
  35403. max: Vector3;
  35404. };
  35405. /**
  35406. * Creates a ray that can be used to pick in the scene
  35407. * @param x defines the x coordinate of the origin (on-screen)
  35408. * @param y defines the y coordinate of the origin (on-screen)
  35409. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35410. * @param camera defines the camera to use for the picking
  35411. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35412. * @returns a Ray
  35413. */
  35414. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35415. /**
  35416. * Creates a ray that can be used to pick in the scene
  35417. * @param x defines the x coordinate of the origin (on-screen)
  35418. * @param y defines the y coordinate of the origin (on-screen)
  35419. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35420. * @param result defines the ray where to store the picking ray
  35421. * @param camera defines the camera to use for the picking
  35422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35423. * @returns the current scene
  35424. */
  35425. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35426. /**
  35427. * Creates a ray that can be used to pick in the scene
  35428. * @param x defines the x coordinate of the origin (on-screen)
  35429. * @param y defines the y coordinate of the origin (on-screen)
  35430. * @param camera defines the camera to use for the picking
  35431. * @returns a Ray
  35432. */
  35433. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35434. /**
  35435. * Creates a ray that can be used to pick in the scene
  35436. * @param x defines the x coordinate of the origin (on-screen)
  35437. * @param y defines the y coordinate of the origin (on-screen)
  35438. * @param result defines the ray where to store the picking ray
  35439. * @param camera defines the camera to use for the picking
  35440. * @returns the current scene
  35441. */
  35442. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35443. /** Launch a ray to try to pick a mesh in the scene
  35444. * @param x position on screen
  35445. * @param y position on screen
  35446. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35448. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35450. * @returns a PickingInfo
  35451. */
  35452. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35453. /** Use the given ray to pick a mesh in the scene
  35454. * @param ray The ray to use to pick meshes
  35455. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  35456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35458. * @returns a PickingInfo
  35459. */
  35460. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35461. /**
  35462. * Launch a ray to try to pick a mesh in the scene
  35463. * @param x X position on screen
  35464. * @param y Y position on screen
  35465. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35466. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35468. * @returns an array of PickingInfo
  35469. */
  35470. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35471. /**
  35472. * Launch a ray to try to pick a mesh in the scene
  35473. * @param ray Ray to use
  35474. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35476. * @returns an array of PickingInfo
  35477. */
  35478. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35479. /**
  35480. * Force the value of meshUnderPointer
  35481. * @param mesh defines the mesh to use
  35482. */
  35483. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35484. /**
  35485. * Gets the mesh under the pointer
  35486. * @returns a Mesh or null if no mesh is under the pointer
  35487. */
  35488. getPointerOverMesh(): Nullable<AbstractMesh>;
  35489. /** @hidden */
  35490. _rebuildGeometries(): void;
  35491. /** @hidden */
  35492. _rebuildTextures(): void;
  35493. private _getByTags;
  35494. /**
  35495. * Get a list of meshes by tags
  35496. * @param tagsQuery defines the tags query to use
  35497. * @param forEach defines a predicate used to filter results
  35498. * @returns an array of Mesh
  35499. */
  35500. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35501. /**
  35502. * Get a list of cameras by tags
  35503. * @param tagsQuery defines the tags query to use
  35504. * @param forEach defines a predicate used to filter results
  35505. * @returns an array of Camera
  35506. */
  35507. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35508. /**
  35509. * Get a list of lights by tags
  35510. * @param tagsQuery defines the tags query to use
  35511. * @param forEach defines a predicate used to filter results
  35512. * @returns an array of Light
  35513. */
  35514. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35515. /**
  35516. * Get a list of materials by tags
  35517. * @param tagsQuery defines the tags query to use
  35518. * @param forEach defines a predicate used to filter results
  35519. * @returns an array of Material
  35520. */
  35521. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35522. /**
  35523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35524. * This allowed control for front to back rendering or reversly depending of the special needs.
  35525. *
  35526. * @param renderingGroupId The rendering group id corresponding to its index
  35527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35530. */
  35531. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  35532. /**
  35533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35534. *
  35535. * @param renderingGroupId The rendering group id corresponding to its index
  35536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35539. */
  35540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35541. /**
  35542. * Gets the current auto clear configuration for one rendering group of the rendering
  35543. * manager.
  35544. * @param index the rendering group index to get the information for
  35545. * @returns The auto clear setup for the requested rendering group
  35546. */
  35547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35548. private _blockMaterialDirtyMechanism;
  35549. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35550. blockMaterialDirtyMechanism: boolean;
  35551. /**
  35552. * Will flag all materials as dirty to trigger new shader compilation
  35553. * @param flag defines the flag used to specify which material part must be marked as dirty
  35554. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35555. */
  35556. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35557. /** @hidden */
  35558. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35559. /** @hidden */
  35560. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35561. }
  35562. }
  35563. declare module "babylonjs/assetContainer" {
  35564. import { AbstractScene } from "babylonjs/abstractScene";
  35565. import { Scene } from "babylonjs/scene";
  35566. import { Mesh } from "babylonjs/Meshes/mesh";
  35567. /**
  35568. * Set of assets to keep when moving a scene into an asset container.
  35569. */
  35570. export class KeepAssets extends AbstractScene {
  35571. }
  35572. /**
  35573. * Container with a set of assets that can be added or removed from a scene.
  35574. */
  35575. export class AssetContainer extends AbstractScene {
  35576. /**
  35577. * The scene the AssetContainer belongs to.
  35578. */
  35579. scene: Scene;
  35580. /**
  35581. * Instantiates an AssetContainer.
  35582. * @param scene The scene the AssetContainer belongs to.
  35583. */
  35584. constructor(scene: Scene);
  35585. /**
  35586. * Adds all the assets from the container to the scene.
  35587. */
  35588. addAllToScene(): void;
  35589. /**
  35590. * Removes all the assets in the container from the scene
  35591. */
  35592. removeAllFromScene(): void;
  35593. /**
  35594. * Disposes all the assets in the container
  35595. */
  35596. dispose(): void;
  35597. private _moveAssets;
  35598. /**
  35599. * Removes all the assets contained in the scene and adds them to the container.
  35600. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35601. */
  35602. moveAllFromScene(keepAssets?: KeepAssets): void;
  35603. /**
  35604. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  35605. * @returns the root mesh
  35606. */
  35607. createRootMesh(): Mesh;
  35608. }
  35609. }
  35610. declare module "babylonjs/abstractScene" {
  35611. import { Scene } from "babylonjs/scene";
  35612. import { Nullable } from "babylonjs/types";
  35613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35615. import { Geometry } from "babylonjs/Meshes/geometry";
  35616. import { Skeleton } from "babylonjs/Bones/skeleton";
  35617. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35618. import { AssetContainer } from "babylonjs/assetContainer";
  35619. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35620. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35622. import { Material } from "babylonjs/Materials/material";
  35623. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35624. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35625. import { Camera } from "babylonjs/Cameras/camera";
  35626. import { Light } from "babylonjs/Lights/light";
  35627. import { Node } from "babylonjs/node";
  35628. import { Animation } from "babylonjs/Animations/animation";
  35629. /**
  35630. * Defines how the parser contract is defined.
  35631. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35632. */
  35633. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35634. /**
  35635. * Defines how the individual parser contract is defined.
  35636. * These parser can parse an individual asset
  35637. */
  35638. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35639. /**
  35640. * Base class of the scene acting as a container for the different elements composing a scene.
  35641. * This class is dynamically extended by the different components of the scene increasing
  35642. * flexibility and reducing coupling
  35643. */
  35644. export abstract class AbstractScene {
  35645. /**
  35646. * Stores the list of available parsers in the application.
  35647. */
  35648. private static _BabylonFileParsers;
  35649. /**
  35650. * Stores the list of available individual parsers in the application.
  35651. */
  35652. private static _IndividualBabylonFileParsers;
  35653. /**
  35654. * Adds a parser in the list of available ones
  35655. * @param name Defines the name of the parser
  35656. * @param parser Defines the parser to add
  35657. */
  35658. static AddParser(name: string, parser: BabylonFileParser): void;
  35659. /**
  35660. * Gets a general parser from the list of avaialble ones
  35661. * @param name Defines the name of the parser
  35662. * @returns the requested parser or null
  35663. */
  35664. static GetParser(name: string): Nullable<BabylonFileParser>;
  35665. /**
  35666. * Adds n individual parser in the list of available ones
  35667. * @param name Defines the name of the parser
  35668. * @param parser Defines the parser to add
  35669. */
  35670. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35671. /**
  35672. * Gets an individual parser from the list of avaialble ones
  35673. * @param name Defines the name of the parser
  35674. * @returns the requested parser or null
  35675. */
  35676. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35677. /**
  35678. * Parser json data and populate both a scene and its associated container object
  35679. * @param jsonData Defines the data to parse
  35680. * @param scene Defines the scene to parse the data for
  35681. * @param container Defines the container attached to the parsing sequence
  35682. * @param rootUrl Defines the root url of the data
  35683. */
  35684. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35685. /**
  35686. * Gets the list of root nodes (ie. nodes with no parent)
  35687. */
  35688. rootNodes: Node[];
  35689. /** All of the cameras added to this scene
  35690. * @see http://doc.babylonjs.com/babylon101/cameras
  35691. */
  35692. cameras: Camera[];
  35693. /**
  35694. * All of the lights added to this scene
  35695. * @see http://doc.babylonjs.com/babylon101/lights
  35696. */
  35697. lights: Light[];
  35698. /**
  35699. * All of the (abstract) meshes added to this scene
  35700. */
  35701. meshes: AbstractMesh[];
  35702. /**
  35703. * The list of skeletons added to the scene
  35704. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35705. */
  35706. skeletons: Skeleton[];
  35707. /**
  35708. * All of the particle systems added to this scene
  35709. * @see http://doc.babylonjs.com/babylon101/particles
  35710. */
  35711. particleSystems: IParticleSystem[];
  35712. /**
  35713. * Gets a list of Animations associated with the scene
  35714. */
  35715. animations: Animation[];
  35716. /**
  35717. * All of the animation groups added to this scene
  35718. * @see http://doc.babylonjs.com/how_to/group
  35719. */
  35720. animationGroups: AnimationGroup[];
  35721. /**
  35722. * All of the multi-materials added to this scene
  35723. * @see http://doc.babylonjs.com/how_to/multi_materials
  35724. */
  35725. multiMaterials: MultiMaterial[];
  35726. /**
  35727. * All of the materials added to this scene
  35728. * In the context of a Scene, it is not supposed to be modified manually.
  35729. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35730. * Note also that the order of the Material wihin the array is not significant and might change.
  35731. * @see http://doc.babylonjs.com/babylon101/materials
  35732. */
  35733. materials: Material[];
  35734. /**
  35735. * The list of morph target managers added to the scene
  35736. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35737. */
  35738. morphTargetManagers: MorphTargetManager[];
  35739. /**
  35740. * The list of geometries used in the scene.
  35741. */
  35742. geometries: Geometry[];
  35743. /**
  35744. * All of the tranform nodes added to this scene
  35745. * In the context of a Scene, it is not supposed to be modified manually.
  35746. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35747. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35748. * @see http://doc.babylonjs.com/how_to/transformnode
  35749. */
  35750. transformNodes: TransformNode[];
  35751. /**
  35752. * ActionManagers available on the scene.
  35753. */
  35754. actionManagers: AbstractActionManager[];
  35755. /**
  35756. * Textures to keep.
  35757. */
  35758. textures: BaseTexture[];
  35759. /**
  35760. * Environment texture for the scene
  35761. */
  35762. environmentTexture: Nullable<BaseTexture>;
  35763. }
  35764. }
  35765. declare module "babylonjs/Audio/sound" {
  35766. import { Observable } from "babylonjs/Misc/observable";
  35767. import { Vector3 } from "babylonjs/Maths/math.vector";
  35768. import { Nullable } from "babylonjs/types";
  35769. import { Scene } from "babylonjs/scene";
  35770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35771. /**
  35772. * Interface used to define options for Sound class
  35773. */
  35774. export interface ISoundOptions {
  35775. /**
  35776. * Does the sound autoplay once loaded.
  35777. */
  35778. autoplay?: boolean;
  35779. /**
  35780. * Does the sound loop after it finishes playing once.
  35781. */
  35782. loop?: boolean;
  35783. /**
  35784. * Sound's volume
  35785. */
  35786. volume?: number;
  35787. /**
  35788. * Is it a spatial sound?
  35789. */
  35790. spatialSound?: boolean;
  35791. /**
  35792. * Maximum distance to hear that sound
  35793. */
  35794. maxDistance?: number;
  35795. /**
  35796. * Uses user defined attenuation function
  35797. */
  35798. useCustomAttenuation?: boolean;
  35799. /**
  35800. * Define the roll off factor of spatial sounds.
  35801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35802. */
  35803. rolloffFactor?: number;
  35804. /**
  35805. * Define the reference distance the sound should be heard perfectly.
  35806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35807. */
  35808. refDistance?: number;
  35809. /**
  35810. * Define the distance attenuation model the sound will follow.
  35811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35812. */
  35813. distanceModel?: string;
  35814. /**
  35815. * Defines the playback speed (1 by default)
  35816. */
  35817. playbackRate?: number;
  35818. /**
  35819. * Defines if the sound is from a streaming source
  35820. */
  35821. streaming?: boolean;
  35822. /**
  35823. * Defines an optional length (in seconds) inside the sound file
  35824. */
  35825. length?: number;
  35826. /**
  35827. * Defines an optional offset (in seconds) inside the sound file
  35828. */
  35829. offset?: number;
  35830. /**
  35831. * If true, URLs will not be required to state the audio file codec to use.
  35832. */
  35833. skipCodecCheck?: boolean;
  35834. }
  35835. /**
  35836. * Defines a sound that can be played in the application.
  35837. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35839. */
  35840. export class Sound {
  35841. /**
  35842. * The name of the sound in the scene.
  35843. */
  35844. name: string;
  35845. /**
  35846. * Does the sound autoplay once loaded.
  35847. */
  35848. autoplay: boolean;
  35849. /**
  35850. * Does the sound loop after it finishes playing once.
  35851. */
  35852. loop: boolean;
  35853. /**
  35854. * Does the sound use a custom attenuation curve to simulate the falloff
  35855. * happening when the source gets further away from the camera.
  35856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35857. */
  35858. useCustomAttenuation: boolean;
  35859. /**
  35860. * The sound track id this sound belongs to.
  35861. */
  35862. soundTrackId: number;
  35863. /**
  35864. * Is this sound currently played.
  35865. */
  35866. isPlaying: boolean;
  35867. /**
  35868. * Is this sound currently paused.
  35869. */
  35870. isPaused: boolean;
  35871. /**
  35872. * Does this sound enables spatial sound.
  35873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35874. */
  35875. spatialSound: boolean;
  35876. /**
  35877. * Define the reference distance the sound should be heard perfectly.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35879. */
  35880. refDistance: number;
  35881. /**
  35882. * Define the roll off factor of spatial sounds.
  35883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35884. */
  35885. rolloffFactor: number;
  35886. /**
  35887. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35889. */
  35890. maxDistance: number;
  35891. /**
  35892. * Define the distance attenuation model the sound will follow.
  35893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35894. */
  35895. distanceModel: string;
  35896. /**
  35897. * @hidden
  35898. * Back Compat
  35899. **/
  35900. onended: () => any;
  35901. /**
  35902. * Observable event when the current playing sound finishes.
  35903. */
  35904. onEndedObservable: Observable<Sound>;
  35905. private _panningModel;
  35906. private _playbackRate;
  35907. private _streaming;
  35908. private _startTime;
  35909. private _startOffset;
  35910. private _position;
  35911. /** @hidden */
  35912. _positionInEmitterSpace: boolean;
  35913. private _localDirection;
  35914. private _volume;
  35915. private _isReadyToPlay;
  35916. private _isDirectional;
  35917. private _readyToPlayCallback;
  35918. private _audioBuffer;
  35919. private _soundSource;
  35920. private _streamingSource;
  35921. private _soundPanner;
  35922. private _soundGain;
  35923. private _inputAudioNode;
  35924. private _outputAudioNode;
  35925. private _coneInnerAngle;
  35926. private _coneOuterAngle;
  35927. private _coneOuterGain;
  35928. private _scene;
  35929. private _connectedTransformNode;
  35930. private _customAttenuationFunction;
  35931. private _registerFunc;
  35932. private _isOutputConnected;
  35933. private _htmlAudioElement;
  35934. private _urlType;
  35935. private _length?;
  35936. private _offset?;
  35937. /** @hidden */
  35938. static _SceneComponentInitialization: (scene: Scene) => void;
  35939. /**
  35940. * Create a sound and attach it to a scene
  35941. * @param name Name of your sound
  35942. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35943. * @param scene defines the scene the sound belongs to
  35944. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35945. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35946. */
  35947. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35948. /**
  35949. * Release the sound and its associated resources
  35950. */
  35951. dispose(): void;
  35952. /**
  35953. * Gets if the sounds is ready to be played or not.
  35954. * @returns true if ready, otherwise false
  35955. */
  35956. isReady(): boolean;
  35957. private _soundLoaded;
  35958. /**
  35959. * Sets the data of the sound from an audiobuffer
  35960. * @param audioBuffer The audioBuffer containing the data
  35961. */
  35962. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35963. /**
  35964. * Updates the current sounds options such as maxdistance, loop...
  35965. * @param options A JSON object containing values named as the object properties
  35966. */
  35967. updateOptions(options: ISoundOptions): void;
  35968. private _createSpatialParameters;
  35969. private _updateSpatialParameters;
  35970. /**
  35971. * Switch the panning model to HRTF:
  35972. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35974. */
  35975. switchPanningModelToHRTF(): void;
  35976. /**
  35977. * Switch the panning model to Equal Power:
  35978. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35980. */
  35981. switchPanningModelToEqualPower(): void;
  35982. private _switchPanningModel;
  35983. /**
  35984. * Connect this sound to a sound track audio node like gain...
  35985. * @param soundTrackAudioNode the sound track audio node to connect to
  35986. */
  35987. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35988. /**
  35989. * Transform this sound into a directional source
  35990. * @param coneInnerAngle Size of the inner cone in degree
  35991. * @param coneOuterAngle Size of the outer cone in degree
  35992. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35993. */
  35994. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35995. /**
  35996. * Gets or sets the inner angle for the directional cone.
  35997. */
  35998. /**
  35999. * Gets or sets the inner angle for the directional cone.
  36000. */
  36001. directionalConeInnerAngle: number;
  36002. /**
  36003. * Gets or sets the outer angle for the directional cone.
  36004. */
  36005. /**
  36006. * Gets or sets the outer angle for the directional cone.
  36007. */
  36008. directionalConeOuterAngle: number;
  36009. /**
  36010. * Sets the position of the emitter if spatial sound is enabled
  36011. * @param newPosition Defines the new posisiton
  36012. */
  36013. setPosition(newPosition: Vector3): void;
  36014. /**
  36015. * Sets the local direction of the emitter if spatial sound is enabled
  36016. * @param newLocalDirection Defines the new local direction
  36017. */
  36018. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36019. private _updateDirection;
  36020. /** @hidden */
  36021. updateDistanceFromListener(): void;
  36022. /**
  36023. * Sets a new custom attenuation function for the sound.
  36024. * @param callback Defines the function used for the attenuation
  36025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36026. */
  36027. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36028. /**
  36029. * Play the sound
  36030. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36031. * @param offset (optional) Start the sound at a specific time in seconds
  36032. * @param length (optional) Sound duration (in seconds)
  36033. */
  36034. play(time?: number, offset?: number, length?: number): void;
  36035. private _onended;
  36036. /**
  36037. * Stop the sound
  36038. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36039. */
  36040. stop(time?: number): void;
  36041. /**
  36042. * Put the sound in pause
  36043. */
  36044. pause(): void;
  36045. /**
  36046. * Sets a dedicated volume for this sounds
  36047. * @param newVolume Define the new volume of the sound
  36048. * @param time Define time for gradual change to new volume
  36049. */
  36050. setVolume(newVolume: number, time?: number): void;
  36051. /**
  36052. * Set the sound play back rate
  36053. * @param newPlaybackRate Define the playback rate the sound should be played at
  36054. */
  36055. setPlaybackRate(newPlaybackRate: number): void;
  36056. /**
  36057. * Gets the volume of the sound.
  36058. * @returns the volume of the sound
  36059. */
  36060. getVolume(): number;
  36061. /**
  36062. * Attach the sound to a dedicated mesh
  36063. * @param transformNode The transform node to connect the sound with
  36064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36065. */
  36066. attachToMesh(transformNode: TransformNode): void;
  36067. /**
  36068. * Detach the sound from the previously attached mesh
  36069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36070. */
  36071. detachFromMesh(): void;
  36072. private _onRegisterAfterWorldMatrixUpdate;
  36073. /**
  36074. * Clone the current sound in the scene.
  36075. * @returns the new sound clone
  36076. */
  36077. clone(): Nullable<Sound>;
  36078. /**
  36079. * Gets the current underlying audio buffer containing the data
  36080. * @returns the audio buffer
  36081. */
  36082. getAudioBuffer(): Nullable<AudioBuffer>;
  36083. /**
  36084. * Serializes the Sound in a JSON representation
  36085. * @returns the JSON representation of the sound
  36086. */
  36087. serialize(): any;
  36088. /**
  36089. * Parse a JSON representation of a sound to innstantiate in a given scene
  36090. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36091. * @param scene Define the scene the new parsed sound should be created in
  36092. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36093. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36094. * @returns the newly parsed sound
  36095. */
  36096. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36097. }
  36098. }
  36099. declare module "babylonjs/Actions/directAudioActions" {
  36100. import { Action } from "babylonjs/Actions/action";
  36101. import { Condition } from "babylonjs/Actions/condition";
  36102. import { Sound } from "babylonjs/Audio/sound";
  36103. /**
  36104. * This defines an action helpful to play a defined sound on a triggered action.
  36105. */
  36106. export class PlaySoundAction extends Action {
  36107. private _sound;
  36108. /**
  36109. * Instantiate the action
  36110. * @param triggerOptions defines the trigger options
  36111. * @param sound defines the sound to play
  36112. * @param condition defines the trigger related conditions
  36113. */
  36114. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36115. /** @hidden */
  36116. _prepare(): void;
  36117. /**
  36118. * Execute the action and play the sound.
  36119. */
  36120. execute(): void;
  36121. /**
  36122. * Serializes the actions and its related information.
  36123. * @param parent defines the object to serialize in
  36124. * @returns the serialized object
  36125. */
  36126. serialize(parent: any): any;
  36127. }
  36128. /**
  36129. * This defines an action helpful to stop a defined sound on a triggered action.
  36130. */
  36131. export class StopSoundAction extends Action {
  36132. private _sound;
  36133. /**
  36134. * Instantiate the action
  36135. * @param triggerOptions defines the trigger options
  36136. * @param sound defines the sound to stop
  36137. * @param condition defines the trigger related conditions
  36138. */
  36139. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36140. /** @hidden */
  36141. _prepare(): void;
  36142. /**
  36143. * Execute the action and stop the sound.
  36144. */
  36145. execute(): void;
  36146. /**
  36147. * Serializes the actions and its related information.
  36148. * @param parent defines the object to serialize in
  36149. * @returns the serialized object
  36150. */
  36151. serialize(parent: any): any;
  36152. }
  36153. }
  36154. declare module "babylonjs/Actions/interpolateValueAction" {
  36155. import { Action } from "babylonjs/Actions/action";
  36156. import { Condition } from "babylonjs/Actions/condition";
  36157. import { Observable } from "babylonjs/Misc/observable";
  36158. /**
  36159. * This defines an action responsible to change the value of a property
  36160. * by interpolating between its current value and the newly set one once triggered.
  36161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36162. */
  36163. export class InterpolateValueAction extends Action {
  36164. /**
  36165. * Defines the path of the property where the value should be interpolated
  36166. */
  36167. propertyPath: string;
  36168. /**
  36169. * Defines the target value at the end of the interpolation.
  36170. */
  36171. value: any;
  36172. /**
  36173. * Defines the time it will take for the property to interpolate to the value.
  36174. */
  36175. duration: number;
  36176. /**
  36177. * Defines if the other scene animations should be stopped when the action has been triggered
  36178. */
  36179. stopOtherAnimations?: boolean;
  36180. /**
  36181. * Defines a callback raised once the interpolation animation has been done.
  36182. */
  36183. onInterpolationDone?: () => void;
  36184. /**
  36185. * Observable triggered once the interpolation animation has been done.
  36186. */
  36187. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36188. private _target;
  36189. private _effectiveTarget;
  36190. private _property;
  36191. /**
  36192. * Instantiate the action
  36193. * @param triggerOptions defines the trigger options
  36194. * @param target defines the object containing the value to interpolate
  36195. * @param propertyPath defines the path to the property in the target object
  36196. * @param value defines the target value at the end of the interpolation
  36197. * @param duration deines the time it will take for the property to interpolate to the value.
  36198. * @param condition defines the trigger related conditions
  36199. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36200. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36201. */
  36202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36203. /** @hidden */
  36204. _prepare(): void;
  36205. /**
  36206. * Execute the action starts the value interpolation.
  36207. */
  36208. execute(): void;
  36209. /**
  36210. * Serializes the actions and its related information.
  36211. * @param parent defines the object to serialize in
  36212. * @returns the serialized object
  36213. */
  36214. serialize(parent: any): any;
  36215. }
  36216. }
  36217. declare module "babylonjs/Actions/index" {
  36218. export * from "babylonjs/Actions/abstractActionManager";
  36219. export * from "babylonjs/Actions/action";
  36220. export * from "babylonjs/Actions/actionEvent";
  36221. export * from "babylonjs/Actions/actionManager";
  36222. export * from "babylonjs/Actions/condition";
  36223. export * from "babylonjs/Actions/directActions";
  36224. export * from "babylonjs/Actions/directAudioActions";
  36225. export * from "babylonjs/Actions/interpolateValueAction";
  36226. }
  36227. declare module "babylonjs/Animations/index" {
  36228. export * from "babylonjs/Animations/animatable";
  36229. export * from "babylonjs/Animations/animation";
  36230. export * from "babylonjs/Animations/animationGroup";
  36231. export * from "babylonjs/Animations/animationPropertiesOverride";
  36232. export * from "babylonjs/Animations/easing";
  36233. export * from "babylonjs/Animations/runtimeAnimation";
  36234. export * from "babylonjs/Animations/animationEvent";
  36235. export * from "babylonjs/Animations/animationGroup";
  36236. export * from "babylonjs/Animations/animationKey";
  36237. export * from "babylonjs/Animations/animationRange";
  36238. export * from "babylonjs/Animations/animatable.interface";
  36239. }
  36240. declare module "babylonjs/Audio/soundTrack" {
  36241. import { Sound } from "babylonjs/Audio/sound";
  36242. import { Analyser } from "babylonjs/Audio/analyser";
  36243. import { Scene } from "babylonjs/scene";
  36244. /**
  36245. * Options allowed during the creation of a sound track.
  36246. */
  36247. export interface ISoundTrackOptions {
  36248. /**
  36249. * The volume the sound track should take during creation
  36250. */
  36251. volume?: number;
  36252. /**
  36253. * Define if the sound track is the main sound track of the scene
  36254. */
  36255. mainTrack?: boolean;
  36256. }
  36257. /**
  36258. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36259. * It will be also used in a future release to apply effects on a specific track.
  36260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36261. */
  36262. export class SoundTrack {
  36263. /**
  36264. * The unique identifier of the sound track in the scene.
  36265. */
  36266. id: number;
  36267. /**
  36268. * The list of sounds included in the sound track.
  36269. */
  36270. soundCollection: Array<Sound>;
  36271. private _outputAudioNode;
  36272. private _scene;
  36273. private _isMainTrack;
  36274. private _connectedAnalyser;
  36275. private _options;
  36276. private _isInitialized;
  36277. /**
  36278. * Creates a new sound track.
  36279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36280. * @param scene Define the scene the sound track belongs to
  36281. * @param options
  36282. */
  36283. constructor(scene: Scene, options?: ISoundTrackOptions);
  36284. private _initializeSoundTrackAudioGraph;
  36285. /**
  36286. * Release the sound track and its associated resources
  36287. */
  36288. dispose(): void;
  36289. /**
  36290. * Adds a sound to this sound track
  36291. * @param sound define the cound to add
  36292. * @ignoreNaming
  36293. */
  36294. AddSound(sound: Sound): void;
  36295. /**
  36296. * Removes a sound to this sound track
  36297. * @param sound define the cound to remove
  36298. * @ignoreNaming
  36299. */
  36300. RemoveSound(sound: Sound): void;
  36301. /**
  36302. * Set a global volume for the full sound track.
  36303. * @param newVolume Define the new volume of the sound track
  36304. */
  36305. setVolume(newVolume: number): void;
  36306. /**
  36307. * Switch the panning model to HRTF:
  36308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36310. */
  36311. switchPanningModelToHRTF(): void;
  36312. /**
  36313. * Switch the panning model to Equal Power:
  36314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36316. */
  36317. switchPanningModelToEqualPower(): void;
  36318. /**
  36319. * Connect the sound track to an audio analyser allowing some amazing
  36320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36322. * @param analyser The analyser to connect to the engine
  36323. */
  36324. connectToAnalyser(analyser: Analyser): void;
  36325. }
  36326. }
  36327. declare module "babylonjs/Audio/audioSceneComponent" {
  36328. import { Sound } from "babylonjs/Audio/sound";
  36329. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36330. import { Nullable } from "babylonjs/types";
  36331. import { Vector3 } from "babylonjs/Maths/math.vector";
  36332. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36333. import { Scene } from "babylonjs/scene";
  36334. import { AbstractScene } from "babylonjs/abstractScene";
  36335. import "babylonjs/Audio/audioEngine";
  36336. module "babylonjs/abstractScene" {
  36337. interface AbstractScene {
  36338. /**
  36339. * The list of sounds used in the scene.
  36340. */
  36341. sounds: Nullable<Array<Sound>>;
  36342. }
  36343. }
  36344. module "babylonjs/scene" {
  36345. interface Scene {
  36346. /**
  36347. * @hidden
  36348. * Backing field
  36349. */
  36350. _mainSoundTrack: SoundTrack;
  36351. /**
  36352. * The main sound track played by the scene.
  36353. * It cotains your primary collection of sounds.
  36354. */
  36355. mainSoundTrack: SoundTrack;
  36356. /**
  36357. * The list of sound tracks added to the scene
  36358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36359. */
  36360. soundTracks: Nullable<Array<SoundTrack>>;
  36361. /**
  36362. * Gets a sound using a given name
  36363. * @param name defines the name to search for
  36364. * @return the found sound or null if not found at all.
  36365. */
  36366. getSoundByName(name: string): Nullable<Sound>;
  36367. /**
  36368. * Gets or sets if audio support is enabled
  36369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36370. */
  36371. audioEnabled: boolean;
  36372. /**
  36373. * Gets or sets if audio will be output to headphones
  36374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36375. */
  36376. headphone: boolean;
  36377. /**
  36378. * Gets or sets custom audio listener position provider
  36379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36380. */
  36381. audioListenerPositionProvider: Nullable<() => Vector3>;
  36382. }
  36383. }
  36384. /**
  36385. * Defines the sound scene component responsible to manage any sounds
  36386. * in a given scene.
  36387. */
  36388. export class AudioSceneComponent implements ISceneSerializableComponent {
  36389. /**
  36390. * The component name helpfull to identify the component in the list of scene components.
  36391. */
  36392. readonly name: string;
  36393. /**
  36394. * The scene the component belongs to.
  36395. */
  36396. scene: Scene;
  36397. private _audioEnabled;
  36398. /**
  36399. * Gets whether audio is enabled or not.
  36400. * Please use related enable/disable method to switch state.
  36401. */
  36402. readonly audioEnabled: boolean;
  36403. private _headphone;
  36404. /**
  36405. * Gets whether audio is outputing to headphone or not.
  36406. * Please use the according Switch methods to change output.
  36407. */
  36408. readonly headphone: boolean;
  36409. private _audioListenerPositionProvider;
  36410. /**
  36411. * Gets the current audio listener position provider
  36412. */
  36413. /**
  36414. * Sets a custom listener position for all sounds in the scene
  36415. * By default, this is the position of the first active camera
  36416. */
  36417. audioListenerPositionProvider: Nullable<() => Vector3>;
  36418. /**
  36419. * Creates a new instance of the component for the given scene
  36420. * @param scene Defines the scene to register the component in
  36421. */
  36422. constructor(scene: Scene);
  36423. /**
  36424. * Registers the component in a given scene
  36425. */
  36426. register(): void;
  36427. /**
  36428. * Rebuilds the elements related to this component in case of
  36429. * context lost for instance.
  36430. */
  36431. rebuild(): void;
  36432. /**
  36433. * Serializes the component data to the specified json object
  36434. * @param serializationObject The object to serialize to
  36435. */
  36436. serialize(serializationObject: any): void;
  36437. /**
  36438. * Adds all the elements from the container to the scene
  36439. * @param container the container holding the elements
  36440. */
  36441. addFromContainer(container: AbstractScene): void;
  36442. /**
  36443. * Removes all the elements in the container from the scene
  36444. * @param container contains the elements to remove
  36445. * @param dispose if the removed element should be disposed (default: false)
  36446. */
  36447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36448. /**
  36449. * Disposes the component and the associated ressources.
  36450. */
  36451. dispose(): void;
  36452. /**
  36453. * Disables audio in the associated scene.
  36454. */
  36455. disableAudio(): void;
  36456. /**
  36457. * Enables audio in the associated scene.
  36458. */
  36459. enableAudio(): void;
  36460. /**
  36461. * Switch audio to headphone output.
  36462. */
  36463. switchAudioModeForHeadphones(): void;
  36464. /**
  36465. * Switch audio to normal speakers.
  36466. */
  36467. switchAudioModeForNormalSpeakers(): void;
  36468. private _afterRender;
  36469. }
  36470. }
  36471. declare module "babylonjs/Audio/weightedsound" {
  36472. import { Sound } from "babylonjs/Audio/sound";
  36473. /**
  36474. * Wraps one or more Sound objects and selects one with random weight for playback.
  36475. */
  36476. export class WeightedSound {
  36477. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36478. loop: boolean;
  36479. private _coneInnerAngle;
  36480. private _coneOuterAngle;
  36481. private _volume;
  36482. /** A Sound is currently playing. */
  36483. isPlaying: boolean;
  36484. /** A Sound is currently paused. */
  36485. isPaused: boolean;
  36486. private _sounds;
  36487. private _weights;
  36488. private _currentIndex?;
  36489. /**
  36490. * Creates a new WeightedSound from the list of sounds given.
  36491. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36492. * @param sounds Array of Sounds that will be selected from.
  36493. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36494. */
  36495. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36496. /**
  36497. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36498. */
  36499. /**
  36500. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36501. */
  36502. directionalConeInnerAngle: number;
  36503. /**
  36504. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36505. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36506. */
  36507. /**
  36508. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36509. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36510. */
  36511. directionalConeOuterAngle: number;
  36512. /**
  36513. * Playback volume.
  36514. */
  36515. /**
  36516. * Playback volume.
  36517. */
  36518. volume: number;
  36519. private _onended;
  36520. /**
  36521. * Suspend playback
  36522. */
  36523. pause(): void;
  36524. /**
  36525. * Stop playback
  36526. */
  36527. stop(): void;
  36528. /**
  36529. * Start playback.
  36530. * @param startOffset Position the clip head at a specific time in seconds.
  36531. */
  36532. play(startOffset?: number): void;
  36533. }
  36534. }
  36535. declare module "babylonjs/Audio/index" {
  36536. export * from "babylonjs/Audio/analyser";
  36537. export * from "babylonjs/Audio/audioEngine";
  36538. export * from "babylonjs/Audio/audioSceneComponent";
  36539. export * from "babylonjs/Audio/sound";
  36540. export * from "babylonjs/Audio/soundTrack";
  36541. export * from "babylonjs/Audio/weightedsound";
  36542. }
  36543. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36544. import { Behavior } from "babylonjs/Behaviors/behavior";
  36545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36546. import { BackEase } from "babylonjs/Animations/easing";
  36547. /**
  36548. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36550. */
  36551. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36552. /**
  36553. * Gets the name of the behavior.
  36554. */
  36555. readonly name: string;
  36556. /**
  36557. * The easing function used by animations
  36558. */
  36559. static EasingFunction: BackEase;
  36560. /**
  36561. * The easing mode used by animations
  36562. */
  36563. static EasingMode: number;
  36564. /**
  36565. * The duration of the animation, in milliseconds
  36566. */
  36567. transitionDuration: number;
  36568. /**
  36569. * Length of the distance animated by the transition when lower radius is reached
  36570. */
  36571. lowerRadiusTransitionRange: number;
  36572. /**
  36573. * Length of the distance animated by the transition when upper radius is reached
  36574. */
  36575. upperRadiusTransitionRange: number;
  36576. private _autoTransitionRange;
  36577. /**
  36578. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36579. */
  36580. /**
  36581. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36582. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36583. */
  36584. autoTransitionRange: boolean;
  36585. private _attachedCamera;
  36586. private _onAfterCheckInputsObserver;
  36587. private _onMeshTargetChangedObserver;
  36588. /**
  36589. * Initializes the behavior.
  36590. */
  36591. init(): void;
  36592. /**
  36593. * Attaches the behavior to its arc rotate camera.
  36594. * @param camera Defines the camera to attach the behavior to
  36595. */
  36596. attach(camera: ArcRotateCamera): void;
  36597. /**
  36598. * Detaches the behavior from its current arc rotate camera.
  36599. */
  36600. detach(): void;
  36601. private _radiusIsAnimating;
  36602. private _radiusBounceTransition;
  36603. private _animatables;
  36604. private _cachedWheelPrecision;
  36605. /**
  36606. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36607. * @param radiusLimit The limit to check against.
  36608. * @return Bool to indicate if at limit.
  36609. */
  36610. private _isRadiusAtLimit;
  36611. /**
  36612. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36613. * @param radiusDelta The delta by which to animate to. Can be negative.
  36614. */
  36615. private _applyBoundRadiusAnimation;
  36616. /**
  36617. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36618. */
  36619. protected _clearAnimationLocks(): void;
  36620. /**
  36621. * Stops and removes all animations that have been applied to the camera
  36622. */
  36623. stopAllAnimations(): void;
  36624. }
  36625. }
  36626. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36627. import { Behavior } from "babylonjs/Behaviors/behavior";
  36628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36629. import { ExponentialEase } from "babylonjs/Animations/easing";
  36630. import { Nullable } from "babylonjs/types";
  36631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36632. import { Vector3 } from "babylonjs/Maths/math.vector";
  36633. /**
  36634. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  36635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36636. */
  36637. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36638. /**
  36639. * Gets the name of the behavior.
  36640. */
  36641. readonly name: string;
  36642. private _mode;
  36643. private _radiusScale;
  36644. private _positionScale;
  36645. private _defaultElevation;
  36646. private _elevationReturnTime;
  36647. private _elevationReturnWaitTime;
  36648. private _zoomStopsAnimation;
  36649. private _framingTime;
  36650. /**
  36651. * The easing function used by animations
  36652. */
  36653. static EasingFunction: ExponentialEase;
  36654. /**
  36655. * The easing mode used by animations
  36656. */
  36657. static EasingMode: number;
  36658. /**
  36659. * Sets the current mode used by the behavior
  36660. */
  36661. /**
  36662. * Gets current mode used by the behavior.
  36663. */
  36664. mode: number;
  36665. /**
  36666. * Sets the scale applied to the radius (1 by default)
  36667. */
  36668. /**
  36669. * Gets the scale applied to the radius
  36670. */
  36671. radiusScale: number;
  36672. /**
  36673. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36674. */
  36675. /**
  36676. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36677. */
  36678. positionScale: number;
  36679. /**
  36680. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36681. * behaviour is triggered, in radians.
  36682. */
  36683. /**
  36684. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36685. * behaviour is triggered, in radians.
  36686. */
  36687. defaultElevation: number;
  36688. /**
  36689. * Sets the time (in milliseconds) taken to return to the default beta position.
  36690. * Negative value indicates camera should not return to default.
  36691. */
  36692. /**
  36693. * Gets the time (in milliseconds) taken to return to the default beta position.
  36694. * Negative value indicates camera should not return to default.
  36695. */
  36696. elevationReturnTime: number;
  36697. /**
  36698. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36699. */
  36700. /**
  36701. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36702. */
  36703. elevationReturnWaitTime: number;
  36704. /**
  36705. * Sets the flag that indicates if user zooming should stop animation.
  36706. */
  36707. /**
  36708. * Gets the flag that indicates if user zooming should stop animation.
  36709. */
  36710. zoomStopsAnimation: boolean;
  36711. /**
  36712. * Sets the transition time when framing the mesh, in milliseconds
  36713. */
  36714. /**
  36715. * Gets the transition time when framing the mesh, in milliseconds
  36716. */
  36717. framingTime: number;
  36718. /**
  36719. * Define if the behavior should automatically change the configured
  36720. * camera limits and sensibilities.
  36721. */
  36722. autoCorrectCameraLimitsAndSensibility: boolean;
  36723. private _onPrePointerObservableObserver;
  36724. private _onAfterCheckInputsObserver;
  36725. private _onMeshTargetChangedObserver;
  36726. private _attachedCamera;
  36727. private _isPointerDown;
  36728. private _lastInteractionTime;
  36729. /**
  36730. * Initializes the behavior.
  36731. */
  36732. init(): void;
  36733. /**
  36734. * Attaches the behavior to its arc rotate camera.
  36735. * @param camera Defines the camera to attach the behavior to
  36736. */
  36737. attach(camera: ArcRotateCamera): void;
  36738. /**
  36739. * Detaches the behavior from its current arc rotate camera.
  36740. */
  36741. detach(): void;
  36742. private _animatables;
  36743. private _betaIsAnimating;
  36744. private _betaTransition;
  36745. private _radiusTransition;
  36746. private _vectorTransition;
  36747. /**
  36748. * Targets the given mesh and updates zoom level accordingly.
  36749. * @param mesh The mesh to target.
  36750. * @param radius Optional. If a cached radius position already exists, overrides default.
  36751. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36752. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36753. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36754. */
  36755. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36756. /**
  36757. * Targets the given mesh with its children and updates zoom level accordingly.
  36758. * @param mesh The mesh to target.
  36759. * @param radius Optional. If a cached radius position already exists, overrides default.
  36760. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36763. */
  36764. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36765. /**
  36766. * Targets the given meshes with their children and updates zoom level accordingly.
  36767. * @param meshes The mesh to target.
  36768. * @param radius Optional. If a cached radius position already exists, overrides default.
  36769. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36770. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36771. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36772. */
  36773. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36774. /**
  36775. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36776. * @param minimumWorld Determines the smaller position of the bounding box extend
  36777. * @param maximumWorld Determines the bigger position of the bounding box extend
  36778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36780. */
  36781. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36782. /**
  36783. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36784. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36785. * frustum width.
  36786. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36787. * to fully enclose the mesh in the viewing frustum.
  36788. */
  36789. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36790. /**
  36791. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36792. * is automatically returned to its default position (expected to be above ground plane).
  36793. */
  36794. private _maintainCameraAboveGround;
  36795. /**
  36796. * Returns the frustum slope based on the canvas ratio and camera FOV
  36797. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36798. */
  36799. private _getFrustumSlope;
  36800. /**
  36801. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36802. */
  36803. private _clearAnimationLocks;
  36804. /**
  36805. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36806. */
  36807. private _applyUserInteraction;
  36808. /**
  36809. * Stops and removes all animations that have been applied to the camera
  36810. */
  36811. stopAllAnimations(): void;
  36812. /**
  36813. * Gets a value indicating if the user is moving the camera
  36814. */
  36815. readonly isUserIsMoving: boolean;
  36816. /**
  36817. * The camera can move all the way towards the mesh.
  36818. */
  36819. static IgnoreBoundsSizeMode: number;
  36820. /**
  36821. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36822. */
  36823. static FitFrustumSidesMode: number;
  36824. }
  36825. }
  36826. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36827. import { Nullable } from "babylonjs/types";
  36828. import { Camera } from "babylonjs/Cameras/camera";
  36829. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36830. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36831. /**
  36832. * Base class for Camera Pointer Inputs.
  36833. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36834. * for example usage.
  36835. */
  36836. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36837. /**
  36838. * Defines the camera the input is attached to.
  36839. */
  36840. abstract camera: Camera;
  36841. /**
  36842. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36843. */
  36844. protected _altKey: boolean;
  36845. protected _ctrlKey: boolean;
  36846. protected _metaKey: boolean;
  36847. protected _shiftKey: boolean;
  36848. /**
  36849. * Which mouse buttons were pressed at time of last mouse event.
  36850. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36851. */
  36852. protected _buttonsPressed: number;
  36853. /**
  36854. * Defines the buttons associated with the input to handle camera move.
  36855. */
  36856. buttons: number[];
  36857. /**
  36858. * Attach the input controls to a specific dom element to get the input from.
  36859. * @param element Defines the element the controls should be listened from
  36860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36861. */
  36862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36863. /**
  36864. * Detach the current controls from the specified dom element.
  36865. * @param element Defines the element to stop listening the inputs from
  36866. */
  36867. detachControl(element: Nullable<HTMLElement>): void;
  36868. /**
  36869. * Gets the class name of the current input.
  36870. * @returns the class name
  36871. */
  36872. getClassName(): string;
  36873. /**
  36874. * Get the friendly name associated with the input class.
  36875. * @returns the input friendly name
  36876. */
  36877. getSimpleName(): string;
  36878. /**
  36879. * Called on pointer POINTERDOUBLETAP event.
  36880. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36881. */
  36882. protected onDoubleTap(type: string): void;
  36883. /**
  36884. * Called on pointer POINTERMOVE event if only a single touch is active.
  36885. * Override this method to provide functionality.
  36886. */
  36887. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36888. /**
  36889. * Called on pointer POINTERMOVE event if multiple touches are active.
  36890. * Override this method to provide functionality.
  36891. */
  36892. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36893. /**
  36894. * Called on JS contextmenu event.
  36895. * Override this method to provide functionality.
  36896. */
  36897. protected onContextMenu(evt: PointerEvent): void;
  36898. /**
  36899. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36900. * press.
  36901. * Override this method to provide functionality.
  36902. */
  36903. protected onButtonDown(evt: PointerEvent): void;
  36904. /**
  36905. * Called each time a new POINTERUP event occurs. Ie, for each button
  36906. * release.
  36907. * Override this method to provide functionality.
  36908. */
  36909. protected onButtonUp(evt: PointerEvent): void;
  36910. /**
  36911. * Called when window becomes inactive.
  36912. * Override this method to provide functionality.
  36913. */
  36914. protected onLostFocus(): void;
  36915. private _pointerInput;
  36916. private _observer;
  36917. private _onLostFocus;
  36918. private pointA;
  36919. private pointB;
  36920. }
  36921. }
  36922. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36923. import { Nullable } from "babylonjs/types";
  36924. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36925. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36926. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36927. /**
  36928. * Manage the pointers inputs to control an arc rotate camera.
  36929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36930. */
  36931. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36932. /**
  36933. * Defines the camera the input is attached to.
  36934. */
  36935. camera: ArcRotateCamera;
  36936. /**
  36937. * Gets the class name of the current input.
  36938. * @returns the class name
  36939. */
  36940. getClassName(): string;
  36941. /**
  36942. * Defines the buttons associated with the input to handle camera move.
  36943. */
  36944. buttons: number[];
  36945. /**
  36946. * Defines the pointer angular sensibility along the X axis or how fast is
  36947. * the camera rotating.
  36948. */
  36949. angularSensibilityX: number;
  36950. /**
  36951. * Defines the pointer angular sensibility along the Y axis or how fast is
  36952. * the camera rotating.
  36953. */
  36954. angularSensibilityY: number;
  36955. /**
  36956. * Defines the pointer pinch precision or how fast is the camera zooming.
  36957. */
  36958. pinchPrecision: number;
  36959. /**
  36960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36961. * from 0.
  36962. * It defines the percentage of current camera.radius to use as delta when
  36963. * pinch zoom is used.
  36964. */
  36965. pinchDeltaPercentage: number;
  36966. /**
  36967. * Defines the pointer panning sensibility or how fast is the camera moving.
  36968. */
  36969. panningSensibility: number;
  36970. /**
  36971. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36972. */
  36973. multiTouchPanning: boolean;
  36974. /**
  36975. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36976. * zoom (pinch) through multitouch.
  36977. */
  36978. multiTouchPanAndZoom: boolean;
  36979. /**
  36980. * Revers pinch action direction.
  36981. */
  36982. pinchInwards: boolean;
  36983. private _isPanClick;
  36984. private _twoFingerActivityCount;
  36985. private _isPinching;
  36986. /**
  36987. * Called on pointer POINTERMOVE event if only a single touch is active.
  36988. */
  36989. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36990. /**
  36991. * Called on pointer POINTERDOUBLETAP event.
  36992. */
  36993. protected onDoubleTap(type: string): void;
  36994. /**
  36995. * Called on pointer POINTERMOVE event if multiple touches are active.
  36996. */
  36997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36998. /**
  36999. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37000. * press.
  37001. */
  37002. protected onButtonDown(evt: PointerEvent): void;
  37003. /**
  37004. * Called each time a new POINTERUP event occurs. Ie, for each button
  37005. * release.
  37006. */
  37007. protected onButtonUp(evt: PointerEvent): void;
  37008. /**
  37009. * Called when window becomes inactive.
  37010. */
  37011. protected onLostFocus(): void;
  37012. }
  37013. }
  37014. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37015. import { Nullable } from "babylonjs/types";
  37016. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37018. /**
  37019. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37021. */
  37022. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37023. /**
  37024. * Defines the camera the input is attached to.
  37025. */
  37026. camera: ArcRotateCamera;
  37027. /**
  37028. * Defines the list of key codes associated with the up action (increase alpha)
  37029. */
  37030. keysUp: number[];
  37031. /**
  37032. * Defines the list of key codes associated with the down action (decrease alpha)
  37033. */
  37034. keysDown: number[];
  37035. /**
  37036. * Defines the list of key codes associated with the left action (increase beta)
  37037. */
  37038. keysLeft: number[];
  37039. /**
  37040. * Defines the list of key codes associated with the right action (decrease beta)
  37041. */
  37042. keysRight: number[];
  37043. /**
  37044. * Defines the list of key codes associated with the reset action.
  37045. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37046. */
  37047. keysReset: number[];
  37048. /**
  37049. * Defines the panning sensibility of the inputs.
  37050. * (How fast is the camera paning)
  37051. */
  37052. panningSensibility: number;
  37053. /**
  37054. * Defines the zooming sensibility of the inputs.
  37055. * (How fast is the camera zooming)
  37056. */
  37057. zoomingSensibility: number;
  37058. /**
  37059. * Defines wether maintaining the alt key down switch the movement mode from
  37060. * orientation to zoom.
  37061. */
  37062. useAltToZoom: boolean;
  37063. /**
  37064. * Rotation speed of the camera
  37065. */
  37066. angularSpeed: number;
  37067. private _keys;
  37068. private _ctrlPressed;
  37069. private _altPressed;
  37070. private _onCanvasBlurObserver;
  37071. private _onKeyboardObserver;
  37072. private _engine;
  37073. private _scene;
  37074. /**
  37075. * Attach the input controls to a specific dom element to get the input from.
  37076. * @param element Defines the element the controls should be listened from
  37077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37078. */
  37079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37080. /**
  37081. * Detach the current controls from the specified dom element.
  37082. * @param element Defines the element to stop listening the inputs from
  37083. */
  37084. detachControl(element: Nullable<HTMLElement>): void;
  37085. /**
  37086. * Update the current camera state depending on the inputs that have been used this frame.
  37087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37088. */
  37089. checkInputs(): void;
  37090. /**
  37091. * Gets the class name of the current intput.
  37092. * @returns the class name
  37093. */
  37094. getClassName(): string;
  37095. /**
  37096. * Get the friendly name associated with the input class.
  37097. * @returns the input friendly name
  37098. */
  37099. getSimpleName(): string;
  37100. }
  37101. }
  37102. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37103. import { Nullable } from "babylonjs/types";
  37104. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37106. /**
  37107. * Manage the mouse wheel inputs to control an arc rotate camera.
  37108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37109. */
  37110. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37111. /**
  37112. * Defines the camera the input is attached to.
  37113. */
  37114. camera: ArcRotateCamera;
  37115. /**
  37116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37117. */
  37118. wheelPrecision: number;
  37119. /**
  37120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37122. */
  37123. wheelDeltaPercentage: number;
  37124. private _wheel;
  37125. private _observer;
  37126. private computeDeltaFromMouseWheelLegacyEvent;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Gets the class name of the current intput.
  37140. * @returns the class name
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input friendly name
  37146. */
  37147. getSimpleName(): string;
  37148. }
  37149. }
  37150. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37151. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37152. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37153. /**
  37154. * Default Inputs manager for the ArcRotateCamera.
  37155. * It groups all the default supported inputs for ease of use.
  37156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37157. */
  37158. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37159. /**
  37160. * Instantiates a new ArcRotateCameraInputsManager.
  37161. * @param camera Defines the camera the inputs belong to
  37162. */
  37163. constructor(camera: ArcRotateCamera);
  37164. /**
  37165. * Add mouse wheel input support to the input manager.
  37166. * @returns the current input manager
  37167. */
  37168. addMouseWheel(): ArcRotateCameraInputsManager;
  37169. /**
  37170. * Add pointers input support to the input manager.
  37171. * @returns the current input manager
  37172. */
  37173. addPointers(): ArcRotateCameraInputsManager;
  37174. /**
  37175. * Add keyboard input support to the input manager.
  37176. * @returns the current input manager
  37177. */
  37178. addKeyboard(): ArcRotateCameraInputsManager;
  37179. }
  37180. }
  37181. declare module "babylonjs/Cameras/arcRotateCamera" {
  37182. import { Observable } from "babylonjs/Misc/observable";
  37183. import { Nullable } from "babylonjs/types";
  37184. import { Scene } from "babylonjs/scene";
  37185. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37187. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37188. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37189. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37190. import { Camera } from "babylonjs/Cameras/camera";
  37191. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37192. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37193. import { Collider } from "babylonjs/Collisions/collider";
  37194. /**
  37195. * This represents an orbital type of camera.
  37196. *
  37197. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  37198. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  37199. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37200. */
  37201. export class ArcRotateCamera extends TargetCamera {
  37202. /**
  37203. * Defines the rotation angle of the camera along the longitudinal axis.
  37204. */
  37205. alpha: number;
  37206. /**
  37207. * Defines the rotation angle of the camera along the latitudinal axis.
  37208. */
  37209. beta: number;
  37210. /**
  37211. * Defines the radius of the camera from it s target point.
  37212. */
  37213. radius: number;
  37214. protected _target: Vector3;
  37215. protected _targetHost: Nullable<AbstractMesh>;
  37216. /**
  37217. * Defines the target point of the camera.
  37218. * The camera looks towards it form the radius distance.
  37219. */
  37220. target: Vector3;
  37221. /**
  37222. * Define the current local position of the camera in the scene
  37223. */
  37224. position: Vector3;
  37225. protected _upVector: Vector3;
  37226. protected _upToYMatrix: Matrix;
  37227. protected _YToUpMatrix: Matrix;
  37228. /**
  37229. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37230. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37231. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37232. */
  37233. upVector: Vector3;
  37234. /**
  37235. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37236. */
  37237. setMatUp(): void;
  37238. /**
  37239. * Current inertia value on the longitudinal axis.
  37240. * The bigger this number the longer it will take for the camera to stop.
  37241. */
  37242. inertialAlphaOffset: number;
  37243. /**
  37244. * Current inertia value on the latitudinal axis.
  37245. * The bigger this number the longer it will take for the camera to stop.
  37246. */
  37247. inertialBetaOffset: number;
  37248. /**
  37249. * Current inertia value on the radius axis.
  37250. * The bigger this number the longer it will take for the camera to stop.
  37251. */
  37252. inertialRadiusOffset: number;
  37253. /**
  37254. * Minimum allowed angle on the longitudinal axis.
  37255. * This can help limiting how the Camera is able to move in the scene.
  37256. */
  37257. lowerAlphaLimit: Nullable<number>;
  37258. /**
  37259. * Maximum allowed angle on the longitudinal axis.
  37260. * This can help limiting how the Camera is able to move in the scene.
  37261. */
  37262. upperAlphaLimit: Nullable<number>;
  37263. /**
  37264. * Minimum allowed angle on the latitudinal axis.
  37265. * This can help limiting how the Camera is able to move in the scene.
  37266. */
  37267. lowerBetaLimit: number;
  37268. /**
  37269. * Maximum allowed angle on the latitudinal axis.
  37270. * This can help limiting how the Camera is able to move in the scene.
  37271. */
  37272. upperBetaLimit: number;
  37273. /**
  37274. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37275. * This can help limiting how the Camera is able to move in the scene.
  37276. */
  37277. lowerRadiusLimit: Nullable<number>;
  37278. /**
  37279. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37280. * This can help limiting how the Camera is able to move in the scene.
  37281. */
  37282. upperRadiusLimit: Nullable<number>;
  37283. /**
  37284. * Defines the current inertia value used during panning of the camera along the X axis.
  37285. */
  37286. inertialPanningX: number;
  37287. /**
  37288. * Defines the current inertia value used during panning of the camera along the Y axis.
  37289. */
  37290. inertialPanningY: number;
  37291. /**
  37292. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37293. * Basically if your fingers moves away from more than this distance you will be considered
  37294. * in pinch mode.
  37295. */
  37296. pinchToPanMaxDistance: number;
  37297. /**
  37298. * Defines the maximum distance the camera can pan.
  37299. * This could help keeping the cammera always in your scene.
  37300. */
  37301. panningDistanceLimit: Nullable<number>;
  37302. /**
  37303. * Defines the target of the camera before paning.
  37304. */
  37305. panningOriginTarget: Vector3;
  37306. /**
  37307. * Defines the value of the inertia used during panning.
  37308. * 0 would mean stop inertia and one would mean no decelleration at all.
  37309. */
  37310. panningInertia: number;
  37311. /**
  37312. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37313. */
  37314. angularSensibilityX: number;
  37315. /**
  37316. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37317. */
  37318. angularSensibilityY: number;
  37319. /**
  37320. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37321. */
  37322. pinchPrecision: number;
  37323. /**
  37324. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37325. * It will be used instead of pinchDeltaPrecision if different from 0.
  37326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37327. */
  37328. pinchDeltaPercentage: number;
  37329. /**
  37330. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37331. */
  37332. panningSensibility: number;
  37333. /**
  37334. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37335. */
  37336. keysUp: number[];
  37337. /**
  37338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37339. */
  37340. keysDown: number[];
  37341. /**
  37342. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37343. */
  37344. keysLeft: number[];
  37345. /**
  37346. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37347. */
  37348. keysRight: number[];
  37349. /**
  37350. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37351. */
  37352. wheelPrecision: number;
  37353. /**
  37354. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37355. * It will be used instead of pinchDeltaPrecision if different from 0.
  37356. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37357. */
  37358. wheelDeltaPercentage: number;
  37359. /**
  37360. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37361. */
  37362. zoomOnFactor: number;
  37363. /**
  37364. * Defines a screen offset for the camera position.
  37365. */
  37366. targetScreenOffset: Vector2;
  37367. /**
  37368. * Allows the camera to be completely reversed.
  37369. * If false the camera can not arrive upside down.
  37370. */
  37371. allowUpsideDown: boolean;
  37372. /**
  37373. * Define if double tap/click is used to restore the previously saved state of the camera.
  37374. */
  37375. useInputToRestoreState: boolean;
  37376. /** @hidden */
  37377. _viewMatrix: Matrix;
  37378. /** @hidden */
  37379. _useCtrlForPanning: boolean;
  37380. /** @hidden */
  37381. _panningMouseButton: number;
  37382. /**
  37383. * Defines the input associated to the camera.
  37384. */
  37385. inputs: ArcRotateCameraInputsManager;
  37386. /** @hidden */
  37387. _reset: () => void;
  37388. /**
  37389. * Defines the allowed panning axis.
  37390. */
  37391. panningAxis: Vector3;
  37392. protected _localDirection: Vector3;
  37393. protected _transformedDirection: Vector3;
  37394. private _bouncingBehavior;
  37395. /**
  37396. * Gets the bouncing behavior of the camera if it has been enabled.
  37397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37398. */
  37399. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37400. /**
  37401. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37403. */
  37404. useBouncingBehavior: boolean;
  37405. private _framingBehavior;
  37406. /**
  37407. * Gets the framing behavior of the camera if it has been enabled.
  37408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37409. */
  37410. readonly framingBehavior: Nullable<FramingBehavior>;
  37411. /**
  37412. * Defines if the framing behavior of the camera is enabled on the camera.
  37413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37414. */
  37415. useFramingBehavior: boolean;
  37416. private _autoRotationBehavior;
  37417. /**
  37418. * Gets the auto rotation behavior of the camera if it has been enabled.
  37419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37420. */
  37421. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37422. /**
  37423. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37425. */
  37426. useAutoRotationBehavior: boolean;
  37427. /**
  37428. * Observable triggered when the mesh target has been changed on the camera.
  37429. */
  37430. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37431. /**
  37432. * Event raised when the camera is colliding with a mesh.
  37433. */
  37434. onCollide: (collidedMesh: AbstractMesh) => void;
  37435. /**
  37436. * Defines whether the camera should check collision with the objects oh the scene.
  37437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37438. */
  37439. checkCollisions: boolean;
  37440. /**
  37441. * Defines the collision radius of the camera.
  37442. * This simulates a sphere around the camera.
  37443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37444. */
  37445. collisionRadius: Vector3;
  37446. protected _collider: Collider;
  37447. protected _previousPosition: Vector3;
  37448. protected _collisionVelocity: Vector3;
  37449. protected _newPosition: Vector3;
  37450. protected _previousAlpha: number;
  37451. protected _previousBeta: number;
  37452. protected _previousRadius: number;
  37453. protected _collisionTriggered: boolean;
  37454. protected _targetBoundingCenter: Nullable<Vector3>;
  37455. private _computationVector;
  37456. /**
  37457. * Instantiates a new ArcRotateCamera in a given scene
  37458. * @param name Defines the name of the camera
  37459. * @param alpha Defines the camera rotation along the logitudinal axis
  37460. * @param beta Defines the camera rotation along the latitudinal axis
  37461. * @param radius Defines the camera distance from its target
  37462. * @param target Defines the camera target
  37463. * @param scene Defines the scene the camera belongs to
  37464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37465. */
  37466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37467. /** @hidden */
  37468. _initCache(): void;
  37469. /** @hidden */
  37470. _updateCache(ignoreParentClass?: boolean): void;
  37471. protected _getTargetPosition(): Vector3;
  37472. private _storedAlpha;
  37473. private _storedBeta;
  37474. private _storedRadius;
  37475. private _storedTarget;
  37476. private _storedTargetScreenOffset;
  37477. /**
  37478. * Stores the current state of the camera (alpha, beta, radius and target)
  37479. * @returns the camera itself
  37480. */
  37481. storeState(): Camera;
  37482. /**
  37483. * @hidden
  37484. * Restored camera state. You must call storeState() first
  37485. */
  37486. _restoreStateValues(): boolean;
  37487. /** @hidden */
  37488. _isSynchronizedViewMatrix(): boolean;
  37489. /**
  37490. * Attached controls to the current camera.
  37491. * @param element Defines the element the controls should be listened from
  37492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37493. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37494. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37495. */
  37496. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37497. /**
  37498. * Detach the current controls from the camera.
  37499. * The camera will stop reacting to inputs.
  37500. * @param element Defines the element to stop listening the inputs from
  37501. */
  37502. detachControl(element: HTMLElement): void;
  37503. /** @hidden */
  37504. _checkInputs(): void;
  37505. protected _checkLimits(): void;
  37506. /**
  37507. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37508. */
  37509. rebuildAnglesAndRadius(): void;
  37510. /**
  37511. * Use a position to define the current camera related information like aplha, beta and radius
  37512. * @param position Defines the position to set the camera at
  37513. */
  37514. setPosition(position: Vector3): void;
  37515. /**
  37516. * Defines the target the camera should look at.
  37517. * This will automatically adapt alpha beta and radius to fit within the new target.
  37518. * @param target Defines the new target as a Vector or a mesh
  37519. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37520. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37521. */
  37522. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37523. /** @hidden */
  37524. _getViewMatrix(): Matrix;
  37525. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37526. /**
  37527. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37528. * @param meshes Defines the mesh to zoom on
  37529. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  37530. */
  37531. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37532. /**
  37533. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37534. * The target will be changed but the radius
  37535. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37536. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  37537. */
  37538. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37539. min: Vector3;
  37540. max: Vector3;
  37541. distance: number;
  37542. }, doNotUpdateMaxZ?: boolean): void;
  37543. /**
  37544. * @override
  37545. * Override Camera.createRigCamera
  37546. */
  37547. createRigCamera(name: string, cameraIndex: number): Camera;
  37548. /**
  37549. * @hidden
  37550. * @override
  37551. * Override Camera._updateRigCameras
  37552. */
  37553. _updateRigCameras(): void;
  37554. /**
  37555. * Destroy the camera and release the current resources hold by it.
  37556. */
  37557. dispose(): void;
  37558. /**
  37559. * Gets the current object class name.
  37560. * @return the class name
  37561. */
  37562. getClassName(): string;
  37563. }
  37564. }
  37565. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37566. import { Behavior } from "babylonjs/Behaviors/behavior";
  37567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37568. /**
  37569. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37571. */
  37572. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37573. /**
  37574. * Gets the name of the behavior.
  37575. */
  37576. readonly name: string;
  37577. private _zoomStopsAnimation;
  37578. private _idleRotationSpeed;
  37579. private _idleRotationWaitTime;
  37580. private _idleRotationSpinupTime;
  37581. /**
  37582. * Sets the flag that indicates if user zooming should stop animation.
  37583. */
  37584. /**
  37585. * Gets the flag that indicates if user zooming should stop animation.
  37586. */
  37587. zoomStopsAnimation: boolean;
  37588. /**
  37589. * Sets the default speed at which the camera rotates around the model.
  37590. */
  37591. /**
  37592. * Gets the default speed at which the camera rotates around the model.
  37593. */
  37594. idleRotationSpeed: number;
  37595. /**
  37596. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37597. */
  37598. /**
  37599. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37600. */
  37601. idleRotationWaitTime: number;
  37602. /**
  37603. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37604. */
  37605. /**
  37606. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37607. */
  37608. idleRotationSpinupTime: number;
  37609. /**
  37610. * Gets a value indicating if the camera is currently rotating because of this behavior
  37611. */
  37612. readonly rotationInProgress: boolean;
  37613. private _onPrePointerObservableObserver;
  37614. private _onAfterCheckInputsObserver;
  37615. private _attachedCamera;
  37616. private _isPointerDown;
  37617. private _lastFrameTime;
  37618. private _lastInteractionTime;
  37619. private _cameraRotationSpeed;
  37620. /**
  37621. * Initializes the behavior.
  37622. */
  37623. init(): void;
  37624. /**
  37625. * Attaches the behavior to its arc rotate camera.
  37626. * @param camera Defines the camera to attach the behavior to
  37627. */
  37628. attach(camera: ArcRotateCamera): void;
  37629. /**
  37630. * Detaches the behavior from its current arc rotate camera.
  37631. */
  37632. detach(): void;
  37633. /**
  37634. * Returns true if user is scrolling.
  37635. * @return true if user is scrolling.
  37636. */
  37637. private _userIsZooming;
  37638. private _lastFrameRadius;
  37639. private _shouldAnimationStopForInteraction;
  37640. /**
  37641. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37642. */
  37643. private _applyUserInteraction;
  37644. private _userIsMoving;
  37645. }
  37646. }
  37647. declare module "babylonjs/Behaviors/Cameras/index" {
  37648. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37649. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37650. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37651. }
  37652. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37653. import { Mesh } from "babylonjs/Meshes/mesh";
  37654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37655. import { Behavior } from "babylonjs/Behaviors/behavior";
  37656. /**
  37657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37658. */
  37659. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37660. private ui;
  37661. /**
  37662. * The name of the behavior
  37663. */
  37664. name: string;
  37665. /**
  37666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37667. */
  37668. distanceAwayFromFace: number;
  37669. /**
  37670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37671. */
  37672. distanceAwayFromBottomOfFace: number;
  37673. private _faceVectors;
  37674. private _target;
  37675. private _scene;
  37676. private _onRenderObserver;
  37677. private _tmpMatrix;
  37678. private _tmpVector;
  37679. /**
  37680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37681. * @param ui The transform node that should be attched to the mesh
  37682. */
  37683. constructor(ui: TransformNode);
  37684. /**
  37685. * Initializes the behavior
  37686. */
  37687. init(): void;
  37688. private _closestFace;
  37689. private _zeroVector;
  37690. private _lookAtTmpMatrix;
  37691. private _lookAtToRef;
  37692. /**
  37693. * Attaches the AttachToBoxBehavior to the passed in mesh
  37694. * @param target The mesh that the specified node will be attached to
  37695. */
  37696. attach(target: Mesh): void;
  37697. /**
  37698. * Detaches the behavior from the mesh
  37699. */
  37700. detach(): void;
  37701. }
  37702. }
  37703. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37704. import { Behavior } from "babylonjs/Behaviors/behavior";
  37705. import { Mesh } from "babylonjs/Meshes/mesh";
  37706. /**
  37707. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37708. */
  37709. export class FadeInOutBehavior implements Behavior<Mesh> {
  37710. /**
  37711. * Time in milliseconds to delay before fading in (Default: 0)
  37712. */
  37713. delay: number;
  37714. /**
  37715. * Time in milliseconds for the mesh to fade in (Default: 300)
  37716. */
  37717. fadeInTime: number;
  37718. private _millisecondsPerFrame;
  37719. private _hovered;
  37720. private _hoverValue;
  37721. private _ownerNode;
  37722. /**
  37723. * Instatiates the FadeInOutBehavior
  37724. */
  37725. constructor();
  37726. /**
  37727. * The name of the behavior
  37728. */
  37729. readonly name: string;
  37730. /**
  37731. * Initializes the behavior
  37732. */
  37733. init(): void;
  37734. /**
  37735. * Attaches the fade behavior on the passed in mesh
  37736. * @param ownerNode The mesh that will be faded in/out once attached
  37737. */
  37738. attach(ownerNode: Mesh): void;
  37739. /**
  37740. * Detaches the behavior from the mesh
  37741. */
  37742. detach(): void;
  37743. /**
  37744. * Triggers the mesh to begin fading in or out
  37745. * @param value if the object should fade in or out (true to fade in)
  37746. */
  37747. fadeIn(value: boolean): void;
  37748. private _update;
  37749. private _setAllVisibility;
  37750. }
  37751. }
  37752. declare module "babylonjs/Misc/pivotTools" {
  37753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37754. /**
  37755. * Class containing a set of static utilities functions for managing Pivots
  37756. * @hidden
  37757. */
  37758. export class PivotTools {
  37759. private static _PivotCached;
  37760. private static _OldPivotPoint;
  37761. private static _PivotTranslation;
  37762. private static _PivotTmpVector;
  37763. /** @hidden */
  37764. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37765. /** @hidden */
  37766. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37767. }
  37768. }
  37769. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37770. import { Scene } from "babylonjs/scene";
  37771. import { Vector4 } from "babylonjs/Maths/math.vector";
  37772. import { Mesh } from "babylonjs/Meshes/mesh";
  37773. import { Nullable } from "babylonjs/types";
  37774. import { Plane } from "babylonjs/Maths/math.plane";
  37775. /**
  37776. * Class containing static functions to help procedurally build meshes
  37777. */
  37778. export class PlaneBuilder {
  37779. /**
  37780. * Creates a plane mesh
  37781. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37782. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37783. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37787. * @param name defines the name of the mesh
  37788. * @param options defines the options used to create the mesh
  37789. * @param scene defines the hosting scene
  37790. * @returns the plane mesh
  37791. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37792. */
  37793. static CreatePlane(name: string, options: {
  37794. size?: number;
  37795. width?: number;
  37796. height?: number;
  37797. sideOrientation?: number;
  37798. frontUVs?: Vector4;
  37799. backUVs?: Vector4;
  37800. updatable?: boolean;
  37801. sourcePlane?: Plane;
  37802. }, scene?: Nullable<Scene>): Mesh;
  37803. }
  37804. }
  37805. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37806. import { Behavior } from "babylonjs/Behaviors/behavior";
  37807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37808. import { Observable } from "babylonjs/Misc/observable";
  37809. import { Vector3 } from "babylonjs/Maths/math.vector";
  37810. import { Ray } from "babylonjs/Culling/ray";
  37811. import "babylonjs/Meshes/Builders/planeBuilder";
  37812. /**
  37813. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37814. */
  37815. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37816. private static _AnyMouseID;
  37817. /**
  37818. * Abstract mesh the behavior is set on
  37819. */
  37820. attachedNode: AbstractMesh;
  37821. private _dragPlane;
  37822. private _scene;
  37823. private _pointerObserver;
  37824. private _beforeRenderObserver;
  37825. private static _planeScene;
  37826. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37827. /**
  37828. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  37829. */
  37830. maxDragAngle: number;
  37831. /**
  37832. * @hidden
  37833. */
  37834. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37835. /**
  37836. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37837. */
  37838. currentDraggingPointerID: number;
  37839. /**
  37840. * The last position where the pointer hit the drag plane in world space
  37841. */
  37842. lastDragPosition: Vector3;
  37843. /**
  37844. * If the behavior is currently in a dragging state
  37845. */
  37846. dragging: boolean;
  37847. /**
  37848. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  37849. */
  37850. dragDeltaRatio: number;
  37851. /**
  37852. * If the drag plane orientation should be updated during the dragging (Default: true)
  37853. */
  37854. updateDragPlane: boolean;
  37855. private _debugMode;
  37856. private _moving;
  37857. /**
  37858. * Fires each time the attached mesh is dragged with the pointer
  37859. * * delta between last drag position and current drag position in world space
  37860. * * dragDistance along the drag axis
  37861. * * dragPlaneNormal normal of the current drag plane used during the drag
  37862. * * dragPlanePoint in world space where the drag intersects the drag plane
  37863. */
  37864. onDragObservable: Observable<{
  37865. delta: Vector3;
  37866. dragPlanePoint: Vector3;
  37867. dragPlaneNormal: Vector3;
  37868. dragDistance: number;
  37869. pointerId: number;
  37870. }>;
  37871. /**
  37872. * Fires each time a drag begins (eg. mouse down on mesh)
  37873. */
  37874. onDragStartObservable: Observable<{
  37875. dragPlanePoint: Vector3;
  37876. pointerId: number;
  37877. }>;
  37878. /**
  37879. * Fires each time a drag ends (eg. mouse release after drag)
  37880. */
  37881. onDragEndObservable: Observable<{
  37882. dragPlanePoint: Vector3;
  37883. pointerId: number;
  37884. }>;
  37885. /**
  37886. * If the attached mesh should be moved when dragged
  37887. */
  37888. moveAttached: boolean;
  37889. /**
  37890. * If the drag behavior will react to drag events (Default: true)
  37891. */
  37892. enabled: boolean;
  37893. /**
  37894. * If pointer events should start and release the drag (Default: true)
  37895. */
  37896. startAndReleaseDragOnPointerEvents: boolean;
  37897. /**
  37898. * If camera controls should be detached during the drag
  37899. */
  37900. detachCameraControls: boolean;
  37901. /**
  37902. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37903. */
  37904. useObjectOrienationForDragging: boolean;
  37905. private _options;
  37906. /**
  37907. * Creates a pointer drag behavior that can be attached to a mesh
  37908. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  37909. */
  37910. constructor(options?: {
  37911. dragAxis?: Vector3;
  37912. dragPlaneNormal?: Vector3;
  37913. });
  37914. /**
  37915. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37916. */
  37917. validateDrag: (targetPosition: Vector3) => boolean;
  37918. /**
  37919. * The name of the behavior
  37920. */
  37921. readonly name: string;
  37922. /**
  37923. * Initializes the behavior
  37924. */
  37925. init(): void;
  37926. private _tmpVector;
  37927. private _alternatePickedPoint;
  37928. private _worldDragAxis;
  37929. private _targetPosition;
  37930. private _attachedElement;
  37931. /**
  37932. * Attaches the drag behavior the passed in mesh
  37933. * @param ownerNode The mesh that will be dragged around once attached
  37934. * @param predicate Predicate to use for pick filtering
  37935. */
  37936. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37937. /**
  37938. * Force relase the drag action by code.
  37939. */
  37940. releaseDrag(): void;
  37941. private _startDragRay;
  37942. private _lastPointerRay;
  37943. /**
  37944. * Simulates the start of a pointer drag event on the behavior
  37945. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37946. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37947. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37948. */
  37949. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37950. private _startDrag;
  37951. private _dragDelta;
  37952. private _moveDrag;
  37953. private _pickWithRayOnDragPlane;
  37954. private _pointA;
  37955. private _pointB;
  37956. private _pointC;
  37957. private _lineA;
  37958. private _lineB;
  37959. private _localAxis;
  37960. private _lookAt;
  37961. private _updateDragPlanePosition;
  37962. /**
  37963. * Detaches the behavior from the mesh
  37964. */
  37965. detach(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37969. import { Mesh } from "babylonjs/Meshes/mesh";
  37970. import { Behavior } from "babylonjs/Behaviors/behavior";
  37971. /**
  37972. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37973. */
  37974. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37975. private _dragBehaviorA;
  37976. private _dragBehaviorB;
  37977. private _startDistance;
  37978. private _initialScale;
  37979. private _targetScale;
  37980. private _ownerNode;
  37981. private _sceneRenderObserver;
  37982. /**
  37983. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37984. */
  37985. constructor();
  37986. /**
  37987. * The name of the behavior
  37988. */
  37989. readonly name: string;
  37990. /**
  37991. * Initializes the behavior
  37992. */
  37993. init(): void;
  37994. private _getCurrentDistance;
  37995. /**
  37996. * Attaches the scale behavior the passed in mesh
  37997. * @param ownerNode The mesh that will be scaled around once attached
  37998. */
  37999. attach(ownerNode: Mesh): void;
  38000. /**
  38001. * Detaches the behavior from the mesh
  38002. */
  38003. detach(): void;
  38004. }
  38005. }
  38006. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38007. import { Behavior } from "babylonjs/Behaviors/behavior";
  38008. import { Mesh } from "babylonjs/Meshes/mesh";
  38009. import { Observable } from "babylonjs/Misc/observable";
  38010. /**
  38011. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  38012. */
  38013. export class SixDofDragBehavior implements Behavior<Mesh> {
  38014. private static _virtualScene;
  38015. private _ownerNode;
  38016. private _sceneRenderObserver;
  38017. private _scene;
  38018. private _targetPosition;
  38019. private _virtualOriginMesh;
  38020. private _virtualDragMesh;
  38021. private _pointerObserver;
  38022. private _moving;
  38023. private _startingOrientation;
  38024. /**
  38025. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  38026. */
  38027. private zDragFactor;
  38028. /**
  38029. * If the object should rotate to face the drag origin
  38030. */
  38031. rotateDraggedObject: boolean;
  38032. /**
  38033. * If the behavior is currently in a dragging state
  38034. */
  38035. dragging: boolean;
  38036. /**
  38037. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  38038. */
  38039. dragDeltaRatio: number;
  38040. /**
  38041. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38042. */
  38043. currentDraggingPointerID: number;
  38044. /**
  38045. * If camera controls should be detached during the drag
  38046. */
  38047. detachCameraControls: boolean;
  38048. /**
  38049. * Fires each time a drag starts
  38050. */
  38051. onDragStartObservable: Observable<{}>;
  38052. /**
  38053. * Fires each time a drag ends (eg. mouse release after drag)
  38054. */
  38055. onDragEndObservable: Observable<{}>;
  38056. /**
  38057. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  38058. */
  38059. constructor();
  38060. /**
  38061. * The name of the behavior
  38062. */
  38063. readonly name: string;
  38064. /**
  38065. * Initializes the behavior
  38066. */
  38067. init(): void;
  38068. /**
  38069. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38070. */
  38071. private readonly _pointerCamera;
  38072. /**
  38073. * Attaches the scale behavior the passed in mesh
  38074. * @param ownerNode The mesh that will be scaled around once attached
  38075. */
  38076. attach(ownerNode: Mesh): void;
  38077. /**
  38078. * Detaches the behavior from the mesh
  38079. */
  38080. detach(): void;
  38081. }
  38082. }
  38083. declare module "babylonjs/Behaviors/Meshes/index" {
  38084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38089. }
  38090. declare module "babylonjs/Behaviors/index" {
  38091. export * from "babylonjs/Behaviors/behavior";
  38092. export * from "babylonjs/Behaviors/Cameras/index";
  38093. export * from "babylonjs/Behaviors/Meshes/index";
  38094. }
  38095. declare module "babylonjs/Bones/boneIKController" {
  38096. import { Bone } from "babylonjs/Bones/bone";
  38097. import { Vector3 } from "babylonjs/Maths/math.vector";
  38098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38099. import { Nullable } from "babylonjs/types";
  38100. /**
  38101. * Class used to apply inverse kinematics to bones
  38102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38103. */
  38104. export class BoneIKController {
  38105. private static _tmpVecs;
  38106. private static _tmpQuat;
  38107. private static _tmpMats;
  38108. /**
  38109. * Gets or sets the target mesh
  38110. */
  38111. targetMesh: AbstractMesh;
  38112. /** Gets or sets the mesh used as pole */
  38113. poleTargetMesh: AbstractMesh;
  38114. /**
  38115. * Gets or sets the bone used as pole
  38116. */
  38117. poleTargetBone: Nullable<Bone>;
  38118. /**
  38119. * Gets or sets the target position
  38120. */
  38121. targetPosition: Vector3;
  38122. /**
  38123. * Gets or sets the pole target position
  38124. */
  38125. poleTargetPosition: Vector3;
  38126. /**
  38127. * Gets or sets the pole target local offset
  38128. */
  38129. poleTargetLocalOffset: Vector3;
  38130. /**
  38131. * Gets or sets the pole angle
  38132. */
  38133. poleAngle: number;
  38134. /**
  38135. * Gets or sets the mesh associated with the controller
  38136. */
  38137. mesh: AbstractMesh;
  38138. /**
  38139. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  38140. */
  38141. slerpAmount: number;
  38142. private _bone1Quat;
  38143. private _bone1Mat;
  38144. private _bone2Ang;
  38145. private _bone1;
  38146. private _bone2;
  38147. private _bone1Length;
  38148. private _bone2Length;
  38149. private _maxAngle;
  38150. private _maxReach;
  38151. private _rightHandedSystem;
  38152. private _bendAxis;
  38153. private _slerping;
  38154. private _adjustRoll;
  38155. /**
  38156. * Gets or sets maximum allowed angle
  38157. */
  38158. maxAngle: number;
  38159. /**
  38160. * Creates a new BoneIKController
  38161. * @param mesh defines the mesh to control
  38162. * @param bone defines the bone to control
  38163. * @param options defines options to set up the controller
  38164. */
  38165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38166. targetMesh?: AbstractMesh;
  38167. poleTargetMesh?: AbstractMesh;
  38168. poleTargetBone?: Bone;
  38169. poleTargetLocalOffset?: Vector3;
  38170. poleAngle?: number;
  38171. bendAxis?: Vector3;
  38172. maxAngle?: number;
  38173. slerpAmount?: number;
  38174. });
  38175. private _setMaxAngle;
  38176. /**
  38177. * Force the controller to update the bones
  38178. */
  38179. update(): void;
  38180. }
  38181. }
  38182. declare module "babylonjs/Bones/boneLookController" {
  38183. import { Vector3 } from "babylonjs/Maths/math.vector";
  38184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38185. import { Bone } from "babylonjs/Bones/bone";
  38186. import { Space } from "babylonjs/Maths/math.axis";
  38187. /**
  38188. * Class used to make a bone look toward a point in space
  38189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38190. */
  38191. export class BoneLookController {
  38192. private static _tmpVecs;
  38193. private static _tmpQuat;
  38194. private static _tmpMats;
  38195. /**
  38196. * The target Vector3 that the bone will look at
  38197. */
  38198. target: Vector3;
  38199. /**
  38200. * The mesh that the bone is attached to
  38201. */
  38202. mesh: AbstractMesh;
  38203. /**
  38204. * The bone that will be looking to the target
  38205. */
  38206. bone: Bone;
  38207. /**
  38208. * The up axis of the coordinate system that is used when the bone is rotated
  38209. */
  38210. upAxis: Vector3;
  38211. /**
  38212. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38213. */
  38214. upAxisSpace: Space;
  38215. /**
  38216. * Used to make an adjustment to the yaw of the bone
  38217. */
  38218. adjustYaw: number;
  38219. /**
  38220. * Used to make an adjustment to the pitch of the bone
  38221. */
  38222. adjustPitch: number;
  38223. /**
  38224. * Used to make an adjustment to the roll of the bone
  38225. */
  38226. adjustRoll: number;
  38227. /**
  38228. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  38229. */
  38230. slerpAmount: number;
  38231. private _minYaw;
  38232. private _maxYaw;
  38233. private _minPitch;
  38234. private _maxPitch;
  38235. private _minYawSin;
  38236. private _minYawCos;
  38237. private _maxYawSin;
  38238. private _maxYawCos;
  38239. private _midYawConstraint;
  38240. private _minPitchTan;
  38241. private _maxPitchTan;
  38242. private _boneQuat;
  38243. private _slerping;
  38244. private _transformYawPitch;
  38245. private _transformYawPitchInv;
  38246. private _firstFrameSkipped;
  38247. private _yawRange;
  38248. private _fowardAxis;
  38249. /**
  38250. * Gets or sets the minimum yaw angle that the bone can look to
  38251. */
  38252. minYaw: number;
  38253. /**
  38254. * Gets or sets the maximum yaw angle that the bone can look to
  38255. */
  38256. maxYaw: number;
  38257. /**
  38258. * Gets or sets the minimum pitch angle that the bone can look to
  38259. */
  38260. minPitch: number;
  38261. /**
  38262. * Gets or sets the maximum pitch angle that the bone can look to
  38263. */
  38264. maxPitch: number;
  38265. /**
  38266. * Create a BoneLookController
  38267. * @param mesh the mesh that the bone belongs to
  38268. * @param bone the bone that will be looking to the target
  38269. * @param target the target Vector3 to look at
  38270. * @param options optional settings:
  38271. * * maxYaw: the maximum angle the bone will yaw to
  38272. * * minYaw: the minimum angle the bone will yaw to
  38273. * * maxPitch: the maximum angle the bone will pitch to
  38274. * * minPitch: the minimum angle the bone will yaw to
  38275. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38276. * * upAxis: the up axis of the coordinate system
  38277. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38278. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38279. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38280. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38281. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38282. * * adjustRoll: used to make an adjustment to the roll of the bone
  38283. **/
  38284. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38285. maxYaw?: number;
  38286. minYaw?: number;
  38287. maxPitch?: number;
  38288. minPitch?: number;
  38289. slerpAmount?: number;
  38290. upAxis?: Vector3;
  38291. upAxisSpace?: Space;
  38292. yawAxis?: Vector3;
  38293. pitchAxis?: Vector3;
  38294. adjustYaw?: number;
  38295. adjustPitch?: number;
  38296. adjustRoll?: number;
  38297. });
  38298. /**
  38299. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38300. */
  38301. update(): void;
  38302. private _getAngleDiff;
  38303. private _getAngleBetween;
  38304. private _isAngleBetween;
  38305. }
  38306. }
  38307. declare module "babylonjs/Bones/index" {
  38308. export * from "babylonjs/Bones/bone";
  38309. export * from "babylonjs/Bones/boneIKController";
  38310. export * from "babylonjs/Bones/boneLookController";
  38311. export * from "babylonjs/Bones/skeleton";
  38312. }
  38313. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38314. import { Nullable } from "babylonjs/types";
  38315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38316. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38317. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38318. /**
  38319. * Manage the gamepad inputs to control an arc rotate camera.
  38320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38321. */
  38322. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38323. /**
  38324. * Defines the camera the input is attached to.
  38325. */
  38326. camera: ArcRotateCamera;
  38327. /**
  38328. * Defines the gamepad the input is gathering event from.
  38329. */
  38330. gamepad: Nullable<Gamepad>;
  38331. /**
  38332. * Defines the gamepad rotation sensiblity.
  38333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38334. */
  38335. gamepadRotationSensibility: number;
  38336. /**
  38337. * Defines the gamepad move sensiblity.
  38338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38339. */
  38340. gamepadMoveSensibility: number;
  38341. private _onGamepadConnectedObserver;
  38342. private _onGamepadDisconnectedObserver;
  38343. /**
  38344. * Attach the input controls to a specific dom element to get the input from.
  38345. * @param element Defines the element the controls should be listened from
  38346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38347. */
  38348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38349. /**
  38350. * Detach the current controls from the specified dom element.
  38351. * @param element Defines the element to stop listening the inputs from
  38352. */
  38353. detachControl(element: Nullable<HTMLElement>): void;
  38354. /**
  38355. * Update the current camera state depending on the inputs that have been used this frame.
  38356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38357. */
  38358. checkInputs(): void;
  38359. /**
  38360. * Gets the class name of the current intput.
  38361. * @returns the class name
  38362. */
  38363. getClassName(): string;
  38364. /**
  38365. * Get the friendly name associated with the input class.
  38366. * @returns the input friendly name
  38367. */
  38368. getSimpleName(): string;
  38369. }
  38370. }
  38371. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38372. import { Nullable } from "babylonjs/types";
  38373. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38374. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38375. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38376. interface ArcRotateCameraInputsManager {
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38382. }
  38383. }
  38384. /**
  38385. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38387. */
  38388. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38389. /**
  38390. * Defines the camera the input is attached to.
  38391. */
  38392. camera: ArcRotateCamera;
  38393. /**
  38394. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38395. */
  38396. alphaCorrection: number;
  38397. /**
  38398. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38399. */
  38400. gammaCorrection: number;
  38401. private _alpha;
  38402. private _gamma;
  38403. private _dirty;
  38404. private _deviceOrientationHandler;
  38405. /**
  38406. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38407. */
  38408. constructor();
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /** @hidden */
  38416. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38417. /**
  38418. * Update the current camera state depending on the inputs that have been used this frame.
  38419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38420. */
  38421. checkInputs(): void;
  38422. /**
  38423. * Detach the current controls from the specified dom element.
  38424. * @param element Defines the element to stop listening the inputs from
  38425. */
  38426. detachControl(element: Nullable<HTMLElement>): void;
  38427. /**
  38428. * Gets the class name of the current intput.
  38429. * @returns the class name
  38430. */
  38431. getClassName(): string;
  38432. /**
  38433. * Get the friendly name associated with the input class.
  38434. * @returns the input friendly name
  38435. */
  38436. getSimpleName(): string;
  38437. }
  38438. }
  38439. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38440. import { Nullable } from "babylonjs/types";
  38441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38442. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38443. /**
  38444. * Listen to mouse events to control the camera.
  38445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38446. */
  38447. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38448. /**
  38449. * Defines the camera the input is attached to.
  38450. */
  38451. camera: FlyCamera;
  38452. /**
  38453. * Defines if touch is enabled. (Default is true.)
  38454. */
  38455. touchEnabled: boolean;
  38456. /**
  38457. * Defines the buttons associated with the input to handle camera rotation.
  38458. */
  38459. buttons: number[];
  38460. /**
  38461. * Assign buttons for Yaw control.
  38462. */
  38463. buttonsYaw: number[];
  38464. /**
  38465. * Assign buttons for Pitch control.
  38466. */
  38467. buttonsPitch: number[];
  38468. /**
  38469. * Assign buttons for Roll control.
  38470. */
  38471. buttonsRoll: number[];
  38472. /**
  38473. * Detect if any button is being pressed while mouse is moved.
  38474. * -1 = Mouse locked.
  38475. * 0 = Left button.
  38476. * 1 = Middle Button.
  38477. * 2 = Right Button.
  38478. */
  38479. activeButton: number;
  38480. /**
  38481. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38482. * Higher values reduce its sensitivity.
  38483. */
  38484. angularSensibility: number;
  38485. private _mousemoveCallback;
  38486. private _observer;
  38487. private _rollObserver;
  38488. private previousPosition;
  38489. private noPreventDefault;
  38490. private element;
  38491. /**
  38492. * Listen to mouse events to control the camera.
  38493. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38495. */
  38496. constructor(touchEnabled?: boolean);
  38497. /**
  38498. * Attach the mouse control to the HTML DOM element.
  38499. * @param element Defines the element that listens to the input events.
  38500. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38501. */
  38502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38503. /**
  38504. * Detach the current controls from the specified dom element.
  38505. * @param element Defines the element to stop listening the inputs from
  38506. */
  38507. detachControl(element: Nullable<HTMLElement>): void;
  38508. /**
  38509. * Gets the class name of the current input.
  38510. * @returns the class name.
  38511. */
  38512. getClassName(): string;
  38513. /**
  38514. * Get the friendly name associated with the input class.
  38515. * @returns the input's friendly name.
  38516. */
  38517. getSimpleName(): string;
  38518. private _pointerInput;
  38519. private _onMouseMove;
  38520. /**
  38521. * Rotate camera by mouse offset.
  38522. */
  38523. private rotateCamera;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38527. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38528. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38529. /**
  38530. * Default Inputs manager for the FlyCamera.
  38531. * It groups all the default supported inputs for ease of use.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38535. /**
  38536. * Instantiates a new FlyCameraInputsManager.
  38537. * @param camera Defines the camera the inputs belong to.
  38538. */
  38539. constructor(camera: FlyCamera);
  38540. /**
  38541. * Add keyboard input support to the input manager.
  38542. * @returns the new FlyCameraKeyboardMoveInput().
  38543. */
  38544. addKeyboard(): FlyCameraInputsManager;
  38545. /**
  38546. * Add mouse input support to the input manager.
  38547. * @param touchEnabled Enable touch screen support.
  38548. * @returns the new FlyCameraMouseInput().
  38549. */
  38550. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38551. }
  38552. }
  38553. declare module "babylonjs/Cameras/flyCamera" {
  38554. import { Scene } from "babylonjs/scene";
  38555. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38557. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38558. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38559. /**
  38560. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38561. * such as in a 3D Space Shooter or a Flight Simulator.
  38562. */
  38563. export class FlyCamera extends TargetCamera {
  38564. /**
  38565. * Define the collision ellipsoid of the camera.
  38566. * This is helpful for simulating a camera body, like a player's body.
  38567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38568. */
  38569. ellipsoid: Vector3;
  38570. /**
  38571. * Define an offset for the position of the ellipsoid around the camera.
  38572. * This can be helpful if the camera is attached away from the player's body center,
  38573. * such as at its head.
  38574. */
  38575. ellipsoidOffset: Vector3;
  38576. /**
  38577. * Enable or disable collisions of the camera with the rest of the scene objects.
  38578. */
  38579. checkCollisions: boolean;
  38580. /**
  38581. * Enable or disable gravity on the camera.
  38582. */
  38583. applyGravity: boolean;
  38584. /**
  38585. * Define the current direction the camera is moving to.
  38586. */
  38587. cameraDirection: Vector3;
  38588. /**
  38589. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38590. * This overrides and empties cameraRotation.
  38591. */
  38592. rotationQuaternion: Quaternion;
  38593. /**
  38594. * Track Roll to maintain the wanted Rolling when looking around.
  38595. */
  38596. _trackRoll: number;
  38597. /**
  38598. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38599. */
  38600. rollCorrect: number;
  38601. /**
  38602. * Mimic a banked turn, Rolling the camera when Yawing.
  38603. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38604. */
  38605. bankedTurn: boolean;
  38606. /**
  38607. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38608. */
  38609. bankedTurnLimit: number;
  38610. /**
  38611. * Value of 0 disables the banked Roll.
  38612. * Value of 1 is equal to the Yaw angle in radians.
  38613. */
  38614. bankedTurnMultiplier: number;
  38615. /**
  38616. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38617. */
  38618. inputs: FlyCameraInputsManager;
  38619. /**
  38620. * Gets the input sensibility for mouse input.
  38621. * Higher values reduce sensitivity.
  38622. */
  38623. /**
  38624. * Sets the input sensibility for a mouse input.
  38625. * Higher values reduce sensitivity.
  38626. */
  38627. angularSensibility: number;
  38628. /**
  38629. * Get the keys for camera movement forward.
  38630. */
  38631. /**
  38632. * Set the keys for camera movement forward.
  38633. */
  38634. keysForward: number[];
  38635. /**
  38636. * Get the keys for camera movement backward.
  38637. */
  38638. keysBackward: number[];
  38639. /**
  38640. * Get the keys for camera movement up.
  38641. */
  38642. /**
  38643. * Set the keys for camera movement up.
  38644. */
  38645. keysUp: number[];
  38646. /**
  38647. * Get the keys for camera movement down.
  38648. */
  38649. /**
  38650. * Set the keys for camera movement down.
  38651. */
  38652. keysDown: number[];
  38653. /**
  38654. * Get the keys for camera movement left.
  38655. */
  38656. /**
  38657. * Set the keys for camera movement left.
  38658. */
  38659. keysLeft: number[];
  38660. /**
  38661. * Set the keys for camera movement right.
  38662. */
  38663. /**
  38664. * Set the keys for camera movement right.
  38665. */
  38666. keysRight: number[];
  38667. /**
  38668. * Event raised when the camera collides with a mesh in the scene.
  38669. */
  38670. onCollide: (collidedMesh: AbstractMesh) => void;
  38671. private _collider;
  38672. private _needMoveForGravity;
  38673. private _oldPosition;
  38674. private _diffPosition;
  38675. private _newPosition;
  38676. /** @hidden */
  38677. _localDirection: Vector3;
  38678. /** @hidden */
  38679. _transformedDirection: Vector3;
  38680. /**
  38681. * Instantiates a FlyCamera.
  38682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38683. * such as in a 3D Space Shooter or a Flight Simulator.
  38684. * @param name Define the name of the camera in the scene.
  38685. * @param position Define the starting position of the camera in the scene.
  38686. * @param scene Define the scene the camera belongs to.
  38687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38688. */
  38689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38690. /**
  38691. * Attach a control to the HTML DOM element.
  38692. * @param element Defines the element that listens to the input events.
  38693. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38694. */
  38695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38696. /**
  38697. * Detach a control from the HTML DOM element.
  38698. * The camera will stop reacting to that input.
  38699. * @param element Defines the element that listens to the input events.
  38700. */
  38701. detachControl(element: HTMLElement): void;
  38702. private _collisionMask;
  38703. /**
  38704. * Get the mask that the camera ignores in collision events.
  38705. */
  38706. /**
  38707. * Set the mask that the camera ignores in collision events.
  38708. */
  38709. collisionMask: number;
  38710. /** @hidden */
  38711. _collideWithWorld(displacement: Vector3): void;
  38712. /** @hidden */
  38713. private _onCollisionPositionChange;
  38714. /** @hidden */
  38715. _checkInputs(): void;
  38716. /** @hidden */
  38717. _decideIfNeedsToMove(): boolean;
  38718. /** @hidden */
  38719. _updatePosition(): void;
  38720. /**
  38721. * Restore the Roll to its target value at the rate specified.
  38722. * @param rate - Higher means slower restoring.
  38723. * @hidden
  38724. */
  38725. restoreRoll(rate: number): void;
  38726. /**
  38727. * Destroy the camera and release the current resources held by it.
  38728. */
  38729. dispose(): void;
  38730. /**
  38731. * Get the current object class name.
  38732. * @returns the class name.
  38733. */
  38734. getClassName(): string;
  38735. }
  38736. }
  38737. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38738. import { Nullable } from "babylonjs/types";
  38739. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38740. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38741. /**
  38742. * Listen to keyboard events to control the camera.
  38743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38744. */
  38745. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38746. /**
  38747. * Defines the camera the input is attached to.
  38748. */
  38749. camera: FlyCamera;
  38750. /**
  38751. * The list of keyboard keys used to control the forward move of the camera.
  38752. */
  38753. keysForward: number[];
  38754. /**
  38755. * The list of keyboard keys used to control the backward move of the camera.
  38756. */
  38757. keysBackward: number[];
  38758. /**
  38759. * The list of keyboard keys used to control the forward move of the camera.
  38760. */
  38761. keysUp: number[];
  38762. /**
  38763. * The list of keyboard keys used to control the backward move of the camera.
  38764. */
  38765. keysDown: number[];
  38766. /**
  38767. * The list of keyboard keys used to control the right strafe move of the camera.
  38768. */
  38769. keysRight: number[];
  38770. /**
  38771. * The list of keyboard keys used to control the left strafe move of the camera.
  38772. */
  38773. keysLeft: number[];
  38774. private _keys;
  38775. private _onCanvasBlurObserver;
  38776. private _onKeyboardObserver;
  38777. private _engine;
  38778. private _scene;
  38779. /**
  38780. * Attach the input controls to a specific dom element to get the input from.
  38781. * @param element Defines the element the controls should be listened from
  38782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38783. */
  38784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38785. /**
  38786. * Detach the current controls from the specified dom element.
  38787. * @param element Defines the element to stop listening the inputs from
  38788. */
  38789. detachControl(element: Nullable<HTMLElement>): void;
  38790. /**
  38791. * Gets the class name of the current intput.
  38792. * @returns the class name
  38793. */
  38794. getClassName(): string;
  38795. /** @hidden */
  38796. _onLostFocus(e: FocusEvent): void;
  38797. /**
  38798. * Get the friendly name associated with the input class.
  38799. * @returns the input friendly name
  38800. */
  38801. getSimpleName(): string;
  38802. /**
  38803. * Update the current camera state depending on the inputs that have been used this frame.
  38804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38805. */
  38806. checkInputs(): void;
  38807. }
  38808. }
  38809. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38810. import { Nullable } from "babylonjs/types";
  38811. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38813. /**
  38814. * Manage the mouse wheel inputs to control a follow camera.
  38815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38816. */
  38817. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38818. /**
  38819. * Defines the camera the input is attached to.
  38820. */
  38821. camera: FollowCamera;
  38822. /**
  38823. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38824. */
  38825. axisControlRadius: boolean;
  38826. /**
  38827. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38828. */
  38829. axisControlHeight: boolean;
  38830. /**
  38831. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38832. */
  38833. axisControlRotation: boolean;
  38834. /**
  38835. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38836. * relation to mouseWheel events.
  38837. */
  38838. wheelPrecision: number;
  38839. /**
  38840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38842. */
  38843. wheelDeltaPercentage: number;
  38844. private _wheel;
  38845. private _observer;
  38846. /**
  38847. * Attach the input controls to a specific dom element to get the input from.
  38848. * @param element Defines the element the controls should be listened from
  38849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38850. */
  38851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38852. /**
  38853. * Detach the current controls from the specified dom element.
  38854. * @param element Defines the element to stop listening the inputs from
  38855. */
  38856. detachControl(element: Nullable<HTMLElement>): void;
  38857. /**
  38858. * Gets the class name of the current intput.
  38859. * @returns the class name
  38860. */
  38861. getClassName(): string;
  38862. /**
  38863. * Get the friendly name associated with the input class.
  38864. * @returns the input friendly name
  38865. */
  38866. getSimpleName(): string;
  38867. }
  38868. }
  38869. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38870. import { Nullable } from "babylonjs/types";
  38871. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38872. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38873. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38874. /**
  38875. * Manage the pointers inputs to control an follow camera.
  38876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38877. */
  38878. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38879. /**
  38880. * Defines the camera the input is attached to.
  38881. */
  38882. camera: FollowCamera;
  38883. /**
  38884. * Gets the class name of the current input.
  38885. * @returns the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Defines the pointer angular sensibility along the X axis or how fast is
  38890. * the camera rotating.
  38891. * A negative number will reverse the axis direction.
  38892. */
  38893. angularSensibilityX: number;
  38894. /**
  38895. * Defines the pointer angular sensibility along the Y axis or how fast is
  38896. * the camera rotating.
  38897. * A negative number will reverse the axis direction.
  38898. */
  38899. angularSensibilityY: number;
  38900. /**
  38901. * Defines the pointer pinch precision or how fast is the camera zooming.
  38902. * A negative number will reverse the axis direction.
  38903. */
  38904. pinchPrecision: number;
  38905. /**
  38906. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38907. * from 0.
  38908. * It defines the percentage of current camera.radius to use as delta when
  38909. * pinch zoom is used.
  38910. */
  38911. pinchDeltaPercentage: number;
  38912. /**
  38913. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38914. */
  38915. axisXControlRadius: boolean;
  38916. /**
  38917. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38918. */
  38919. axisXControlHeight: boolean;
  38920. /**
  38921. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38922. */
  38923. axisXControlRotation: boolean;
  38924. /**
  38925. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38926. */
  38927. axisYControlRadius: boolean;
  38928. /**
  38929. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38930. */
  38931. axisYControlHeight: boolean;
  38932. /**
  38933. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38934. */
  38935. axisYControlRotation: boolean;
  38936. /**
  38937. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38938. */
  38939. axisPinchControlRadius: boolean;
  38940. /**
  38941. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38942. */
  38943. axisPinchControlHeight: boolean;
  38944. /**
  38945. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38946. */
  38947. axisPinchControlRotation: boolean;
  38948. /**
  38949. * Log error messages if basic misconfiguration has occurred.
  38950. */
  38951. warningEnable: boolean;
  38952. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38954. private _warningCounter;
  38955. private _warning;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38959. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38960. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38961. /**
  38962. * Default Inputs manager for the FollowCamera.
  38963. * It groups all the default supported inputs for ease of use.
  38964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38965. */
  38966. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38967. /**
  38968. * Instantiates a new FollowCameraInputsManager.
  38969. * @param camera Defines the camera the inputs belong to
  38970. */
  38971. constructor(camera: FollowCamera);
  38972. /**
  38973. * Add keyboard input support to the input manager.
  38974. * @returns the current input manager
  38975. */
  38976. addKeyboard(): FollowCameraInputsManager;
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): FollowCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): FollowCameraInputsManager;
  38987. /**
  38988. * Add orientation input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addVRDeviceOrientation(): FollowCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/followCamera" {
  38995. import { Nullable } from "babylonjs/types";
  38996. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Vector3 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39001. /**
  39002. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39003. * an arc rotate version arcFollowCamera are available.
  39004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39005. */
  39006. export class FollowCamera extends TargetCamera {
  39007. /**
  39008. * Distance the follow camera should follow an object at
  39009. */
  39010. radius: number;
  39011. /**
  39012. * Minimum allowed distance of the camera to the axis of rotation
  39013. * (The camera can not get closer).
  39014. * This can help limiting how the Camera is able to move in the scene.
  39015. */
  39016. lowerRadiusLimit: Nullable<number>;
  39017. /**
  39018. * Maximum allowed distance of the camera to the axis of rotation
  39019. * (The camera can not get further).
  39020. * This can help limiting how the Camera is able to move in the scene.
  39021. */
  39022. upperRadiusLimit: Nullable<number>;
  39023. /**
  39024. * Define a rotation offset between the camera and the object it follows
  39025. */
  39026. rotationOffset: number;
  39027. /**
  39028. * Minimum allowed angle to camera position relative to target object.
  39029. * This can help limiting how the Camera is able to move in the scene.
  39030. */
  39031. lowerRotationOffsetLimit: Nullable<number>;
  39032. /**
  39033. * Maximum allowed angle to camera position relative to target object.
  39034. * This can help limiting how the Camera is able to move in the scene.
  39035. */
  39036. upperRotationOffsetLimit: Nullable<number>;
  39037. /**
  39038. * Define a height offset between the camera and the object it follows.
  39039. * It can help following an object from the top (like a car chaing a plane)
  39040. */
  39041. heightOffset: number;
  39042. /**
  39043. * Minimum allowed height of camera position relative to target object.
  39044. * This can help limiting how the Camera is able to move in the scene.
  39045. */
  39046. lowerHeightOffsetLimit: Nullable<number>;
  39047. /**
  39048. * Maximum allowed height of camera position relative to target object.
  39049. * This can help limiting how the Camera is able to move in the scene.
  39050. */
  39051. upperHeightOffsetLimit: Nullable<number>;
  39052. /**
  39053. * Define how fast the camera can accelerate to follow it s target.
  39054. */
  39055. cameraAcceleration: number;
  39056. /**
  39057. * Define the speed limit of the camera following an object.
  39058. */
  39059. maxCameraSpeed: number;
  39060. /**
  39061. * Define the target of the camera.
  39062. */
  39063. lockedTarget: Nullable<AbstractMesh>;
  39064. /**
  39065. * Defines the input associated with the camera.
  39066. */
  39067. inputs: FollowCameraInputsManager;
  39068. /**
  39069. * Instantiates the follow camera.
  39070. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39071. * @param name Define the name of the camera in the scene
  39072. * @param position Define the position of the camera
  39073. * @param scene Define the scene the camera belong to
  39074. * @param lockedTarget Define the target of the camera
  39075. */
  39076. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39077. private _follow;
  39078. /**
  39079. * Attached controls to the current camera.
  39080. * @param element Defines the element the controls should be listened from
  39081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39082. */
  39083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39084. /**
  39085. * Detach the current controls from the camera.
  39086. * The camera will stop reacting to inputs.
  39087. * @param element Defines the element to stop listening the inputs from
  39088. */
  39089. detachControl(element: HTMLElement): void;
  39090. /** @hidden */
  39091. _checkInputs(): void;
  39092. private _checkLimits;
  39093. /**
  39094. * Gets the camera class name.
  39095. * @returns the class name
  39096. */
  39097. getClassName(): string;
  39098. }
  39099. /**
  39100. * Arc Rotate version of the follow camera.
  39101. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39102. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39103. */
  39104. export class ArcFollowCamera extends TargetCamera {
  39105. /** The longitudinal angle of the camera */
  39106. alpha: number;
  39107. /** The latitudinal angle of the camera */
  39108. beta: number;
  39109. /** The radius of the camera from its target */
  39110. radius: number;
  39111. /** Define the camera target (the messh it should follow) */
  39112. target: Nullable<AbstractMesh>;
  39113. private _cartesianCoordinates;
  39114. /**
  39115. * Instantiates a new ArcFollowCamera
  39116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39117. * @param name Define the name of the camera
  39118. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39119. * @param beta Define the rotation angle of the camera around the elevation axis
  39120. * @param radius Define the radius of the camera from its target point
  39121. * @param target Define the target of the camera
  39122. * @param scene Define the scene the camera belongs to
  39123. */
  39124. constructor(name: string,
  39125. /** The longitudinal angle of the camera */
  39126. alpha: number,
  39127. /** The latitudinal angle of the camera */
  39128. beta: number,
  39129. /** The radius of the camera from its target */
  39130. radius: number,
  39131. /** Define the camera target (the messh it should follow) */
  39132. target: Nullable<AbstractMesh>, scene: Scene);
  39133. private _follow;
  39134. /** @hidden */
  39135. _checkInputs(): void;
  39136. /**
  39137. * Returns the class name of the object.
  39138. * It is mostly used internally for serialization purposes.
  39139. */
  39140. getClassName(): string;
  39141. }
  39142. }
  39143. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39145. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39146. import { Nullable } from "babylonjs/types";
  39147. /**
  39148. * Manage the keyboard inputs to control the movement of a follow camera.
  39149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39150. */
  39151. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39152. /**
  39153. * Defines the camera the input is attached to.
  39154. */
  39155. camera: FollowCamera;
  39156. /**
  39157. * Defines the list of key codes associated with the up action (increase heightOffset)
  39158. */
  39159. keysHeightOffsetIncr: number[];
  39160. /**
  39161. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39162. */
  39163. keysHeightOffsetDecr: number[];
  39164. /**
  39165. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39166. */
  39167. keysHeightOffsetModifierAlt: boolean;
  39168. /**
  39169. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39170. */
  39171. keysHeightOffsetModifierCtrl: boolean;
  39172. /**
  39173. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39174. */
  39175. keysHeightOffsetModifierShift: boolean;
  39176. /**
  39177. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39178. */
  39179. keysRotationOffsetIncr: number[];
  39180. /**
  39181. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39182. */
  39183. keysRotationOffsetDecr: number[];
  39184. /**
  39185. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39186. */
  39187. keysRotationOffsetModifierAlt: boolean;
  39188. /**
  39189. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39190. */
  39191. keysRotationOffsetModifierCtrl: boolean;
  39192. /**
  39193. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39194. */
  39195. keysRotationOffsetModifierShift: boolean;
  39196. /**
  39197. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39198. */
  39199. keysRadiusIncr: number[];
  39200. /**
  39201. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39202. */
  39203. keysRadiusDecr: number[];
  39204. /**
  39205. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39206. */
  39207. keysRadiusModifierAlt: boolean;
  39208. /**
  39209. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39210. */
  39211. keysRadiusModifierCtrl: boolean;
  39212. /**
  39213. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39214. */
  39215. keysRadiusModifierShift: boolean;
  39216. /**
  39217. * Defines the rate of change of heightOffset.
  39218. */
  39219. heightSensibility: number;
  39220. /**
  39221. * Defines the rate of change of rotationOffset.
  39222. */
  39223. rotationSensibility: number;
  39224. /**
  39225. * Defines the rate of change of radius.
  39226. */
  39227. radiusSensibility: number;
  39228. private _keys;
  39229. private _ctrlPressed;
  39230. private _altPressed;
  39231. private _shiftPressed;
  39232. private _onCanvasBlurObserver;
  39233. private _onKeyboardObserver;
  39234. private _engine;
  39235. private _scene;
  39236. /**
  39237. * Attach the input controls to a specific dom element to get the input from.
  39238. * @param element Defines the element the controls should be listened from
  39239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39240. */
  39241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39242. /**
  39243. * Detach the current controls from the specified dom element.
  39244. * @param element Defines the element to stop listening the inputs from
  39245. */
  39246. detachControl(element: Nullable<HTMLElement>): void;
  39247. /**
  39248. * Update the current camera state depending on the inputs that have been used this frame.
  39249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39250. */
  39251. checkInputs(): void;
  39252. /**
  39253. * Gets the class name of the current input.
  39254. * @returns the class name
  39255. */
  39256. getClassName(): string;
  39257. /**
  39258. * Get the friendly name associated with the input class.
  39259. * @returns the input friendly name
  39260. */
  39261. getSimpleName(): string;
  39262. /**
  39263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39264. * allow modification of the heightOffset value.
  39265. */
  39266. private _modifierHeightOffset;
  39267. /**
  39268. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39269. * allow modification of the rotationOffset value.
  39270. */
  39271. private _modifierRotationOffset;
  39272. /**
  39273. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39274. * allow modification of the radius value.
  39275. */
  39276. private _modifierRadius;
  39277. }
  39278. }
  39279. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39280. import { Nullable } from "babylonjs/types";
  39281. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39283. import { Observable } from "babylonjs/Misc/observable";
  39284. module "babylonjs/Cameras/freeCameraInputsManager" {
  39285. interface FreeCameraInputsManager {
  39286. /**
  39287. * @hidden
  39288. */
  39289. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39290. /**
  39291. * Add orientation input support to the input manager.
  39292. * @returns the current input manager
  39293. */
  39294. addDeviceOrientation(): FreeCameraInputsManager;
  39295. }
  39296. }
  39297. /**
  39298. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39299. * Screen rotation is taken into account.
  39300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39301. */
  39302. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39303. private _camera;
  39304. private _screenOrientationAngle;
  39305. private _constantTranform;
  39306. private _screenQuaternion;
  39307. private _alpha;
  39308. private _beta;
  39309. private _gamma;
  39310. /**
  39311. * Can be used to detect if a device orientation sensor is availible on a device
  39312. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39313. * @returns a promise that will resolve on orientation change
  39314. */
  39315. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39316. /**
  39317. * @hidden
  39318. */
  39319. _onDeviceOrientationChangedObservable: Observable<void>;
  39320. /**
  39321. * Instantiates a new input
  39322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39323. */
  39324. constructor();
  39325. /**
  39326. * Define the camera controlled by the input.
  39327. */
  39328. camera: FreeCamera;
  39329. /**
  39330. * Attach the input controls to a specific dom element to get the input from.
  39331. * @param element Defines the element the controls should be listened from
  39332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39333. */
  39334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39335. private _orientationChanged;
  39336. private _deviceOrientation;
  39337. /**
  39338. * Detach the current controls from the specified dom element.
  39339. * @param element Defines the element to stop listening the inputs from
  39340. */
  39341. detachControl(element: Nullable<HTMLElement>): void;
  39342. /**
  39343. * Update the current camera state depending on the inputs that have been used this frame.
  39344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39345. */
  39346. checkInputs(): void;
  39347. /**
  39348. * Gets the class name of the current intput.
  39349. * @returns the class name
  39350. */
  39351. getClassName(): string;
  39352. /**
  39353. * Get the friendly name associated with the input class.
  39354. * @returns the input friendly name
  39355. */
  39356. getSimpleName(): string;
  39357. }
  39358. }
  39359. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39360. import { Nullable } from "babylonjs/types";
  39361. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39362. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39364. /**
  39365. * Manage the gamepad inputs to control a free camera.
  39366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39367. */
  39368. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39369. /**
  39370. * Define the camera the input is attached to.
  39371. */
  39372. camera: FreeCamera;
  39373. /**
  39374. * Define the Gamepad controlling the input
  39375. */
  39376. gamepad: Nullable<Gamepad>;
  39377. /**
  39378. * Defines the gamepad rotation sensiblity.
  39379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39380. */
  39381. gamepadAngularSensibility: number;
  39382. /**
  39383. * Defines the gamepad move sensiblity.
  39384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39385. */
  39386. gamepadMoveSensibility: number;
  39387. private _onGamepadConnectedObserver;
  39388. private _onGamepadDisconnectedObserver;
  39389. private _cameraTransform;
  39390. private _deltaTransform;
  39391. private _vector3;
  39392. private _vector2;
  39393. /**
  39394. * Attach the input controls to a specific dom element to get the input from.
  39395. * @param element Defines the element the controls should be listened from
  39396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39397. */
  39398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39399. /**
  39400. * Detach the current controls from the specified dom element.
  39401. * @param element Defines the element to stop listening the inputs from
  39402. */
  39403. detachControl(element: Nullable<HTMLElement>): void;
  39404. /**
  39405. * Update the current camera state depending on the inputs that have been used this frame.
  39406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39407. */
  39408. checkInputs(): void;
  39409. /**
  39410. * Gets the class name of the current intput.
  39411. * @returns the class name
  39412. */
  39413. getClassName(): string;
  39414. /**
  39415. * Get the friendly name associated with the input class.
  39416. * @returns the input friendly name
  39417. */
  39418. getSimpleName(): string;
  39419. }
  39420. }
  39421. declare module "babylonjs/Misc/virtualJoystick" {
  39422. import { Nullable } from "babylonjs/types";
  39423. import { Vector3 } from "babylonjs/Maths/math.vector";
  39424. /**
  39425. * Defines the potential axis of a Joystick
  39426. */
  39427. export enum JoystickAxis {
  39428. /** X axis */
  39429. X = 0,
  39430. /** Y axis */
  39431. Y = 1,
  39432. /** Z axis */
  39433. Z = 2
  39434. }
  39435. /**
  39436. * Class used to define virtual joystick (used in touch mode)
  39437. */
  39438. export class VirtualJoystick {
  39439. /**
  39440. * Gets or sets a boolean indicating that left and right values must be inverted
  39441. */
  39442. reverseLeftRight: boolean;
  39443. /**
  39444. * Gets or sets a boolean indicating that up and down values must be inverted
  39445. */
  39446. reverseUpDown: boolean;
  39447. /**
  39448. * Gets the offset value for the position (ie. the change of the position value)
  39449. */
  39450. deltaPosition: Vector3;
  39451. /**
  39452. * Gets a boolean indicating if the virtual joystick was pressed
  39453. */
  39454. pressed: boolean;
  39455. /**
  39456. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39457. */
  39458. static Canvas: Nullable<HTMLCanvasElement>;
  39459. private static _globalJoystickIndex;
  39460. private static vjCanvasContext;
  39461. private static vjCanvasWidth;
  39462. private static vjCanvasHeight;
  39463. private static halfWidth;
  39464. private _action;
  39465. private _axisTargetedByLeftAndRight;
  39466. private _axisTargetedByUpAndDown;
  39467. private _joystickSensibility;
  39468. private _inversedSensibility;
  39469. private _joystickPointerID;
  39470. private _joystickColor;
  39471. private _joystickPointerPos;
  39472. private _joystickPreviousPointerPos;
  39473. private _joystickPointerStartPos;
  39474. private _deltaJoystickVector;
  39475. private _leftJoystick;
  39476. private _touches;
  39477. private _onPointerDownHandlerRef;
  39478. private _onPointerMoveHandlerRef;
  39479. private _onPointerUpHandlerRef;
  39480. private _onResize;
  39481. /**
  39482. * Creates a new virtual joystick
  39483. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39484. */
  39485. constructor(leftJoystick?: boolean);
  39486. /**
  39487. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39488. * @param newJoystickSensibility defines the new sensibility
  39489. */
  39490. setJoystickSensibility(newJoystickSensibility: number): void;
  39491. private _onPointerDown;
  39492. private _onPointerMove;
  39493. private _onPointerUp;
  39494. /**
  39495. * Change the color of the virtual joystick
  39496. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39497. */
  39498. setJoystickColor(newColor: string): void;
  39499. /**
  39500. * Defines a callback to call when the joystick is touched
  39501. * @param action defines the callback
  39502. */
  39503. setActionOnTouch(action: () => any): void;
  39504. /**
  39505. * Defines which axis you'd like to control for left & right
  39506. * @param axis defines the axis to use
  39507. */
  39508. setAxisForLeftRight(axis: JoystickAxis): void;
  39509. /**
  39510. * Defines which axis you'd like to control for up & down
  39511. * @param axis defines the axis to use
  39512. */
  39513. setAxisForUpDown(axis: JoystickAxis): void;
  39514. private _drawVirtualJoystick;
  39515. /**
  39516. * Release internal HTML canvas
  39517. */
  39518. releaseCanvas(): void;
  39519. }
  39520. }
  39521. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39522. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39523. import { Nullable } from "babylonjs/types";
  39524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39526. module "babylonjs/Cameras/freeCameraInputsManager" {
  39527. interface FreeCameraInputsManager {
  39528. /**
  39529. * Add virtual joystick input support to the input manager.
  39530. * @returns the current input manager
  39531. */
  39532. addVirtualJoystick(): FreeCameraInputsManager;
  39533. }
  39534. }
  39535. /**
  39536. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39540. /**
  39541. * Defines the camera the input is attached to.
  39542. */
  39543. camera: FreeCamera;
  39544. private _leftjoystick;
  39545. private _rightjoystick;
  39546. /**
  39547. * Gets the left stick of the virtual joystick.
  39548. * @returns The virtual Joystick
  39549. */
  39550. getLeftJoystick(): VirtualJoystick;
  39551. /**
  39552. * Gets the right stick of the virtual joystick.
  39553. * @returns The virtual Joystick
  39554. */
  39555. getRightJoystick(): VirtualJoystick;
  39556. /**
  39557. * Update the current camera state depending on the inputs that have been used this frame.
  39558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39559. */
  39560. checkInputs(): void;
  39561. /**
  39562. * Attach the input controls to a specific dom element to get the input from.
  39563. * @param element Defines the element the controls should be listened from
  39564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39565. */
  39566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39567. /**
  39568. * Detach the current controls from the specified dom element.
  39569. * @param element Defines the element to stop listening the inputs from
  39570. */
  39571. detachControl(element: Nullable<HTMLElement>): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/index" {
  39585. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39586. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39587. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39588. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39589. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39590. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39591. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39592. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39593. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39594. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39595. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39596. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39597. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39598. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39599. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39600. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39601. }
  39602. declare module "babylonjs/Cameras/touchCamera" {
  39603. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39604. import { Scene } from "babylonjs/scene";
  39605. import { Vector3 } from "babylonjs/Maths/math.vector";
  39606. /**
  39607. * This represents a FPS type of camera controlled by touch.
  39608. * This is like a universal camera minus the Gamepad controls.
  39609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39610. */
  39611. export class TouchCamera extends FreeCamera {
  39612. /**
  39613. * Defines the touch sensibility for rotation.
  39614. * The higher the faster.
  39615. */
  39616. touchAngularSensibility: number;
  39617. /**
  39618. * Defines the touch sensibility for move.
  39619. * The higher the faster.
  39620. */
  39621. touchMoveSensibility: number;
  39622. /**
  39623. * Instantiates a new touch camera.
  39624. * This represents a FPS type of camera controlled by touch.
  39625. * This is like a universal camera minus the Gamepad controls.
  39626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39627. * @param name Define the name of the camera in the scene
  39628. * @param position Define the start position of the camera in the scene
  39629. * @param scene Define the scene the camera belongs to
  39630. */
  39631. constructor(name: string, position: Vector3, scene: Scene);
  39632. /**
  39633. * Gets the current object class name.
  39634. * @return the class name
  39635. */
  39636. getClassName(): string;
  39637. /** @hidden */
  39638. _setupInputs(): void;
  39639. }
  39640. }
  39641. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39642. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39643. import { Scene } from "babylonjs/scene";
  39644. import { Vector3 } from "babylonjs/Maths/math.vector";
  39645. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39646. import { Axis } from "babylonjs/Maths/math.axis";
  39647. /**
  39648. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39649. * being tilted forward or back and left or right.
  39650. */
  39651. export class DeviceOrientationCamera extends FreeCamera {
  39652. private _initialQuaternion;
  39653. private _quaternionCache;
  39654. private _tmpDragQuaternion;
  39655. private _disablePointerInputWhenUsingDeviceOrientation;
  39656. /**
  39657. * Creates a new device orientation camera
  39658. * @param name The name of the camera
  39659. * @param position The start position camera
  39660. * @param scene The scene the camera belongs to
  39661. */
  39662. constructor(name: string, position: Vector3, scene: Scene);
  39663. /**
  39664. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39665. */
  39666. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39667. private _dragFactor;
  39668. /**
  39669. * Enabled turning on the y axis when the orientation sensor is active
  39670. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39671. */
  39672. enableHorizontalDragging(dragFactor?: number): void;
  39673. /**
  39674. * Gets the current instance class name ("DeviceOrientationCamera").
  39675. * This helps avoiding instanceof at run time.
  39676. * @returns the class name
  39677. */
  39678. getClassName(): string;
  39679. /**
  39680. * @hidden
  39681. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39682. */
  39683. _checkInputs(): void;
  39684. /**
  39685. * Reset the camera to its default orientation on the specified axis only.
  39686. * @param axis The axis to reset
  39687. */
  39688. resetToCurrentRotation(axis?: Axis): void;
  39689. }
  39690. }
  39691. declare module "babylonjs/Gamepads/xboxGamepad" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39694. /**
  39695. * Defines supported buttons for XBox360 compatible gamepads
  39696. */
  39697. export enum Xbox360Button {
  39698. /** A */
  39699. A = 0,
  39700. /** B */
  39701. B = 1,
  39702. /** X */
  39703. X = 2,
  39704. /** Y */
  39705. Y = 3,
  39706. /** Start */
  39707. Start = 4,
  39708. /** Back */
  39709. Back = 5,
  39710. /** Left button */
  39711. LB = 6,
  39712. /** Right button */
  39713. RB = 7,
  39714. /** Left stick */
  39715. LeftStick = 8,
  39716. /** Right stick */
  39717. RightStick = 9
  39718. }
  39719. /** Defines values for XBox360 DPad */
  39720. export enum Xbox360Dpad {
  39721. /** Up */
  39722. Up = 0,
  39723. /** Down */
  39724. Down = 1,
  39725. /** Left */
  39726. Left = 2,
  39727. /** Right */
  39728. Right = 3
  39729. }
  39730. /**
  39731. * Defines a XBox360 gamepad
  39732. */
  39733. export class Xbox360Pad extends Gamepad {
  39734. private _leftTrigger;
  39735. private _rightTrigger;
  39736. private _onlefttriggerchanged;
  39737. private _onrighttriggerchanged;
  39738. private _onbuttondown;
  39739. private _onbuttonup;
  39740. private _ondpaddown;
  39741. private _ondpadup;
  39742. /** Observable raised when a button is pressed */
  39743. onButtonDownObservable: Observable<Xbox360Button>;
  39744. /** Observable raised when a button is released */
  39745. onButtonUpObservable: Observable<Xbox360Button>;
  39746. /** Observable raised when a pad is pressed */
  39747. onPadDownObservable: Observable<Xbox360Dpad>;
  39748. /** Observable raised when a pad is released */
  39749. onPadUpObservable: Observable<Xbox360Dpad>;
  39750. private _buttonA;
  39751. private _buttonB;
  39752. private _buttonX;
  39753. private _buttonY;
  39754. private _buttonBack;
  39755. private _buttonStart;
  39756. private _buttonLB;
  39757. private _buttonRB;
  39758. private _buttonLeftStick;
  39759. private _buttonRightStick;
  39760. private _dPadUp;
  39761. private _dPadDown;
  39762. private _dPadLeft;
  39763. private _dPadRight;
  39764. private _isXboxOnePad;
  39765. /**
  39766. * Creates a new XBox360 gamepad object
  39767. * @param id defines the id of this gamepad
  39768. * @param index defines its index
  39769. * @param gamepad defines the internal HTML gamepad object
  39770. * @param xboxOne defines if it is a XBox One gamepad
  39771. */
  39772. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39773. /**
  39774. * Defines the callback to call when left trigger is pressed
  39775. * @param callback defines the callback to use
  39776. */
  39777. onlefttriggerchanged(callback: (value: number) => void): void;
  39778. /**
  39779. * Defines the callback to call when right trigger is pressed
  39780. * @param callback defines the callback to use
  39781. */
  39782. onrighttriggerchanged(callback: (value: number) => void): void;
  39783. /**
  39784. * Gets the left trigger value
  39785. */
  39786. /**
  39787. * Sets the left trigger value
  39788. */
  39789. leftTrigger: number;
  39790. /**
  39791. * Gets the right trigger value
  39792. */
  39793. /**
  39794. * Sets the right trigger value
  39795. */
  39796. rightTrigger: number;
  39797. /**
  39798. * Defines the callback to call when a button is pressed
  39799. * @param callback defines the callback to use
  39800. */
  39801. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39802. /**
  39803. * Defines the callback to call when a button is released
  39804. * @param callback defines the callback to use
  39805. */
  39806. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39807. /**
  39808. * Defines the callback to call when a pad is pressed
  39809. * @param callback defines the callback to use
  39810. */
  39811. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39812. /**
  39813. * Defines the callback to call when a pad is released
  39814. * @param callback defines the callback to use
  39815. */
  39816. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39817. private _setButtonValue;
  39818. private _setDPadValue;
  39819. /**
  39820. * Gets the value of the `A` button
  39821. */
  39822. /**
  39823. * Sets the value of the `A` button
  39824. */
  39825. buttonA: number;
  39826. /**
  39827. * Gets the value of the `B` button
  39828. */
  39829. /**
  39830. * Sets the value of the `B` button
  39831. */
  39832. buttonB: number;
  39833. /**
  39834. * Gets the value of the `X` button
  39835. */
  39836. /**
  39837. * Sets the value of the `X` button
  39838. */
  39839. buttonX: number;
  39840. /**
  39841. * Gets the value of the `Y` button
  39842. */
  39843. /**
  39844. * Sets the value of the `Y` button
  39845. */
  39846. buttonY: number;
  39847. /**
  39848. * Gets the value of the `Start` button
  39849. */
  39850. /**
  39851. * Sets the value of the `Start` button
  39852. */
  39853. buttonStart: number;
  39854. /**
  39855. * Gets the value of the `Back` button
  39856. */
  39857. /**
  39858. * Sets the value of the `Back` button
  39859. */
  39860. buttonBack: number;
  39861. /**
  39862. * Gets the value of the `Left` button
  39863. */
  39864. /**
  39865. * Sets the value of the `Left` button
  39866. */
  39867. buttonLB: number;
  39868. /**
  39869. * Gets the value of the `Right` button
  39870. */
  39871. /**
  39872. * Sets the value of the `Right` button
  39873. */
  39874. buttonRB: number;
  39875. /**
  39876. * Gets the value of the Left joystick
  39877. */
  39878. /**
  39879. * Sets the value of the Left joystick
  39880. */
  39881. buttonLeftStick: number;
  39882. /**
  39883. * Gets the value of the Right joystick
  39884. */
  39885. /**
  39886. * Sets the value of the Right joystick
  39887. */
  39888. buttonRightStick: number;
  39889. /**
  39890. * Gets the value of D-pad up
  39891. */
  39892. /**
  39893. * Sets the value of D-pad up
  39894. */
  39895. dPadUp: number;
  39896. /**
  39897. * Gets the value of D-pad down
  39898. */
  39899. /**
  39900. * Sets the value of D-pad down
  39901. */
  39902. dPadDown: number;
  39903. /**
  39904. * Gets the value of D-pad left
  39905. */
  39906. /**
  39907. * Sets the value of D-pad left
  39908. */
  39909. dPadLeft: number;
  39910. /**
  39911. * Gets the value of D-pad right
  39912. */
  39913. /**
  39914. * Sets the value of D-pad right
  39915. */
  39916. dPadRight: number;
  39917. /**
  39918. * Force the gamepad to synchronize with device values
  39919. */
  39920. update(): void;
  39921. /**
  39922. * Disposes the gamepad
  39923. */
  39924. dispose(): void;
  39925. }
  39926. }
  39927. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39928. import { Observable } from "babylonjs/Misc/observable";
  39929. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39930. /**
  39931. * Defines supported buttons for DualShock compatible gamepads
  39932. */
  39933. export enum DualShockButton {
  39934. /** Cross */
  39935. Cross = 0,
  39936. /** Circle */
  39937. Circle = 1,
  39938. /** Square */
  39939. Square = 2,
  39940. /** Triangle */
  39941. Triangle = 3,
  39942. /** Options */
  39943. Options = 4,
  39944. /** Share */
  39945. Share = 5,
  39946. /** L1 */
  39947. L1 = 6,
  39948. /** R1 */
  39949. R1 = 7,
  39950. /** Left stick */
  39951. LeftStick = 8,
  39952. /** Right stick */
  39953. RightStick = 9
  39954. }
  39955. /** Defines values for DualShock DPad */
  39956. export enum DualShockDpad {
  39957. /** Up */
  39958. Up = 0,
  39959. /** Down */
  39960. Down = 1,
  39961. /** Left */
  39962. Left = 2,
  39963. /** Right */
  39964. Right = 3
  39965. }
  39966. /**
  39967. * Defines a DualShock gamepad
  39968. */
  39969. export class DualShockPad extends Gamepad {
  39970. private _leftTrigger;
  39971. private _rightTrigger;
  39972. private _onlefttriggerchanged;
  39973. private _onrighttriggerchanged;
  39974. private _onbuttondown;
  39975. private _onbuttonup;
  39976. private _ondpaddown;
  39977. private _ondpadup;
  39978. /** Observable raised when a button is pressed */
  39979. onButtonDownObservable: Observable<DualShockButton>;
  39980. /** Observable raised when a button is released */
  39981. onButtonUpObservable: Observable<DualShockButton>;
  39982. /** Observable raised when a pad is pressed */
  39983. onPadDownObservable: Observable<DualShockDpad>;
  39984. /** Observable raised when a pad is released */
  39985. onPadUpObservable: Observable<DualShockDpad>;
  39986. private _buttonCross;
  39987. private _buttonCircle;
  39988. private _buttonSquare;
  39989. private _buttonTriangle;
  39990. private _buttonShare;
  39991. private _buttonOptions;
  39992. private _buttonL1;
  39993. private _buttonR1;
  39994. private _buttonLeftStick;
  39995. private _buttonRightStick;
  39996. private _dPadUp;
  39997. private _dPadDown;
  39998. private _dPadLeft;
  39999. private _dPadRight;
  40000. /**
  40001. * Creates a new DualShock gamepad object
  40002. * @param id defines the id of this gamepad
  40003. * @param index defines its index
  40004. * @param gamepad defines the internal HTML gamepad object
  40005. */
  40006. constructor(id: string, index: number, gamepad: any);
  40007. /**
  40008. * Defines the callback to call when left trigger is pressed
  40009. * @param callback defines the callback to use
  40010. */
  40011. onlefttriggerchanged(callback: (value: number) => void): void;
  40012. /**
  40013. * Defines the callback to call when right trigger is pressed
  40014. * @param callback defines the callback to use
  40015. */
  40016. onrighttriggerchanged(callback: (value: number) => void): void;
  40017. /**
  40018. * Gets the left trigger value
  40019. */
  40020. /**
  40021. * Sets the left trigger value
  40022. */
  40023. leftTrigger: number;
  40024. /**
  40025. * Gets the right trigger value
  40026. */
  40027. /**
  40028. * Sets the right trigger value
  40029. */
  40030. rightTrigger: number;
  40031. /**
  40032. * Defines the callback to call when a button is pressed
  40033. * @param callback defines the callback to use
  40034. */
  40035. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40036. /**
  40037. * Defines the callback to call when a button is released
  40038. * @param callback defines the callback to use
  40039. */
  40040. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40041. /**
  40042. * Defines the callback to call when a pad is pressed
  40043. * @param callback defines the callback to use
  40044. */
  40045. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40046. /**
  40047. * Defines the callback to call when a pad is released
  40048. * @param callback defines the callback to use
  40049. */
  40050. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40051. private _setButtonValue;
  40052. private _setDPadValue;
  40053. /**
  40054. * Gets the value of the `Cross` button
  40055. */
  40056. /**
  40057. * Sets the value of the `Cross` button
  40058. */
  40059. buttonCross: number;
  40060. /**
  40061. * Gets the value of the `Circle` button
  40062. */
  40063. /**
  40064. * Sets the value of the `Circle` button
  40065. */
  40066. buttonCircle: number;
  40067. /**
  40068. * Gets the value of the `Square` button
  40069. */
  40070. /**
  40071. * Sets the value of the `Square` button
  40072. */
  40073. buttonSquare: number;
  40074. /**
  40075. * Gets the value of the `Triangle` button
  40076. */
  40077. /**
  40078. * Sets the value of the `Triangle` button
  40079. */
  40080. buttonTriangle: number;
  40081. /**
  40082. * Gets the value of the `Options` button
  40083. */
  40084. /**
  40085. * Sets the value of the `Options` button
  40086. */
  40087. buttonOptions: number;
  40088. /**
  40089. * Gets the value of the `Share` button
  40090. */
  40091. /**
  40092. * Sets the value of the `Share` button
  40093. */
  40094. buttonShare: number;
  40095. /**
  40096. * Gets the value of the `L1` button
  40097. */
  40098. /**
  40099. * Sets the value of the `L1` button
  40100. */
  40101. buttonL1: number;
  40102. /**
  40103. * Gets the value of the `R1` button
  40104. */
  40105. /**
  40106. * Sets the value of the `R1` button
  40107. */
  40108. buttonR1: number;
  40109. /**
  40110. * Gets the value of the Left joystick
  40111. */
  40112. /**
  40113. * Sets the value of the Left joystick
  40114. */
  40115. buttonLeftStick: number;
  40116. /**
  40117. * Gets the value of the Right joystick
  40118. */
  40119. /**
  40120. * Sets the value of the Right joystick
  40121. */
  40122. buttonRightStick: number;
  40123. /**
  40124. * Gets the value of D-pad up
  40125. */
  40126. /**
  40127. * Sets the value of D-pad up
  40128. */
  40129. dPadUp: number;
  40130. /**
  40131. * Gets the value of D-pad down
  40132. */
  40133. /**
  40134. * Sets the value of D-pad down
  40135. */
  40136. dPadDown: number;
  40137. /**
  40138. * Gets the value of D-pad left
  40139. */
  40140. /**
  40141. * Sets the value of D-pad left
  40142. */
  40143. dPadLeft: number;
  40144. /**
  40145. * Gets the value of D-pad right
  40146. */
  40147. /**
  40148. * Sets the value of D-pad right
  40149. */
  40150. dPadRight: number;
  40151. /**
  40152. * Force the gamepad to synchronize with device values
  40153. */
  40154. update(): void;
  40155. /**
  40156. * Disposes the gamepad
  40157. */
  40158. dispose(): void;
  40159. }
  40160. }
  40161. declare module "babylonjs/Gamepads/gamepadManager" {
  40162. import { Observable } from "babylonjs/Misc/observable";
  40163. import { Nullable } from "babylonjs/types";
  40164. import { Scene } from "babylonjs/scene";
  40165. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40166. /**
  40167. * Manager for handling gamepads
  40168. */
  40169. export class GamepadManager {
  40170. private _scene?;
  40171. private _babylonGamepads;
  40172. private _oneGamepadConnected;
  40173. /** @hidden */
  40174. _isMonitoring: boolean;
  40175. private _gamepadEventSupported;
  40176. private _gamepadSupport;
  40177. /**
  40178. * observable to be triggered when the gamepad controller has been connected
  40179. */
  40180. onGamepadConnectedObservable: Observable<Gamepad>;
  40181. /**
  40182. * observable to be triggered when the gamepad controller has been disconnected
  40183. */
  40184. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40185. private _onGamepadConnectedEvent;
  40186. private _onGamepadDisconnectedEvent;
  40187. /**
  40188. * Initializes the gamepad manager
  40189. * @param _scene BabylonJS scene
  40190. */
  40191. constructor(_scene?: Scene | undefined);
  40192. /**
  40193. * The gamepads in the game pad manager
  40194. */
  40195. readonly gamepads: Gamepad[];
  40196. /**
  40197. * Get the gamepad controllers based on type
  40198. * @param type The type of gamepad controller
  40199. * @returns Nullable gamepad
  40200. */
  40201. getGamepadByType(type?: number): Nullable<Gamepad>;
  40202. /**
  40203. * Disposes the gamepad manager
  40204. */
  40205. dispose(): void;
  40206. private _addNewGamepad;
  40207. private _startMonitoringGamepads;
  40208. private _stopMonitoringGamepads;
  40209. /** @hidden */
  40210. _checkGamepadsStatus(): void;
  40211. private _updateGamepadObjects;
  40212. }
  40213. }
  40214. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40215. import { Nullable } from "babylonjs/types";
  40216. import { Scene } from "babylonjs/scene";
  40217. import { ISceneComponent } from "babylonjs/sceneComponent";
  40218. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40219. module "babylonjs/scene" {
  40220. interface Scene {
  40221. /** @hidden */
  40222. _gamepadManager: Nullable<GamepadManager>;
  40223. /**
  40224. * Gets the gamepad manager associated with the scene
  40225. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40226. */
  40227. gamepadManager: GamepadManager;
  40228. }
  40229. }
  40230. module "babylonjs/Cameras/freeCameraInputsManager" {
  40231. /**
  40232. * Interface representing a free camera inputs manager
  40233. */
  40234. interface FreeCameraInputsManager {
  40235. /**
  40236. * Adds gamepad input support to the FreeCameraInputsManager.
  40237. * @returns the FreeCameraInputsManager
  40238. */
  40239. addGamepad(): FreeCameraInputsManager;
  40240. }
  40241. }
  40242. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40243. /**
  40244. * Interface representing an arc rotate camera inputs manager
  40245. */
  40246. interface ArcRotateCameraInputsManager {
  40247. /**
  40248. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40249. * @returns the camera inputs manager
  40250. */
  40251. addGamepad(): ArcRotateCameraInputsManager;
  40252. }
  40253. }
  40254. /**
  40255. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40256. */
  40257. export class GamepadSystemSceneComponent implements ISceneComponent {
  40258. /**
  40259. * The component name helpfull to identify the component in the list of scene components.
  40260. */
  40261. readonly name: string;
  40262. /**
  40263. * The scene the component belongs to.
  40264. */
  40265. scene: Scene;
  40266. /**
  40267. * Creates a new instance of the component for the given scene
  40268. * @param scene Defines the scene to register the component in
  40269. */
  40270. constructor(scene: Scene);
  40271. /**
  40272. * Registers the component in a given scene
  40273. */
  40274. register(): void;
  40275. /**
  40276. * Rebuilds the elements related to this component in case of
  40277. * context lost for instance.
  40278. */
  40279. rebuild(): void;
  40280. /**
  40281. * Disposes the component and the associated ressources
  40282. */
  40283. dispose(): void;
  40284. private _beforeCameraUpdate;
  40285. }
  40286. }
  40287. declare module "babylonjs/Cameras/universalCamera" {
  40288. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40289. import { Scene } from "babylonjs/scene";
  40290. import { Vector3 } from "babylonjs/Maths/math.vector";
  40291. import "babylonjs/Gamepads/gamepadSceneComponent";
  40292. /**
  40293. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  40294. * which still works and will still be found in many Playgrounds.
  40295. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40296. */
  40297. export class UniversalCamera extends TouchCamera {
  40298. /**
  40299. * Defines the gamepad rotation sensiblity.
  40300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40301. */
  40302. gamepadAngularSensibility: number;
  40303. /**
  40304. * Defines the gamepad move sensiblity.
  40305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40306. */
  40307. gamepadMoveSensibility: number;
  40308. /**
  40309. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  40310. * which still works and will still be found in many Playgrounds.
  40311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40312. * @param name Define the name of the camera in the scene
  40313. * @param position Define the start position of the camera in the scene
  40314. * @param scene Define the scene the camera belongs to
  40315. */
  40316. constructor(name: string, position: Vector3, scene: Scene);
  40317. /**
  40318. * Gets the current object class name.
  40319. * @return the class name
  40320. */
  40321. getClassName(): string;
  40322. }
  40323. }
  40324. declare module "babylonjs/Cameras/gamepadCamera" {
  40325. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40326. import { Scene } from "babylonjs/scene";
  40327. import { Vector3 } from "babylonjs/Maths/math.vector";
  40328. /**
  40329. * This represents a FPS type of camera. This is only here for back compat purpose.
  40330. * Please use the UniversalCamera instead as both are identical.
  40331. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40332. */
  40333. export class GamepadCamera extends UniversalCamera {
  40334. /**
  40335. * Instantiates a new Gamepad Camera
  40336. * This represents a FPS type of camera. This is only here for back compat purpose.
  40337. * Please use the UniversalCamera instead as both are identical.
  40338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40339. * @param name Define the name of the camera in the scene
  40340. * @param position Define the start position of the camera in the scene
  40341. * @param scene Define the scene the camera belongs to
  40342. */
  40343. constructor(name: string, position: Vector3, scene: Scene);
  40344. /**
  40345. * Gets the current object class name.
  40346. * @return the class name
  40347. */
  40348. getClassName(): string;
  40349. }
  40350. }
  40351. declare module "babylonjs/Shaders/pass.fragment" {
  40352. /** @hidden */
  40353. export var passPixelShader: {
  40354. name: string;
  40355. shader: string;
  40356. };
  40357. }
  40358. declare module "babylonjs/Shaders/passCube.fragment" {
  40359. /** @hidden */
  40360. export var passCubePixelShader: {
  40361. name: string;
  40362. shader: string;
  40363. };
  40364. }
  40365. declare module "babylonjs/PostProcesses/passPostProcess" {
  40366. import { Nullable } from "babylonjs/types";
  40367. import { Camera } from "babylonjs/Cameras/camera";
  40368. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40369. import { Engine } from "babylonjs/Engines/engine";
  40370. import "babylonjs/Shaders/pass.fragment";
  40371. import "babylonjs/Shaders/passCube.fragment";
  40372. /**
  40373. * PassPostProcess which produces an output the same as it's input
  40374. */
  40375. export class PassPostProcess extends PostProcess {
  40376. /**
  40377. * Creates the PassPostProcess
  40378. * @param name The name of the effect.
  40379. * @param options The required width/height ratio to downsize to before computing the render pass.
  40380. * @param camera The camera to apply the render pass to.
  40381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40382. * @param engine The engine which the post process will be applied. (default: current engine)
  40383. * @param reusable If the post process can be reused on the same frame. (default: false)
  40384. * @param textureType The type of texture to be used when performing the post processing.
  40385. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  40386. */
  40387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40388. }
  40389. /**
  40390. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40391. */
  40392. export class PassCubePostProcess extends PostProcess {
  40393. private _face;
  40394. /**
  40395. * Gets or sets the cube face to display.
  40396. * * 0 is +X
  40397. * * 1 is -X
  40398. * * 2 is +Y
  40399. * * 3 is -Y
  40400. * * 4 is +Z
  40401. * * 5 is -Z
  40402. */
  40403. face: number;
  40404. /**
  40405. * Creates the PassCubePostProcess
  40406. * @param name The name of the effect.
  40407. * @param options The required width/height ratio to downsize to before computing the render pass.
  40408. * @param camera The camera to apply the render pass to.
  40409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40410. * @param engine The engine which the post process will be applied. (default: current engine)
  40411. * @param reusable If the post process can be reused on the same frame. (default: false)
  40412. * @param textureType The type of texture to be used when performing the post processing.
  40413. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  40414. */
  40415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40416. }
  40417. }
  40418. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40419. /** @hidden */
  40420. export var anaglyphPixelShader: {
  40421. name: string;
  40422. shader: string;
  40423. };
  40424. }
  40425. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40426. import { Engine } from "babylonjs/Engines/engine";
  40427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40428. import { Camera } from "babylonjs/Cameras/camera";
  40429. import "babylonjs/Shaders/anaglyph.fragment";
  40430. /**
  40431. * Postprocess used to generate anaglyphic rendering
  40432. */
  40433. export class AnaglyphPostProcess extends PostProcess {
  40434. private _passedProcess;
  40435. /**
  40436. * Creates a new AnaglyphPostProcess
  40437. * @param name defines postprocess name
  40438. * @param options defines creation options or target ratio scale
  40439. * @param rigCameras defines cameras using this postprocess
  40440. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40441. * @param engine defines hosting engine
  40442. * @param reusable defines if the postprocess will be reused multiple times per frame
  40443. */
  40444. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40445. }
  40446. }
  40447. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40448. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40450. import { Scene } from "babylonjs/scene";
  40451. import { Vector3 } from "babylonjs/Maths/math.vector";
  40452. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40453. /**
  40454. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40455. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40456. */
  40457. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40458. /**
  40459. * Creates a new AnaglyphArcRotateCamera
  40460. * @param name defines camera name
  40461. * @param alpha defines alpha angle (in radians)
  40462. * @param beta defines beta angle (in radians)
  40463. * @param radius defines radius
  40464. * @param target defines camera target
  40465. * @param interaxialDistance defines distance between each color axis
  40466. * @param scene defines the hosting scene
  40467. */
  40468. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40469. /**
  40470. * Gets camera class name
  40471. * @returns AnaglyphArcRotateCamera
  40472. */
  40473. getClassName(): string;
  40474. }
  40475. }
  40476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40477. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40478. import { Scene } from "babylonjs/scene";
  40479. import { Vector3 } from "babylonjs/Maths/math.vector";
  40480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40481. /**
  40482. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40484. */
  40485. export class AnaglyphFreeCamera extends FreeCamera {
  40486. /**
  40487. * Creates a new AnaglyphFreeCamera
  40488. * @param name defines camera name
  40489. * @param position defines initial position
  40490. * @param interaxialDistance defines distance between each color axis
  40491. * @param scene defines the hosting scene
  40492. */
  40493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40494. /**
  40495. * Gets camera class name
  40496. * @returns AnaglyphFreeCamera
  40497. */
  40498. getClassName(): string;
  40499. }
  40500. }
  40501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40502. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40503. import { Scene } from "babylonjs/scene";
  40504. import { Vector3 } from "babylonjs/Maths/math.vector";
  40505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40506. /**
  40507. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40509. */
  40510. export class AnaglyphGamepadCamera extends GamepadCamera {
  40511. /**
  40512. * Creates a new AnaglyphGamepadCamera
  40513. * @param name defines camera name
  40514. * @param position defines initial position
  40515. * @param interaxialDistance defines distance between each color axis
  40516. * @param scene defines the hosting scene
  40517. */
  40518. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40519. /**
  40520. * Gets camera class name
  40521. * @returns AnaglyphGamepadCamera
  40522. */
  40523. getClassName(): string;
  40524. }
  40525. }
  40526. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40527. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40528. import { Scene } from "babylonjs/scene";
  40529. import { Vector3 } from "babylonjs/Maths/math.vector";
  40530. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40531. /**
  40532. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40533. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40534. */
  40535. export class AnaglyphUniversalCamera extends UniversalCamera {
  40536. /**
  40537. * Creates a new AnaglyphUniversalCamera
  40538. * @param name defines camera name
  40539. * @param position defines initial position
  40540. * @param interaxialDistance defines distance between each color axis
  40541. * @param scene defines the hosting scene
  40542. */
  40543. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40544. /**
  40545. * Gets camera class name
  40546. * @returns AnaglyphUniversalCamera
  40547. */
  40548. getClassName(): string;
  40549. }
  40550. }
  40551. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40552. /** @hidden */
  40553. export var stereoscopicInterlacePixelShader: {
  40554. name: string;
  40555. shader: string;
  40556. };
  40557. }
  40558. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40559. import { Camera } from "babylonjs/Cameras/camera";
  40560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40561. import { Engine } from "babylonjs/Engines/engine";
  40562. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40563. /**
  40564. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40565. */
  40566. export class StereoscopicInterlacePostProcess extends PostProcess {
  40567. private _stepSize;
  40568. private _passedProcess;
  40569. /**
  40570. * Initializes a StereoscopicInterlacePostProcess
  40571. * @param name The name of the effect.
  40572. * @param rigCameras The rig cameras to be appled to the post process
  40573. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40575. * @param engine The engine which the post process will be applied. (default: current engine)
  40576. * @param reusable If the post process can be reused on the same frame. (default: false)
  40577. */
  40578. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40579. }
  40580. }
  40581. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40582. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40583. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40584. import { Scene } from "babylonjs/scene";
  40585. import { Vector3 } from "babylonjs/Maths/math.vector";
  40586. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40587. /**
  40588. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40589. * @see http://doc.babylonjs.com/features/cameras
  40590. */
  40591. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40592. /**
  40593. * Creates a new StereoscopicArcRotateCamera
  40594. * @param name defines camera name
  40595. * @param alpha defines alpha angle (in radians)
  40596. * @param beta defines beta angle (in radians)
  40597. * @param radius defines radius
  40598. * @param target defines camera target
  40599. * @param interaxialDistance defines distance between each color axis
  40600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40601. * @param scene defines the hosting scene
  40602. */
  40603. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40604. /**
  40605. * Gets camera class name
  40606. * @returns StereoscopicArcRotateCamera
  40607. */
  40608. getClassName(): string;
  40609. }
  40610. }
  40611. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40613. import { Scene } from "babylonjs/scene";
  40614. import { Vector3 } from "babylonjs/Maths/math.vector";
  40615. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40616. /**
  40617. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40618. * @see http://doc.babylonjs.com/features/cameras
  40619. */
  40620. export class StereoscopicFreeCamera extends FreeCamera {
  40621. /**
  40622. * Creates a new StereoscopicFreeCamera
  40623. * @param name defines camera name
  40624. * @param position defines initial position
  40625. * @param interaxialDistance defines distance between each color axis
  40626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40627. * @param scene defines the hosting scene
  40628. */
  40629. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40630. /**
  40631. * Gets camera class name
  40632. * @returns StereoscopicFreeCamera
  40633. */
  40634. getClassName(): string;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40638. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40639. import { Scene } from "babylonjs/scene";
  40640. import { Vector3 } from "babylonjs/Maths/math.vector";
  40641. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40642. /**
  40643. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40644. * @see http://doc.babylonjs.com/features/cameras
  40645. */
  40646. export class StereoscopicGamepadCamera extends GamepadCamera {
  40647. /**
  40648. * Creates a new StereoscopicGamepadCamera
  40649. * @param name defines camera name
  40650. * @param position defines initial position
  40651. * @param interaxialDistance defines distance between each color axis
  40652. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40653. * @param scene defines the hosting scene
  40654. */
  40655. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40656. /**
  40657. * Gets camera class name
  40658. * @returns StereoscopicGamepadCamera
  40659. */
  40660. getClassName(): string;
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40664. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40665. import { Scene } from "babylonjs/scene";
  40666. import { Vector3 } from "babylonjs/Maths/math.vector";
  40667. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40668. /**
  40669. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40670. * @see http://doc.babylonjs.com/features/cameras
  40671. */
  40672. export class StereoscopicUniversalCamera extends UniversalCamera {
  40673. /**
  40674. * Creates a new StereoscopicUniversalCamera
  40675. * @param name defines camera name
  40676. * @param position defines initial position
  40677. * @param interaxialDistance defines distance between each color axis
  40678. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40679. * @param scene defines the hosting scene
  40680. */
  40681. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns StereoscopicUniversalCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40690. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40691. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40692. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40693. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40694. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40695. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40696. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40697. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40698. }
  40699. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40700. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40701. import { Scene } from "babylonjs/scene";
  40702. import { Vector3 } from "babylonjs/Maths/math.vector";
  40703. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40704. /**
  40705. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40706. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40707. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40708. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40709. */
  40710. export class VirtualJoysticksCamera extends FreeCamera {
  40711. /**
  40712. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40713. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40714. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40715. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40716. * @param name Define the name of the camera in the scene
  40717. * @param position Define the start position of the camera in the scene
  40718. * @param scene Define the scene the camera belongs to
  40719. */
  40720. constructor(name: string, position: Vector3, scene: Scene);
  40721. /**
  40722. * Gets the current object class name.
  40723. * @return the class name
  40724. */
  40725. getClassName(): string;
  40726. }
  40727. }
  40728. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40729. import { Matrix } from "babylonjs/Maths/math.vector";
  40730. /**
  40731. * This represents all the required metrics to create a VR camera.
  40732. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40733. */
  40734. export class VRCameraMetrics {
  40735. /**
  40736. * Define the horizontal resolution off the screen.
  40737. */
  40738. hResolution: number;
  40739. /**
  40740. * Define the vertical resolution off the screen.
  40741. */
  40742. vResolution: number;
  40743. /**
  40744. * Define the horizontal screen size.
  40745. */
  40746. hScreenSize: number;
  40747. /**
  40748. * Define the vertical screen size.
  40749. */
  40750. vScreenSize: number;
  40751. /**
  40752. * Define the vertical screen center position.
  40753. */
  40754. vScreenCenter: number;
  40755. /**
  40756. * Define the distance of the eyes to the screen.
  40757. */
  40758. eyeToScreenDistance: number;
  40759. /**
  40760. * Define the distance between both lenses
  40761. */
  40762. lensSeparationDistance: number;
  40763. /**
  40764. * Define the distance between both viewer's eyes.
  40765. */
  40766. interpupillaryDistance: number;
  40767. /**
  40768. * Define the distortion factor of the VR postprocess.
  40769. * Please, touch with care.
  40770. */
  40771. distortionK: number[];
  40772. /**
  40773. * Define the chromatic aberration correction factors for the VR post process.
  40774. */
  40775. chromaAbCorrection: number[];
  40776. /**
  40777. * Define the scale factor of the post process.
  40778. * The smaller the better but the slower.
  40779. */
  40780. postProcessScaleFactor: number;
  40781. /**
  40782. * Define an offset for the lens center.
  40783. */
  40784. lensCenterOffset: number;
  40785. /**
  40786. * Define if the current vr camera should compensate the distortion of the lense or not.
  40787. */
  40788. compensateDistortion: boolean;
  40789. /**
  40790. * Defines if multiview should be enabled when rendering (Default: false)
  40791. */
  40792. multiviewEnabled: boolean;
  40793. /**
  40794. * Gets the rendering aspect ratio based on the provided resolutions.
  40795. */
  40796. readonly aspectRatio: number;
  40797. /**
  40798. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40799. */
  40800. readonly aspectRatioFov: number;
  40801. /**
  40802. * @hidden
  40803. */
  40804. readonly leftHMatrix: Matrix;
  40805. /**
  40806. * @hidden
  40807. */
  40808. readonly rightHMatrix: Matrix;
  40809. /**
  40810. * @hidden
  40811. */
  40812. readonly leftPreViewMatrix: Matrix;
  40813. /**
  40814. * @hidden
  40815. */
  40816. readonly rightPreViewMatrix: Matrix;
  40817. /**
  40818. * Get the default VRMetrics based on the most generic setup.
  40819. * @returns the default vr metrics
  40820. */
  40821. static GetDefault(): VRCameraMetrics;
  40822. }
  40823. }
  40824. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40825. /** @hidden */
  40826. export var vrDistortionCorrectionPixelShader: {
  40827. name: string;
  40828. shader: string;
  40829. };
  40830. }
  40831. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40832. import { Camera } from "babylonjs/Cameras/camera";
  40833. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40835. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40836. /**
  40837. * VRDistortionCorrectionPostProcess used for mobile VR
  40838. */
  40839. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40840. private _isRightEye;
  40841. private _distortionFactors;
  40842. private _postProcessScaleFactor;
  40843. private _lensCenterOffset;
  40844. private _scaleIn;
  40845. private _scaleFactor;
  40846. private _lensCenter;
  40847. /**
  40848. * Initializes the VRDistortionCorrectionPostProcess
  40849. * @param name The name of the effect.
  40850. * @param camera The camera to apply the render pass to.
  40851. * @param isRightEye If this is for the right eye distortion
  40852. * @param vrMetrics All the required metrics for the VR camera
  40853. */
  40854. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40855. }
  40856. }
  40857. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40858. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40860. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40861. import { Scene } from "babylonjs/scene";
  40862. import { Vector3 } from "babylonjs/Maths/math.vector";
  40863. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40864. import "babylonjs/Cameras/RigModes/vrRigMode";
  40865. /**
  40866. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40868. */
  40869. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40870. /**
  40871. * Creates a new VRDeviceOrientationArcRotateCamera
  40872. * @param name defines camera name
  40873. * @param alpha defines the camera rotation along the logitudinal axis
  40874. * @param beta defines the camera rotation along the latitudinal axis
  40875. * @param radius defines the camera distance from its target
  40876. * @param target defines the camera target
  40877. * @param scene defines the scene the camera belongs to
  40878. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40879. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40880. */
  40881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40882. /**
  40883. * Gets camera class name
  40884. * @returns VRDeviceOrientationArcRotateCamera
  40885. */
  40886. getClassName(): string;
  40887. }
  40888. }
  40889. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40890. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40891. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40892. import { Scene } from "babylonjs/scene";
  40893. import { Vector3 } from "babylonjs/Maths/math.vector";
  40894. import "babylonjs/Cameras/RigModes/vrRigMode";
  40895. /**
  40896. * Camera used to simulate VR rendering (based on FreeCamera)
  40897. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40898. */
  40899. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40900. /**
  40901. * Creates a new VRDeviceOrientationFreeCamera
  40902. * @param name defines camera name
  40903. * @param position defines the start position of the camera
  40904. * @param scene defines the scene the camera belongs to
  40905. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40906. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40907. */
  40908. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40909. /**
  40910. * Gets camera class name
  40911. * @returns VRDeviceOrientationFreeCamera
  40912. */
  40913. getClassName(): string;
  40914. }
  40915. }
  40916. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40917. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40918. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40919. import { Scene } from "babylonjs/scene";
  40920. import { Vector3 } from "babylonjs/Maths/math.vector";
  40921. import "babylonjs/Gamepads/gamepadSceneComponent";
  40922. /**
  40923. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40924. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40925. */
  40926. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40927. /**
  40928. * Creates a new VRDeviceOrientationGamepadCamera
  40929. * @param name defines camera name
  40930. * @param position defines the start position of the camera
  40931. * @param scene defines the scene the camera belongs to
  40932. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40933. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40934. */
  40935. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40936. /**
  40937. * Gets camera class name
  40938. * @returns VRDeviceOrientationGamepadCamera
  40939. */
  40940. getClassName(): string;
  40941. }
  40942. }
  40943. declare module "babylonjs/Materials/pushMaterial" {
  40944. import { Nullable } from "babylonjs/types";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Matrix } from "babylonjs/Maths/math.vector";
  40947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40948. import { Mesh } from "babylonjs/Meshes/mesh";
  40949. import { Material } from "babylonjs/Materials/material";
  40950. import { Effect } from "babylonjs/Materials/effect";
  40951. /**
  40952. * Base class of materials working in push mode in babylon JS
  40953. * @hidden
  40954. */
  40955. export class PushMaterial extends Material {
  40956. protected _activeEffect: Effect;
  40957. protected _normalMatrix: Matrix;
  40958. /**
  40959. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40960. * This means that the material can keep using a previous shader while a new one is being compiled.
  40961. * This is mostly used when shader parallel compilation is supported (true by default)
  40962. */
  40963. allowShaderHotSwapping: boolean;
  40964. constructor(name: string, scene: Scene);
  40965. getEffect(): Effect;
  40966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40967. /**
  40968. * Binds the given world matrix to the active effect
  40969. *
  40970. * @param world the matrix to bind
  40971. */
  40972. bindOnlyWorldMatrix(world: Matrix): void;
  40973. /**
  40974. * Binds the given normal matrix to the active effect
  40975. *
  40976. * @param normalMatrix the matrix to bind
  40977. */
  40978. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40979. bind(world: Matrix, mesh?: Mesh): void;
  40980. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40981. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40982. }
  40983. }
  40984. declare module "babylonjs/Materials/materialFlags" {
  40985. /**
  40986. * This groups all the flags used to control the materials channel.
  40987. */
  40988. export class MaterialFlags {
  40989. private static _DiffuseTextureEnabled;
  40990. /**
  40991. * Are diffuse textures enabled in the application.
  40992. */
  40993. static DiffuseTextureEnabled: boolean;
  40994. private static _AmbientTextureEnabled;
  40995. /**
  40996. * Are ambient textures enabled in the application.
  40997. */
  40998. static AmbientTextureEnabled: boolean;
  40999. private static _OpacityTextureEnabled;
  41000. /**
  41001. * Are opacity textures enabled in the application.
  41002. */
  41003. static OpacityTextureEnabled: boolean;
  41004. private static _ReflectionTextureEnabled;
  41005. /**
  41006. * Are reflection textures enabled in the application.
  41007. */
  41008. static ReflectionTextureEnabled: boolean;
  41009. private static _EmissiveTextureEnabled;
  41010. /**
  41011. * Are emissive textures enabled in the application.
  41012. */
  41013. static EmissiveTextureEnabled: boolean;
  41014. private static _SpecularTextureEnabled;
  41015. /**
  41016. * Are specular textures enabled in the application.
  41017. */
  41018. static SpecularTextureEnabled: boolean;
  41019. private static _BumpTextureEnabled;
  41020. /**
  41021. * Are bump textures enabled in the application.
  41022. */
  41023. static BumpTextureEnabled: boolean;
  41024. private static _LightmapTextureEnabled;
  41025. /**
  41026. * Are lightmap textures enabled in the application.
  41027. */
  41028. static LightmapTextureEnabled: boolean;
  41029. private static _RefractionTextureEnabled;
  41030. /**
  41031. * Are refraction textures enabled in the application.
  41032. */
  41033. static RefractionTextureEnabled: boolean;
  41034. private static _ColorGradingTextureEnabled;
  41035. /**
  41036. * Are color grading textures enabled in the application.
  41037. */
  41038. static ColorGradingTextureEnabled: boolean;
  41039. private static _FresnelEnabled;
  41040. /**
  41041. * Are fresnels enabled in the application.
  41042. */
  41043. static FresnelEnabled: boolean;
  41044. private static _ClearCoatTextureEnabled;
  41045. /**
  41046. * Are clear coat textures enabled in the application.
  41047. */
  41048. static ClearCoatTextureEnabled: boolean;
  41049. private static _ClearCoatBumpTextureEnabled;
  41050. /**
  41051. * Are clear coat bump textures enabled in the application.
  41052. */
  41053. static ClearCoatBumpTextureEnabled: boolean;
  41054. private static _ClearCoatTintTextureEnabled;
  41055. /**
  41056. * Are clear coat tint textures enabled in the application.
  41057. */
  41058. static ClearCoatTintTextureEnabled: boolean;
  41059. private static _SheenTextureEnabled;
  41060. /**
  41061. * Are sheen textures enabled in the application.
  41062. */
  41063. static SheenTextureEnabled: boolean;
  41064. private static _AnisotropicTextureEnabled;
  41065. /**
  41066. * Are anisotropic textures enabled in the application.
  41067. */
  41068. static AnisotropicTextureEnabled: boolean;
  41069. private static _ThicknessTextureEnabled;
  41070. /**
  41071. * Are thickness textures enabled in the application.
  41072. */
  41073. static ThicknessTextureEnabled: boolean;
  41074. }
  41075. }
  41076. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41077. /** @hidden */
  41078. export var defaultFragmentDeclaration: {
  41079. name: string;
  41080. shader: string;
  41081. };
  41082. }
  41083. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41084. /** @hidden */
  41085. export var defaultUboDeclaration: {
  41086. name: string;
  41087. shader: string;
  41088. };
  41089. }
  41090. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41091. /** @hidden */
  41092. export var lightFragmentDeclaration: {
  41093. name: string;
  41094. shader: string;
  41095. };
  41096. }
  41097. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41098. /** @hidden */
  41099. export var lightUboDeclaration: {
  41100. name: string;
  41101. shader: string;
  41102. };
  41103. }
  41104. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41105. /** @hidden */
  41106. export var lightsFragmentFunctions: {
  41107. name: string;
  41108. shader: string;
  41109. };
  41110. }
  41111. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41112. /** @hidden */
  41113. export var shadowsFragmentFunctions: {
  41114. name: string;
  41115. shader: string;
  41116. };
  41117. }
  41118. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41119. /** @hidden */
  41120. export var fresnelFunction: {
  41121. name: string;
  41122. shader: string;
  41123. };
  41124. }
  41125. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41126. /** @hidden */
  41127. export var reflectionFunction: {
  41128. name: string;
  41129. shader: string;
  41130. };
  41131. }
  41132. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41133. /** @hidden */
  41134. export var bumpFragmentFunctions: {
  41135. name: string;
  41136. shader: string;
  41137. };
  41138. }
  41139. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41140. /** @hidden */
  41141. export var logDepthDeclaration: {
  41142. name: string;
  41143. shader: string;
  41144. };
  41145. }
  41146. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41147. /** @hidden */
  41148. export var bumpFragment: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41154. /** @hidden */
  41155. export var depthPrePass: {
  41156. name: string;
  41157. shader: string;
  41158. };
  41159. }
  41160. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41161. /** @hidden */
  41162. export var lightFragment: {
  41163. name: string;
  41164. shader: string;
  41165. };
  41166. }
  41167. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41168. /** @hidden */
  41169. export var logDepthFragment: {
  41170. name: string;
  41171. shader: string;
  41172. };
  41173. }
  41174. declare module "babylonjs/Shaders/default.fragment" {
  41175. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41176. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41178. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41179. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41180. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41181. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41182. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41183. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41184. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41185. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41186. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41188. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41189. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41191. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41192. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41193. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41194. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41195. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41196. /** @hidden */
  41197. export var defaultPixelShader: {
  41198. name: string;
  41199. shader: string;
  41200. };
  41201. }
  41202. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41203. /** @hidden */
  41204. export var defaultVertexDeclaration: {
  41205. name: string;
  41206. shader: string;
  41207. };
  41208. }
  41209. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41210. /** @hidden */
  41211. export var bumpVertexDeclaration: {
  41212. name: string;
  41213. shader: string;
  41214. };
  41215. }
  41216. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41217. /** @hidden */
  41218. export var bumpVertex: {
  41219. name: string;
  41220. shader: string;
  41221. };
  41222. }
  41223. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41224. /** @hidden */
  41225. export var fogVertex: {
  41226. name: string;
  41227. shader: string;
  41228. };
  41229. }
  41230. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41231. /** @hidden */
  41232. export var shadowsVertex: {
  41233. name: string;
  41234. shader: string;
  41235. };
  41236. }
  41237. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41238. /** @hidden */
  41239. export var pointCloudVertex: {
  41240. name: string;
  41241. shader: string;
  41242. };
  41243. }
  41244. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41245. /** @hidden */
  41246. export var logDepthVertex: {
  41247. name: string;
  41248. shader: string;
  41249. };
  41250. }
  41251. declare module "babylonjs/Shaders/default.vertex" {
  41252. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41253. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41255. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41257. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41259. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41260. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41261. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41263. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41264. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41268. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41269. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41270. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41271. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41272. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41273. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41274. /** @hidden */
  41275. export var defaultVertexShader: {
  41276. name: string;
  41277. shader: string;
  41278. };
  41279. }
  41280. declare module "babylonjs/Materials/standardMaterial" {
  41281. import { SmartArray } from "babylonjs/Misc/smartArray";
  41282. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41283. import { Nullable } from "babylonjs/types";
  41284. import { Scene } from "babylonjs/scene";
  41285. import { Matrix } from "babylonjs/Maths/math.vector";
  41286. import { Color3 } from "babylonjs/Maths/math.color";
  41287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41289. import { Mesh } from "babylonjs/Meshes/mesh";
  41290. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41291. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41292. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41293. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41294. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41296. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41297. import "babylonjs/Shaders/default.fragment";
  41298. import "babylonjs/Shaders/default.vertex";
  41299. /** @hidden */
  41300. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41301. MAINUV1: boolean;
  41302. MAINUV2: boolean;
  41303. DIFFUSE: boolean;
  41304. DIFFUSEDIRECTUV: number;
  41305. AMBIENT: boolean;
  41306. AMBIENTDIRECTUV: number;
  41307. OPACITY: boolean;
  41308. OPACITYDIRECTUV: number;
  41309. OPACITYRGB: boolean;
  41310. REFLECTION: boolean;
  41311. EMISSIVE: boolean;
  41312. EMISSIVEDIRECTUV: number;
  41313. SPECULAR: boolean;
  41314. SPECULARDIRECTUV: number;
  41315. BUMP: boolean;
  41316. BUMPDIRECTUV: number;
  41317. PARALLAX: boolean;
  41318. PARALLAXOCCLUSION: boolean;
  41319. SPECULAROVERALPHA: boolean;
  41320. CLIPPLANE: boolean;
  41321. CLIPPLANE2: boolean;
  41322. CLIPPLANE3: boolean;
  41323. CLIPPLANE4: boolean;
  41324. ALPHATEST: boolean;
  41325. DEPTHPREPASS: boolean;
  41326. ALPHAFROMDIFFUSE: boolean;
  41327. POINTSIZE: boolean;
  41328. FOG: boolean;
  41329. SPECULARTERM: boolean;
  41330. DIFFUSEFRESNEL: boolean;
  41331. OPACITYFRESNEL: boolean;
  41332. REFLECTIONFRESNEL: boolean;
  41333. REFRACTIONFRESNEL: boolean;
  41334. EMISSIVEFRESNEL: boolean;
  41335. FRESNEL: boolean;
  41336. NORMAL: boolean;
  41337. UV1: boolean;
  41338. UV2: boolean;
  41339. VERTEXCOLOR: boolean;
  41340. VERTEXALPHA: boolean;
  41341. NUM_BONE_INFLUENCERS: number;
  41342. BonesPerMesh: number;
  41343. BONETEXTURE: boolean;
  41344. INSTANCES: boolean;
  41345. GLOSSINESS: boolean;
  41346. ROUGHNESS: boolean;
  41347. EMISSIVEASILLUMINATION: boolean;
  41348. LINKEMISSIVEWITHDIFFUSE: boolean;
  41349. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41350. LIGHTMAP: boolean;
  41351. LIGHTMAPDIRECTUV: number;
  41352. OBJECTSPACE_NORMALMAP: boolean;
  41353. USELIGHTMAPASSHADOWMAP: boolean;
  41354. REFLECTIONMAP_3D: boolean;
  41355. REFLECTIONMAP_SPHERICAL: boolean;
  41356. REFLECTIONMAP_PLANAR: boolean;
  41357. REFLECTIONMAP_CUBIC: boolean;
  41358. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41359. REFLECTIONMAP_PROJECTION: boolean;
  41360. REFLECTIONMAP_SKYBOX: boolean;
  41361. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41362. REFLECTIONMAP_EXPLICIT: boolean;
  41363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41366. INVERTCUBICMAP: boolean;
  41367. LOGARITHMICDEPTH: boolean;
  41368. REFRACTION: boolean;
  41369. REFRACTIONMAP_3D: boolean;
  41370. REFLECTIONOVERALPHA: boolean;
  41371. TWOSIDEDLIGHTING: boolean;
  41372. SHADOWFLOAT: boolean;
  41373. MORPHTARGETS: boolean;
  41374. MORPHTARGETS_NORMAL: boolean;
  41375. MORPHTARGETS_TANGENT: boolean;
  41376. MORPHTARGETS_UV: boolean;
  41377. NUM_MORPH_INFLUENCERS: number;
  41378. NONUNIFORMSCALING: boolean;
  41379. PREMULTIPLYALPHA: boolean;
  41380. IMAGEPROCESSING: boolean;
  41381. VIGNETTE: boolean;
  41382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41383. VIGNETTEBLENDMODEOPAQUE: boolean;
  41384. TONEMAPPING: boolean;
  41385. TONEMAPPING_ACES: boolean;
  41386. CONTRAST: boolean;
  41387. COLORCURVES: boolean;
  41388. COLORGRADING: boolean;
  41389. COLORGRADING3D: boolean;
  41390. SAMPLER3DGREENDEPTH: boolean;
  41391. SAMPLER3DBGRMAP: boolean;
  41392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41393. MULTIVIEW: boolean;
  41394. /**
  41395. * If the reflection texture on this material is in linear color space
  41396. * @hidden
  41397. */
  41398. IS_REFLECTION_LINEAR: boolean;
  41399. /**
  41400. * If the refraction texture on this material is in linear color space
  41401. * @hidden
  41402. */
  41403. IS_REFRACTION_LINEAR: boolean;
  41404. EXPOSURE: boolean;
  41405. constructor();
  41406. setReflectionMode(modeToEnable: string): void;
  41407. }
  41408. /**
  41409. * This is the default material used in Babylon. It is the best trade off between quality
  41410. * and performances.
  41411. * @see http://doc.babylonjs.com/babylon101/materials
  41412. */
  41413. export class StandardMaterial extends PushMaterial {
  41414. private _diffuseTexture;
  41415. /**
  41416. * The basic texture of the material as viewed under a light.
  41417. */
  41418. diffuseTexture: Nullable<BaseTexture>;
  41419. private _ambientTexture;
  41420. /**
  41421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41422. */
  41423. ambientTexture: Nullable<BaseTexture>;
  41424. private _opacityTexture;
  41425. /**
  41426. * Define the transparency of the material from a texture.
  41427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41429. */
  41430. opacityTexture: Nullable<BaseTexture>;
  41431. private _reflectionTexture;
  41432. /**
  41433. * Define the texture used to display the reflection.
  41434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41435. */
  41436. reflectionTexture: Nullable<BaseTexture>;
  41437. private _emissiveTexture;
  41438. /**
  41439. * Define texture of the material as if self lit.
  41440. * This will be mixed in the final result even in the absence of light.
  41441. */
  41442. emissiveTexture: Nullable<BaseTexture>;
  41443. private _specularTexture;
  41444. /**
  41445. * Define how the color and intensity of the highlight given by the light in the material.
  41446. */
  41447. specularTexture: Nullable<BaseTexture>;
  41448. private _bumpTexture;
  41449. /**
  41450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41451. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  41452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41453. */
  41454. bumpTexture: Nullable<BaseTexture>;
  41455. private _lightmapTexture;
  41456. /**
  41457. * Complex lighting can be computationally expensive to compute at runtime.
  41458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41460. */
  41461. lightmapTexture: Nullable<BaseTexture>;
  41462. private _refractionTexture;
  41463. /**
  41464. * Define the texture used to display the refraction.
  41465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41466. */
  41467. refractionTexture: Nullable<BaseTexture>;
  41468. /**
  41469. * The color of the material lit by the environmental background lighting.
  41470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41471. */
  41472. ambientColor: Color3;
  41473. /**
  41474. * The basic color of the material as viewed under a light.
  41475. */
  41476. diffuseColor: Color3;
  41477. /**
  41478. * Define how the color and intensity of the highlight given by the light in the material.
  41479. */
  41480. specularColor: Color3;
  41481. /**
  41482. * Define the color of the material as if self lit.
  41483. * This will be mixed in the final result even in the absence of light.
  41484. */
  41485. emissiveColor: Color3;
  41486. /**
  41487. * Defines how sharp are the highlights in the material.
  41488. * The bigger the value the sharper giving a more glossy feeling to the result.
  41489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41490. */
  41491. specularPower: number;
  41492. private _useAlphaFromDiffuseTexture;
  41493. /**
  41494. * Does the transparency come from the diffuse texture alpha channel.
  41495. */
  41496. useAlphaFromDiffuseTexture: boolean;
  41497. private _useEmissiveAsIllumination;
  41498. /**
  41499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41500. */
  41501. useEmissiveAsIllumination: boolean;
  41502. private _linkEmissiveWithDiffuse;
  41503. /**
  41504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41505. * the emissive level when the final color is close to one.
  41506. */
  41507. linkEmissiveWithDiffuse: boolean;
  41508. private _useSpecularOverAlpha;
  41509. /**
  41510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41512. */
  41513. useSpecularOverAlpha: boolean;
  41514. private _useReflectionOverAlpha;
  41515. /**
  41516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41518. */
  41519. useReflectionOverAlpha: boolean;
  41520. private _disableLighting;
  41521. /**
  41522. * Does lights from the scene impacts this material.
  41523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41524. */
  41525. disableLighting: boolean;
  41526. private _useObjectSpaceNormalMap;
  41527. /**
  41528. * Allows using an object space normal map (instead of tangent space).
  41529. */
  41530. useObjectSpaceNormalMap: boolean;
  41531. private _useParallax;
  41532. /**
  41533. * Is parallax enabled or not.
  41534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41535. */
  41536. useParallax: boolean;
  41537. private _useParallaxOcclusion;
  41538. /**
  41539. * Is parallax occlusion enabled or not.
  41540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41542. */
  41543. useParallaxOcclusion: boolean;
  41544. /**
  41545. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  41546. */
  41547. parallaxScaleBias: number;
  41548. private _roughness;
  41549. /**
  41550. * Helps to define how blurry the reflections should appears in the material.
  41551. */
  41552. roughness: number;
  41553. /**
  41554. * In case of refraction, define the value of the index of refraction.
  41555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41556. */
  41557. indexOfRefraction: number;
  41558. /**
  41559. * Invert the refraction texture alongside the y axis.
  41560. * It can be useful with procedural textures or probe for instance.
  41561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41562. */
  41563. invertRefractionY: boolean;
  41564. /**
  41565. * Defines the alpha limits in alpha test mode.
  41566. */
  41567. alphaCutOff: number;
  41568. private _useLightmapAsShadowmap;
  41569. /**
  41570. * In case of light mapping, define whether the map contains light or shadow informations.
  41571. */
  41572. useLightmapAsShadowmap: boolean;
  41573. private _diffuseFresnelParameters;
  41574. /**
  41575. * Define the diffuse fresnel parameters of the material.
  41576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41577. */
  41578. diffuseFresnelParameters: FresnelParameters;
  41579. private _opacityFresnelParameters;
  41580. /**
  41581. * Define the opacity fresnel parameters of the material.
  41582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41583. */
  41584. opacityFresnelParameters: FresnelParameters;
  41585. private _reflectionFresnelParameters;
  41586. /**
  41587. * Define the reflection fresnel parameters of the material.
  41588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41589. */
  41590. reflectionFresnelParameters: FresnelParameters;
  41591. private _refractionFresnelParameters;
  41592. /**
  41593. * Define the refraction fresnel parameters of the material.
  41594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41595. */
  41596. refractionFresnelParameters: FresnelParameters;
  41597. private _emissiveFresnelParameters;
  41598. /**
  41599. * Define the emissive fresnel parameters of the material.
  41600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41601. */
  41602. emissiveFresnelParameters: FresnelParameters;
  41603. private _useReflectionFresnelFromSpecular;
  41604. /**
  41605. * If true automatically deducts the fresnels values from the material specularity.
  41606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41607. */
  41608. useReflectionFresnelFromSpecular: boolean;
  41609. private _useGlossinessFromSpecularMapAlpha;
  41610. /**
  41611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41612. */
  41613. useGlossinessFromSpecularMapAlpha: boolean;
  41614. private _maxSimultaneousLights;
  41615. /**
  41616. * Defines the maximum number of lights that can be used in the material
  41617. */
  41618. maxSimultaneousLights: number;
  41619. private _invertNormalMapX;
  41620. /**
  41621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41622. */
  41623. invertNormalMapX: boolean;
  41624. private _invertNormalMapY;
  41625. /**
  41626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41627. */
  41628. invertNormalMapY: boolean;
  41629. private _twoSidedLighting;
  41630. /**
  41631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41632. */
  41633. twoSidedLighting: boolean;
  41634. /**
  41635. * Default configuration related to image processing available in the standard Material.
  41636. */
  41637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41638. /**
  41639. * Gets the image processing configuration used either in this material.
  41640. */
  41641. /**
  41642. * Sets the Default image processing configuration used either in the this material.
  41643. *
  41644. * If sets to null, the scene one is in use.
  41645. */
  41646. imageProcessingConfiguration: ImageProcessingConfiguration;
  41647. /**
  41648. * Keep track of the image processing observer to allow dispose and replace.
  41649. */
  41650. private _imageProcessingObserver;
  41651. /**
  41652. * Attaches a new image processing configuration to the Standard Material.
  41653. * @param configuration
  41654. */
  41655. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41656. /**
  41657. * Gets wether the color curves effect is enabled.
  41658. */
  41659. /**
  41660. * Sets wether the color curves effect is enabled.
  41661. */
  41662. cameraColorCurvesEnabled: boolean;
  41663. /**
  41664. * Gets wether the color grading effect is enabled.
  41665. */
  41666. /**
  41667. * Gets wether the color grading effect is enabled.
  41668. */
  41669. cameraColorGradingEnabled: boolean;
  41670. /**
  41671. * Gets wether tonemapping is enabled or not.
  41672. */
  41673. /**
  41674. * Sets wether tonemapping is enabled or not
  41675. */
  41676. cameraToneMappingEnabled: boolean;
  41677. /**
  41678. * The camera exposure used on this material.
  41679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41680. * This corresponds to a photographic exposure.
  41681. */
  41682. /**
  41683. * The camera exposure used on this material.
  41684. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41685. * This corresponds to a photographic exposure.
  41686. */
  41687. cameraExposure: number;
  41688. /**
  41689. * Gets The camera contrast used on this material.
  41690. */
  41691. /**
  41692. * Sets The camera contrast used on this material.
  41693. */
  41694. cameraContrast: number;
  41695. /**
  41696. * Gets the Color Grading 2D Lookup Texture.
  41697. */
  41698. /**
  41699. * Sets the Color Grading 2D Lookup Texture.
  41700. */
  41701. cameraColorGradingTexture: Nullable<BaseTexture>;
  41702. /**
  41703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41705. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  41706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41707. */
  41708. /**
  41709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41711. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  41712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41713. */
  41714. cameraColorCurves: Nullable<ColorCurves>;
  41715. /**
  41716. * Custom callback helping to override the default shader used in the material.
  41717. */
  41718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41719. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41720. protected _worldViewProjectionMatrix: Matrix;
  41721. protected _globalAmbientColor: Color3;
  41722. protected _useLogarithmicDepth: boolean;
  41723. protected _rebuildInParallel: boolean;
  41724. /**
  41725. * Instantiates a new standard material.
  41726. * This is the default material used in Babylon. It is the best trade off between quality
  41727. * and performances.
  41728. * @see http://doc.babylonjs.com/babylon101/materials
  41729. * @param name Define the name of the material in the scene
  41730. * @param scene Define the scene the material belong to
  41731. */
  41732. constructor(name: string, scene: Scene);
  41733. /**
  41734. * Gets a boolean indicating that current material needs to register RTT
  41735. */
  41736. readonly hasRenderTargetTextures: boolean;
  41737. /**
  41738. * Gets the current class name of the material e.g. "StandardMaterial"
  41739. * Mainly use in serialization.
  41740. * @returns the class name
  41741. */
  41742. getClassName(): string;
  41743. /**
  41744. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41745. * You can try switching to logarithmic depth.
  41746. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41747. */
  41748. useLogarithmicDepth: boolean;
  41749. /**
  41750. * Specifies if the material will require alpha blending
  41751. * @returns a boolean specifying if alpha blending is needed
  41752. */
  41753. needAlphaBlending(): boolean;
  41754. /**
  41755. * Specifies if this material should be rendered in alpha test mode
  41756. * @returns a boolean specifying if an alpha test is needed.
  41757. */
  41758. needAlphaTesting(): boolean;
  41759. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41760. /**
  41761. * Get the texture used for alpha test purpose.
  41762. * @returns the diffuse texture in case of the standard material.
  41763. */
  41764. getAlphaTestTexture(): Nullable<BaseTexture>;
  41765. /**
  41766. * Get if the submesh is ready to be used and all its information available.
  41767. * Child classes can use it to update shaders
  41768. * @param mesh defines the mesh to check
  41769. * @param subMesh defines which submesh to check
  41770. * @param useInstances specifies that instances should be used
  41771. * @returns a boolean indicating that the submesh is ready or not
  41772. */
  41773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41774. /**
  41775. * Builds the material UBO layouts.
  41776. * Used internally during the effect preparation.
  41777. */
  41778. buildUniformLayout(): void;
  41779. /**
  41780. * Unbinds the material from the mesh
  41781. */
  41782. unbind(): void;
  41783. /**
  41784. * Binds the submesh to this material by preparing the effect and shader to draw
  41785. * @param world defines the world transformation matrix
  41786. * @param mesh defines the mesh containing the submesh
  41787. * @param subMesh defines the submesh to bind the material to
  41788. */
  41789. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41790. /**
  41791. * Get the list of animatables in the material.
  41792. * @returns the list of animatables object used in the material
  41793. */
  41794. getAnimatables(): IAnimatable[];
  41795. /**
  41796. * Gets the active textures from the material
  41797. * @returns an array of textures
  41798. */
  41799. getActiveTextures(): BaseTexture[];
  41800. /**
  41801. * Specifies if the material uses a texture
  41802. * @param texture defines the texture to check against the material
  41803. * @returns a boolean specifying if the material uses the texture
  41804. */
  41805. hasTexture(texture: BaseTexture): boolean;
  41806. /**
  41807. * Disposes the material
  41808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41809. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41810. */
  41811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41812. /**
  41813. * Makes a duplicate of the material, and gives it a new name
  41814. * @param name defines the new name for the duplicated material
  41815. * @returns the cloned material
  41816. */
  41817. clone(name: string): StandardMaterial;
  41818. /**
  41819. * Serializes this material in a JSON representation
  41820. * @returns the serialized material object
  41821. */
  41822. serialize(): any;
  41823. /**
  41824. * Creates a standard material from parsed material data
  41825. * @param source defines the JSON representation of the material
  41826. * @param scene defines the hosting scene
  41827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41828. * @returns a new standard material
  41829. */
  41830. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41831. /**
  41832. * Are diffuse textures enabled in the application.
  41833. */
  41834. static DiffuseTextureEnabled: boolean;
  41835. /**
  41836. * Are ambient textures enabled in the application.
  41837. */
  41838. static AmbientTextureEnabled: boolean;
  41839. /**
  41840. * Are opacity textures enabled in the application.
  41841. */
  41842. static OpacityTextureEnabled: boolean;
  41843. /**
  41844. * Are reflection textures enabled in the application.
  41845. */
  41846. static ReflectionTextureEnabled: boolean;
  41847. /**
  41848. * Are emissive textures enabled in the application.
  41849. */
  41850. static EmissiveTextureEnabled: boolean;
  41851. /**
  41852. * Are specular textures enabled in the application.
  41853. */
  41854. static SpecularTextureEnabled: boolean;
  41855. /**
  41856. * Are bump textures enabled in the application.
  41857. */
  41858. static BumpTextureEnabled: boolean;
  41859. /**
  41860. * Are lightmap textures enabled in the application.
  41861. */
  41862. static LightmapTextureEnabled: boolean;
  41863. /**
  41864. * Are refraction textures enabled in the application.
  41865. */
  41866. static RefractionTextureEnabled: boolean;
  41867. /**
  41868. * Are color grading textures enabled in the application.
  41869. */
  41870. static ColorGradingTextureEnabled: boolean;
  41871. /**
  41872. * Are fresnels enabled in the application.
  41873. */
  41874. static FresnelEnabled: boolean;
  41875. }
  41876. }
  41877. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41878. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41880. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41881. /** @hidden */
  41882. export var imageProcessingPixelShader: {
  41883. name: string;
  41884. shader: string;
  41885. };
  41886. }
  41887. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41888. import { Nullable } from "babylonjs/types";
  41889. import { Color4 } from "babylonjs/Maths/math.color";
  41890. import { Camera } from "babylonjs/Cameras/camera";
  41891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41892. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41893. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41895. import { Engine } from "babylonjs/Engines/engine";
  41896. import "babylonjs/Shaders/imageProcessing.fragment";
  41897. import "babylonjs/Shaders/postprocess.vertex";
  41898. /**
  41899. * ImageProcessingPostProcess
  41900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41901. */
  41902. export class ImageProcessingPostProcess extends PostProcess {
  41903. /**
  41904. * Default configuration related to image processing available in the PBR Material.
  41905. */
  41906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41907. /**
  41908. * Gets the image processing configuration used either in this material.
  41909. */
  41910. /**
  41911. * Sets the Default image processing configuration used either in the this material.
  41912. *
  41913. * If sets to null, the scene one is in use.
  41914. */
  41915. imageProcessingConfiguration: ImageProcessingConfiguration;
  41916. /**
  41917. * Keep track of the image processing observer to allow dispose and replace.
  41918. */
  41919. private _imageProcessingObserver;
  41920. /**
  41921. * Attaches a new image processing configuration to the PBR Material.
  41922. * @param configuration
  41923. */
  41924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41925. /**
  41926. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41927. */
  41928. /**
  41929. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41930. */
  41931. colorCurves: Nullable<ColorCurves>;
  41932. /**
  41933. * Gets wether the color curves effect is enabled.
  41934. */
  41935. /**
  41936. * Sets wether the color curves effect is enabled.
  41937. */
  41938. colorCurvesEnabled: boolean;
  41939. /**
  41940. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41941. */
  41942. /**
  41943. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41944. */
  41945. colorGradingTexture: Nullable<BaseTexture>;
  41946. /**
  41947. * Gets wether the color grading effect is enabled.
  41948. */
  41949. /**
  41950. * Gets wether the color grading effect is enabled.
  41951. */
  41952. colorGradingEnabled: boolean;
  41953. /**
  41954. * Gets exposure used in the effect.
  41955. */
  41956. /**
  41957. * Sets exposure used in the effect.
  41958. */
  41959. exposure: number;
  41960. /**
  41961. * Gets wether tonemapping is enabled or not.
  41962. */
  41963. /**
  41964. * Sets wether tonemapping is enabled or not
  41965. */
  41966. toneMappingEnabled: boolean;
  41967. /**
  41968. * Gets the type of tone mapping effect.
  41969. */
  41970. /**
  41971. * Sets the type of tone mapping effect.
  41972. */
  41973. toneMappingType: number;
  41974. /**
  41975. * Gets contrast used in the effect.
  41976. */
  41977. /**
  41978. * Sets contrast used in the effect.
  41979. */
  41980. contrast: number;
  41981. /**
  41982. * Gets Vignette stretch size.
  41983. */
  41984. /**
  41985. * Sets Vignette stretch size.
  41986. */
  41987. vignetteStretch: number;
  41988. /**
  41989. * Gets Vignette centre X Offset.
  41990. */
  41991. /**
  41992. * Sets Vignette centre X Offset.
  41993. */
  41994. vignetteCentreX: number;
  41995. /**
  41996. * Gets Vignette centre Y Offset.
  41997. */
  41998. /**
  41999. * Sets Vignette centre Y Offset.
  42000. */
  42001. vignetteCentreY: number;
  42002. /**
  42003. * Gets Vignette weight or intensity of the vignette effect.
  42004. */
  42005. /**
  42006. * Sets Vignette weight or intensity of the vignette effect.
  42007. */
  42008. vignetteWeight: number;
  42009. /**
  42010. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42011. * if vignetteEnabled is set to true.
  42012. */
  42013. /**
  42014. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42015. * if vignetteEnabled is set to true.
  42016. */
  42017. vignetteColor: Color4;
  42018. /**
  42019. * Gets Camera field of view used by the Vignette effect.
  42020. */
  42021. /**
  42022. * Sets Camera field of view used by the Vignette effect.
  42023. */
  42024. vignetteCameraFov: number;
  42025. /**
  42026. * Gets the vignette blend mode allowing different kind of effect.
  42027. */
  42028. /**
  42029. * Sets the vignette blend mode allowing different kind of effect.
  42030. */
  42031. vignetteBlendMode: number;
  42032. /**
  42033. * Gets wether the vignette effect is enabled.
  42034. */
  42035. /**
  42036. * Sets wether the vignette effect is enabled.
  42037. */
  42038. vignetteEnabled: boolean;
  42039. private _fromLinearSpace;
  42040. /**
  42041. * Gets wether the input of the processing is in Gamma or Linear Space.
  42042. */
  42043. /**
  42044. * Sets wether the input of the processing is in Gamma or Linear Space.
  42045. */
  42046. fromLinearSpace: boolean;
  42047. /**
  42048. * Defines cache preventing GC.
  42049. */
  42050. private _defines;
  42051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42052. /**
  42053. * "ImageProcessingPostProcess"
  42054. * @returns "ImageProcessingPostProcess"
  42055. */
  42056. getClassName(): string;
  42057. protected _updateParameters(): void;
  42058. dispose(camera?: Camera): void;
  42059. }
  42060. }
  42061. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42062. import { Scene } from "babylonjs/scene";
  42063. import { Color3 } from "babylonjs/Maths/math.color";
  42064. import { Mesh } from "babylonjs/Meshes/mesh";
  42065. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42066. import { Nullable } from "babylonjs/types";
  42067. /**
  42068. * Class containing static functions to help procedurally build meshes
  42069. */
  42070. export class GroundBuilder {
  42071. /**
  42072. * Creates a ground mesh
  42073. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42074. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42076. * @param name defines the name of the mesh
  42077. * @param options defines the options used to create the mesh
  42078. * @param scene defines the hosting scene
  42079. * @returns the ground mesh
  42080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42081. */
  42082. static CreateGround(name: string, options: {
  42083. width?: number;
  42084. height?: number;
  42085. subdivisions?: number;
  42086. subdivisionsX?: number;
  42087. subdivisionsY?: number;
  42088. updatable?: boolean;
  42089. }, scene: any): Mesh;
  42090. /**
  42091. * Creates a tiled ground mesh
  42092. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42093. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42094. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  42095. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  42096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42097. * @param name defines the name of the mesh
  42098. * @param options defines the options used to create the mesh
  42099. * @param scene defines the hosting scene
  42100. * @returns the tiled ground mesh
  42101. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42102. */
  42103. static CreateTiledGround(name: string, options: {
  42104. xmin: number;
  42105. zmin: number;
  42106. xmax: number;
  42107. zmax: number;
  42108. subdivisions?: {
  42109. w: number;
  42110. h: number;
  42111. };
  42112. precision?: {
  42113. w: number;
  42114. h: number;
  42115. };
  42116. updatable?: boolean;
  42117. }, scene?: Nullable<Scene>): Mesh;
  42118. /**
  42119. * Creates a ground mesh from a height map
  42120. * * The parameter `url` sets the URL of the height map image resource.
  42121. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42122. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42123. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42124. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42125. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  42126. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  42127. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42129. * @param name defines the name of the mesh
  42130. * @param url defines the url to the height map
  42131. * @param options defines the options used to create the mesh
  42132. * @param scene defines the hosting scene
  42133. * @returns the ground mesh
  42134. * @see https://doc.babylonjs.com/babylon101/height_map
  42135. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42136. */
  42137. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42138. width?: number;
  42139. height?: number;
  42140. subdivisions?: number;
  42141. minHeight?: number;
  42142. maxHeight?: number;
  42143. colorFilter?: Color3;
  42144. alphaFilter?: number;
  42145. updatable?: boolean;
  42146. onReady?: (mesh: GroundMesh) => void;
  42147. }, scene?: Nullable<Scene>): GroundMesh;
  42148. }
  42149. }
  42150. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42151. import { Vector4 } from "babylonjs/Maths/math.vector";
  42152. import { Mesh } from "babylonjs/Meshes/mesh";
  42153. /**
  42154. * Class containing static functions to help procedurally build meshes
  42155. */
  42156. export class TorusBuilder {
  42157. /**
  42158. * Creates a torus mesh
  42159. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42160. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42161. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42165. * @param name defines the name of the mesh
  42166. * @param options defines the options used to create the mesh
  42167. * @param scene defines the hosting scene
  42168. * @returns the torus mesh
  42169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42170. */
  42171. static CreateTorus(name: string, options: {
  42172. diameter?: number;
  42173. thickness?: number;
  42174. tessellation?: number;
  42175. updatable?: boolean;
  42176. sideOrientation?: number;
  42177. frontUVs?: Vector4;
  42178. backUVs?: Vector4;
  42179. }, scene: any): Mesh;
  42180. }
  42181. }
  42182. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42183. import { Vector4 } from "babylonjs/Maths/math.vector";
  42184. import { Color4 } from "babylonjs/Maths/math.color";
  42185. import { Mesh } from "babylonjs/Meshes/mesh";
  42186. /**
  42187. * Class containing static functions to help procedurally build meshes
  42188. */
  42189. export class CylinderBuilder {
  42190. /**
  42191. * Creates a cylinder or a cone mesh
  42192. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42193. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42194. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  42195. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42196. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42197. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42198. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42199. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  42200. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42201. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  42202. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  42203. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42204. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  42205. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  42206. * * If `enclose` is false, a ring surface is one element.
  42207. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42208. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  42209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42212. * @param name defines the name of the mesh
  42213. * @param options defines the options used to create the mesh
  42214. * @param scene defines the hosting scene
  42215. * @returns the cylinder mesh
  42216. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42217. */
  42218. static CreateCylinder(name: string, options: {
  42219. height?: number;
  42220. diameterTop?: number;
  42221. diameterBottom?: number;
  42222. diameter?: number;
  42223. tessellation?: number;
  42224. subdivisions?: number;
  42225. arc?: number;
  42226. faceColors?: Color4[];
  42227. faceUV?: Vector4[];
  42228. updatable?: boolean;
  42229. hasRings?: boolean;
  42230. enclose?: boolean;
  42231. cap?: number;
  42232. sideOrientation?: number;
  42233. frontUVs?: Vector4;
  42234. backUVs?: Vector4;
  42235. }, scene: any): Mesh;
  42236. }
  42237. }
  42238. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42239. import { Observable } from "babylonjs/Misc/observable";
  42240. import { Nullable } from "babylonjs/types";
  42241. import { Camera } from "babylonjs/Cameras/camera";
  42242. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42243. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42244. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42245. import { Scene } from "babylonjs/scene";
  42246. import { Vector3 } from "babylonjs/Maths/math.vector";
  42247. import { Color3 } from "babylonjs/Maths/math.color";
  42248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42250. import { Mesh } from "babylonjs/Meshes/mesh";
  42251. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42252. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42253. import "babylonjs/Meshes/Builders/groundBuilder";
  42254. import "babylonjs/Meshes/Builders/torusBuilder";
  42255. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42256. import "babylonjs/Gamepads/gamepadSceneComponent";
  42257. import "babylonjs/Animations/animatable";
  42258. /**
  42259. * Options to modify the vr teleportation behavior.
  42260. */
  42261. export interface VRTeleportationOptions {
  42262. /**
  42263. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42264. */
  42265. floorMeshName?: string;
  42266. /**
  42267. * A list of meshes to be used as the teleportation floor. (default: empty)
  42268. */
  42269. floorMeshes?: Mesh[];
  42270. }
  42271. /**
  42272. * Options to modify the vr experience helper's behavior.
  42273. */
  42274. export interface VRExperienceHelperOptions extends WebVROptions {
  42275. /**
  42276. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42277. */
  42278. createDeviceOrientationCamera?: boolean;
  42279. /**
  42280. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42281. */
  42282. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42283. /**
  42284. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42285. */
  42286. laserToggle?: boolean;
  42287. /**
  42288. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42289. */
  42290. floorMeshes?: Mesh[];
  42291. /**
  42292. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42293. */
  42294. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42295. }
  42296. /**
  42297. * Event containing information after VR has been entered
  42298. */
  42299. export class OnAfterEnteringVRObservableEvent {
  42300. /**
  42301. * If entering vr was successful
  42302. */
  42303. success: boolean;
  42304. }
  42305. /**
  42306. * Helps to quickly add VR support to an existing scene.
  42307. * See http://doc.babylonjs.com/how_to/webvr_helper
  42308. */
  42309. export class VRExperienceHelper {
  42310. /** Options to modify the vr experience helper's behavior. */
  42311. webVROptions: VRExperienceHelperOptions;
  42312. private _scene;
  42313. private _position;
  42314. private _btnVR;
  42315. private _btnVRDisplayed;
  42316. private _webVRsupported;
  42317. private _webVRready;
  42318. private _webVRrequesting;
  42319. private _webVRpresenting;
  42320. private _hasEnteredVR;
  42321. private _fullscreenVRpresenting;
  42322. private _canvas;
  42323. private _webVRCamera;
  42324. private _vrDeviceOrientationCamera;
  42325. private _deviceOrientationCamera;
  42326. private _existingCamera;
  42327. private _onKeyDown;
  42328. private _onVrDisplayPresentChange;
  42329. private _onVRDisplayChanged;
  42330. private _onVRRequestPresentStart;
  42331. private _onVRRequestPresentComplete;
  42332. /**
  42333. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42334. */
  42335. enableGazeEvenWhenNoPointerLock: boolean;
  42336. /**
  42337. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42338. */
  42339. exitVROnDoubleTap: boolean;
  42340. /**
  42341. * Observable raised right before entering VR.
  42342. */
  42343. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42344. /**
  42345. * Observable raised when entering VR has completed.
  42346. */
  42347. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42348. /**
  42349. * Observable raised when exiting VR.
  42350. */
  42351. onExitingVRObservable: Observable<VRExperienceHelper>;
  42352. /**
  42353. * Observable raised when controller mesh is loaded.
  42354. */
  42355. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42356. /** Return this.onEnteringVRObservable
  42357. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42358. */
  42359. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42360. /** Return this.onExitingVRObservable
  42361. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42362. */
  42363. readonly onExitingVR: Observable<VRExperienceHelper>;
  42364. /** Return this.onControllerMeshLoadedObservable
  42365. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42366. */
  42367. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42368. private _rayLength;
  42369. private _useCustomVRButton;
  42370. private _teleportationRequested;
  42371. private _teleportActive;
  42372. private _floorMeshName;
  42373. private _floorMeshesCollection;
  42374. private _rotationAllowed;
  42375. private _teleportBackwardsVector;
  42376. private _teleportationTarget;
  42377. private _isDefaultTeleportationTarget;
  42378. private _postProcessMove;
  42379. private _teleportationFillColor;
  42380. private _teleportationBorderColor;
  42381. private _rotationAngle;
  42382. private _haloCenter;
  42383. private _cameraGazer;
  42384. private _padSensibilityUp;
  42385. private _padSensibilityDown;
  42386. private _leftController;
  42387. private _rightController;
  42388. /**
  42389. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42390. */
  42391. onNewMeshSelected: Observable<AbstractMesh>;
  42392. /**
  42393. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42394. * This observable will provide the mesh and the controller used to select the mesh
  42395. */
  42396. onMeshSelectedWithController: Observable<{
  42397. mesh: AbstractMesh;
  42398. controller: WebVRController;
  42399. }>;
  42400. /**
  42401. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42402. */
  42403. onNewMeshPicked: Observable<PickingInfo>;
  42404. private _circleEase;
  42405. /**
  42406. * Observable raised before camera teleportation
  42407. */
  42408. onBeforeCameraTeleport: Observable<Vector3>;
  42409. /**
  42410. * Observable raised after camera teleportation
  42411. */
  42412. onAfterCameraTeleport: Observable<Vector3>;
  42413. /**
  42414. * Observable raised when current selected mesh gets unselected
  42415. */
  42416. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42417. private _raySelectionPredicate;
  42418. /**
  42419. * To be optionaly changed by user to define custom ray selection
  42420. */
  42421. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42422. /**
  42423. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42424. */
  42425. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42426. /**
  42427. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42428. */
  42429. teleportationEnabled: boolean;
  42430. private _defaultHeight;
  42431. private _teleportationInitialized;
  42432. private _interactionsEnabled;
  42433. private _interactionsRequested;
  42434. private _displayGaze;
  42435. private _displayLaserPointer;
  42436. /**
  42437. * The mesh used to display where the user is going to teleport.
  42438. */
  42439. /**
  42440. * Sets the mesh to be used to display where the user is going to teleport.
  42441. */
  42442. teleportationTarget: Mesh;
  42443. /**
  42444. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  42445. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42446. * See http://doc.babylonjs.com/resources/baking_transformations
  42447. */
  42448. gazeTrackerMesh: Mesh;
  42449. /**
  42450. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42451. */
  42452. updateGazeTrackerScale: boolean;
  42453. /**
  42454. * If the gaze trackers color should be updated when selecting meshes
  42455. */
  42456. updateGazeTrackerColor: boolean;
  42457. /**
  42458. * If the controller laser color should be updated when selecting meshes
  42459. */
  42460. updateControllerLaserColor: boolean;
  42461. /**
  42462. * The gaze tracking mesh corresponding to the left controller
  42463. */
  42464. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42465. /**
  42466. * The gaze tracking mesh corresponding to the right controller
  42467. */
  42468. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42469. /**
  42470. * If the ray of the gaze should be displayed.
  42471. */
  42472. /**
  42473. * Sets if the ray of the gaze should be displayed.
  42474. */
  42475. displayGaze: boolean;
  42476. /**
  42477. * If the ray of the LaserPointer should be displayed.
  42478. */
  42479. /**
  42480. * Sets if the ray of the LaserPointer should be displayed.
  42481. */
  42482. displayLaserPointer: boolean;
  42483. /**
  42484. * The deviceOrientationCamera used as the camera when not in VR.
  42485. */
  42486. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42487. /**
  42488. * Based on the current WebVR support, returns the current VR camera used.
  42489. */
  42490. readonly currentVRCamera: Nullable<Camera>;
  42491. /**
  42492. * The webVRCamera which is used when in VR.
  42493. */
  42494. readonly webVRCamera: WebVRFreeCamera;
  42495. /**
  42496. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42497. */
  42498. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42499. /**
  42500. * The html button that is used to trigger entering into VR.
  42501. */
  42502. readonly vrButton: Nullable<HTMLButtonElement>;
  42503. private readonly _teleportationRequestInitiated;
  42504. /**
  42505. * Defines wether or not Pointer lock should be requested when switching to
  42506. * full screen.
  42507. */
  42508. requestPointerLockOnFullScreen: boolean;
  42509. /**
  42510. * Instantiates a VRExperienceHelper.
  42511. * Helps to quickly add VR support to an existing scene.
  42512. * @param scene The scene the VRExperienceHelper belongs to.
  42513. * @param webVROptions Options to modify the vr experience helper's behavior.
  42514. */
  42515. constructor(scene: Scene,
  42516. /** Options to modify the vr experience helper's behavior. */
  42517. webVROptions?: VRExperienceHelperOptions);
  42518. private _onDefaultMeshLoaded;
  42519. private _onResize;
  42520. private _onFullscreenChange;
  42521. /**
  42522. * Gets a value indicating if we are currently in VR mode.
  42523. */
  42524. readonly isInVRMode: boolean;
  42525. private onVrDisplayPresentChange;
  42526. private onVRDisplayChanged;
  42527. private moveButtonToBottomRight;
  42528. private displayVRButton;
  42529. private updateButtonVisibility;
  42530. private _cachedAngularSensibility;
  42531. /**
  42532. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42533. * Otherwise, will use the fullscreen API.
  42534. */
  42535. enterVR(): void;
  42536. /**
  42537. * Attempt to exit VR, or fullscreen.
  42538. */
  42539. exitVR(): void;
  42540. /**
  42541. * The position of the vr experience helper.
  42542. */
  42543. /**
  42544. * Sets the position of the vr experience helper.
  42545. */
  42546. position: Vector3;
  42547. /**
  42548. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42549. */
  42550. enableInteractions(): void;
  42551. private readonly _noControllerIsActive;
  42552. private beforeRender;
  42553. private _isTeleportationFloor;
  42554. /**
  42555. * Adds a floor mesh to be used for teleportation.
  42556. * @param floorMesh the mesh to be used for teleportation.
  42557. */
  42558. addFloorMesh(floorMesh: Mesh): void;
  42559. /**
  42560. * Removes a floor mesh from being used for teleportation.
  42561. * @param floorMesh the mesh to be removed.
  42562. */
  42563. removeFloorMesh(floorMesh: Mesh): void;
  42564. /**
  42565. * Enables interactions and teleportation using the VR controllers and gaze.
  42566. * @param vrTeleportationOptions options to modify teleportation behavior.
  42567. */
  42568. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42569. private _onNewGamepadConnected;
  42570. private _tryEnableInteractionOnController;
  42571. private _onNewGamepadDisconnected;
  42572. private _enableInteractionOnController;
  42573. private _checkTeleportWithRay;
  42574. private _checkRotate;
  42575. private _checkTeleportBackwards;
  42576. private _enableTeleportationOnController;
  42577. private _createTeleportationCircles;
  42578. private _displayTeleportationTarget;
  42579. private _hideTeleportationTarget;
  42580. private _rotateCamera;
  42581. private _moveTeleportationSelectorTo;
  42582. private _workingVector;
  42583. private _workingQuaternion;
  42584. private _workingMatrix;
  42585. /**
  42586. * Teleports the users feet to the desired location
  42587. * @param location The location where the user's feet should be placed
  42588. */
  42589. teleportCamera(location: Vector3): void;
  42590. private _convertNormalToDirectionOfRay;
  42591. private _castRayAndSelectObject;
  42592. private _notifySelectedMeshUnselected;
  42593. /**
  42594. * Sets the color of the laser ray from the vr controllers.
  42595. * @param color new color for the ray.
  42596. */
  42597. changeLaserColor(color: Color3): void;
  42598. /**
  42599. * Sets the color of the ray from the vr headsets gaze.
  42600. * @param color new color for the ray.
  42601. */
  42602. changeGazeColor(color: Color3): void;
  42603. /**
  42604. * Exits VR and disposes of the vr experience helper
  42605. */
  42606. dispose(): void;
  42607. /**
  42608. * Gets the name of the VRExperienceHelper class
  42609. * @returns "VRExperienceHelper"
  42610. */
  42611. getClassName(): string;
  42612. }
  42613. }
  42614. declare module "babylonjs/Cameras/VR/index" {
  42615. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42616. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42617. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42618. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42619. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42620. export * from "babylonjs/Cameras/VR/webVRCamera";
  42621. }
  42622. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable } from "babylonjs/types";
  42625. import { IDisposable, Scene } from "babylonjs/scene";
  42626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42627. /**
  42628. * Manages an XRSession to work with Babylon's engine
  42629. * @see https://doc.babylonjs.com/how_to/webxr
  42630. */
  42631. export class WebXRSessionManager implements IDisposable {
  42632. private scene;
  42633. /**
  42634. * Fires every time a new xrFrame arrives which can be used to update the camera
  42635. */
  42636. onXRFrameObservable: Observable<any>;
  42637. /**
  42638. * Fires when the xr session is ended either by the device or manually done
  42639. */
  42640. onXRSessionEnded: Observable<any>;
  42641. /**
  42642. * Underlying xr session
  42643. */
  42644. session: XRSession;
  42645. /**
  42646. * Type of reference space used when creating the session
  42647. */
  42648. referenceSpace: XRReferenceSpace;
  42649. /** @hidden */
  42650. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42651. /**
  42652. * Current XR frame
  42653. */
  42654. currentFrame: Nullable<XRFrame>;
  42655. private _xrNavigator;
  42656. private baseLayer;
  42657. /**
  42658. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42659. * @param scene The scene which the session should be created for
  42660. */
  42661. constructor(scene: Scene);
  42662. /**
  42663. * Initializes the manager
  42664. * After initialization enterXR can be called to start an XR session
  42665. * @returns Promise which resolves after it is initialized
  42666. */
  42667. initializeAsync(): Promise<void>;
  42668. /**
  42669. * Initializes an xr session
  42670. * @param xrSessionMode mode to initialize
  42671. * @returns a promise which will resolve once the session has been initialized
  42672. */
  42673. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42674. /**
  42675. * Sets the reference space on the xr session
  42676. * @param referenceSpace space to set
  42677. * @returns a promise that will resolve once the reference space has been set
  42678. */
  42679. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42680. /**
  42681. * Updates the render state of the session
  42682. * @param state state to set
  42683. * @returns a promise that resolves once the render state has been updated
  42684. */
  42685. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42686. /**
  42687. * Starts rendering to the xr layer
  42688. * @returns a promise that will resolve once rendering has started
  42689. */
  42690. startRenderingToXRAsync(): Promise<void>;
  42691. /**
  42692. * Stops the xrSession and restores the renderloop
  42693. * @returns Promise which resolves after it exits XR
  42694. */
  42695. exitXRAsync(): Promise<unknown>;
  42696. /**
  42697. * Checks if a session would be supported for the creation options specified
  42698. * @param sessionMode session mode to check if supported eg. immersive-vr
  42699. * @returns true if supported
  42700. */
  42701. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42702. /**
  42703. * @hidden
  42704. * Converts the render layer of xrSession to a render target
  42705. * @param session session to create render target for
  42706. * @param scene scene the new render target should be created for
  42707. */
  42708. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42709. /**
  42710. * Disposes of the session manager
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42716. import { Scene } from "babylonjs/scene";
  42717. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42718. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42719. /**
  42720. * WebXR Camera which holds the views for the xrSession
  42721. * @see https://doc.babylonjs.com/how_to/webxr
  42722. */
  42723. export class WebXRCamera extends FreeCamera {
  42724. private static _TmpMatrix;
  42725. /**
  42726. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42727. * @param name the name of the camera
  42728. * @param scene the scene to add the camera to
  42729. */
  42730. constructor(name: string, scene: Scene);
  42731. private _updateNumberOfRigCameras;
  42732. /** @hidden */
  42733. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42734. /**
  42735. * Updates the cameras position from the current pose information of the XR session
  42736. * @param xrSessionManager the session containing pose information
  42737. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42738. */
  42739. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42740. }
  42741. }
  42742. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42743. import { Nullable } from "babylonjs/types";
  42744. import { IDisposable } from "babylonjs/scene";
  42745. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42746. /**
  42747. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42748. */
  42749. export class WebXRManagedOutputCanvas implements IDisposable {
  42750. private helper;
  42751. private _canvas;
  42752. /**
  42753. * xrpresent context of the canvas which can be used to display/mirror xr content
  42754. */
  42755. canvasContext: WebGLRenderingContext;
  42756. /**
  42757. * xr layer for the canvas
  42758. */
  42759. xrLayer: Nullable<XRWebGLLayer>;
  42760. /**
  42761. * Initializes the xr layer for the session
  42762. * @param xrSession xr session
  42763. * @returns a promise that will resolve once the XR Layer has been created
  42764. */
  42765. initializeXRLayerAsync(xrSession: any): any;
  42766. /**
  42767. * Initializes the canvas to be added/removed upon entering/exiting xr
  42768. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42769. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42770. */
  42771. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42772. /**
  42773. * Disposes of the object
  42774. */
  42775. dispose(): void;
  42776. private _setManagedOutputCanvas;
  42777. private _addCanvas;
  42778. private _removeCanvas;
  42779. }
  42780. }
  42781. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42782. import { Observable } from "babylonjs/Misc/observable";
  42783. import { IDisposable, Scene } from "babylonjs/scene";
  42784. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42786. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42787. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42788. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42789. /**
  42790. * States of the webXR experience
  42791. */
  42792. export enum WebXRState {
  42793. /**
  42794. * Transitioning to being in XR mode
  42795. */
  42796. ENTERING_XR = 0,
  42797. /**
  42798. * Transitioning to non XR mode
  42799. */
  42800. EXITING_XR = 1,
  42801. /**
  42802. * In XR mode and presenting
  42803. */
  42804. IN_XR = 2,
  42805. /**
  42806. * Not entered XR mode
  42807. */
  42808. NOT_IN_XR = 3
  42809. }
  42810. /**
  42811. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42812. * @see https://doc.babylonjs.com/how_to/webxr
  42813. */
  42814. export class WebXRExperienceHelper implements IDisposable {
  42815. private scene;
  42816. /**
  42817. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42818. */
  42819. container: AbstractMesh;
  42820. /**
  42821. * Camera used to render xr content
  42822. */
  42823. camera: WebXRCamera;
  42824. /**
  42825. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42826. */
  42827. state: WebXRState;
  42828. private _setState;
  42829. private static _TmpVector;
  42830. /**
  42831. * Fires when the state of the experience helper has changed
  42832. */
  42833. onStateChangedObservable: Observable<WebXRState>;
  42834. /** Session manager used to keep track of xr session */
  42835. sessionManager: WebXRSessionManager;
  42836. private _nonVRCamera;
  42837. private _originalSceneAutoClear;
  42838. private _supported;
  42839. /**
  42840. * Creates the experience helper
  42841. * @param scene the scene to attach the experience helper to
  42842. * @returns a promise for the experience helper
  42843. */
  42844. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42845. /**
  42846. * Creates a WebXRExperienceHelper
  42847. * @param scene The scene the helper should be created in
  42848. */
  42849. private constructor();
  42850. /**
  42851. * Exits XR mode and returns the scene to its original state
  42852. * @returns promise that resolves after xr mode has exited
  42853. */
  42854. exitXRAsync(): Promise<unknown>;
  42855. /**
  42856. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42857. * @param sessionCreationOptions options for the XR session
  42858. * @param referenceSpaceType frame of reference of the XR session
  42859. * @param outputCanvas the output canvas that will be used to enter XR mode
  42860. * @returns promise that resolves after xr mode has entered
  42861. */
  42862. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42863. /**
  42864. * Updates the global position of the camera by moving the camera's container
  42865. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42866. * @param position The desired global position of the camera
  42867. */
  42868. setPositionOfCameraUsingContainer(position: Vector3): void;
  42869. /**
  42870. * Rotates the xr camera by rotating the camera's container around the camera's position
  42871. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42872. * @param rotation the desired quaternion rotation to apply to the camera
  42873. */
  42874. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42875. /**
  42876. * Disposes of the experience helper
  42877. */
  42878. dispose(): void;
  42879. }
  42880. }
  42881. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42882. import { Nullable } from "babylonjs/types";
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { IDisposable, Scene } from "babylonjs/scene";
  42885. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42886. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42887. /**
  42888. * Button which can be used to enter a different mode of XR
  42889. */
  42890. export class WebXREnterExitUIButton {
  42891. /** button element */
  42892. element: HTMLElement;
  42893. /** XR initialization options for the button */
  42894. sessionMode: XRSessionMode;
  42895. /** Reference space type */
  42896. referenceSpaceType: XRReferenceSpaceType;
  42897. /**
  42898. * Creates a WebXREnterExitUIButton
  42899. * @param element button element
  42900. * @param sessionMode XR initialization session mode
  42901. * @param referenceSpaceType the type of reference space to be used
  42902. */
  42903. constructor(
  42904. /** button element */
  42905. element: HTMLElement,
  42906. /** XR initialization options for the button */
  42907. sessionMode: XRSessionMode,
  42908. /** Reference space type */
  42909. referenceSpaceType: XRReferenceSpaceType);
  42910. /**
  42911. * Overwritable function which can be used to update the button's visuals when the state changes
  42912. * @param activeButton the current active button in the UI
  42913. */
  42914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42915. }
  42916. /**
  42917. * Options to create the webXR UI
  42918. */
  42919. export class WebXREnterExitUIOptions {
  42920. /**
  42921. * Context to enter xr with
  42922. */
  42923. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42924. /**
  42925. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42926. */
  42927. customButtons?: Array<WebXREnterExitUIButton>;
  42928. }
  42929. /**
  42930. * UI to allow the user to enter/exit XR mode
  42931. */
  42932. export class WebXREnterExitUI implements IDisposable {
  42933. private scene;
  42934. private _overlay;
  42935. private _buttons;
  42936. private _activeButton;
  42937. /**
  42938. * Fired every time the active button is changed.
  42939. *
  42940. * When xr is entered via a button that launches xr that button will be the callback parameter
  42941. *
  42942. * When exiting xr the callback parameter will be null)
  42943. */
  42944. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42945. /**
  42946. * Creates UI to allow the user to enter/exit XR mode
  42947. * @param scene the scene to add the ui to
  42948. * @param helper the xr experience helper to enter/exit xr with
  42949. * @param options options to configure the UI
  42950. * @returns the created ui
  42951. */
  42952. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42953. private constructor();
  42954. private _updateButtons;
  42955. /**
  42956. * Disposes of the object
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module "babylonjs/Cameras/XR/webXRController" {
  42962. import { Nullable } from "babylonjs/types";
  42963. import { Observable } from "babylonjs/Misc/observable";
  42964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42965. import { Ray } from "babylonjs/Culling/ray";
  42966. import { Scene } from "babylonjs/scene";
  42967. /**
  42968. * Represents an XR input
  42969. */
  42970. export class WebXRController {
  42971. private scene;
  42972. /** The underlying input source for the controller */
  42973. inputSource: XRInputSource;
  42974. private parentContainer;
  42975. /**
  42976. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  42977. */
  42978. grip?: AbstractMesh;
  42979. /**
  42980. * Pointer which can be used to select objects or attach a visible laser to
  42981. */
  42982. pointer: AbstractMesh;
  42983. /**
  42984. * Event that fires when the controller is removed/disposed
  42985. */
  42986. onDisposeObservable: Observable<{}>;
  42987. private _tmpMatrix;
  42988. private _tmpQuaternion;
  42989. private _tmpVector;
  42990. /**
  42991. * Creates the controller
  42992. * @see https://doc.babylonjs.com/how_to/webxr
  42993. * @param scene the scene which the controller should be associated to
  42994. * @param inputSource the underlying input source for the controller
  42995. * @param parentContainer parent that the controller meshes should be children of
  42996. */
  42997. constructor(scene: Scene,
  42998. /** The underlying input source for the controller */
  42999. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43000. /**
  43001. * Updates the controller pose based on the given XRFrame
  43002. * @param xrFrame xr frame to update the pose with
  43003. * @param referenceSpace reference space to use
  43004. */
  43005. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43006. /**
  43007. * Gets a world space ray coming from the controller
  43008. * @param result the resulting ray
  43009. */
  43010. getWorldPointerRayToRef(result: Ray): void;
  43011. /**
  43012. * Disposes of the object
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/XR/webXRInput" {
  43018. import { Observable } from "babylonjs/Misc/observable";
  43019. import { IDisposable } from "babylonjs/scene";
  43020. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43021. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43022. /**
  43023. * XR input used to track XR inputs such as controllers/rays
  43024. */
  43025. export class WebXRInput implements IDisposable {
  43026. /**
  43027. * Base experience the input listens to
  43028. */
  43029. baseExperience: WebXRExperienceHelper;
  43030. /**
  43031. * XR controllers being tracked
  43032. */
  43033. controllers: Array<WebXRController>;
  43034. private _frameObserver;
  43035. private _stateObserver;
  43036. /**
  43037. * Event when a controller has been connected/added
  43038. */
  43039. onControllerAddedObservable: Observable<WebXRController>;
  43040. /**
  43041. * Event when a controller has been removed/disconnected
  43042. */
  43043. onControllerRemovedObservable: Observable<WebXRController>;
  43044. /**
  43045. * Initializes the WebXRInput
  43046. * @param baseExperience experience helper which the input should be created for
  43047. */
  43048. constructor(
  43049. /**
  43050. * Base experience the input listens to
  43051. */
  43052. baseExperience: WebXRExperienceHelper);
  43053. private _onInputSourcesChange;
  43054. private _addAndRemoveControllers;
  43055. /**
  43056. * Disposes of the object
  43057. */
  43058. dispose(): void;
  43059. }
  43060. }
  43061. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43063. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43064. /**
  43065. * Enables teleportation
  43066. */
  43067. export class WebXRControllerTeleportation {
  43068. private _teleportationFillColor;
  43069. private _teleportationBorderColor;
  43070. private _tmpRay;
  43071. private _tmpVector;
  43072. /**
  43073. * Creates a WebXRControllerTeleportation
  43074. * @param input input manager to add teleportation to
  43075. * @param floorMeshes floormeshes which can be teleported to
  43076. */
  43077. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43078. }
  43079. }
  43080. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43081. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43082. /**
  43083. * Handles pointer input automatically for the pointer of XR controllers
  43084. */
  43085. export class WebXRControllerPointerSelection {
  43086. private static _idCounter;
  43087. private _tmpRay;
  43088. /**
  43089. * Creates a WebXRControllerPointerSelection
  43090. * @param input input manager to setup pointer selection
  43091. */
  43092. constructor(input: WebXRInput);
  43093. private _convertNormalToDirectionOfRay;
  43094. private _updatePointerDistance;
  43095. }
  43096. }
  43097. declare module "babylonjs/Loading/sceneLoader" {
  43098. import { Observable } from "babylonjs/Misc/observable";
  43099. import { Nullable } from "babylonjs/types";
  43100. import { Scene } from "babylonjs/scene";
  43101. import { Engine } from "babylonjs/Engines/engine";
  43102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43103. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43104. import { AssetContainer } from "babylonjs/assetContainer";
  43105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43106. import { Skeleton } from "babylonjs/Bones/skeleton";
  43107. /**
  43108. * Class used to represent data loading progression
  43109. */
  43110. export class SceneLoaderProgressEvent {
  43111. /** defines if data length to load can be evaluated */
  43112. readonly lengthComputable: boolean;
  43113. /** defines the loaded data length */
  43114. readonly loaded: number;
  43115. /** defines the data length to load */
  43116. readonly total: number;
  43117. /**
  43118. * Create a new progress event
  43119. * @param lengthComputable defines if data length to load can be evaluated
  43120. * @param loaded defines the loaded data length
  43121. * @param total defines the data length to load
  43122. */
  43123. constructor(
  43124. /** defines if data length to load can be evaluated */
  43125. lengthComputable: boolean,
  43126. /** defines the loaded data length */
  43127. loaded: number,
  43128. /** defines the data length to load */
  43129. total: number);
  43130. /**
  43131. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43132. * @param event defines the source event
  43133. * @returns a new SceneLoaderProgressEvent
  43134. */
  43135. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43136. }
  43137. /**
  43138. * Interface used by SceneLoader plugins to define supported file extensions
  43139. */
  43140. export interface ISceneLoaderPluginExtensions {
  43141. /**
  43142. * Defines the list of supported extensions
  43143. */
  43144. [extension: string]: {
  43145. isBinary: boolean;
  43146. };
  43147. }
  43148. /**
  43149. * Interface used by SceneLoader plugin factory
  43150. */
  43151. export interface ISceneLoaderPluginFactory {
  43152. /**
  43153. * Defines the name of the factory
  43154. */
  43155. name: string;
  43156. /**
  43157. * Function called to create a new plugin
  43158. * @return the new plugin
  43159. */
  43160. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43161. /**
  43162. * Boolean indicating if the plugin can direct load specific data
  43163. */
  43164. canDirectLoad?: (data: string) => boolean;
  43165. }
  43166. /**
  43167. * Interface used to define a SceneLoader plugin
  43168. */
  43169. export interface ISceneLoaderPlugin {
  43170. /**
  43171. * The friendly name of this plugin.
  43172. */
  43173. name: string;
  43174. /**
  43175. * The file extensions supported by this plugin.
  43176. */
  43177. extensions: string | ISceneLoaderPluginExtensions;
  43178. /**
  43179. * Import meshes into a scene.
  43180. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43181. * @param scene The scene to import into
  43182. * @param data The data to import
  43183. * @param rootUrl The root url for scene and resources
  43184. * @param meshes The meshes array to import into
  43185. * @param particleSystems The particle systems array to import into
  43186. * @param skeletons The skeletons array to import into
  43187. * @param onError The callback when import fails
  43188. * @returns True if successful or false otherwise
  43189. */
  43190. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43191. /**
  43192. * Load into a scene.
  43193. * @param scene The scene to load into
  43194. * @param data The data to import
  43195. * @param rootUrl The root url for scene and resources
  43196. * @param onError The callback when import fails
  43197. * @returns true if successful or false otherwise
  43198. */
  43199. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43200. /**
  43201. * The callback that returns true if the data can be directly loaded.
  43202. */
  43203. canDirectLoad?: (data: string) => boolean;
  43204. /**
  43205. * The callback that allows custom handling of the root url based on the response url.
  43206. */
  43207. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43208. /**
  43209. * Load into an asset container.
  43210. * @param scene The scene to load into
  43211. * @param data The data to import
  43212. * @param rootUrl The root url for scene and resources
  43213. * @param onError The callback when import fails
  43214. * @returns The loaded asset container
  43215. */
  43216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43217. }
  43218. /**
  43219. * Interface used to define an async SceneLoader plugin
  43220. */
  43221. export interface ISceneLoaderPluginAsync {
  43222. /**
  43223. * The friendly name of this plugin.
  43224. */
  43225. name: string;
  43226. /**
  43227. * The file extensions supported by this plugin.
  43228. */
  43229. extensions: string | ISceneLoaderPluginExtensions;
  43230. /**
  43231. * Import meshes into a scene.
  43232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43233. * @param scene The scene to import into
  43234. * @param data The data to import
  43235. * @param rootUrl The root url for scene and resources
  43236. * @param onProgress The callback when the load progresses
  43237. * @param fileName Defines the name of the file to load
  43238. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43239. */
  43240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43241. meshes: AbstractMesh[];
  43242. particleSystems: IParticleSystem[];
  43243. skeletons: Skeleton[];
  43244. animationGroups: AnimationGroup[];
  43245. }>;
  43246. /**
  43247. * Load into a scene.
  43248. * @param scene The scene to load into
  43249. * @param data The data to import
  43250. * @param rootUrl The root url for scene and resources
  43251. * @param onProgress The callback when the load progresses
  43252. * @param fileName Defines the name of the file to load
  43253. * @returns Nothing
  43254. */
  43255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43256. /**
  43257. * The callback that returns true if the data can be directly loaded.
  43258. */
  43259. canDirectLoad?: (data: string) => boolean;
  43260. /**
  43261. * The callback that allows custom handling of the root url based on the response url.
  43262. */
  43263. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43264. /**
  43265. * Load into an asset container.
  43266. * @param scene The scene to load into
  43267. * @param data The data to import
  43268. * @param rootUrl The root url for scene and resources
  43269. * @param onProgress The callback when the load progresses
  43270. * @param fileName Defines the name of the file to load
  43271. * @returns The loaded asset container
  43272. */
  43273. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43274. }
  43275. /**
  43276. * Class used to load scene from various file formats using registered plugins
  43277. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43278. */
  43279. export class SceneLoader {
  43280. /**
  43281. * No logging while loading
  43282. */
  43283. static readonly NO_LOGGING: number;
  43284. /**
  43285. * Minimal logging while loading
  43286. */
  43287. static readonly MINIMAL_LOGGING: number;
  43288. /**
  43289. * Summary logging while loading
  43290. */
  43291. static readonly SUMMARY_LOGGING: number;
  43292. /**
  43293. * Detailled logging while loading
  43294. */
  43295. static readonly DETAILED_LOGGING: number;
  43296. /**
  43297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43298. */
  43299. static ForceFullSceneLoadingForIncremental: boolean;
  43300. /**
  43301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43302. */
  43303. static ShowLoadingScreen: boolean;
  43304. /**
  43305. * Defines the current logging level (while loading the scene)
  43306. * @ignorenaming
  43307. */
  43308. static loggingLevel: number;
  43309. /**
  43310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43311. */
  43312. static CleanBoneMatrixWeights: boolean;
  43313. /**
  43314. * Event raised when a plugin is used to load a scene
  43315. */
  43316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43317. private static _registeredPlugins;
  43318. private static _getDefaultPlugin;
  43319. private static _getPluginForExtension;
  43320. private static _getPluginForDirectLoad;
  43321. private static _getPluginForFilename;
  43322. private static _getDirectLoad;
  43323. private static _loadData;
  43324. private static _getFileInfo;
  43325. /**
  43326. * Gets a plugin that can load the given extension
  43327. * @param extension defines the extension to load
  43328. * @returns a plugin or null if none works
  43329. */
  43330. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43331. /**
  43332. * Gets a boolean indicating that the given extension can be loaded
  43333. * @param extension defines the extension to load
  43334. * @returns true if the extension is supported
  43335. */
  43336. static IsPluginForExtensionAvailable(extension: string): boolean;
  43337. /**
  43338. * Adds a new plugin to the list of registered plugins
  43339. * @param plugin defines the plugin to add
  43340. */
  43341. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43342. /**
  43343. * Import meshes into a scene
  43344. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43345. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43346. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43347. * @param scene the instance of BABYLON.Scene to append to
  43348. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43349. * @param onProgress a callback with a progress event for each file being loaded
  43350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43351. * @param pluginExtension the extension used to determine the plugin
  43352. * @returns The loaded plugin
  43353. */
  43354. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43355. /**
  43356. * Import meshes into a scene
  43357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43358. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43359. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43360. * @param scene the instance of BABYLON.Scene to append to
  43361. * @param onProgress a callback with a progress event for each file being loaded
  43362. * @param pluginExtension the extension used to determine the plugin
  43363. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43364. */
  43365. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43366. meshes: AbstractMesh[];
  43367. particleSystems: IParticleSystem[];
  43368. skeletons: Skeleton[];
  43369. animationGroups: AnimationGroup[];
  43370. }>;
  43371. /**
  43372. * Load a scene
  43373. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43374. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43376. * @param onSuccess a callback with the scene when import succeeds
  43377. * @param onProgress a callback with a progress event for each file being loaded
  43378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded plugin
  43381. */
  43382. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43383. /**
  43384. * Load a scene
  43385. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43386. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43388. * @param onProgress a callback with a progress event for each file being loaded
  43389. * @param pluginExtension the extension used to determine the plugin
  43390. * @returns The loaded scene
  43391. */
  43392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43393. /**
  43394. * Append a scene
  43395. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43396. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43397. * @param scene is the instance of BABYLON.Scene to append to
  43398. * @param onSuccess a callback with the scene when import succeeds
  43399. * @param onProgress a callback with a progress event for each file being loaded
  43400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43401. * @param pluginExtension the extension used to determine the plugin
  43402. * @returns The loaded plugin
  43403. */
  43404. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43405. /**
  43406. * Append a scene
  43407. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43408. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43409. * @param scene is the instance of BABYLON.Scene to append to
  43410. * @param onProgress a callback with a progress event for each file being loaded
  43411. * @param pluginExtension the extension used to determine the plugin
  43412. * @returns The given scene
  43413. */
  43414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43415. /**
  43416. * Load a scene into an asset container
  43417. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43418. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43420. * @param onSuccess a callback with the scene when import succeeds
  43421. * @param onProgress a callback with a progress event for each file being loaded
  43422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43423. * @param pluginExtension the extension used to determine the plugin
  43424. * @returns The loaded plugin
  43425. */
  43426. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43427. /**
  43428. * Load a scene into an asset container
  43429. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43430. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  43431. * @param scene is the instance of Scene to append to
  43432. * @param onProgress a callback with a progress event for each file being loaded
  43433. * @param pluginExtension the extension used to determine the plugin
  43434. * @returns The loaded asset container
  43435. */
  43436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43437. }
  43438. }
  43439. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43440. import { Scene } from "babylonjs/scene";
  43441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43442. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43443. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43444. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43445. /**
  43446. * Generic Controller
  43447. */
  43448. export class GenericController extends WebVRController {
  43449. /**
  43450. * Base Url for the controller model.
  43451. */
  43452. static readonly MODEL_BASE_URL: string;
  43453. /**
  43454. * File name for the controller model.
  43455. */
  43456. static readonly MODEL_FILENAME: string;
  43457. /**
  43458. * Creates a new GenericController from a gamepad
  43459. * @param vrGamepad the gamepad that the controller should be created from
  43460. */
  43461. constructor(vrGamepad: any);
  43462. /**
  43463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43464. * @param scene scene in which to add meshes
  43465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43466. */
  43467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43468. /**
  43469. * Called once for each button that changed state since the last frame
  43470. * @param buttonIdx Which button index changed
  43471. * @param state New state of the button
  43472. * @param changes Which properties on the state changed since last frame
  43473. */
  43474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43475. }
  43476. }
  43477. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43478. import { Observable } from "babylonjs/Misc/observable";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43481. import { Ray } from "babylonjs/Culling/ray";
  43482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43484. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43485. /**
  43486. * Defines the WindowsMotionController object that the state of the windows motion controller
  43487. */
  43488. export class WindowsMotionController extends WebVRController {
  43489. /**
  43490. * The base url used to load the left and right controller models
  43491. */
  43492. static MODEL_BASE_URL: string;
  43493. /**
  43494. * The name of the left controller model file
  43495. */
  43496. static MODEL_LEFT_FILENAME: string;
  43497. /**
  43498. * The name of the right controller model file
  43499. */
  43500. static MODEL_RIGHT_FILENAME: string;
  43501. /**
  43502. * The controller name prefix for this controller type
  43503. */
  43504. static readonly GAMEPAD_ID_PREFIX: string;
  43505. /**
  43506. * The controller id pattern for this controller type
  43507. */
  43508. private static readonly GAMEPAD_ID_PATTERN;
  43509. private _loadedMeshInfo;
  43510. private readonly _mapping;
  43511. /**
  43512. * Fired when the trackpad on this controller is clicked
  43513. */
  43514. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43515. /**
  43516. * Fired when the trackpad on this controller is modified
  43517. */
  43518. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43519. /**
  43520. * The current x and y values of this controller's trackpad
  43521. */
  43522. trackpad: StickValues;
  43523. /**
  43524. * Creates a new WindowsMotionController from a gamepad
  43525. * @param vrGamepad the gamepad that the controller should be created from
  43526. */
  43527. constructor(vrGamepad: any);
  43528. /**
  43529. * Fired when the trigger on this controller is modified
  43530. */
  43531. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Fired when the menu button on this controller is modified
  43534. */
  43535. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43536. /**
  43537. * Fired when the grip button on this controller is modified
  43538. */
  43539. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the thumbstick button on this controller is modified
  43542. */
  43543. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43544. /**
  43545. * Fired when the touchpad button on this controller is modified
  43546. */
  43547. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43548. /**
  43549. * Fired when the touchpad values on this controller are modified
  43550. */
  43551. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43552. private _updateTrackpad;
  43553. /**
  43554. * Called once per frame by the engine.
  43555. */
  43556. update(): void;
  43557. /**
  43558. * Called once for each button that changed state since the last frame
  43559. * @param buttonIdx Which button index changed
  43560. * @param state New state of the button
  43561. * @param changes Which properties on the state changed since last frame
  43562. */
  43563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43564. /**
  43565. * Moves the buttons on the controller mesh based on their current state
  43566. * @param buttonName the name of the button to move
  43567. * @param buttonValue the value of the button which determines the buttons new position
  43568. */
  43569. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43570. /**
  43571. * Moves the axis on the controller mesh based on its current state
  43572. * @param axis the index of the axis
  43573. * @param axisValue the value of the axis which determines the meshes new position
  43574. * @hidden
  43575. */
  43576. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43577. /**
  43578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43579. * @param scene scene in which to add meshes
  43580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43581. */
  43582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43583. /**
  43584. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43585. * can be transformed by button presses and axes values, based on this._mapping.
  43586. *
  43587. * @param scene scene in which the meshes exist
  43588. * @param meshes list of meshes that make up the controller model to process
  43589. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43590. */
  43591. private processModel;
  43592. private createMeshInfo;
  43593. /**
  43594. * Gets the ray of the controller in the direction the controller is pointing
  43595. * @param length the length the resulting ray should be
  43596. * @returns a ray in the direction the controller is pointing
  43597. */
  43598. getForwardRay(length?: number): Ray;
  43599. /**
  43600. * Disposes of the controller
  43601. */
  43602. dispose(): void;
  43603. }
  43604. }
  43605. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43606. import { Observable } from "babylonjs/Misc/observable";
  43607. import { Scene } from "babylonjs/scene";
  43608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43609. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43610. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43611. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43612. /**
  43613. * Oculus Touch Controller
  43614. */
  43615. export class OculusTouchController extends WebVRController {
  43616. /**
  43617. * Base Url for the controller model.
  43618. */
  43619. static MODEL_BASE_URL: string;
  43620. /**
  43621. * File name for the left controller model.
  43622. */
  43623. static MODEL_LEFT_FILENAME: string;
  43624. /**
  43625. * File name for the right controller model.
  43626. */
  43627. static MODEL_RIGHT_FILENAME: string;
  43628. /**
  43629. * Base Url for the Quest controller model.
  43630. */
  43631. static QUEST_MODEL_BASE_URL: string;
  43632. /**
  43633. * @hidden
  43634. * If the controllers are running on a device that needs the updated Quest controller models
  43635. */
  43636. static _IsQuest: boolean;
  43637. /**
  43638. * Fired when the secondary trigger on this controller is modified
  43639. */
  43640. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43641. /**
  43642. * Fired when the thumb rest on this controller is modified
  43643. */
  43644. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43645. /**
  43646. * Creates a new OculusTouchController from a gamepad
  43647. * @param vrGamepad the gamepad that the controller should be created from
  43648. */
  43649. constructor(vrGamepad: any);
  43650. /**
  43651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43652. * @param scene scene in which to add meshes
  43653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43654. */
  43655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43656. /**
  43657. * Fired when the A button on this controller is modified
  43658. */
  43659. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43660. /**
  43661. * Fired when the B button on this controller is modified
  43662. */
  43663. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43664. /**
  43665. * Fired when the X button on this controller is modified
  43666. */
  43667. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43668. /**
  43669. * Fired when the Y button on this controller is modified
  43670. */
  43671. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43672. /**
  43673. * Called once for each button that changed state since the last frame
  43674. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43675. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43676. * 2) secondary trigger (same)
  43677. * 3) A (right) X (left), touch, pressed = value
  43678. * 4) B / Y
  43679. * 5) thumb rest
  43680. * @param buttonIdx Which button index changed
  43681. * @param state New state of the button
  43682. * @param changes Which properties on the state changed since last frame
  43683. */
  43684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43685. }
  43686. }
  43687. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43688. import { Scene } from "babylonjs/scene";
  43689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43690. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43691. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43692. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43693. import { Observable } from "babylonjs/Misc/observable";
  43694. /**
  43695. * Vive Controller
  43696. */
  43697. export class ViveController extends WebVRController {
  43698. /**
  43699. * Base Url for the controller model.
  43700. */
  43701. static MODEL_BASE_URL: string;
  43702. /**
  43703. * File name for the controller model.
  43704. */
  43705. static MODEL_FILENAME: string;
  43706. /**
  43707. * Creates a new ViveController from a gamepad
  43708. * @param vrGamepad the gamepad that the controller should be created from
  43709. */
  43710. constructor(vrGamepad: any);
  43711. /**
  43712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43713. * @param scene scene in which to add meshes
  43714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43715. */
  43716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43717. /**
  43718. * Fired when the left button on this controller is modified
  43719. */
  43720. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the right button on this controller is modified
  43723. */
  43724. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43725. /**
  43726. * Fired when the menu button on this controller is modified
  43727. */
  43728. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43729. /**
  43730. * Called once for each button that changed state since the last frame
  43731. * Vive mapping:
  43732. * 0: touchpad
  43733. * 1: trigger
  43734. * 2: left AND right buttons
  43735. * 3: menu button
  43736. * @param buttonIdx Which button index changed
  43737. * @param state New state of the button
  43738. * @param changes Which properties on the state changed since last frame
  43739. */
  43740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43741. }
  43742. }
  43743. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43744. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43745. /**
  43746. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43747. */
  43748. export class WebXRControllerModelLoader {
  43749. /**
  43750. * Creates the WebXRControllerModelLoader
  43751. * @param input xr input that creates the controllers
  43752. */
  43753. constructor(input: WebXRInput);
  43754. }
  43755. }
  43756. declare module "babylonjs/Cameras/XR/index" {
  43757. export * from "babylonjs/Cameras/XR/webXRCamera";
  43758. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43759. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43760. export * from "babylonjs/Cameras/XR/webXRInput";
  43761. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43762. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43763. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43764. export * from "babylonjs/Cameras/XR/webXRController";
  43765. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43766. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43767. }
  43768. declare module "babylonjs/Cameras/RigModes/index" {
  43769. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43770. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43771. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43772. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43773. }
  43774. declare module "babylonjs/Cameras/index" {
  43775. export * from "babylonjs/Cameras/Inputs/index";
  43776. export * from "babylonjs/Cameras/cameraInputsManager";
  43777. export * from "babylonjs/Cameras/camera";
  43778. export * from "babylonjs/Cameras/targetCamera";
  43779. export * from "babylonjs/Cameras/freeCamera";
  43780. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43781. export * from "babylonjs/Cameras/touchCamera";
  43782. export * from "babylonjs/Cameras/arcRotateCamera";
  43783. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43784. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43785. export * from "babylonjs/Cameras/flyCamera";
  43786. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43787. export * from "babylonjs/Cameras/followCamera";
  43788. export * from "babylonjs/Cameras/followCameraInputsManager";
  43789. export * from "babylonjs/Cameras/gamepadCamera";
  43790. export * from "babylonjs/Cameras/Stereoscopic/index";
  43791. export * from "babylonjs/Cameras/universalCamera";
  43792. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43793. export * from "babylonjs/Cameras/VR/index";
  43794. export * from "babylonjs/Cameras/XR/index";
  43795. export * from "babylonjs/Cameras/RigModes/index";
  43796. }
  43797. declare module "babylonjs/Collisions/index" {
  43798. export * from "babylonjs/Collisions/collider";
  43799. export * from "babylonjs/Collisions/collisionCoordinator";
  43800. export * from "babylonjs/Collisions/pickingInfo";
  43801. export * from "babylonjs/Collisions/intersectionInfo";
  43802. export * from "babylonjs/Collisions/meshCollisionData";
  43803. }
  43804. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43805. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43806. import { Vector3 } from "babylonjs/Maths/math.vector";
  43807. import { Ray } from "babylonjs/Culling/ray";
  43808. import { Plane } from "babylonjs/Maths/math.plane";
  43809. /**
  43810. * Contains an array of blocks representing the octree
  43811. */
  43812. export interface IOctreeContainer<T> {
  43813. /**
  43814. * Blocks within the octree
  43815. */
  43816. blocks: Array<OctreeBlock<T>>;
  43817. }
  43818. /**
  43819. * Class used to store a cell in an octree
  43820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43821. */
  43822. export class OctreeBlock<T> {
  43823. /**
  43824. * Gets the content of the current block
  43825. */
  43826. entries: T[];
  43827. /**
  43828. * Gets the list of block children
  43829. */
  43830. blocks: Array<OctreeBlock<T>>;
  43831. private _depth;
  43832. private _maxDepth;
  43833. private _capacity;
  43834. private _minPoint;
  43835. private _maxPoint;
  43836. private _boundingVectors;
  43837. private _creationFunc;
  43838. /**
  43839. * Creates a new block
  43840. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43841. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43842. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43843. * @param depth defines the current depth of this block in the octree
  43844. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43845. * @param creationFunc defines a callback to call when an element is added to the block
  43846. */
  43847. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43848. /**
  43849. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43850. */
  43851. readonly capacity: number;
  43852. /**
  43853. * Gets the minimum vector (in world space) of the block's bounding box
  43854. */
  43855. readonly minPoint: Vector3;
  43856. /**
  43857. * Gets the maximum vector (in world space) of the block's bounding box
  43858. */
  43859. readonly maxPoint: Vector3;
  43860. /**
  43861. * Add a new element to this block
  43862. * @param entry defines the element to add
  43863. */
  43864. addEntry(entry: T): void;
  43865. /**
  43866. * Remove an element from this block
  43867. * @param entry defines the element to remove
  43868. */
  43869. removeEntry(entry: T): void;
  43870. /**
  43871. * Add an array of elements to this block
  43872. * @param entries defines the array of elements to add
  43873. */
  43874. addEntries(entries: T[]): void;
  43875. /**
  43876. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43877. * @param frustumPlanes defines the frustum planes to test
  43878. * @param selection defines the array to store current content if selection is positive
  43879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43880. */
  43881. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43882. /**
  43883. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43884. * @param sphereCenter defines the bounding sphere center
  43885. * @param sphereRadius defines the bounding sphere radius
  43886. * @param selection defines the array to store current content if selection is positive
  43887. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43888. */
  43889. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43890. /**
  43891. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43892. * @param ray defines the ray to test with
  43893. * @param selection defines the array to store current content if selection is positive
  43894. */
  43895. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43896. /**
  43897. * Subdivide the content into child blocks (this block will then be empty)
  43898. */
  43899. createInnerBlocks(): void;
  43900. /**
  43901. * @hidden
  43902. */
  43903. static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  43904. }
  43905. }
  43906. declare module "babylonjs/Culling/Octrees/octree" {
  43907. import { SmartArray } from "babylonjs/Misc/smartArray";
  43908. import { Vector3 } from "babylonjs/Maths/math.vector";
  43909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { Ray } from "babylonjs/Culling/ray";
  43912. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43913. import { Plane } from "babylonjs/Maths/math.plane";
  43914. /**
  43915. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43917. */
  43918. export class Octree<T> {
  43919. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  43920. maxDepth: number;
  43921. /**
  43922. * Blocks within the octree containing objects
  43923. */
  43924. blocks: Array<OctreeBlock<T>>;
  43925. /**
  43926. * Content stored in the octree
  43927. */
  43928. dynamicContent: T[];
  43929. private _maxBlockCapacity;
  43930. private _selectionContent;
  43931. private _creationFunc;
  43932. /**
  43933. * Creates a octree
  43934. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43935. * @param creationFunc function to be used to instatiate the octree
  43936. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43937. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  43938. */
  43939. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43940. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  43941. maxDepth?: number);
  43942. /**
  43943. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43944. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  43945. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  43946. * @param entries meshes to be added to the octree blocks
  43947. */
  43948. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43949. /**
  43950. * Adds a mesh to the octree
  43951. * @param entry Mesh to add to the octree
  43952. */
  43953. addMesh(entry: T): void;
  43954. /**
  43955. * Remove an element from the octree
  43956. * @param entry defines the element to remove
  43957. */
  43958. removeMesh(entry: T): void;
  43959. /**
  43960. * Selects an array of meshes within the frustum
  43961. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43962. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43963. * @returns array of meshes within the frustum
  43964. */
  43965. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43966. /**
  43967. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43968. * @param sphereCenter defines the bounding sphere center
  43969. * @param sphereRadius defines the bounding sphere radius
  43970. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43971. * @returns an array of objects that intersect the sphere
  43972. */
  43973. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43974. /**
  43975. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43976. * @param ray defines the ray to test with
  43977. * @returns array of intersected objects
  43978. */
  43979. intersectsRay(ray: Ray): SmartArray<T>;
  43980. /**
  43981. * Adds a mesh into the octree block if it intersects the block
  43982. */
  43983. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43984. /**
  43985. * Adds a submesh into the octree block if it intersects the block
  43986. */
  43987. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43988. }
  43989. }
  43990. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43991. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43992. import { Scene } from "babylonjs/scene";
  43993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { Ray } from "babylonjs/Culling/ray";
  43996. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43997. import { Collider } from "babylonjs/Collisions/collider";
  43998. module "babylonjs/scene" {
  43999. interface Scene {
  44000. /**
  44001. * @hidden
  44002. * Backing Filed
  44003. */
  44004. _selectionOctree: Octree<AbstractMesh>;
  44005. /**
  44006. * Gets the octree used to boost mesh selection (picking)
  44007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44008. */
  44009. selectionOctree: Octree<AbstractMesh>;
  44010. /**
  44011. * Creates or updates the octree used to boost selection (picking)
  44012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44013. * @param maxCapacity defines the maximum capacity per leaf
  44014. * @param maxDepth defines the maximum depth of the octree
  44015. * @returns an octree of AbstractMesh
  44016. */
  44017. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44018. }
  44019. }
  44020. module "babylonjs/Meshes/abstractMesh" {
  44021. interface AbstractMesh {
  44022. /**
  44023. * @hidden
  44024. * Backing Field
  44025. */
  44026. _submeshesOctree: Octree<SubMesh>;
  44027. /**
  44028. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44030. * @param maxCapacity defines the maximum size of each block (64 by default)
  44031. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44032. * @returns the new octree
  44033. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44035. */
  44036. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44037. }
  44038. }
  44039. /**
  44040. * Defines the octree scene component responsible to manage any octrees
  44041. * in a given scene.
  44042. */
  44043. export class OctreeSceneComponent {
  44044. /**
  44045. * The component name help to identify the component in the list of scene components.
  44046. */
  44047. readonly name: string;
  44048. /**
  44049. * The scene the component belongs to.
  44050. */
  44051. scene: Scene;
  44052. /**
  44053. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44054. */
  44055. readonly checksIsEnabled: boolean;
  44056. /**
  44057. * Creates a new instance of the component for the given scene
  44058. * @param scene Defines the scene to register the component in
  44059. */
  44060. constructor(scene: Scene);
  44061. /**
  44062. * Registers the component in a given scene
  44063. */
  44064. register(): void;
  44065. /**
  44066. * Return the list of active meshes
  44067. * @returns the list of active meshes
  44068. */
  44069. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44070. /**
  44071. * Return the list of active sub meshes
  44072. * @param mesh The mesh to get the candidates sub meshes from
  44073. * @returns the list of active sub meshes
  44074. */
  44075. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44076. private _tempRay;
  44077. /**
  44078. * Return the list of sub meshes intersecting with a given local ray
  44079. * @param mesh defines the mesh to find the submesh for
  44080. * @param localRay defines the ray in local space
  44081. * @returns the list of intersecting sub meshes
  44082. */
  44083. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44084. /**
  44085. * Return the list of sub meshes colliding with a collider
  44086. * @param mesh defines the mesh to find the submesh for
  44087. * @param collider defines the collider to evaluate the collision against
  44088. * @returns the list of colliding sub meshes
  44089. */
  44090. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44091. /**
  44092. * Rebuilds the elements related to this component in case of
  44093. * context lost for instance.
  44094. */
  44095. rebuild(): void;
  44096. /**
  44097. * Disposes the component and the associated ressources.
  44098. */
  44099. dispose(): void;
  44100. }
  44101. }
  44102. declare module "babylonjs/Culling/Octrees/index" {
  44103. export * from "babylonjs/Culling/Octrees/octree";
  44104. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44105. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44106. }
  44107. declare module "babylonjs/Culling/index" {
  44108. export * from "babylonjs/Culling/boundingBox";
  44109. export * from "babylonjs/Culling/boundingInfo";
  44110. export * from "babylonjs/Culling/boundingSphere";
  44111. export * from "babylonjs/Culling/Octrees/index";
  44112. export * from "babylonjs/Culling/ray";
  44113. }
  44114. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44115. import { IDisposable, Scene } from "babylonjs/scene";
  44116. import { Nullable } from "babylonjs/types";
  44117. import { Observable } from "babylonjs/Misc/observable";
  44118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44119. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44120. import { Camera } from "babylonjs/Cameras/camera";
  44121. /**
  44122. * Renders a layer on top of an existing scene
  44123. */
  44124. export class UtilityLayerRenderer implements IDisposable {
  44125. /** the original scene that will be rendered on top of */
  44126. originalScene: Scene;
  44127. private _pointerCaptures;
  44128. private _lastPointerEvents;
  44129. private static _DefaultUtilityLayer;
  44130. private static _DefaultKeepDepthUtilityLayer;
  44131. private _sharedGizmoLight;
  44132. private _renderCamera;
  44133. /**
  44134. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44135. * @returns the camera that is used when rendering the utility layer
  44136. */
  44137. getRenderCamera(): Nullable<Camera>;
  44138. /**
  44139. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44140. * @param cam the camera that should be used when rendering the utility layer
  44141. */
  44142. setRenderCamera(cam: Nullable<Camera>): void;
  44143. /**
  44144. * @hidden
  44145. * Light which used by gizmos to get light shading
  44146. */
  44147. _getSharedGizmoLight(): HemisphericLight;
  44148. /**
  44149. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44150. */
  44151. pickUtilitySceneFirst: boolean;
  44152. /**
  44153. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  44154. */
  44155. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44156. /**
  44157. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  44158. */
  44159. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44160. /**
  44161. * The scene that is rendered on top of the original scene
  44162. */
  44163. utilityLayerScene: Scene;
  44164. /**
  44165. * If the utility layer should automatically be rendered on top of existing scene
  44166. */
  44167. shouldRender: boolean;
  44168. /**
  44169. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44170. */
  44171. onlyCheckPointerDownEvents: boolean;
  44172. /**
  44173. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44174. */
  44175. processAllEvents: boolean;
  44176. /**
  44177. * Observable raised when the pointer move from the utility layer scene to the main scene
  44178. */
  44179. onPointerOutObservable: Observable<number>;
  44180. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44181. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44182. private _afterRenderObserver;
  44183. private _sceneDisposeObserver;
  44184. private _originalPointerObserver;
  44185. /**
  44186. * Instantiates a UtilityLayerRenderer
  44187. * @param originalScene the original scene that will be rendered on top of
  44188. * @param handleEvents boolean indicating if the utility layer should handle events
  44189. */
  44190. constructor(
  44191. /** the original scene that will be rendered on top of */
  44192. originalScene: Scene, handleEvents?: boolean);
  44193. private _notifyObservers;
  44194. /**
  44195. * Renders the utility layers scene on top of the original scene
  44196. */
  44197. render(): void;
  44198. /**
  44199. * Disposes of the renderer
  44200. */
  44201. dispose(): void;
  44202. private _updateCamera;
  44203. }
  44204. }
  44205. declare module "babylonjs/Gizmos/gizmo" {
  44206. import { Nullable } from "babylonjs/types";
  44207. import { IDisposable } from "babylonjs/scene";
  44208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44209. import { Mesh } from "babylonjs/Meshes/mesh";
  44210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44211. /**
  44212. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44213. */
  44214. export class Gizmo implements IDisposable {
  44215. /** The utility layer the gizmo will be added to */
  44216. gizmoLayer: UtilityLayerRenderer;
  44217. /**
  44218. * The root mesh of the gizmo
  44219. */
  44220. _rootMesh: Mesh;
  44221. private _attachedMesh;
  44222. /**
  44223. * Ratio for the scale of the gizmo (Default: 1)
  44224. */
  44225. scaleRatio: number;
  44226. /**
  44227. * If a custom mesh has been set (Default: false)
  44228. */
  44229. protected _customMeshSet: boolean;
  44230. /**
  44231. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44232. * * When set, interactions will be enabled
  44233. */
  44234. attachedMesh: Nullable<AbstractMesh>;
  44235. /**
  44236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44237. * @param mesh The mesh to replace the default mesh of the gizmo
  44238. */
  44239. setCustomMesh(mesh: Mesh): void;
  44240. /**
  44241. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44242. */
  44243. updateGizmoRotationToMatchAttachedMesh: boolean;
  44244. /**
  44245. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44246. */
  44247. updateGizmoPositionToMatchAttachedMesh: boolean;
  44248. /**
  44249. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44250. */
  44251. updateScale: boolean;
  44252. protected _interactionsEnabled: boolean;
  44253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44254. private _beforeRenderObserver;
  44255. private _tempVector;
  44256. /**
  44257. * Creates a gizmo
  44258. * @param gizmoLayer The utility layer the gizmo will be added to
  44259. */
  44260. constructor(
  44261. /** The utility layer the gizmo will be added to */
  44262. gizmoLayer?: UtilityLayerRenderer);
  44263. /**
  44264. * Updates the gizmo to match the attached mesh's position/rotation
  44265. */
  44266. protected _update(): void;
  44267. /**
  44268. * Disposes of the gizmo
  44269. */
  44270. dispose(): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44274. import { Observable } from "babylonjs/Misc/observable";
  44275. import { Nullable } from "babylonjs/types";
  44276. import { Vector3 } from "babylonjs/Maths/math.vector";
  44277. import { Color3 } from "babylonjs/Maths/math.color";
  44278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44280. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44281. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44282. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44283. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44284. import { Scene } from "babylonjs/scene";
  44285. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44286. /**
  44287. * Single plane drag gizmo
  44288. */
  44289. export class PlaneDragGizmo extends Gizmo {
  44290. /**
  44291. * Drag behavior responsible for the gizmos dragging interactions
  44292. */
  44293. dragBehavior: PointerDragBehavior;
  44294. private _pointerObserver;
  44295. /**
  44296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44297. */
  44298. snapDistance: number;
  44299. /**
  44300. * Event that fires each time the gizmo snaps to a new location.
  44301. * * snapDistance is the the change in distance
  44302. */
  44303. onSnapObservable: Observable<{
  44304. snapDistance: number;
  44305. }>;
  44306. private _plane;
  44307. private _coloredMaterial;
  44308. private _hoverMaterial;
  44309. private _isEnabled;
  44310. private _parent;
  44311. /** @hidden */
  44312. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44313. /** @hidden */
  44314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44315. /**
  44316. * Creates a PlaneDragGizmo
  44317. * @param gizmoLayer The utility layer the gizmo will be added to
  44318. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44319. * @param color The color of the gizmo
  44320. */
  44321. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44323. /**
  44324. * If the gizmo is enabled
  44325. */
  44326. isEnabled: boolean;
  44327. /**
  44328. * Disposes of the gizmo
  44329. */
  44330. dispose(): void;
  44331. }
  44332. }
  44333. declare module "babylonjs/Gizmos/positionGizmo" {
  44334. import { Observable } from "babylonjs/Misc/observable";
  44335. import { Nullable } from "babylonjs/types";
  44336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44337. import { Mesh } from "babylonjs/Meshes/mesh";
  44338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44339. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44340. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44341. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44342. /**
  44343. * Gizmo that enables dragging a mesh along 3 axis
  44344. */
  44345. export class PositionGizmo extends Gizmo {
  44346. /**
  44347. * Internal gizmo used for interactions on the x axis
  44348. */
  44349. xGizmo: AxisDragGizmo;
  44350. /**
  44351. * Internal gizmo used for interactions on the y axis
  44352. */
  44353. yGizmo: AxisDragGizmo;
  44354. /**
  44355. * Internal gizmo used for interactions on the z axis
  44356. */
  44357. zGizmo: AxisDragGizmo;
  44358. /**
  44359. * Internal gizmo used for interactions on the yz plane
  44360. */
  44361. xPlaneGizmo: PlaneDragGizmo;
  44362. /**
  44363. * Internal gizmo used for interactions on the xz plane
  44364. */
  44365. yPlaneGizmo: PlaneDragGizmo;
  44366. /**
  44367. * Internal gizmo used for interactions on the xy plane
  44368. */
  44369. zPlaneGizmo: PlaneDragGizmo;
  44370. /**
  44371. * private variables
  44372. */
  44373. private _meshAttached;
  44374. private _updateGizmoRotationToMatchAttachedMesh;
  44375. private _snapDistance;
  44376. private _scaleRatio;
  44377. /** Fires an event when any of it's sub gizmos are dragged */
  44378. onDragStartObservable: Observable<unknown>;
  44379. /** Fires an event when any of it's sub gizmos are released from dragging */
  44380. onDragEndObservable: Observable<unknown>;
  44381. /**
  44382. * If set to true, planar drag is enabled
  44383. */
  44384. private _planarGizmoEnabled;
  44385. attachedMesh: Nullable<AbstractMesh>;
  44386. /**
  44387. * Creates a PositionGizmo
  44388. * @param gizmoLayer The utility layer the gizmo will be added to
  44389. */
  44390. constructor(gizmoLayer?: UtilityLayerRenderer);
  44391. /**
  44392. * If the planar drag gizmo is enabled
  44393. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44394. */
  44395. planarGizmoEnabled: boolean;
  44396. updateGizmoRotationToMatchAttachedMesh: boolean;
  44397. /**
  44398. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44399. */
  44400. snapDistance: number;
  44401. /**
  44402. * Ratio for the scale of the gizmo (Default: 1)
  44403. */
  44404. scaleRatio: number;
  44405. /**
  44406. * Disposes of the gizmo
  44407. */
  44408. dispose(): void;
  44409. /**
  44410. * CustomMeshes are not supported by this gizmo
  44411. * @param mesh The mesh to replace the default mesh of the gizmo
  44412. */
  44413. setCustomMesh(mesh: Mesh): void;
  44414. }
  44415. }
  44416. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44417. import { Observable } from "babylonjs/Misc/observable";
  44418. import { Nullable } from "babylonjs/types";
  44419. import { Vector3 } from "babylonjs/Maths/math.vector";
  44420. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44422. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44423. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44424. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44425. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44428. import { Color3 } from "babylonjs/Maths/math.color";
  44429. /**
  44430. * Single axis drag gizmo
  44431. */
  44432. export class AxisDragGizmo extends Gizmo {
  44433. /**
  44434. * Drag behavior responsible for the gizmos dragging interactions
  44435. */
  44436. dragBehavior: PointerDragBehavior;
  44437. private _pointerObserver;
  44438. /**
  44439. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44440. */
  44441. snapDistance: number;
  44442. /**
  44443. * Event that fires each time the gizmo snaps to a new location.
  44444. * * snapDistance is the the change in distance
  44445. */
  44446. onSnapObservable: Observable<{
  44447. snapDistance: number;
  44448. }>;
  44449. private _isEnabled;
  44450. private _parent;
  44451. private _arrow;
  44452. private _coloredMaterial;
  44453. private _hoverMaterial;
  44454. /** @hidden */
  44455. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44456. /** @hidden */
  44457. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44458. /**
  44459. * Creates an AxisDragGizmo
  44460. * @param gizmoLayer The utility layer the gizmo will be added to
  44461. * @param dragAxis The axis which the gizmo will be able to drag on
  44462. * @param color The color of the gizmo
  44463. */
  44464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44466. /**
  44467. * If the gizmo is enabled
  44468. */
  44469. isEnabled: boolean;
  44470. /**
  44471. * Disposes of the gizmo
  44472. */
  44473. dispose(): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Debug/axesViewer" {
  44477. import { Vector3 } from "babylonjs/Maths/math.vector";
  44478. import { Nullable } from "babylonjs/types";
  44479. import { Scene } from "babylonjs/scene";
  44480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44481. /**
  44482. * The Axes viewer will show 3 axes in a specific point in space
  44483. */
  44484. export class AxesViewer {
  44485. private _xAxis;
  44486. private _yAxis;
  44487. private _zAxis;
  44488. private _scaleLinesFactor;
  44489. private _instanced;
  44490. /**
  44491. * Gets the hosting scene
  44492. */
  44493. scene: Scene;
  44494. /**
  44495. * Gets or sets a number used to scale line length
  44496. */
  44497. scaleLines: number;
  44498. /** Gets the node hierarchy used to render x-axis */
  44499. readonly xAxis: TransformNode;
  44500. /** Gets the node hierarchy used to render y-axis */
  44501. readonly yAxis: TransformNode;
  44502. /** Gets the node hierarchy used to render z-axis */
  44503. readonly zAxis: TransformNode;
  44504. /**
  44505. * Creates a new AxesViewer
  44506. * @param scene defines the hosting scene
  44507. * @param scaleLines defines a number used to scale line length (1 by default)
  44508. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44509. * @param xAxis defines the node hierarchy used to render the x-axis
  44510. * @param yAxis defines the node hierarchy used to render the y-axis
  44511. * @param zAxis defines the node hierarchy used to render the z-axis
  44512. */
  44513. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44514. /**
  44515. * Force the viewer to update
  44516. * @param position defines the position of the viewer
  44517. * @param xaxis defines the x axis of the viewer
  44518. * @param yaxis defines the y axis of the viewer
  44519. * @param zaxis defines the z axis of the viewer
  44520. */
  44521. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44522. /**
  44523. * Creates an instance of this axes viewer.
  44524. * @returns a new axes viewer with instanced meshes
  44525. */
  44526. createInstance(): AxesViewer;
  44527. /** Releases resources */
  44528. dispose(): void;
  44529. private static _SetRenderingGroupId;
  44530. }
  44531. }
  44532. declare module "babylonjs/Debug/boneAxesViewer" {
  44533. import { Nullable } from "babylonjs/types";
  44534. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44535. import { Vector3 } from "babylonjs/Maths/math.vector";
  44536. import { Mesh } from "babylonjs/Meshes/mesh";
  44537. import { Bone } from "babylonjs/Bones/bone";
  44538. import { Scene } from "babylonjs/scene";
  44539. /**
  44540. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44541. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44542. */
  44543. export class BoneAxesViewer extends AxesViewer {
  44544. /**
  44545. * Gets or sets the target mesh where to display the axes viewer
  44546. */
  44547. mesh: Nullable<Mesh>;
  44548. /**
  44549. * Gets or sets the target bone where to display the axes viewer
  44550. */
  44551. bone: Nullable<Bone>;
  44552. /** Gets current position */
  44553. pos: Vector3;
  44554. /** Gets direction of X axis */
  44555. xaxis: Vector3;
  44556. /** Gets direction of Y axis */
  44557. yaxis: Vector3;
  44558. /** Gets direction of Z axis */
  44559. zaxis: Vector3;
  44560. /**
  44561. * Creates a new BoneAxesViewer
  44562. * @param scene defines the hosting scene
  44563. * @param bone defines the target bone
  44564. * @param mesh defines the target mesh
  44565. * @param scaleLines defines a scaling factor for line length (1 by default)
  44566. */
  44567. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44568. /**
  44569. * Force the viewer to update
  44570. */
  44571. update(): void;
  44572. /** Releases resources */
  44573. dispose(): void;
  44574. }
  44575. }
  44576. declare module "babylonjs/Debug/debugLayer" {
  44577. import { Scene } from "babylonjs/scene";
  44578. /**
  44579. * Interface used to define scene explorer extensibility option
  44580. */
  44581. export interface IExplorerExtensibilityOption {
  44582. /**
  44583. * Define the option label
  44584. */
  44585. label: string;
  44586. /**
  44587. * Defines the action to execute on click
  44588. */
  44589. action: (entity: any) => void;
  44590. }
  44591. /**
  44592. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44593. */
  44594. export interface IExplorerExtensibilityGroup {
  44595. /**
  44596. * Defines a predicate to test if a given type mut be extended
  44597. */
  44598. predicate: (entity: any) => boolean;
  44599. /**
  44600. * Gets the list of options added to a type
  44601. */
  44602. entries: IExplorerExtensibilityOption[];
  44603. }
  44604. /**
  44605. * Interface used to define the options to use to create the Inspector
  44606. */
  44607. export interface IInspectorOptions {
  44608. /**
  44609. * Display in overlay mode (default: false)
  44610. */
  44611. overlay?: boolean;
  44612. /**
  44613. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44614. */
  44615. globalRoot?: HTMLElement;
  44616. /**
  44617. * Display the Scene explorer
  44618. */
  44619. showExplorer?: boolean;
  44620. /**
  44621. * Display the property inspector
  44622. */
  44623. showInspector?: boolean;
  44624. /**
  44625. * Display in embed mode (both panes on the right)
  44626. */
  44627. embedMode?: boolean;
  44628. /**
  44629. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44630. */
  44631. handleResize?: boolean;
  44632. /**
  44633. * Allow the panes to popup (default: true)
  44634. */
  44635. enablePopup?: boolean;
  44636. /**
  44637. * Allow the panes to be closed by users (default: true)
  44638. */
  44639. enableClose?: boolean;
  44640. /**
  44641. * Optional list of extensibility entries
  44642. */
  44643. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44644. /**
  44645. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44646. */
  44647. inspectorURL?: string;
  44648. }
  44649. module "babylonjs/scene" {
  44650. interface Scene {
  44651. /**
  44652. * @hidden
  44653. * Backing field
  44654. */
  44655. _debugLayer: DebugLayer;
  44656. /**
  44657. * Gets the debug layer (aka Inspector) associated with the scene
  44658. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44659. */
  44660. debugLayer: DebugLayer;
  44661. }
  44662. }
  44663. /**
  44664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44665. * what is happening in your scene
  44666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44667. */
  44668. export class DebugLayer {
  44669. /**
  44670. * Define the url to get the inspector script from.
  44671. * By default it uses the babylonjs CDN.
  44672. * @ignoreNaming
  44673. */
  44674. static InspectorURL: string;
  44675. private _scene;
  44676. private BJSINSPECTOR;
  44677. private _onPropertyChangedObservable?;
  44678. /**
  44679. * Observable triggered when a property is changed through the inspector.
  44680. */
  44681. readonly onPropertyChangedObservable: any;
  44682. /**
  44683. * Instantiates a new debug layer.
  44684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44685. * what is happening in your scene
  44686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44687. * @param scene Defines the scene to inspect
  44688. */
  44689. constructor(scene: Scene);
  44690. /** Creates the inspector window. */
  44691. private _createInspector;
  44692. /**
  44693. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44694. * @param entity defines the entity to select
  44695. * @param lineContainerTitle defines the specific block to highlight
  44696. */
  44697. select(entity: any, lineContainerTitle?: string): void;
  44698. /** Get the inspector from bundle or global */
  44699. private _getGlobalInspector;
  44700. /**
  44701. * Get if the inspector is visible or not.
  44702. * @returns true if visible otherwise, false
  44703. */
  44704. isVisible(): boolean;
  44705. /**
  44706. * Hide the inspector and close its window.
  44707. */
  44708. hide(): void;
  44709. /**
  44710. * Launch the debugLayer.
  44711. * @param config Define the configuration of the inspector
  44712. * @return a promise fulfilled when the debug layer is visible
  44713. */
  44714. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44715. }
  44716. }
  44717. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44718. import { Nullable } from "babylonjs/types";
  44719. import { Scene } from "babylonjs/scene";
  44720. import { Vector4 } from "babylonjs/Maths/math.vector";
  44721. import { Color4 } from "babylonjs/Maths/math.color";
  44722. import { Mesh } from "babylonjs/Meshes/mesh";
  44723. /**
  44724. * Class containing static functions to help procedurally build meshes
  44725. */
  44726. export class BoxBuilder {
  44727. /**
  44728. * Creates a box mesh
  44729. * * The parameter `size` sets the size (float) of each box side (default 1)
  44730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44731. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  44732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44737. * @param name defines the name of the mesh
  44738. * @param options defines the options used to create the mesh
  44739. * @param scene defines the hosting scene
  44740. * @returns the box mesh
  44741. */
  44742. static CreateBox(name: string, options: {
  44743. size?: number;
  44744. width?: number;
  44745. height?: number;
  44746. depth?: number;
  44747. faceUV?: Vector4[];
  44748. faceColors?: Color4[];
  44749. sideOrientation?: number;
  44750. frontUVs?: Vector4;
  44751. backUVs?: Vector4;
  44752. wrap?: boolean;
  44753. topBaseAt?: number;
  44754. bottomBaseAt?: number;
  44755. updatable?: boolean;
  44756. }, scene?: Nullable<Scene>): Mesh;
  44757. }
  44758. }
  44759. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44760. import { Vector4 } from "babylonjs/Maths/math.vector";
  44761. import { Mesh } from "babylonjs/Meshes/mesh";
  44762. import { Scene } from "babylonjs/scene";
  44763. import { Nullable } from "babylonjs/types";
  44764. /**
  44765. * Class containing static functions to help procedurally build meshes
  44766. */
  44767. export class SphereBuilder {
  44768. /**
  44769. * Creates a sphere mesh
  44770. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44771. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  44772. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44773. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  44774. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  44775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44778. * @param name defines the name of the mesh
  44779. * @param options defines the options used to create the mesh
  44780. * @param scene defines the hosting scene
  44781. * @returns the sphere mesh
  44782. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44783. */
  44784. static CreateSphere(name: string, options: {
  44785. segments?: number;
  44786. diameter?: number;
  44787. diameterX?: number;
  44788. diameterY?: number;
  44789. diameterZ?: number;
  44790. arc?: number;
  44791. slice?: number;
  44792. sideOrientation?: number;
  44793. frontUVs?: Vector4;
  44794. backUVs?: Vector4;
  44795. updatable?: boolean;
  44796. }, scene?: Nullable<Scene>): Mesh;
  44797. }
  44798. }
  44799. declare module "babylonjs/Debug/physicsViewer" {
  44800. import { Nullable } from "babylonjs/types";
  44801. import { Scene } from "babylonjs/scene";
  44802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44803. import { Mesh } from "babylonjs/Meshes/mesh";
  44804. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44805. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44806. /**
  44807. * Used to show the physics impostor around the specific mesh
  44808. */
  44809. export class PhysicsViewer {
  44810. /** @hidden */
  44811. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44812. /** @hidden */
  44813. protected _meshes: Array<Nullable<AbstractMesh>>;
  44814. /** @hidden */
  44815. protected _scene: Nullable<Scene>;
  44816. /** @hidden */
  44817. protected _numMeshes: number;
  44818. /** @hidden */
  44819. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44820. private _renderFunction;
  44821. private _utilityLayer;
  44822. private _debugBoxMesh;
  44823. private _debugSphereMesh;
  44824. private _debugCylinderMesh;
  44825. private _debugMaterial;
  44826. private _debugMeshMeshes;
  44827. /**
  44828. * Creates a new PhysicsViewer
  44829. * @param scene defines the hosting scene
  44830. */
  44831. constructor(scene: Scene);
  44832. /** @hidden */
  44833. protected _updateDebugMeshes(): void;
  44834. /**
  44835. * Renders a specified physic impostor
  44836. * @param impostor defines the impostor to render
  44837. * @param targetMesh defines the mesh represented by the impostor
  44838. * @returns the new debug mesh used to render the impostor
  44839. */
  44840. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44841. /**
  44842. * Hides a specified physic impostor
  44843. * @param impostor defines the impostor to hide
  44844. */
  44845. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44846. private _getDebugMaterial;
  44847. private _getDebugBoxMesh;
  44848. private _getDebugSphereMesh;
  44849. private _getDebugCylinderMesh;
  44850. private _getDebugMeshMesh;
  44851. private _getDebugMesh;
  44852. /** Releases all resources */
  44853. dispose(): void;
  44854. }
  44855. }
  44856. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44857. import { Vector3 } from "babylonjs/Maths/math.vector";
  44858. import { Color4 } from "babylonjs/Maths/math.color";
  44859. import { Nullable } from "babylonjs/types";
  44860. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44861. import { Scene } from "babylonjs/scene";
  44862. /**
  44863. * Class containing static functions to help procedurally build meshes
  44864. */
  44865. export class LinesBuilder {
  44866. /**
  44867. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44868. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  44869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44870. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44871. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44872. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44874. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44875. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44878. * @param name defines the name of the new line system
  44879. * @param options defines the options used to create the line system
  44880. * @param scene defines the hosting scene
  44881. * @returns a new line system mesh
  44882. */
  44883. static CreateLineSystem(name: string, options: {
  44884. lines: Vector3[][];
  44885. updatable?: boolean;
  44886. instance?: Nullable<LinesMesh>;
  44887. colors?: Nullable<Color4[][]>;
  44888. useVertexAlpha?: boolean;
  44889. }, scene: Nullable<Scene>): LinesMesh;
  44890. /**
  44891. * Creates a line mesh
  44892. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  44893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44894. * * The parameter `points` is an array successive Vector3
  44895. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44896. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44898. * * When updating an instance, remember that only point positions can change, not the number of points
  44899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44901. * @param name defines the name of the new line system
  44902. * @param options defines the options used to create the line system
  44903. * @param scene defines the hosting scene
  44904. * @returns a new line mesh
  44905. */
  44906. static CreateLines(name: string, options: {
  44907. points: Vector3[];
  44908. updatable?: boolean;
  44909. instance?: Nullable<LinesMesh>;
  44910. colors?: Color4[];
  44911. useVertexAlpha?: boolean;
  44912. }, scene?: Nullable<Scene>): LinesMesh;
  44913. /**
  44914. * Creates a dashed line mesh
  44915. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  44916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44917. * * The parameter `points` is an array successive Vector3
  44918. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44919. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44920. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44921. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44922. * * When updating an instance, remember that only point positions can change, not the number of points
  44923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44924. * @param name defines the name of the mesh
  44925. * @param options defines the options used to create the mesh
  44926. * @param scene defines the hosting scene
  44927. * @returns the dashed line mesh
  44928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44929. */
  44930. static CreateDashedLines(name: string, options: {
  44931. points: Vector3[];
  44932. dashSize?: number;
  44933. gapSize?: number;
  44934. dashNb?: number;
  44935. updatable?: boolean;
  44936. instance?: LinesMesh;
  44937. }, scene?: Nullable<Scene>): LinesMesh;
  44938. }
  44939. }
  44940. declare module "babylonjs/Debug/rayHelper" {
  44941. import { Nullable } from "babylonjs/types";
  44942. import { Ray } from "babylonjs/Culling/ray";
  44943. import { Vector3 } from "babylonjs/Maths/math.vector";
  44944. import { Color3 } from "babylonjs/Maths/math.color";
  44945. import { Scene } from "babylonjs/scene";
  44946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44947. import "babylonjs/Meshes/Builders/linesBuilder";
  44948. /**
  44949. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44950. * in order to better appreciate the issue one might have.
  44951. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44952. */
  44953. export class RayHelper {
  44954. /**
  44955. * Defines the ray we are currently tryin to visualize.
  44956. */
  44957. ray: Nullable<Ray>;
  44958. private _renderPoints;
  44959. private _renderLine;
  44960. private _renderFunction;
  44961. private _scene;
  44962. private _updateToMeshFunction;
  44963. private _attachedToMesh;
  44964. private _meshSpaceDirection;
  44965. private _meshSpaceOrigin;
  44966. /**
  44967. * Helper function to create a colored helper in a scene in one line.
  44968. * @param ray Defines the ray we are currently tryin to visualize
  44969. * @param scene Defines the scene the ray is used in
  44970. * @param color Defines the color we want to see the ray in
  44971. * @returns The newly created ray helper.
  44972. */
  44973. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44974. /**
  44975. * Instantiate a new ray helper.
  44976. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44977. * in order to better appreciate the issue one might have.
  44978. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44979. * @param ray Defines the ray we are currently tryin to visualize
  44980. */
  44981. constructor(ray: Ray);
  44982. /**
  44983. * Shows the ray we are willing to debug.
  44984. * @param scene Defines the scene the ray needs to be rendered in
  44985. * @param color Defines the color the ray needs to be rendered in
  44986. */
  44987. show(scene: Scene, color?: Color3): void;
  44988. /**
  44989. * Hides the ray we are debugging.
  44990. */
  44991. hide(): void;
  44992. private _render;
  44993. /**
  44994. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44995. * @param mesh Defines the mesh we want the helper attached to
  44996. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44997. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44998. * @param length Defines the length of the ray
  44999. */
  45000. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45001. /**
  45002. * Detach the ray helper from the mesh it has previously been attached to.
  45003. */
  45004. detachFromMesh(): void;
  45005. private _updateToMesh;
  45006. /**
  45007. * Dispose the helper and release its associated resources.
  45008. */
  45009. dispose(): void;
  45010. }
  45011. }
  45012. declare module "babylonjs/Debug/skeletonViewer" {
  45013. import { Color3 } from "babylonjs/Maths/math.color";
  45014. import { Scene } from "babylonjs/scene";
  45015. import { Nullable } from "babylonjs/types";
  45016. import { Skeleton } from "babylonjs/Bones/skeleton";
  45017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45018. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45019. /**
  45020. * Class used to render a debug view of a given skeleton
  45021. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45022. */
  45023. export class SkeletonViewer {
  45024. /** defines the skeleton to render */
  45025. skeleton: Skeleton;
  45026. /** defines the mesh attached to the skeleton */
  45027. mesh: AbstractMesh;
  45028. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45029. autoUpdateBonesMatrices: boolean;
  45030. /** defines the rendering group id to use with the viewer */
  45031. renderingGroupId: number;
  45032. /** Gets or sets the color used to render the skeleton */
  45033. color: Color3;
  45034. private _scene;
  45035. private _debugLines;
  45036. private _debugMesh;
  45037. private _isEnabled;
  45038. private _renderFunction;
  45039. private _utilityLayer;
  45040. /**
  45041. * Returns the mesh used to render the bones
  45042. */
  45043. readonly debugMesh: Nullable<LinesMesh>;
  45044. /**
  45045. * Creates a new SkeletonViewer
  45046. * @param skeleton defines the skeleton to render
  45047. * @param mesh defines the mesh attached to the skeleton
  45048. * @param scene defines the hosting scene
  45049. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45050. * @param renderingGroupId defines the rendering group id to use with the viewer
  45051. */
  45052. constructor(
  45053. /** defines the skeleton to render */
  45054. skeleton: Skeleton,
  45055. /** defines the mesh attached to the skeleton */
  45056. mesh: AbstractMesh, scene: Scene,
  45057. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45058. autoUpdateBonesMatrices?: boolean,
  45059. /** defines the rendering group id to use with the viewer */
  45060. renderingGroupId?: number);
  45061. /** Gets or sets a boolean indicating if the viewer is enabled */
  45062. isEnabled: boolean;
  45063. private _getBonePosition;
  45064. private _getLinesForBonesWithLength;
  45065. private _getLinesForBonesNoLength;
  45066. /** Update the viewer to sync with current skeleton state */
  45067. update(): void;
  45068. /** Release associated resources */
  45069. dispose(): void;
  45070. }
  45071. }
  45072. declare module "babylonjs/Debug/index" {
  45073. export * from "babylonjs/Debug/axesViewer";
  45074. export * from "babylonjs/Debug/boneAxesViewer";
  45075. export * from "babylonjs/Debug/debugLayer";
  45076. export * from "babylonjs/Debug/physicsViewer";
  45077. export * from "babylonjs/Debug/rayHelper";
  45078. export * from "babylonjs/Debug/skeletonViewer";
  45079. }
  45080. declare module "babylonjs/Engines/nullEngine" {
  45081. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45082. import { Scene } from "babylonjs/scene";
  45083. import { Engine } from "babylonjs/Engines/engine";
  45084. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45085. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45087. import { Effect } from "babylonjs/Materials/effect";
  45088. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45089. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45090. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45091. /**
  45092. * Options to create the null engine
  45093. */
  45094. export class NullEngineOptions {
  45095. /**
  45096. * Render width (Default: 512)
  45097. */
  45098. renderWidth: number;
  45099. /**
  45100. * Render height (Default: 256)
  45101. */
  45102. renderHeight: number;
  45103. /**
  45104. * Texture size (Default: 512)
  45105. */
  45106. textureSize: number;
  45107. /**
  45108. * If delta time between frames should be constant
  45109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45110. */
  45111. deterministicLockstep: boolean;
  45112. /**
  45113. * Maximum about of steps between frames (Default: 4)
  45114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45115. */
  45116. lockstepMaxSteps: number;
  45117. }
  45118. /**
  45119. * The null engine class provides support for headless version of babylon.js.
  45120. * This can be used in server side scenario or for testing purposes
  45121. */
  45122. export class NullEngine extends Engine {
  45123. private _options;
  45124. /**
  45125. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45126. */
  45127. isDeterministicLockStep(): boolean;
  45128. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45129. getLockstepMaxSteps(): number;
  45130. /**
  45131. * Sets hardware scaling, used to save performance if needed
  45132. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45133. */
  45134. getHardwareScalingLevel(): number;
  45135. constructor(options?: NullEngineOptions);
  45136. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45137. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45138. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45139. getRenderWidth(useScreen?: boolean): number;
  45140. getRenderHeight(useScreen?: boolean): number;
  45141. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45142. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45143. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45144. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45145. bindSamplers(effect: Effect): void;
  45146. enableEffect(effect: Effect): void;
  45147. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45148. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45149. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45150. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45151. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45152. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45153. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45154. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45155. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45156. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45157. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45158. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45159. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45160. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45162. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45163. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45164. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45165. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45166. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45167. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45168. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45169. bindBuffers(vertexBuffers: {
  45170. [key: string]: VertexBuffer;
  45171. }, indexBuffer: DataBuffer, effect: Effect): void;
  45172. wipeCaches(bruteForce?: boolean): void;
  45173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45176. /** @hidden */
  45177. _createTexture(): WebGLTexture;
  45178. /** @hidden */
  45179. _releaseTexture(texture: InternalTexture): void;
  45180. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  45181. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45182. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45183. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45184. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45185. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45186. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45187. areAllEffectsReady(): boolean;
  45188. /**
  45189. * @hidden
  45190. * Get the current error code of the webGL context
  45191. * @returns the error code
  45192. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45193. */
  45194. getError(): number;
  45195. /** @hidden */
  45196. _getUnpackAlignement(): number;
  45197. /** @hidden */
  45198. _unpackFlipY(value: boolean): void;
  45199. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45200. /**
  45201. * Updates a dynamic vertex buffer.
  45202. * @param vertexBuffer the vertex buffer to update
  45203. * @param data the data used to update the vertex buffer
  45204. * @param byteOffset the byte offset of the data (optional)
  45205. * @param byteLength the byte length of the data (optional)
  45206. */
  45207. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45208. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45209. /** @hidden */
  45210. _bindTexture(channel: number, texture: InternalTexture): void;
  45211. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45212. releaseEffects(): void;
  45213. displayLoadingUI(): void;
  45214. hideLoadingUI(): void;
  45215. /** @hidden */
  45216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45217. /** @hidden */
  45218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45219. /** @hidden */
  45220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45221. /** @hidden */
  45222. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45223. }
  45224. }
  45225. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45226. import { Nullable, int } from "babylonjs/types";
  45227. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45228. /** @hidden */
  45229. export class _OcclusionDataStorage {
  45230. /** @hidden */
  45231. occlusionInternalRetryCounter: number;
  45232. /** @hidden */
  45233. isOcclusionQueryInProgress: boolean;
  45234. /** @hidden */
  45235. isOccluded: boolean;
  45236. /** @hidden */
  45237. occlusionRetryCount: number;
  45238. /** @hidden */
  45239. occlusionType: number;
  45240. /** @hidden */
  45241. occlusionQueryAlgorithmType: number;
  45242. }
  45243. module "babylonjs/Engines/engine" {
  45244. interface Engine {
  45245. /**
  45246. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45247. * @return the new query
  45248. */
  45249. createQuery(): WebGLQuery;
  45250. /**
  45251. * Delete and release a webGL query
  45252. * @param query defines the query to delete
  45253. * @return the current engine
  45254. */
  45255. deleteQuery(query: WebGLQuery): Engine;
  45256. /**
  45257. * Check if a given query has resolved and got its value
  45258. * @param query defines the query to check
  45259. * @returns true if the query got its value
  45260. */
  45261. isQueryResultAvailable(query: WebGLQuery): boolean;
  45262. /**
  45263. * Gets the value of a given query
  45264. * @param query defines the query to check
  45265. * @returns the value of the query
  45266. */
  45267. getQueryResult(query: WebGLQuery): number;
  45268. /**
  45269. * Initiates an occlusion query
  45270. * @param algorithmType defines the algorithm to use
  45271. * @param query defines the query to use
  45272. * @returns the current engine
  45273. * @see http://doc.babylonjs.com/features/occlusionquery
  45274. */
  45275. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45276. /**
  45277. * Ends an occlusion query
  45278. * @see http://doc.babylonjs.com/features/occlusionquery
  45279. * @param algorithmType defines the algorithm to use
  45280. * @returns the current engine
  45281. */
  45282. endOcclusionQuery(algorithmType: number): Engine;
  45283. /**
  45284. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45285. * Please note that only one query can be issued at a time
  45286. * @returns a time token used to track the time span
  45287. */
  45288. startTimeQuery(): Nullable<_TimeToken>;
  45289. /**
  45290. * Ends a time query
  45291. * @param token defines the token used to measure the time span
  45292. * @returns the time spent (in ns)
  45293. */
  45294. endTimeQuery(token: _TimeToken): int;
  45295. /** @hidden */
  45296. _currentNonTimestampToken: Nullable<_TimeToken>;
  45297. /** @hidden */
  45298. _createTimeQuery(): WebGLQuery;
  45299. /** @hidden */
  45300. _deleteTimeQuery(query: WebGLQuery): void;
  45301. /** @hidden */
  45302. _getGlAlgorithmType(algorithmType: number): number;
  45303. /** @hidden */
  45304. _getTimeQueryResult(query: WebGLQuery): any;
  45305. /** @hidden */
  45306. _getTimeQueryAvailability(query: WebGLQuery): any;
  45307. }
  45308. }
  45309. module "babylonjs/Meshes/abstractMesh" {
  45310. interface AbstractMesh {
  45311. /**
  45312. * Backing filed
  45313. * @hidden
  45314. */
  45315. __occlusionDataStorage: _OcclusionDataStorage;
  45316. /**
  45317. * Access property
  45318. * @hidden
  45319. */
  45320. _occlusionDataStorage: _OcclusionDataStorage;
  45321. /**
  45322. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  45323. * The default value is -1 which means don't break the query and wait till the result
  45324. * @see http://doc.babylonjs.com/features/occlusionquery
  45325. */
  45326. occlusionRetryCount: number;
  45327. /**
  45328. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  45329. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45330. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45331. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  45332. * @see http://doc.babylonjs.com/features/occlusionquery
  45333. */
  45334. occlusionType: number;
  45335. /**
  45336. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45337. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45338. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  45339. * @see http://doc.babylonjs.com/features/occlusionquery
  45340. */
  45341. occlusionQueryAlgorithmType: number;
  45342. /**
  45343. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  45344. * @see http://doc.babylonjs.com/features/occlusionquery
  45345. */
  45346. isOccluded: boolean;
  45347. /**
  45348. * Flag to check the progress status of the query
  45349. * @see http://doc.babylonjs.com/features/occlusionquery
  45350. */
  45351. isOcclusionQueryInProgress: boolean;
  45352. }
  45353. }
  45354. }
  45355. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45356. import { Nullable } from "babylonjs/types";
  45357. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45358. /** @hidden */
  45359. export var _forceTransformFeedbackToBundle: boolean;
  45360. module "babylonjs/Engines/engine" {
  45361. interface Engine {
  45362. /**
  45363. * Creates a webGL transform feedback object
  45364. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45365. * @returns the webGL transform feedback object
  45366. */
  45367. createTransformFeedback(): WebGLTransformFeedback;
  45368. /**
  45369. * Delete a webGL transform feedback object
  45370. * @param value defines the webGL transform feedback object to delete
  45371. */
  45372. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45373. /**
  45374. * Bind a webGL transform feedback object to the webgl context
  45375. * @param value defines the webGL transform feedback object to bind
  45376. */
  45377. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45378. /**
  45379. * Begins a transform feedback operation
  45380. * @param usePoints defines if points or triangles must be used
  45381. */
  45382. beginTransformFeedback(usePoints: boolean): void;
  45383. /**
  45384. * Ends a transform feedback operation
  45385. */
  45386. endTransformFeedback(): void;
  45387. /**
  45388. * Specify the varyings to use with transform feedback
  45389. * @param program defines the associated webGL program
  45390. * @param value defines the list of strings representing the varying names
  45391. */
  45392. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45393. /**
  45394. * Bind a webGL buffer for a transform feedback operation
  45395. * @param value defines the webGL buffer to bind
  45396. */
  45397. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45398. }
  45399. }
  45400. }
  45401. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45402. import { Scene } from "babylonjs/scene";
  45403. import { Engine } from "babylonjs/Engines/engine";
  45404. import { Texture } from "babylonjs/Materials/Textures/texture";
  45405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45406. import "babylonjs/Engines/Extensions/engine.multiRender";
  45407. /**
  45408. * Creation options of the multi render target texture.
  45409. */
  45410. export interface IMultiRenderTargetOptions {
  45411. /**
  45412. * Define if the texture needs to create mip maps after render.
  45413. */
  45414. generateMipMaps?: boolean;
  45415. /**
  45416. * Define the types of all the draw buffers we want to create
  45417. */
  45418. types?: number[];
  45419. /**
  45420. * Define the sampling modes of all the draw buffers we want to create
  45421. */
  45422. samplingModes?: number[];
  45423. /**
  45424. * Define if a depth buffer is required
  45425. */
  45426. generateDepthBuffer?: boolean;
  45427. /**
  45428. * Define if a stencil buffer is required
  45429. */
  45430. generateStencilBuffer?: boolean;
  45431. /**
  45432. * Define if a depth texture is required instead of a depth buffer
  45433. */
  45434. generateDepthTexture?: boolean;
  45435. /**
  45436. * Define the number of desired draw buffers
  45437. */
  45438. textureCount?: number;
  45439. /**
  45440. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45441. */
  45442. doNotChangeAspectRatio?: boolean;
  45443. /**
  45444. * Define the default type of the buffers we are creating
  45445. */
  45446. defaultType?: number;
  45447. }
  45448. /**
  45449. * A multi render target, like a render target provides the ability to render to a texture.
  45450. * Unlike the render target, it can render to several draw buffers in one draw.
  45451. * This is specially interesting in deferred rendering or for any effects requiring more than
  45452. * just one color from a single pass.
  45453. */
  45454. export class MultiRenderTarget extends RenderTargetTexture {
  45455. private _internalTextures;
  45456. private _textures;
  45457. private _multiRenderTargetOptions;
  45458. /**
  45459. * Get if draw buffers are currently supported by the used hardware and browser.
  45460. */
  45461. readonly isSupported: boolean;
  45462. /**
  45463. * Get the list of textures generated by the multi render target.
  45464. */
  45465. readonly textures: Texture[];
  45466. /**
  45467. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45468. */
  45469. readonly depthTexture: Texture;
  45470. /**
  45471. * Set the wrapping mode on U of all the textures we are rendering to.
  45472. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45473. */
  45474. wrapU: number;
  45475. /**
  45476. * Set the wrapping mode on V of all the textures we are rendering to.
  45477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45478. */
  45479. wrapV: number;
  45480. /**
  45481. * Instantiate a new multi render target texture.
  45482. * A multi render target, like a render target provides the ability to render to a texture.
  45483. * Unlike the render target, it can render to several draw buffers in one draw.
  45484. * This is specially interesting in deferred rendering or for any effects requiring more than
  45485. * just one color from a single pass.
  45486. * @param name Define the name of the texture
  45487. * @param size Define the size of the buffers to render to
  45488. * @param count Define the number of target we are rendering into
  45489. * @param scene Define the scene the texture belongs to
  45490. * @param options Define the options used to create the multi render target
  45491. */
  45492. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45493. /** @hidden */
  45494. _rebuild(): void;
  45495. private _createInternalTextures;
  45496. private _createTextures;
  45497. /**
  45498. * Define the number of samples used if MSAA is enabled.
  45499. */
  45500. samples: number;
  45501. /**
  45502. * Resize all the textures in the multi render target.
  45503. * Be carrefull as it will recreate all the data in the new texture.
  45504. * @param size Define the new size
  45505. */
  45506. resize(size: any): void;
  45507. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45508. /**
  45509. * Dispose the render targets and their associated resources
  45510. */
  45511. dispose(): void;
  45512. /**
  45513. * Release all the underlying texture used as draw buffers.
  45514. */
  45515. releaseInternalTextures(): void;
  45516. }
  45517. }
  45518. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45520. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45521. import { Nullable } from "babylonjs/types";
  45522. module "babylonjs/Engines/engine" {
  45523. interface Engine {
  45524. /**
  45525. * Unbind a list of render target textures from the webGL context
  45526. * This is used only when drawBuffer extension or webGL2 are active
  45527. * @param textures defines the render target textures to unbind
  45528. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45529. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45530. */
  45531. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45532. /**
  45533. * Create a multi render target texture
  45534. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45535. * @param size defines the size of the texture
  45536. * @param options defines the creation options
  45537. * @returns the cube texture as an InternalTexture
  45538. */
  45539. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45540. /**
  45541. * Update the sample count for a given multiple render target texture
  45542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45543. * @param textures defines the textures to update
  45544. * @param samples defines the sample count to set
  45545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45546. */
  45547. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45548. }
  45549. }
  45550. }
  45551. declare module "babylonjs/Engines/Extensions/index" {
  45552. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45553. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45554. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45555. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45556. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45557. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45558. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45559. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45560. }
  45561. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45563. /** @hidden */
  45564. export var rgbdEncodePixelShader: {
  45565. name: string;
  45566. shader: string;
  45567. };
  45568. }
  45569. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45571. /** @hidden */
  45572. export var rgbdDecodePixelShader: {
  45573. name: string;
  45574. shader: string;
  45575. };
  45576. }
  45577. declare module "babylonjs/Misc/environmentTextureTools" {
  45578. import { Nullable } from "babylonjs/types";
  45579. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45581. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45582. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45583. import "babylonjs/Shaders/rgbdEncode.fragment";
  45584. import "babylonjs/Shaders/rgbdDecode.fragment";
  45585. /**
  45586. * Raw texture data and descriptor sufficient for WebGL texture upload
  45587. */
  45588. export interface EnvironmentTextureInfo {
  45589. /**
  45590. * Version of the environment map
  45591. */
  45592. version: number;
  45593. /**
  45594. * Width of image
  45595. */
  45596. width: number;
  45597. /**
  45598. * Irradiance information stored in the file.
  45599. */
  45600. irradiance: any;
  45601. /**
  45602. * Specular information stored in the file.
  45603. */
  45604. specular: any;
  45605. }
  45606. /**
  45607. * Defines One Image in the file. It requires only the position in the file
  45608. * as well as the length.
  45609. */
  45610. interface BufferImageData {
  45611. /**
  45612. * Length of the image data.
  45613. */
  45614. length: number;
  45615. /**
  45616. * Position of the data from the null terminator delimiting the end of the JSON.
  45617. */
  45618. position: number;
  45619. }
  45620. /**
  45621. * Defines the specular data enclosed in the file.
  45622. * This corresponds to the version 1 of the data.
  45623. */
  45624. export interface EnvironmentTextureSpecularInfoV1 {
  45625. /**
  45626. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45627. */
  45628. specularDataPosition?: number;
  45629. /**
  45630. * This contains all the images data needed to reconstruct the cubemap.
  45631. */
  45632. mipmaps: Array<BufferImageData>;
  45633. /**
  45634. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45635. */
  45636. lodGenerationScale: number;
  45637. }
  45638. /**
  45639. * Sets of helpers addressing the serialization and deserialization of environment texture
  45640. * stored in a BabylonJS env file.
  45641. * Those files are usually stored as .env files.
  45642. */
  45643. export class EnvironmentTextureTools {
  45644. /**
  45645. * Magic number identifying the env file.
  45646. */
  45647. private static _MagicBytes;
  45648. /**
  45649. * Gets the environment info from an env file.
  45650. * @param data The array buffer containing the .env bytes.
  45651. * @returns the environment file info (the json header) if successfully parsed.
  45652. */
  45653. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45654. /**
  45655. * Creates an environment texture from a loaded cube texture.
  45656. * @param texture defines the cube texture to convert in env file
  45657. * @return a promise containing the environment data if succesfull.
  45658. */
  45659. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45660. /**
  45661. * Creates a JSON representation of the spherical data.
  45662. * @param texture defines the texture containing the polynomials
  45663. * @return the JSON representation of the spherical info
  45664. */
  45665. private static _CreateEnvTextureIrradiance;
  45666. /**
  45667. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45668. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45669. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45670. * @return the views described by info providing access to the underlying buffer
  45671. */
  45672. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45673. /**
  45674. * Uploads the texture info contained in the env file to the GPU.
  45675. * @param texture defines the internal texture to upload to
  45676. * @param arrayBuffer defines the buffer cotaining the data to load
  45677. * @param info defines the texture info retrieved through the GetEnvInfo method
  45678. * @returns a promise
  45679. */
  45680. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45681. /**
  45682. * Uploads the levels of image data to the GPU.
  45683. * @param texture defines the internal texture to upload to
  45684. * @param imageData defines the array buffer views of image data [mipmap][face]
  45685. * @returns a promise
  45686. */
  45687. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45688. /**
  45689. * Uploads spherical polynomials information to the texture.
  45690. * @param texture defines the texture we are trying to upload the information to
  45691. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45692. */
  45693. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45694. /** @hidden */
  45695. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45696. }
  45697. }
  45698. declare module "babylonjs/Maths/math.vertexFormat" {
  45699. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45700. /**
  45701. * Contains position and normal vectors for a vertex
  45702. */
  45703. export class PositionNormalVertex {
  45704. /** the position of the vertex (defaut: 0,0,0) */
  45705. position: Vector3;
  45706. /** the normal of the vertex (defaut: 0,1,0) */
  45707. normal: Vector3;
  45708. /**
  45709. * Creates a PositionNormalVertex
  45710. * @param position the position of the vertex (defaut: 0,0,0)
  45711. * @param normal the normal of the vertex (defaut: 0,1,0)
  45712. */
  45713. constructor(
  45714. /** the position of the vertex (defaut: 0,0,0) */
  45715. position?: Vector3,
  45716. /** the normal of the vertex (defaut: 0,1,0) */
  45717. normal?: Vector3);
  45718. /**
  45719. * Clones the PositionNormalVertex
  45720. * @returns the cloned PositionNormalVertex
  45721. */
  45722. clone(): PositionNormalVertex;
  45723. }
  45724. /**
  45725. * Contains position, normal and uv vectors for a vertex
  45726. */
  45727. export class PositionNormalTextureVertex {
  45728. /** the position of the vertex (defaut: 0,0,0) */
  45729. position: Vector3;
  45730. /** the normal of the vertex (defaut: 0,1,0) */
  45731. normal: Vector3;
  45732. /** the uv of the vertex (default: 0,0) */
  45733. uv: Vector2;
  45734. /**
  45735. * Creates a PositionNormalTextureVertex
  45736. * @param position the position of the vertex (defaut: 0,0,0)
  45737. * @param normal the normal of the vertex (defaut: 0,1,0)
  45738. * @param uv the uv of the vertex (default: 0,0)
  45739. */
  45740. constructor(
  45741. /** the position of the vertex (defaut: 0,0,0) */
  45742. position?: Vector3,
  45743. /** the normal of the vertex (defaut: 0,1,0) */
  45744. normal?: Vector3,
  45745. /** the uv of the vertex (default: 0,0) */
  45746. uv?: Vector2);
  45747. /**
  45748. * Clones the PositionNormalTextureVertex
  45749. * @returns the cloned PositionNormalTextureVertex
  45750. */
  45751. clone(): PositionNormalTextureVertex;
  45752. }
  45753. }
  45754. declare module "babylonjs/Maths/math" {
  45755. export * from "babylonjs/Maths/math.axis";
  45756. export * from "babylonjs/Maths/math.color";
  45757. export * from "babylonjs/Maths/math.constants";
  45758. export * from "babylonjs/Maths/math.frustum";
  45759. export * from "babylonjs/Maths/math.path";
  45760. export * from "babylonjs/Maths/math.plane";
  45761. export * from "babylonjs/Maths/math.size";
  45762. export * from "babylonjs/Maths/math.vector";
  45763. export * from "babylonjs/Maths/math.vertexFormat";
  45764. export * from "babylonjs/Maths/math.viewport";
  45765. }
  45766. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45767. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45768. /** @hidden */
  45769. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45770. private _genericAttributeLocation;
  45771. private _varyingLocationCount;
  45772. private _varyingLocationMap;
  45773. private _replacements;
  45774. private _textureCount;
  45775. private _uniforms;
  45776. lineProcessor(line: string): string;
  45777. attributeProcessor(attribute: string): string;
  45778. varyingProcessor(varying: string, isFragment: boolean): string;
  45779. uniformProcessor(uniform: string): string;
  45780. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45781. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45782. }
  45783. }
  45784. declare module "babylonjs/Engines/nativeEngine" {
  45785. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45786. import { Engine } from "babylonjs/Engines/engine";
  45787. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45790. import { Effect } from "babylonjs/Materials/effect";
  45791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45792. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45793. import { Scene } from "babylonjs/scene";
  45794. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45795. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45796. /**
  45797. * Container for accessors for natively-stored mesh data buffers.
  45798. */
  45799. class NativeDataBuffer extends DataBuffer {
  45800. /**
  45801. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45802. */
  45803. nativeIndexBuffer?: any;
  45804. /**
  45805. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45806. */
  45807. nativeVertexBuffer?: any;
  45808. }
  45809. /** @hidden */
  45810. export class NativeEngine extends Engine {
  45811. private readonly _native;
  45812. getHardwareScalingLevel(): number;
  45813. constructor();
  45814. /**
  45815. * Can be used to override the current requestAnimationFrame requester.
  45816. * @hidden
  45817. */
  45818. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45819. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45820. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45821. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45822. recordVertexArrayObject(vertexBuffers: {
  45823. [key: string]: VertexBuffer;
  45824. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45825. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45826. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45827. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45828. /**
  45829. * Draw a list of indexed primitives
  45830. * @param fillMode defines the primitive to use
  45831. * @param indexStart defines the starting index
  45832. * @param indexCount defines the number of index to draw
  45833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45834. */
  45835. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45836. /**
  45837. * Draw a list of unindexed primitives
  45838. * @param fillMode defines the primitive to use
  45839. * @param verticesStart defines the index of first vertex to draw
  45840. * @param verticesCount defines the count of vertices to draw
  45841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45842. */
  45843. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45844. createPipelineContext(): IPipelineContext;
  45845. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45846. /** @hidden */
  45847. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45848. /** @hidden */
  45849. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45850. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45851. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45852. protected _setProgram(program: WebGLProgram): void;
  45853. _releaseEffect(effect: Effect): void;
  45854. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45856. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45857. bindSamplers(effect: Effect): void;
  45858. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45859. getRenderWidth(useScreen?: boolean): number;
  45860. getRenderHeight(useScreen?: boolean): number;
  45861. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45863. /**
  45864. * Set the z offset to apply to current rendering
  45865. * @param value defines the offset to apply
  45866. */
  45867. setZOffset(value: number): void;
  45868. /**
  45869. * Gets the current value of the zOffset
  45870. * @returns the current zOffset state
  45871. */
  45872. getZOffset(): number;
  45873. /**
  45874. * Enable or disable depth buffering
  45875. * @param enable defines the state to set
  45876. */
  45877. setDepthBuffer(enable: boolean): void;
  45878. /**
  45879. * Gets a boolean indicating if depth writing is enabled
  45880. * @returns the current depth writing state
  45881. */
  45882. getDepthWrite(): boolean;
  45883. /**
  45884. * Enable or disable depth writing
  45885. * @param enable defines the state to set
  45886. */
  45887. setDepthWrite(enable: boolean): void;
  45888. /**
  45889. * Enable or disable color writing
  45890. * @param enable defines the state to set
  45891. */
  45892. setColorWrite(enable: boolean): void;
  45893. /**
  45894. * Gets a boolean indicating if color writing is enabled
  45895. * @returns the current color writing state
  45896. */
  45897. getColorWrite(): boolean;
  45898. /**
  45899. * Sets alpha constants used by some alpha blending modes
  45900. * @param r defines the red component
  45901. * @param g defines the green component
  45902. * @param b defines the blue component
  45903. * @param a defines the alpha component
  45904. */
  45905. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45906. /**
  45907. * Sets the current alpha mode
  45908. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45911. */
  45912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45913. /**
  45914. * Gets the current alpha mode
  45915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45916. * @returns the current alpha mode
  45917. */
  45918. getAlphaMode(): number;
  45919. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45920. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45921. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45922. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45923. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45926. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45927. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45928. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45929. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45930. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45931. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45934. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45935. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45937. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45938. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45939. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45940. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45941. wipeCaches(bruteForce?: boolean): void;
  45942. _createTexture(): WebGLTexture;
  45943. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45944. /**
  45945. * Usually called from BABYLON.Texture.ts.
  45946. * Passed information to create a WebGLTexture
  45947. * @param urlArg defines a value which contains one of the following:
  45948. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45949. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45950. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45952. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45953. * @param scene needed for loading to the correct scene
  45954. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45955. * @param onLoad optional callback to be called upon successful completion
  45956. * @param onError optional callback to be called upon failure
  45957. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45958. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45959. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45960. * @param forcedExtension defines the extension to use to pick the right loader
  45961. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45962. */
  45963. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45964. /**
  45965. * Creates a cube texture
  45966. * @param rootUrl defines the url where the files to load is located
  45967. * @param scene defines the current scene
  45968. * @param files defines the list of files to load (1 per face)
  45969. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45970. * @param onLoad defines an optional callback raised when the texture is loaded
  45971. * @param onError defines an optional callback raised if there is an issue to load the texture
  45972. * @param format defines the format of the data
  45973. * @param forcedExtension defines the extension to use to pick the right loader
  45974. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45975. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45976. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45977. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45978. * @returns the cube texture as an InternalTexture
  45979. */
  45980. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  45981. private _getSamplingFilter;
  45982. private static _GetNativeTextureFormat;
  45983. createRenderTargetTexture(size: number | {
  45984. width: number;
  45985. height: number;
  45986. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45987. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45988. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45990. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45991. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45992. /**
  45993. * Updates a dynamic vertex buffer.
  45994. * @param vertexBuffer the vertex buffer to update
  45995. * @param data the data used to update the vertex buffer
  45996. * @param byteOffset the byte offset of the data (optional)
  45997. * @param byteLength the byte length of the data (optional)
  45998. */
  45999. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46000. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46001. private _updateAnisotropicLevel;
  46002. private _getAddressMode;
  46003. /** @hidden */
  46004. _bindTexture(channel: number, texture: InternalTexture): void;
  46005. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46006. releaseEffects(): void;
  46007. /** @hidden */
  46008. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46009. /** @hidden */
  46010. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46011. /** @hidden */
  46012. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46013. /** @hidden */
  46014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46015. }
  46016. }
  46017. declare module "babylonjs/Engines/index" {
  46018. export * from "babylonjs/Engines/constants";
  46019. export * from "babylonjs/Engines/engine";
  46020. export * from "babylonjs/Engines/engineStore";
  46021. export * from "babylonjs/Engines/nullEngine";
  46022. export * from "babylonjs/Engines/Extensions/index";
  46023. export * from "babylonjs/Engines/IPipelineContext";
  46024. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46025. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46026. export * from "babylonjs/Engines/nativeEngine";
  46027. }
  46028. declare module "babylonjs/Events/clipboardEvents" {
  46029. /**
  46030. * Gather the list of clipboard event types as constants.
  46031. */
  46032. export class ClipboardEventTypes {
  46033. /**
  46034. * The clipboard event is fired when a copy command is active (pressed).
  46035. */
  46036. static readonly COPY: number;
  46037. /**
  46038. * The clipboard event is fired when a cut command is active (pressed).
  46039. */
  46040. static readonly CUT: number;
  46041. /**
  46042. * The clipboard event is fired when a paste command is active (pressed).
  46043. */
  46044. static readonly PASTE: number;
  46045. }
  46046. /**
  46047. * This class is used to store clipboard related info for the onClipboardObservable event.
  46048. */
  46049. export class ClipboardInfo {
  46050. /**
  46051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46052. */
  46053. type: number;
  46054. /**
  46055. * Defines the related dom event
  46056. */
  46057. event: ClipboardEvent;
  46058. /**
  46059. *Creates an instance of ClipboardInfo.
  46060. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46061. * @param event Defines the related dom event
  46062. */
  46063. constructor(
  46064. /**
  46065. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46066. */
  46067. type: number,
  46068. /**
  46069. * Defines the related dom event
  46070. */
  46071. event: ClipboardEvent);
  46072. /**
  46073. * Get the clipboard event's type from the keycode.
  46074. * @param keyCode Defines the keyCode for the current keyboard event.
  46075. * @return {number}
  46076. */
  46077. static GetTypeFromCharacter(keyCode: number): number;
  46078. }
  46079. }
  46080. declare module "babylonjs/Events/index" {
  46081. export * from "babylonjs/Events/keyboardEvents";
  46082. export * from "babylonjs/Events/pointerEvents";
  46083. export * from "babylonjs/Events/clipboardEvents";
  46084. }
  46085. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46086. import { Scene } from "babylonjs/scene";
  46087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46088. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46089. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46090. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46091. /**
  46092. * Google Daydream controller
  46093. */
  46094. export class DaydreamController extends WebVRController {
  46095. /**
  46096. * Base Url for the controller model.
  46097. */
  46098. static MODEL_BASE_URL: string;
  46099. /**
  46100. * File name for the controller model.
  46101. */
  46102. static MODEL_FILENAME: string;
  46103. /**
  46104. * Gamepad Id prefix used to identify Daydream Controller.
  46105. */
  46106. static readonly GAMEPAD_ID_PREFIX: string;
  46107. /**
  46108. * Creates a new DaydreamController from a gamepad
  46109. * @param vrGamepad the gamepad that the controller should be created from
  46110. */
  46111. constructor(vrGamepad: any);
  46112. /**
  46113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46114. * @param scene scene in which to add meshes
  46115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46116. */
  46117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46118. /**
  46119. * Called once for each button that changed state since the last frame
  46120. * @param buttonIdx Which button index changed
  46121. * @param state New state of the button
  46122. * @param changes Which properties on the state changed since last frame
  46123. */
  46124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46125. }
  46126. }
  46127. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46128. import { Scene } from "babylonjs/scene";
  46129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46130. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46131. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46132. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46133. /**
  46134. * Gear VR Controller
  46135. */
  46136. export class GearVRController extends WebVRController {
  46137. /**
  46138. * Base Url for the controller model.
  46139. */
  46140. static MODEL_BASE_URL: string;
  46141. /**
  46142. * File name for the controller model.
  46143. */
  46144. static MODEL_FILENAME: string;
  46145. /**
  46146. * Gamepad Id prefix used to identify this controller.
  46147. */
  46148. static readonly GAMEPAD_ID_PREFIX: string;
  46149. private readonly _buttonIndexToObservableNameMap;
  46150. /**
  46151. * Creates a new GearVRController from a gamepad
  46152. * @param vrGamepad the gamepad that the controller should be created from
  46153. */
  46154. constructor(vrGamepad: any);
  46155. /**
  46156. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46157. * @param scene scene in which to add meshes
  46158. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46159. */
  46160. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46161. /**
  46162. * Called once for each button that changed state since the last frame
  46163. * @param buttonIdx Which button index changed
  46164. * @param state New state of the button
  46165. * @param changes Which properties on the state changed since last frame
  46166. */
  46167. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46168. }
  46169. }
  46170. declare module "babylonjs/Gamepads/Controllers/index" {
  46171. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46172. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46173. export * from "babylonjs/Gamepads/Controllers/genericController";
  46174. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46175. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46176. export * from "babylonjs/Gamepads/Controllers/viveController";
  46177. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46178. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46179. }
  46180. declare module "babylonjs/Gamepads/index" {
  46181. export * from "babylonjs/Gamepads/Controllers/index";
  46182. export * from "babylonjs/Gamepads/gamepad";
  46183. export * from "babylonjs/Gamepads/gamepadManager";
  46184. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46185. export * from "babylonjs/Gamepads/xboxGamepad";
  46186. export * from "babylonjs/Gamepads/dualShockGamepad";
  46187. }
  46188. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46189. import { Scene } from "babylonjs/scene";
  46190. import { Vector4 } from "babylonjs/Maths/math.vector";
  46191. import { Color4 } from "babylonjs/Maths/math.color";
  46192. import { Mesh } from "babylonjs/Meshes/mesh";
  46193. import { Nullable } from "babylonjs/types";
  46194. /**
  46195. * Class containing static functions to help procedurally build meshes
  46196. */
  46197. export class PolyhedronBuilder {
  46198. /**
  46199. * Creates a polyhedron mesh
  46200. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  46201. * * The parameter `size` (positive float, default 1) sets the polygon size
  46202. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46203. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  46204. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  46205. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  46206. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46207. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  46208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46211. * @param name defines the name of the mesh
  46212. * @param options defines the options used to create the mesh
  46213. * @param scene defines the hosting scene
  46214. * @returns the polyhedron mesh
  46215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46216. */
  46217. static CreatePolyhedron(name: string, options: {
  46218. type?: number;
  46219. size?: number;
  46220. sizeX?: number;
  46221. sizeY?: number;
  46222. sizeZ?: number;
  46223. custom?: any;
  46224. faceUV?: Vector4[];
  46225. faceColors?: Color4[];
  46226. flat?: boolean;
  46227. updatable?: boolean;
  46228. sideOrientation?: number;
  46229. frontUVs?: Vector4;
  46230. backUVs?: Vector4;
  46231. }, scene?: Nullable<Scene>): Mesh;
  46232. }
  46233. }
  46234. declare module "babylonjs/Gizmos/scaleGizmo" {
  46235. import { Observable } from "babylonjs/Misc/observable";
  46236. import { Nullable } from "babylonjs/types";
  46237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46238. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46239. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46241. /**
  46242. * Gizmo that enables scaling a mesh along 3 axis
  46243. */
  46244. export class ScaleGizmo extends Gizmo {
  46245. /**
  46246. * Internal gizmo used for interactions on the x axis
  46247. */
  46248. xGizmo: AxisScaleGizmo;
  46249. /**
  46250. * Internal gizmo used for interactions on the y axis
  46251. */
  46252. yGizmo: AxisScaleGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the z axis
  46255. */
  46256. zGizmo: AxisScaleGizmo;
  46257. /**
  46258. * Internal gizmo used to scale all axis equally
  46259. */
  46260. uniformScaleGizmo: AxisScaleGizmo;
  46261. private _meshAttached;
  46262. private _updateGizmoRotationToMatchAttachedMesh;
  46263. private _snapDistance;
  46264. private _scaleRatio;
  46265. private _uniformScalingMesh;
  46266. private _octahedron;
  46267. /** Fires an event when any of it's sub gizmos are dragged */
  46268. onDragStartObservable: Observable<unknown>;
  46269. /** Fires an event when any of it's sub gizmos are released from dragging */
  46270. onDragEndObservable: Observable<unknown>;
  46271. attachedMesh: Nullable<AbstractMesh>;
  46272. /**
  46273. * Creates a ScaleGizmo
  46274. * @param gizmoLayer The utility layer the gizmo will be added to
  46275. */
  46276. constructor(gizmoLayer?: UtilityLayerRenderer);
  46277. updateGizmoRotationToMatchAttachedMesh: boolean;
  46278. /**
  46279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46280. */
  46281. snapDistance: number;
  46282. /**
  46283. * Ratio for the scale of the gizmo (Default: 1)
  46284. */
  46285. scaleRatio: number;
  46286. /**
  46287. * Disposes of the gizmo
  46288. */
  46289. dispose(): void;
  46290. }
  46291. }
  46292. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46293. import { Observable } from "babylonjs/Misc/observable";
  46294. import { Nullable } from "babylonjs/types";
  46295. import { Vector3 } from "babylonjs/Maths/math.vector";
  46296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46297. import { Mesh } from "babylonjs/Meshes/mesh";
  46298. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46300. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46301. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46302. import { Color3 } from "babylonjs/Maths/math.color";
  46303. /**
  46304. * Single axis scale gizmo
  46305. */
  46306. export class AxisScaleGizmo extends Gizmo {
  46307. /**
  46308. * Drag behavior responsible for the gizmos dragging interactions
  46309. */
  46310. dragBehavior: PointerDragBehavior;
  46311. private _pointerObserver;
  46312. /**
  46313. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46314. */
  46315. snapDistance: number;
  46316. /**
  46317. * Event that fires each time the gizmo snaps to a new location.
  46318. * * snapDistance is the the change in distance
  46319. */
  46320. onSnapObservable: Observable<{
  46321. snapDistance: number;
  46322. }>;
  46323. /**
  46324. * If the scaling operation should be done on all axis (default: false)
  46325. */
  46326. uniformScaling: boolean;
  46327. private _isEnabled;
  46328. private _parent;
  46329. private _arrow;
  46330. private _coloredMaterial;
  46331. private _hoverMaterial;
  46332. /**
  46333. * Creates an AxisScaleGizmo
  46334. * @param gizmoLayer The utility layer the gizmo will be added to
  46335. * @param dragAxis The axis which the gizmo will be able to scale on
  46336. * @param color The color of the gizmo
  46337. */
  46338. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46340. /**
  46341. * If the gizmo is enabled
  46342. */
  46343. isEnabled: boolean;
  46344. /**
  46345. * Disposes of the gizmo
  46346. */
  46347. dispose(): void;
  46348. /**
  46349. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46350. * @param mesh The mesh to replace the default mesh of the gizmo
  46351. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46352. */
  46353. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46354. }
  46355. }
  46356. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46357. import { Observable } from "babylonjs/Misc/observable";
  46358. import { Nullable } from "babylonjs/types";
  46359. import { Vector3 } from "babylonjs/Maths/math.vector";
  46360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46361. import { Mesh } from "babylonjs/Meshes/mesh";
  46362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46364. import { Color3 } from "babylonjs/Maths/math.color";
  46365. import "babylonjs/Meshes/Builders/boxBuilder";
  46366. /**
  46367. * Bounding box gizmo
  46368. */
  46369. export class BoundingBoxGizmo extends Gizmo {
  46370. private _lineBoundingBox;
  46371. private _rotateSpheresParent;
  46372. private _scaleBoxesParent;
  46373. private _boundingDimensions;
  46374. private _renderObserver;
  46375. private _pointerObserver;
  46376. private _scaleDragSpeed;
  46377. private _tmpQuaternion;
  46378. private _tmpVector;
  46379. private _tmpRotationMatrix;
  46380. /**
  46381. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  46382. */
  46383. ignoreChildren: boolean;
  46384. /**
  46385. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  46386. */
  46387. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46388. /**
  46389. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46390. */
  46391. rotationSphereSize: number;
  46392. /**
  46393. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46394. */
  46395. scaleBoxSize: number;
  46396. /**
  46397. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  46398. */
  46399. fixedDragMeshScreenSize: boolean;
  46400. /**
  46401. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46402. */
  46403. fixedDragMeshScreenSizeDistanceFactor: number;
  46404. /**
  46405. * Fired when a rotation sphere or scale box is dragged
  46406. */
  46407. onDragStartObservable: Observable<{}>;
  46408. /**
  46409. * Fired when a scale box is dragged
  46410. */
  46411. onScaleBoxDragObservable: Observable<{}>;
  46412. /**
  46413. * Fired when a scale box drag is ended
  46414. */
  46415. onScaleBoxDragEndObservable: Observable<{}>;
  46416. /**
  46417. * Fired when a rotation sphere is dragged
  46418. */
  46419. onRotationSphereDragObservable: Observable<{}>;
  46420. /**
  46421. * Fired when a rotation sphere drag is ended
  46422. */
  46423. onRotationSphereDragEndObservable: Observable<{}>;
  46424. /**
  46425. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  46426. */
  46427. scalePivot: Nullable<Vector3>;
  46428. /**
  46429. * Mesh used as a pivot to rotate the attached mesh
  46430. */
  46431. private _anchorMesh;
  46432. private _existingMeshScale;
  46433. private _dragMesh;
  46434. private pointerDragBehavior;
  46435. private coloredMaterial;
  46436. private hoverColoredMaterial;
  46437. /**
  46438. * Sets the color of the bounding box gizmo
  46439. * @param color the color to set
  46440. */
  46441. setColor(color: Color3): void;
  46442. /**
  46443. * Creates an BoundingBoxGizmo
  46444. * @param gizmoLayer The utility layer the gizmo will be added to
  46445. * @param color The color of the gizmo
  46446. */
  46447. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46448. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46449. private _selectNode;
  46450. /**
  46451. * Updates the bounding box information for the Gizmo
  46452. */
  46453. updateBoundingBox(): void;
  46454. private _updateRotationSpheres;
  46455. private _updateScaleBoxes;
  46456. /**
  46457. * Enables rotation on the specified axis and disables rotation on the others
  46458. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46459. */
  46460. setEnabledRotationAxis(axis: string): void;
  46461. /**
  46462. * Enables/disables scaling
  46463. * @param enable if scaling should be enabled
  46464. */
  46465. setEnabledScaling(enable: boolean): void;
  46466. private _updateDummy;
  46467. /**
  46468. * Enables a pointer drag behavior on the bounding box of the gizmo
  46469. */
  46470. enableDragBehavior(): void;
  46471. /**
  46472. * Disposes of the gizmo
  46473. */
  46474. dispose(): void;
  46475. /**
  46476. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  46477. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46478. * @returns the bounding box mesh with the passed in mesh as a child
  46479. */
  46480. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46481. /**
  46482. * CustomMeshes are not supported by this gizmo
  46483. * @param mesh The mesh to replace the default mesh of the gizmo
  46484. */
  46485. setCustomMesh(mesh: Mesh): void;
  46486. }
  46487. }
  46488. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46489. import { Observable } from "babylonjs/Misc/observable";
  46490. import { Nullable } from "babylonjs/types";
  46491. import { Vector3 } from "babylonjs/Maths/math.vector";
  46492. import { Color3 } from "babylonjs/Maths/math.color";
  46493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46494. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46495. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46497. import "babylonjs/Meshes/Builders/linesBuilder";
  46498. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46499. /**
  46500. * Single plane rotation gizmo
  46501. */
  46502. export class PlaneRotationGizmo extends Gizmo {
  46503. /**
  46504. * Drag behavior responsible for the gizmos dragging interactions
  46505. */
  46506. dragBehavior: PointerDragBehavior;
  46507. private _pointerObserver;
  46508. /**
  46509. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46510. */
  46511. snapDistance: number;
  46512. /**
  46513. * Event that fires each time the gizmo snaps to a new location.
  46514. * * snapDistance is the the change in distance
  46515. */
  46516. onSnapObservable: Observable<{
  46517. snapDistance: number;
  46518. }>;
  46519. private _isEnabled;
  46520. private _parent;
  46521. /**
  46522. * Creates a PlaneRotationGizmo
  46523. * @param gizmoLayer The utility layer the gizmo will be added to
  46524. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46525. * @param color The color of the gizmo
  46526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46527. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46528. */
  46529. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46530. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46531. /**
  46532. * If the gizmo is enabled
  46533. */
  46534. isEnabled: boolean;
  46535. /**
  46536. * Disposes of the gizmo
  46537. */
  46538. dispose(): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Gizmos/rotationGizmo" {
  46542. import { Observable } from "babylonjs/Misc/observable";
  46543. import { Nullable } from "babylonjs/types";
  46544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46545. import { Mesh } from "babylonjs/Meshes/mesh";
  46546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46547. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46549. /**
  46550. * Gizmo that enables rotating a mesh along 3 axis
  46551. */
  46552. export class RotationGizmo extends Gizmo {
  46553. /**
  46554. * Internal gizmo used for interactions on the x axis
  46555. */
  46556. xGizmo: PlaneRotationGizmo;
  46557. /**
  46558. * Internal gizmo used for interactions on the y axis
  46559. */
  46560. yGizmo: PlaneRotationGizmo;
  46561. /**
  46562. * Internal gizmo used for interactions on the z axis
  46563. */
  46564. zGizmo: PlaneRotationGizmo;
  46565. /** Fires an event when any of it's sub gizmos are dragged */
  46566. onDragStartObservable: Observable<unknown>;
  46567. /** Fires an event when any of it's sub gizmos are released from dragging */
  46568. onDragEndObservable: Observable<unknown>;
  46569. private _meshAttached;
  46570. attachedMesh: Nullable<AbstractMesh>;
  46571. /**
  46572. * Creates a RotationGizmo
  46573. * @param gizmoLayer The utility layer the gizmo will be added to
  46574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46575. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46576. */
  46577. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46578. updateGizmoRotationToMatchAttachedMesh: boolean;
  46579. /**
  46580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46581. */
  46582. snapDistance: number;
  46583. /**
  46584. * Ratio for the scale of the gizmo (Default: 1)
  46585. */
  46586. scaleRatio: number;
  46587. /**
  46588. * Disposes of the gizmo
  46589. */
  46590. dispose(): void;
  46591. /**
  46592. * CustomMeshes are not supported by this gizmo
  46593. * @param mesh The mesh to replace the default mesh of the gizmo
  46594. */
  46595. setCustomMesh(mesh: Mesh): void;
  46596. }
  46597. }
  46598. declare module "babylonjs/Gizmos/gizmoManager" {
  46599. import { Observable } from "babylonjs/Misc/observable";
  46600. import { Nullable } from "babylonjs/types";
  46601. import { Scene, IDisposable } from "babylonjs/scene";
  46602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46604. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46605. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46606. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46607. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46608. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46609. /**
  46610. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46611. */
  46612. export class GizmoManager implements IDisposable {
  46613. private scene;
  46614. /**
  46615. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46616. */
  46617. gizmos: {
  46618. positionGizmo: Nullable<PositionGizmo>;
  46619. rotationGizmo: Nullable<RotationGizmo>;
  46620. scaleGizmo: Nullable<ScaleGizmo>;
  46621. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46622. };
  46623. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46624. clearGizmoOnEmptyPointerEvent: boolean;
  46625. /** Fires an event when the manager is attached to a mesh */
  46626. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46627. private _gizmosEnabled;
  46628. private _pointerObserver;
  46629. private _attachedMesh;
  46630. private _boundingBoxColor;
  46631. private _defaultUtilityLayer;
  46632. private _defaultKeepDepthUtilityLayer;
  46633. /**
  46634. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46635. */
  46636. boundingBoxDragBehavior: SixDofDragBehavior;
  46637. /**
  46638. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46639. */
  46640. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46641. /**
  46642. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46643. */
  46644. usePointerToAttachGizmos: boolean;
  46645. /**
  46646. * Utility layer that the bounding box gizmo belongs to
  46647. */
  46648. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46649. /**
  46650. * Utility layer that all gizmos besides bounding box belong to
  46651. */
  46652. readonly utilityLayer: UtilityLayerRenderer;
  46653. /**
  46654. * Instatiates a gizmo manager
  46655. * @param scene the scene to overlay the gizmos on top of
  46656. */
  46657. constructor(scene: Scene);
  46658. /**
  46659. * Attaches a set of gizmos to the specified mesh
  46660. * @param mesh The mesh the gizmo's should be attached to
  46661. */
  46662. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46663. /**
  46664. * If the position gizmo is enabled
  46665. */
  46666. positionGizmoEnabled: boolean;
  46667. /**
  46668. * If the rotation gizmo is enabled
  46669. */
  46670. rotationGizmoEnabled: boolean;
  46671. /**
  46672. * If the scale gizmo is enabled
  46673. */
  46674. scaleGizmoEnabled: boolean;
  46675. /**
  46676. * If the boundingBox gizmo is enabled
  46677. */
  46678. boundingBoxGizmoEnabled: boolean;
  46679. /**
  46680. * Disposes of the gizmo manager
  46681. */
  46682. dispose(): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Lights/directionalLight" {
  46686. import { Camera } from "babylonjs/Cameras/camera";
  46687. import { Scene } from "babylonjs/scene";
  46688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46690. import { Light } from "babylonjs/Lights/light";
  46691. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46692. import { Effect } from "babylonjs/Materials/effect";
  46693. /**
  46694. * A directional light is defined by a direction (what a surprise!).
  46695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46696. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  46697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46698. */
  46699. export class DirectionalLight extends ShadowLight {
  46700. private _shadowFrustumSize;
  46701. /**
  46702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46703. */
  46704. /**
  46705. * Specifies a fix frustum size for the shadow generation.
  46706. */
  46707. shadowFrustumSize: number;
  46708. private _shadowOrthoScale;
  46709. /**
  46710. * Gets the shadow projection scale against the optimal computed one.
  46711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46713. */
  46714. /**
  46715. * Sets the shadow projection scale against the optimal computed one.
  46716. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46717. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46718. */
  46719. shadowOrthoScale: number;
  46720. /**
  46721. * Automatically compute the projection matrix to best fit (including all the casters)
  46722. * on each frame.
  46723. */
  46724. autoUpdateExtends: boolean;
  46725. private _orthoLeft;
  46726. private _orthoRight;
  46727. private _orthoTop;
  46728. private _orthoBottom;
  46729. /**
  46730. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46731. * The directional light is emitted from everywhere in the given direction.
  46732. * It can cast shadows.
  46733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46734. * @param name The friendly name of the light
  46735. * @param direction The direction of the light
  46736. * @param scene The scene the light belongs to
  46737. */
  46738. constructor(name: string, direction: Vector3, scene: Scene);
  46739. /**
  46740. * Returns the string "DirectionalLight".
  46741. * @return The class name
  46742. */
  46743. getClassName(): string;
  46744. /**
  46745. * Returns the integer 1.
  46746. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46747. */
  46748. getTypeID(): number;
  46749. /**
  46750. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46751. * Returns the DirectionalLight Shadow projection matrix.
  46752. */
  46753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46754. /**
  46755. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46756. * Returns the DirectionalLight Shadow projection matrix.
  46757. */
  46758. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46759. /**
  46760. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46761. * Returns the DirectionalLight Shadow projection matrix.
  46762. */
  46763. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46764. protected _buildUniformLayout(): void;
  46765. /**
  46766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46767. * @param effect The effect to update
  46768. * @param lightIndex The index of the light in the effect to update
  46769. * @returns The directional light
  46770. */
  46771. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46772. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46773. /**
  46774. * Gets the minZ used for shadow according to both the scene and the light.
  46775. *
  46776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46778. * @param activeCamera The camera we are returning the min for
  46779. * @returns the depth min z
  46780. */
  46781. getDepthMinZ(activeCamera: Camera): number;
  46782. /**
  46783. * Gets the maxZ used for shadow according to both the scene and the light.
  46784. *
  46785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46787. * @param activeCamera The camera we are returning the max for
  46788. * @returns the depth max z
  46789. */
  46790. getDepthMaxZ(activeCamera: Camera): number;
  46791. /**
  46792. * Prepares the list of defines specific to the light type.
  46793. * @param defines the list of defines
  46794. * @param lightIndex defines the index of the light for the effect
  46795. */
  46796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46797. }
  46798. }
  46799. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46800. import { Mesh } from "babylonjs/Meshes/mesh";
  46801. /**
  46802. * Class containing static functions to help procedurally build meshes
  46803. */
  46804. export class HemisphereBuilder {
  46805. /**
  46806. * Creates a hemisphere mesh
  46807. * @param name defines the name of the mesh
  46808. * @param options defines the options used to create the mesh
  46809. * @param scene defines the hosting scene
  46810. * @returns the hemisphere mesh
  46811. */
  46812. static CreateHemisphere(name: string, options: {
  46813. segments?: number;
  46814. diameter?: number;
  46815. sideOrientation?: number;
  46816. }, scene: any): Mesh;
  46817. }
  46818. }
  46819. declare module "babylonjs/Lights/spotLight" {
  46820. import { Nullable } from "babylonjs/types";
  46821. import { Scene } from "babylonjs/scene";
  46822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46824. import { Effect } from "babylonjs/Materials/effect";
  46825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46826. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46827. /**
  46828. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46829. * These values define a cone of light starting from the position, emitting toward the direction.
  46830. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46831. * and the exponent defines the speed of the decay of the light with distance (reach).
  46832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46833. */
  46834. export class SpotLight extends ShadowLight {
  46835. private _angle;
  46836. private _innerAngle;
  46837. private _cosHalfAngle;
  46838. private _lightAngleScale;
  46839. private _lightAngleOffset;
  46840. /**
  46841. * Gets the cone angle of the spot light in Radians.
  46842. */
  46843. /**
  46844. * Sets the cone angle of the spot light in Radians.
  46845. */
  46846. angle: number;
  46847. /**
  46848. * Only used in gltf falloff mode, this defines the angle where
  46849. * the directional falloff will start before cutting at angle which could be seen
  46850. * as outer angle.
  46851. */
  46852. /**
  46853. * Only used in gltf falloff mode, this defines the angle where
  46854. * the directional falloff will start before cutting at angle which could be seen
  46855. * as outer angle.
  46856. */
  46857. innerAngle: number;
  46858. private _shadowAngleScale;
  46859. /**
  46860. * Allows scaling the angle of the light for shadow generation only.
  46861. */
  46862. /**
  46863. * Allows scaling the angle of the light for shadow generation only.
  46864. */
  46865. shadowAngleScale: number;
  46866. /**
  46867. * The light decay speed with the distance from the emission spot.
  46868. */
  46869. exponent: number;
  46870. private _projectionTextureMatrix;
  46871. /**
  46872. * Allows reading the projecton texture
  46873. */
  46874. readonly projectionTextureMatrix: Matrix;
  46875. protected _projectionTextureLightNear: number;
  46876. /**
  46877. * Gets the near clip of the Spotlight for texture projection.
  46878. */
  46879. /**
  46880. * Sets the near clip of the Spotlight for texture projection.
  46881. */
  46882. projectionTextureLightNear: number;
  46883. protected _projectionTextureLightFar: number;
  46884. /**
  46885. * Gets the far clip of the Spotlight for texture projection.
  46886. */
  46887. /**
  46888. * Sets the far clip of the Spotlight for texture projection.
  46889. */
  46890. projectionTextureLightFar: number;
  46891. protected _projectionTextureUpDirection: Vector3;
  46892. /**
  46893. * Gets the Up vector of the Spotlight for texture projection.
  46894. */
  46895. /**
  46896. * Sets the Up vector of the Spotlight for texture projection.
  46897. */
  46898. projectionTextureUpDirection: Vector3;
  46899. private _projectionTexture;
  46900. /**
  46901. * Gets the projection texture of the light.
  46902. */
  46903. /**
  46904. * Sets the projection texture of the light.
  46905. */
  46906. projectionTexture: Nullable<BaseTexture>;
  46907. private _projectionTextureViewLightDirty;
  46908. private _projectionTextureProjectionLightDirty;
  46909. private _projectionTextureDirty;
  46910. private _projectionTextureViewTargetVector;
  46911. private _projectionTextureViewLightMatrix;
  46912. private _projectionTextureProjectionLightMatrix;
  46913. private _projectionTextureScalingMatrix;
  46914. /**
  46915. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46916. * It can cast shadows.
  46917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46918. * @param name The light friendly name
  46919. * @param position The position of the spot light in the scene
  46920. * @param direction The direction of the light in the scene
  46921. * @param angle The cone angle of the light in Radians
  46922. * @param exponent The light decay speed with the distance from the emission spot
  46923. * @param scene The scene the lights belongs to
  46924. */
  46925. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46926. /**
  46927. * Returns the string "SpotLight".
  46928. * @returns the class name
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Returns the integer 2.
  46933. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46934. */
  46935. getTypeID(): number;
  46936. /**
  46937. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46938. */
  46939. protected _setDirection(value: Vector3): void;
  46940. /**
  46941. * Overrides the position setter to recompute the projection texture view light Matrix.
  46942. */
  46943. protected _setPosition(value: Vector3): void;
  46944. /**
  46945. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  46946. * Returns the SpotLight.
  46947. */
  46948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46949. protected _computeProjectionTextureViewLightMatrix(): void;
  46950. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46951. /**
  46952. * Main function for light texture projection matrix computing.
  46953. */
  46954. protected _computeProjectionTextureMatrix(): void;
  46955. protected _buildUniformLayout(): void;
  46956. private _computeAngleValues;
  46957. /**
  46958. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46959. * @param effect The effect to update
  46960. * @param lightIndex The index of the light in the effect to update
  46961. * @returns The spot light
  46962. */
  46963. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46964. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46965. /**
  46966. * Disposes the light and the associated resources.
  46967. */
  46968. dispose(): void;
  46969. /**
  46970. * Prepares the list of defines specific to the light type.
  46971. * @param defines the list of defines
  46972. * @param lightIndex defines the index of the light for the effect
  46973. */
  46974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46975. }
  46976. }
  46977. declare module "babylonjs/Gizmos/lightGizmo" {
  46978. import { Nullable } from "babylonjs/types";
  46979. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46980. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46981. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46982. import { Light } from "babylonjs/Lights/light";
  46983. /**
  46984. * Gizmo that enables viewing a light
  46985. */
  46986. export class LightGizmo extends Gizmo {
  46987. private _lightMesh;
  46988. private _material;
  46989. private cachedPosition;
  46990. private cachedForward;
  46991. /**
  46992. * Creates a LightGizmo
  46993. * @param gizmoLayer The utility layer the gizmo will be added to
  46994. */
  46995. constructor(gizmoLayer?: UtilityLayerRenderer);
  46996. private _light;
  46997. /**
  46998. * The light that the gizmo is attached to
  46999. */
  47000. light: Nullable<Light>;
  47001. /**
  47002. * Gets the material used to render the light gizmo
  47003. */
  47004. readonly material: StandardMaterial;
  47005. /**
  47006. * @hidden
  47007. * Updates the gizmo to match the attached mesh's position/rotation
  47008. */
  47009. protected _update(): void;
  47010. private static _Scale;
  47011. /**
  47012. * Creates the lines for a light mesh
  47013. */
  47014. private static _createLightLines;
  47015. /**
  47016. * Disposes of the light gizmo
  47017. */
  47018. dispose(): void;
  47019. private static _CreateHemisphericLightMesh;
  47020. private static _CreatePointLightMesh;
  47021. private static _CreateSpotLightMesh;
  47022. private static _CreateDirectionalLightMesh;
  47023. }
  47024. }
  47025. declare module "babylonjs/Gizmos/index" {
  47026. export * from "babylonjs/Gizmos/axisDragGizmo";
  47027. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47028. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47029. export * from "babylonjs/Gizmos/gizmo";
  47030. export * from "babylonjs/Gizmos/gizmoManager";
  47031. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47032. export * from "babylonjs/Gizmos/positionGizmo";
  47033. export * from "babylonjs/Gizmos/rotationGizmo";
  47034. export * from "babylonjs/Gizmos/scaleGizmo";
  47035. export * from "babylonjs/Gizmos/lightGizmo";
  47036. export * from "babylonjs/Gizmos/planeDragGizmo";
  47037. }
  47038. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47039. /** @hidden */
  47040. export var backgroundFragmentDeclaration: {
  47041. name: string;
  47042. shader: string;
  47043. };
  47044. }
  47045. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47046. /** @hidden */
  47047. export var backgroundUboDeclaration: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module "babylonjs/Shaders/background.fragment" {
  47053. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47054. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47055. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47056. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47057. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47058. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47060. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47061. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47062. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47064. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47065. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47066. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47067. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47068. /** @hidden */
  47069. export var backgroundPixelShader: {
  47070. name: string;
  47071. shader: string;
  47072. };
  47073. }
  47074. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47075. /** @hidden */
  47076. export var backgroundVertexDeclaration: {
  47077. name: string;
  47078. shader: string;
  47079. };
  47080. }
  47081. declare module "babylonjs/Shaders/background.vertex" {
  47082. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47085. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47086. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47088. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47089. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47090. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47091. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47092. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47094. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47095. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47096. /** @hidden */
  47097. export var backgroundVertexShader: {
  47098. name: string;
  47099. shader: string;
  47100. };
  47101. }
  47102. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47103. import { Nullable, int, float } from "babylonjs/types";
  47104. import { Scene } from "babylonjs/scene";
  47105. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47106. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47108. import { Mesh } from "babylonjs/Meshes/mesh";
  47109. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47110. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47111. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47113. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47114. import { Color3 } from "babylonjs/Maths/math.color";
  47115. import "babylonjs/Shaders/background.fragment";
  47116. import "babylonjs/Shaders/background.vertex";
  47117. /**
  47118. * Background material used to create an efficient environement around your scene.
  47119. */
  47120. export class BackgroundMaterial extends PushMaterial {
  47121. /**
  47122. * Standard reflectance value at parallel view angle.
  47123. */
  47124. static StandardReflectance0: number;
  47125. /**
  47126. * Standard reflectance value at grazing angle.
  47127. */
  47128. static StandardReflectance90: number;
  47129. protected _primaryColor: Color3;
  47130. /**
  47131. * Key light Color (multiply against the environement texture)
  47132. */
  47133. primaryColor: Color3;
  47134. protected __perceptualColor: Nullable<Color3>;
  47135. /**
  47136. * Experimental Internal Use Only.
  47137. *
  47138. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47139. * This acts as a helper to set the primary color to a more "human friendly" value.
  47140. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47141. * output color as close as possible from the chosen value.
  47142. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47143. * part of lighting setup.)
  47144. */
  47145. _perceptualColor: Nullable<Color3>;
  47146. protected _primaryColorShadowLevel: float;
  47147. /**
  47148. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47149. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47150. */
  47151. primaryColorShadowLevel: float;
  47152. protected _primaryColorHighlightLevel: float;
  47153. /**
  47154. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47155. * The primary color is used at the level chosen to define what the white area would look.
  47156. */
  47157. primaryColorHighlightLevel: float;
  47158. protected _reflectionTexture: Nullable<BaseTexture>;
  47159. /**
  47160. * Reflection Texture used in the material.
  47161. * Should be author in a specific way for the best result (refer to the documentation).
  47162. */
  47163. reflectionTexture: Nullable<BaseTexture>;
  47164. protected _reflectionBlur: float;
  47165. /**
  47166. * Reflection Texture level of blur.
  47167. *
  47168. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47169. * texture twice.
  47170. */
  47171. reflectionBlur: float;
  47172. protected _diffuseTexture: Nullable<BaseTexture>;
  47173. /**
  47174. * Diffuse Texture used in the material.
  47175. * Should be author in a specific way for the best result (refer to the documentation).
  47176. */
  47177. diffuseTexture: Nullable<BaseTexture>;
  47178. protected _shadowLights: Nullable<IShadowLight[]>;
  47179. /**
  47180. * Specify the list of lights casting shadow on the material.
  47181. * All scene shadow lights will be included if null.
  47182. */
  47183. shadowLights: Nullable<IShadowLight[]>;
  47184. protected _shadowLevel: float;
  47185. /**
  47186. * Helps adjusting the shadow to a softer level if required.
  47187. * 0 means black shadows and 1 means no shadows.
  47188. */
  47189. shadowLevel: float;
  47190. protected _sceneCenter: Vector3;
  47191. /**
  47192. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47193. * It is usually zero but might be interesting to modify according to your setup.
  47194. */
  47195. sceneCenter: Vector3;
  47196. protected _opacityFresnel: boolean;
  47197. /**
  47198. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47199. * This helps ensuring a nice transition when the camera goes under the ground.
  47200. */
  47201. opacityFresnel: boolean;
  47202. protected _reflectionFresnel: boolean;
  47203. /**
  47204. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47205. * This helps adding a mirror texture on the ground.
  47206. */
  47207. reflectionFresnel: boolean;
  47208. protected _reflectionFalloffDistance: number;
  47209. /**
  47210. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47211. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47212. */
  47213. reflectionFalloffDistance: number;
  47214. protected _reflectionAmount: number;
  47215. /**
  47216. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47217. */
  47218. reflectionAmount: number;
  47219. protected _reflectionReflectance0: number;
  47220. /**
  47221. * This specifies the weight of the reflection at grazing angle.
  47222. */
  47223. reflectionReflectance0: number;
  47224. protected _reflectionReflectance90: number;
  47225. /**
  47226. * This specifies the weight of the reflection at a perpendicular point of view.
  47227. */
  47228. reflectionReflectance90: number;
  47229. /**
  47230. * Sets the reflection reflectance fresnel values according to the default standard
  47231. * empirically know to work well :-)
  47232. */
  47233. reflectionStandardFresnelWeight: number;
  47234. protected _useRGBColor: boolean;
  47235. /**
  47236. * Helps to directly use the maps channels instead of their level.
  47237. */
  47238. useRGBColor: boolean;
  47239. protected _enableNoise: boolean;
  47240. /**
  47241. * This helps reducing the banding effect that could occur on the background.
  47242. */
  47243. enableNoise: boolean;
  47244. /**
  47245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47246. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47247. * Recommended to be keep at 1.0 except for special cases.
  47248. */
  47249. fovMultiplier: number;
  47250. private _fovMultiplier;
  47251. /**
  47252. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47253. */
  47254. useEquirectangularFOV: boolean;
  47255. private _maxSimultaneousLights;
  47256. /**
  47257. * Number of Simultaneous lights allowed on the material.
  47258. */
  47259. maxSimultaneousLights: int;
  47260. /**
  47261. * Default configuration related to image processing available in the Background Material.
  47262. */
  47263. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47264. /**
  47265. * Keep track of the image processing observer to allow dispose and replace.
  47266. */
  47267. private _imageProcessingObserver;
  47268. /**
  47269. * Attaches a new image processing configuration to the PBR Material.
  47270. * @param configuration (if null the scene configuration will be use)
  47271. */
  47272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47273. /**
  47274. * Gets the image processing configuration used either in this material.
  47275. */
  47276. /**
  47277. * Sets the Default image processing configuration used either in the this material.
  47278. *
  47279. * If sets to null, the scene one is in use.
  47280. */
  47281. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47282. /**
  47283. * Gets wether the color curves effect is enabled.
  47284. */
  47285. /**
  47286. * Sets wether the color curves effect is enabled.
  47287. */
  47288. cameraColorCurvesEnabled: boolean;
  47289. /**
  47290. * Gets wether the color grading effect is enabled.
  47291. */
  47292. /**
  47293. * Gets wether the color grading effect is enabled.
  47294. */
  47295. cameraColorGradingEnabled: boolean;
  47296. /**
  47297. * Gets wether tonemapping is enabled or not.
  47298. */
  47299. /**
  47300. * Sets wether tonemapping is enabled or not
  47301. */
  47302. cameraToneMappingEnabled: boolean;
  47303. /**
  47304. * The camera exposure used on this material.
  47305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47306. * This corresponds to a photographic exposure.
  47307. */
  47308. /**
  47309. * The camera exposure used on this material.
  47310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47311. * This corresponds to a photographic exposure.
  47312. */
  47313. cameraExposure: float;
  47314. /**
  47315. * Gets The camera contrast used on this material.
  47316. */
  47317. /**
  47318. * Sets The camera contrast used on this material.
  47319. */
  47320. cameraContrast: float;
  47321. /**
  47322. * Gets the Color Grading 2D Lookup Texture.
  47323. */
  47324. /**
  47325. * Sets the Color Grading 2D Lookup Texture.
  47326. */
  47327. cameraColorGradingTexture: Nullable<BaseTexture>;
  47328. /**
  47329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47331. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47333. */
  47334. /**
  47335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47337. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47339. */
  47340. cameraColorCurves: Nullable<ColorCurves>;
  47341. /**
  47342. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47343. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47344. */
  47345. switchToBGR: boolean;
  47346. private _renderTargets;
  47347. private _reflectionControls;
  47348. private _white;
  47349. private _primaryShadowColor;
  47350. private _primaryHighlightColor;
  47351. /**
  47352. * Instantiates a Background Material in the given scene
  47353. * @param name The friendly name of the material
  47354. * @param scene The scene to add the material to
  47355. */
  47356. constructor(name: string, scene: Scene);
  47357. /**
  47358. * Gets a boolean indicating that current material needs to register RTT
  47359. */
  47360. readonly hasRenderTargetTextures: boolean;
  47361. /**
  47362. * The entire material has been created in order to prevent overdraw.
  47363. * @returns false
  47364. */
  47365. needAlphaTesting(): boolean;
  47366. /**
  47367. * The entire material has been created in order to prevent overdraw.
  47368. * @returns true if blending is enable
  47369. */
  47370. needAlphaBlending(): boolean;
  47371. /**
  47372. * Checks wether the material is ready to be rendered for a given mesh.
  47373. * @param mesh The mesh to render
  47374. * @param subMesh The submesh to check against
  47375. * @param useInstances Specify wether or not the material is used with instances
  47376. * @returns true if all the dependencies are ready (Textures, Effects...)
  47377. */
  47378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47379. /**
  47380. * Compute the primary color according to the chosen perceptual color.
  47381. */
  47382. private _computePrimaryColorFromPerceptualColor;
  47383. /**
  47384. * Compute the highlights and shadow colors according to their chosen levels.
  47385. */
  47386. private _computePrimaryColors;
  47387. /**
  47388. * Build the uniform buffer used in the material.
  47389. */
  47390. buildUniformLayout(): void;
  47391. /**
  47392. * Unbind the material.
  47393. */
  47394. unbind(): void;
  47395. /**
  47396. * Bind only the world matrix to the material.
  47397. * @param world The world matrix to bind.
  47398. */
  47399. bindOnlyWorldMatrix(world: Matrix): void;
  47400. /**
  47401. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47402. * @param world The world matrix to bind.
  47403. * @param subMesh The submesh to bind for.
  47404. */
  47405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47406. /**
  47407. * Checks to see if a texture is used in the material.
  47408. * @param texture - Base texture to use.
  47409. * @returns - Boolean specifying if a texture is used in the material.
  47410. */
  47411. hasTexture(texture: BaseTexture): boolean;
  47412. /**
  47413. * Dispose the material.
  47414. * @param forceDisposeEffect Force disposal of the associated effect.
  47415. * @param forceDisposeTextures Force disposal of the associated textures.
  47416. */
  47417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47418. /**
  47419. * Clones the material.
  47420. * @param name The cloned name.
  47421. * @returns The cloned material.
  47422. */
  47423. clone(name: string): BackgroundMaterial;
  47424. /**
  47425. * Serializes the current material to its JSON representation.
  47426. * @returns The JSON representation.
  47427. */
  47428. serialize(): any;
  47429. /**
  47430. * Gets the class name of the material
  47431. * @returns "BackgroundMaterial"
  47432. */
  47433. getClassName(): string;
  47434. /**
  47435. * Parse a JSON input to create back a background material.
  47436. * @param source The JSON data to parse
  47437. * @param scene The scene to create the parsed material in
  47438. * @param rootUrl The root url of the assets the material depends upon
  47439. * @returns the instantiated BackgroundMaterial.
  47440. */
  47441. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47442. }
  47443. }
  47444. declare module "babylonjs/Helpers/environmentHelper" {
  47445. import { Observable } from "babylonjs/Misc/observable";
  47446. import { Nullable } from "babylonjs/types";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { Vector3 } from "babylonjs/Maths/math.vector";
  47449. import { Color3 } from "babylonjs/Maths/math.color";
  47450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47451. import { Mesh } from "babylonjs/Meshes/mesh";
  47452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47453. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47454. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47455. import "babylonjs/Meshes/Builders/planeBuilder";
  47456. import "babylonjs/Meshes/Builders/boxBuilder";
  47457. /**
  47458. * Represents the different options available during the creation of
  47459. * a Environment helper.
  47460. *
  47461. * This can control the default ground, skybox and image processing setup of your scene.
  47462. */
  47463. export interface IEnvironmentHelperOptions {
  47464. /**
  47465. * Specifies wether or not to create a ground.
  47466. * True by default.
  47467. */
  47468. createGround: boolean;
  47469. /**
  47470. * Specifies the ground size.
  47471. * 15 by default.
  47472. */
  47473. groundSize: number;
  47474. /**
  47475. * The texture used on the ground for the main color.
  47476. * Comes from the BabylonJS CDN by default.
  47477. *
  47478. * Remarks: Can be either a texture or a url.
  47479. */
  47480. groundTexture: string | BaseTexture;
  47481. /**
  47482. * The color mixed in the ground texture by default.
  47483. * BabylonJS clearColor by default.
  47484. */
  47485. groundColor: Color3;
  47486. /**
  47487. * Specifies the ground opacity.
  47488. * 1 by default.
  47489. */
  47490. groundOpacity: number;
  47491. /**
  47492. * Enables the ground to receive shadows.
  47493. * True by default.
  47494. */
  47495. enableGroundShadow: boolean;
  47496. /**
  47497. * Helps preventing the shadow to be fully black on the ground.
  47498. * 0.5 by default.
  47499. */
  47500. groundShadowLevel: number;
  47501. /**
  47502. * Creates a mirror texture attach to the ground.
  47503. * false by default.
  47504. */
  47505. enableGroundMirror: boolean;
  47506. /**
  47507. * Specifies the ground mirror size ratio.
  47508. * 0.3 by default as the default kernel is 64.
  47509. */
  47510. groundMirrorSizeRatio: number;
  47511. /**
  47512. * Specifies the ground mirror blur kernel size.
  47513. * 64 by default.
  47514. */
  47515. groundMirrorBlurKernel: number;
  47516. /**
  47517. * Specifies the ground mirror visibility amount.
  47518. * 1 by default
  47519. */
  47520. groundMirrorAmount: number;
  47521. /**
  47522. * Specifies the ground mirror reflectance weight.
  47523. * This uses the standard weight of the background material to setup the fresnel effect
  47524. * of the mirror.
  47525. * 1 by default.
  47526. */
  47527. groundMirrorFresnelWeight: number;
  47528. /**
  47529. * Specifies the ground mirror Falloff distance.
  47530. * This can helps reducing the size of the reflection.
  47531. * 0 by Default.
  47532. */
  47533. groundMirrorFallOffDistance: number;
  47534. /**
  47535. * Specifies the ground mirror texture type.
  47536. * Unsigned Int by Default.
  47537. */
  47538. groundMirrorTextureType: number;
  47539. /**
  47540. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47541. * the shown objects.
  47542. */
  47543. groundYBias: number;
  47544. /**
  47545. * Specifies wether or not to create a skybox.
  47546. * True by default.
  47547. */
  47548. createSkybox: boolean;
  47549. /**
  47550. * Specifies the skybox size.
  47551. * 20 by default.
  47552. */
  47553. skyboxSize: number;
  47554. /**
  47555. * The texture used on the skybox for the main color.
  47556. * Comes from the BabylonJS CDN by default.
  47557. *
  47558. * Remarks: Can be either a texture or a url.
  47559. */
  47560. skyboxTexture: string | BaseTexture;
  47561. /**
  47562. * The color mixed in the skybox texture by default.
  47563. * BabylonJS clearColor by default.
  47564. */
  47565. skyboxColor: Color3;
  47566. /**
  47567. * The background rotation around the Y axis of the scene.
  47568. * This helps aligning the key lights of your scene with the background.
  47569. * 0 by default.
  47570. */
  47571. backgroundYRotation: number;
  47572. /**
  47573. * Compute automatically the size of the elements to best fit with the scene.
  47574. */
  47575. sizeAuto: boolean;
  47576. /**
  47577. * Default position of the rootMesh if autoSize is not true.
  47578. */
  47579. rootPosition: Vector3;
  47580. /**
  47581. * Sets up the image processing in the scene.
  47582. * true by default.
  47583. */
  47584. setupImageProcessing: boolean;
  47585. /**
  47586. * The texture used as your environment texture in the scene.
  47587. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47588. *
  47589. * Remarks: Can be either a texture or a url.
  47590. */
  47591. environmentTexture: string | BaseTexture;
  47592. /**
  47593. * The value of the exposure to apply to the scene.
  47594. * 0.6 by default if setupImageProcessing is true.
  47595. */
  47596. cameraExposure: number;
  47597. /**
  47598. * The value of the contrast to apply to the scene.
  47599. * 1.6 by default if setupImageProcessing is true.
  47600. */
  47601. cameraContrast: number;
  47602. /**
  47603. * Specifies wether or not tonemapping should be enabled in the scene.
  47604. * true by default if setupImageProcessing is true.
  47605. */
  47606. toneMappingEnabled: boolean;
  47607. }
  47608. /**
  47609. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47610. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47611. * It also helps with the default setup of your imageProcessing configuration.
  47612. */
  47613. export class EnvironmentHelper {
  47614. /**
  47615. * Default ground texture URL.
  47616. */
  47617. private static _groundTextureCDNUrl;
  47618. /**
  47619. * Default skybox texture URL.
  47620. */
  47621. private static _skyboxTextureCDNUrl;
  47622. /**
  47623. * Default environment texture URL.
  47624. */
  47625. private static _environmentTextureCDNUrl;
  47626. /**
  47627. * Creates the default options for the helper.
  47628. */
  47629. private static _getDefaultOptions;
  47630. private _rootMesh;
  47631. /**
  47632. * Gets the root mesh created by the helper.
  47633. */
  47634. readonly rootMesh: Mesh;
  47635. private _skybox;
  47636. /**
  47637. * Gets the skybox created by the helper.
  47638. */
  47639. readonly skybox: Nullable<Mesh>;
  47640. private _skyboxTexture;
  47641. /**
  47642. * Gets the skybox texture created by the helper.
  47643. */
  47644. readonly skyboxTexture: Nullable<BaseTexture>;
  47645. private _skyboxMaterial;
  47646. /**
  47647. * Gets the skybox material created by the helper.
  47648. */
  47649. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47650. private _ground;
  47651. /**
  47652. * Gets the ground mesh created by the helper.
  47653. */
  47654. readonly ground: Nullable<Mesh>;
  47655. private _groundTexture;
  47656. /**
  47657. * Gets the ground texture created by the helper.
  47658. */
  47659. readonly groundTexture: Nullable<BaseTexture>;
  47660. private _groundMirror;
  47661. /**
  47662. * Gets the ground mirror created by the helper.
  47663. */
  47664. readonly groundMirror: Nullable<MirrorTexture>;
  47665. /**
  47666. * Gets the ground mirror render list to helps pushing the meshes
  47667. * you wish in the ground reflection.
  47668. */
  47669. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47670. private _groundMaterial;
  47671. /**
  47672. * Gets the ground material created by the helper.
  47673. */
  47674. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47675. /**
  47676. * Stores the creation options.
  47677. */
  47678. private readonly _scene;
  47679. private _options;
  47680. /**
  47681. * This observable will be notified with any error during the creation of the environment,
  47682. * mainly texture creation errors.
  47683. */
  47684. onErrorObservable: Observable<{
  47685. message?: string;
  47686. exception?: any;
  47687. }>;
  47688. /**
  47689. * constructor
  47690. * @param options Defines the options we want to customize the helper
  47691. * @param scene The scene to add the material to
  47692. */
  47693. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47694. /**
  47695. * Updates the background according to the new options
  47696. * @param options
  47697. */
  47698. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47699. /**
  47700. * Sets the primary color of all the available elements.
  47701. * @param color the main color to affect to the ground and the background
  47702. */
  47703. setMainColor(color: Color3): void;
  47704. /**
  47705. * Setup the image processing according to the specified options.
  47706. */
  47707. private _setupImageProcessing;
  47708. /**
  47709. * Setup the environment texture according to the specified options.
  47710. */
  47711. private _setupEnvironmentTexture;
  47712. /**
  47713. * Setup the background according to the specified options.
  47714. */
  47715. private _setupBackground;
  47716. /**
  47717. * Get the scene sizes according to the setup.
  47718. */
  47719. private _getSceneSize;
  47720. /**
  47721. * Setup the ground according to the specified options.
  47722. */
  47723. private _setupGround;
  47724. /**
  47725. * Setup the ground material according to the specified options.
  47726. */
  47727. private _setupGroundMaterial;
  47728. /**
  47729. * Setup the ground diffuse texture according to the specified options.
  47730. */
  47731. private _setupGroundDiffuseTexture;
  47732. /**
  47733. * Setup the ground mirror texture according to the specified options.
  47734. */
  47735. private _setupGroundMirrorTexture;
  47736. /**
  47737. * Setup the ground to receive the mirror texture.
  47738. */
  47739. private _setupMirrorInGroundMaterial;
  47740. /**
  47741. * Setup the skybox according to the specified options.
  47742. */
  47743. private _setupSkybox;
  47744. /**
  47745. * Setup the skybox material according to the specified options.
  47746. */
  47747. private _setupSkyboxMaterial;
  47748. /**
  47749. * Setup the skybox reflection texture according to the specified options.
  47750. */
  47751. private _setupSkyboxReflectionTexture;
  47752. private _errorHandler;
  47753. /**
  47754. * Dispose all the elements created by the Helper.
  47755. */
  47756. dispose(): void;
  47757. }
  47758. }
  47759. declare module "babylonjs/Helpers/photoDome" {
  47760. import { Observable } from "babylonjs/Misc/observable";
  47761. import { Nullable } from "babylonjs/types";
  47762. import { Scene } from "babylonjs/scene";
  47763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47764. import { Mesh } from "babylonjs/Meshes/mesh";
  47765. import { Texture } from "babylonjs/Materials/Textures/texture";
  47766. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47767. import "babylonjs/Meshes/Builders/sphereBuilder";
  47768. /**
  47769. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47770. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47771. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47773. */
  47774. export class PhotoDome extends TransformNode {
  47775. /**
  47776. * Define the image as a Monoscopic panoramic 360 image.
  47777. */
  47778. static readonly MODE_MONOSCOPIC: number;
  47779. /**
  47780. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47781. */
  47782. static readonly MODE_TOPBOTTOM: number;
  47783. /**
  47784. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47785. */
  47786. static readonly MODE_SIDEBYSIDE: number;
  47787. private _useDirectMapping;
  47788. /**
  47789. * The texture being displayed on the sphere
  47790. */
  47791. protected _photoTexture: Texture;
  47792. /**
  47793. * Gets or sets the texture being displayed on the sphere
  47794. */
  47795. photoTexture: Texture;
  47796. /**
  47797. * Observable raised when an error occured while loading the 360 image
  47798. */
  47799. onLoadErrorObservable: Observable<string>;
  47800. /**
  47801. * The skybox material
  47802. */
  47803. protected _material: BackgroundMaterial;
  47804. /**
  47805. * The surface used for the skybox
  47806. */
  47807. protected _mesh: Mesh;
  47808. /**
  47809. * Gets the mesh used for the skybox.
  47810. */
  47811. readonly mesh: Mesh;
  47812. /**
  47813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47814. * Also see the options.resolution property.
  47815. */
  47816. fovMultiplier: number;
  47817. private _imageMode;
  47818. /**
  47819. * Gets or set the current video mode for the video. It can be:
  47820. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47821. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47822. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47823. */
  47824. imageMode: number;
  47825. /**
  47826. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47827. * @param name Element's name, child elements will append suffixes for their own names.
  47828. * @param urlsOfPhoto defines the url of the photo to display
  47829. * @param options defines an object containing optional or exposed sub element properties
  47830. * @param onError defines a callback called when an error occured while loading the texture
  47831. */
  47832. constructor(name: string, urlOfPhoto: string, options: {
  47833. resolution?: number;
  47834. size?: number;
  47835. useDirectMapping?: boolean;
  47836. faceForward?: boolean;
  47837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47838. private _onBeforeCameraRenderObserver;
  47839. private _changeImageMode;
  47840. /**
  47841. * Releases resources associated with this node.
  47842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47844. */
  47845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47846. }
  47847. }
  47848. declare module "babylonjs/Misc/rgbdTextureTools" {
  47849. import "babylonjs/Shaders/rgbdDecode.fragment";
  47850. import { Texture } from "babylonjs/Materials/Textures/texture";
  47851. /**
  47852. * Class used to host RGBD texture specific utilities
  47853. */
  47854. export class RGBDTextureTools {
  47855. /**
  47856. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47857. * @param texture the texture to expand.
  47858. */
  47859. static ExpandRGBDTexture(texture: Texture): void;
  47860. }
  47861. }
  47862. declare module "babylonjs/Misc/brdfTextureTools" {
  47863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47864. import { Scene } from "babylonjs/scene";
  47865. /**
  47866. * Class used to host texture specific utilities
  47867. */
  47868. export class BRDFTextureTools {
  47869. /**
  47870. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47871. * @param scene defines the hosting scene
  47872. * @returns the environment BRDF texture
  47873. */
  47874. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47875. private static _environmentBRDFBase64Texture;
  47876. }
  47877. }
  47878. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47879. import { Nullable } from "babylonjs/types";
  47880. import { Color3 } from "babylonjs/Maths/math.color";
  47881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47882. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47885. import { Engine } from "babylonjs/Engines/engine";
  47886. import { Scene } from "babylonjs/scene";
  47887. /**
  47888. * @hidden
  47889. */
  47890. export interface IMaterialClearCoatDefines {
  47891. CLEARCOAT: boolean;
  47892. CLEARCOAT_DEFAULTIOR: boolean;
  47893. CLEARCOAT_TEXTURE: boolean;
  47894. CLEARCOAT_TEXTUREDIRECTUV: number;
  47895. CLEARCOAT_BUMP: boolean;
  47896. CLEARCOAT_BUMPDIRECTUV: number;
  47897. CLEARCOAT_TINT: boolean;
  47898. CLEARCOAT_TINT_TEXTURE: boolean;
  47899. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47900. /** @hidden */
  47901. _areTexturesDirty: boolean;
  47902. }
  47903. /**
  47904. * Define the code related to the clear coat parameters of the pbr material.
  47905. */
  47906. export class PBRClearCoatConfiguration {
  47907. /**
  47908. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47909. * The default fits with a polyurethane material.
  47910. */
  47911. private static readonly _DefaultIndexOfRefraction;
  47912. private _isEnabled;
  47913. /**
  47914. * Defines if the clear coat is enabled in the material.
  47915. */
  47916. isEnabled: boolean;
  47917. /**
  47918. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47919. */
  47920. intensity: number;
  47921. /**
  47922. * Defines the clear coat layer roughness.
  47923. */
  47924. roughness: number;
  47925. private _indexOfRefraction;
  47926. /**
  47927. * Defines the index of refraction of the clear coat.
  47928. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47929. * The default fits with a polyurethane material.
  47930. * Changing the default value is more performance intensive.
  47931. */
  47932. indexOfRefraction: number;
  47933. private _texture;
  47934. /**
  47935. * Stores the clear coat values in a texture.
  47936. */
  47937. texture: Nullable<BaseTexture>;
  47938. private _bumpTexture;
  47939. /**
  47940. * Define the clear coat specific bump texture.
  47941. */
  47942. bumpTexture: Nullable<BaseTexture>;
  47943. private _isTintEnabled;
  47944. /**
  47945. * Defines if the clear coat tint is enabled in the material.
  47946. */
  47947. isTintEnabled: boolean;
  47948. /**
  47949. * Defines the clear coat tint of the material.
  47950. * This is only use if tint is enabled
  47951. */
  47952. tintColor: Color3;
  47953. /**
  47954. * Defines the distance at which the tint color should be found in the
  47955. * clear coat media.
  47956. * This is only use if tint is enabled
  47957. */
  47958. tintColorAtDistance: number;
  47959. /**
  47960. * Defines the clear coat layer thickness.
  47961. * This is only use if tint is enabled
  47962. */
  47963. tintThickness: number;
  47964. private _tintTexture;
  47965. /**
  47966. * Stores the clear tint values in a texture.
  47967. * rgb is tint
  47968. * a is a thickness factor
  47969. */
  47970. tintTexture: Nullable<BaseTexture>;
  47971. /** @hidden */
  47972. private _internalMarkAllSubMeshesAsTexturesDirty;
  47973. /** @hidden */
  47974. _markAllSubMeshesAsTexturesDirty(): void;
  47975. /**
  47976. * Instantiate a new istance of clear coat configuration.
  47977. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47978. */
  47979. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47980. /**
  47981. * Gets wehter the submesh is ready to be used or not.
  47982. * @param defines the list of "defines" to update.
  47983. * @param scene defines the scene the material belongs to.
  47984. * @param engine defines the engine the material belongs to.
  47985. * @param disableBumpMap defines wether the material disables bump or not.
  47986. * @returns - boolean indicating that the submesh is ready or not.
  47987. */
  47988. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47989. /**
  47990. * Checks to see if a texture is used in the material.
  47991. * @param defines the list of "defines" to update.
  47992. * @param scene defines the scene to the material belongs to.
  47993. */
  47994. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47995. /**
  47996. * Binds the material data.
  47997. * @param uniformBuffer defines the Uniform buffer to fill in.
  47998. * @param scene defines the scene the material belongs to.
  47999. * @param engine defines the engine the material belongs to.
  48000. * @param disableBumpMap defines wether the material disables bump or not.
  48001. * @param isFrozen defines wether the material is frozen or not.
  48002. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48003. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48004. */
  48005. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48006. /**
  48007. * Checks to see if a texture is used in the material.
  48008. * @param texture - Base texture to use.
  48009. * @returns - Boolean specifying if a texture is used in the material.
  48010. */
  48011. hasTexture(texture: BaseTexture): boolean;
  48012. /**
  48013. * Returns an array of the actively used textures.
  48014. * @param activeTextures Array of BaseTextures
  48015. */
  48016. getActiveTextures(activeTextures: BaseTexture[]): void;
  48017. /**
  48018. * Returns the animatable textures.
  48019. * @param animatables Array of animatable textures.
  48020. */
  48021. getAnimatables(animatables: IAnimatable[]): void;
  48022. /**
  48023. * Disposes the resources of the material.
  48024. * @param forceDisposeTextures - Forces the disposal of all textures.
  48025. */
  48026. dispose(forceDisposeTextures?: boolean): void;
  48027. /**
  48028. * Get the current class name of the texture useful for serialization or dynamic coding.
  48029. * @returns "PBRClearCoatConfiguration"
  48030. */
  48031. getClassName(): string;
  48032. /**
  48033. * Add fallbacks to the effect fallbacks list.
  48034. * @param defines defines the Base texture to use.
  48035. * @param fallbacks defines the current fallback list.
  48036. * @param currentRank defines the current fallback rank.
  48037. * @returns the new fallback rank.
  48038. */
  48039. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48040. /**
  48041. * Add the required uniforms to the current list.
  48042. * @param uniforms defines the current uniform list.
  48043. */
  48044. static AddUniforms(uniforms: string[]): void;
  48045. /**
  48046. * Add the required samplers to the current list.
  48047. * @param samplers defines the current sampler list.
  48048. */
  48049. static AddSamplers(samplers: string[]): void;
  48050. /**
  48051. * Add the required uniforms to the current buffer.
  48052. * @param uniformBuffer defines the current uniform buffer.
  48053. */
  48054. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48055. /**
  48056. * Makes a duplicate of the current configuration into another one.
  48057. * @param clearCoatConfiguration define the config where to copy the info
  48058. */
  48059. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48060. /**
  48061. * Serializes this clear coat configuration.
  48062. * @returns - An object with the serialized config.
  48063. */
  48064. serialize(): any;
  48065. /**
  48066. * Parses a anisotropy Configuration from a serialized object.
  48067. * @param source - Serialized object.
  48068. * @param scene Defines the scene we are parsing for
  48069. * @param rootUrl Defines the rootUrl to load from
  48070. */
  48071. parse(source: any, scene: Scene, rootUrl: string): void;
  48072. }
  48073. }
  48074. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48075. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48076. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48078. import { Vector2 } from "babylonjs/Maths/math.vector";
  48079. import { Scene } from "babylonjs/scene";
  48080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48081. import { Nullable } from "babylonjs/types";
  48082. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48083. /**
  48084. * @hidden
  48085. */
  48086. export interface IMaterialAnisotropicDefines {
  48087. ANISOTROPIC: boolean;
  48088. ANISOTROPIC_TEXTURE: boolean;
  48089. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48090. MAINUV1: boolean;
  48091. _areTexturesDirty: boolean;
  48092. _needUVs: boolean;
  48093. }
  48094. /**
  48095. * Define the code related to the anisotropic parameters of the pbr material.
  48096. */
  48097. export class PBRAnisotropicConfiguration {
  48098. private _isEnabled;
  48099. /**
  48100. * Defines if the anisotropy is enabled in the material.
  48101. */
  48102. isEnabled: boolean;
  48103. /**
  48104. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48105. */
  48106. intensity: number;
  48107. /**
  48108. * Defines if the effect is along the tangents, bitangents or in between.
  48109. * By default, the effect is "strectching" the highlights along the tangents.
  48110. */
  48111. direction: Vector2;
  48112. private _texture;
  48113. /**
  48114. * Stores the anisotropy values in a texture.
  48115. * rg is direction (like normal from -1 to 1)
  48116. * b is a intensity
  48117. */
  48118. texture: Nullable<BaseTexture>;
  48119. /** @hidden */
  48120. private _internalMarkAllSubMeshesAsTexturesDirty;
  48121. /** @hidden */
  48122. _markAllSubMeshesAsTexturesDirty(): void;
  48123. /**
  48124. * Instantiate a new istance of anisotropy configuration.
  48125. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48126. */
  48127. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48128. /**
  48129. * Specifies that the submesh is ready to be used.
  48130. * @param defines the list of "defines" to update.
  48131. * @param scene defines the scene the material belongs to.
  48132. * @returns - boolean indicating that the submesh is ready or not.
  48133. */
  48134. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48135. /**
  48136. * Checks to see if a texture is used in the material.
  48137. * @param defines the list of "defines" to update.
  48138. * @param mesh the mesh we are preparing the defines for.
  48139. * @param scene defines the scene the material belongs to.
  48140. */
  48141. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48142. /**
  48143. * Binds the material data.
  48144. * @param uniformBuffer defines the Uniform buffer to fill in.
  48145. * @param scene defines the scene the material belongs to.
  48146. * @param isFrozen defines wether the material is frozen or not.
  48147. */
  48148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48149. /**
  48150. * Checks to see if a texture is used in the material.
  48151. * @param texture - Base texture to use.
  48152. * @returns - Boolean specifying if a texture is used in the material.
  48153. */
  48154. hasTexture(texture: BaseTexture): boolean;
  48155. /**
  48156. * Returns an array of the actively used textures.
  48157. * @param activeTextures Array of BaseTextures
  48158. */
  48159. getActiveTextures(activeTextures: BaseTexture[]): void;
  48160. /**
  48161. * Returns the animatable textures.
  48162. * @param animatables Array of animatable textures.
  48163. */
  48164. getAnimatables(animatables: IAnimatable[]): void;
  48165. /**
  48166. * Disposes the resources of the material.
  48167. * @param forceDisposeTextures - Forces the disposal of all textures.
  48168. */
  48169. dispose(forceDisposeTextures?: boolean): void;
  48170. /**
  48171. * Get the current class name of the texture useful for serialization or dynamic coding.
  48172. * @returns "PBRAnisotropicConfiguration"
  48173. */
  48174. getClassName(): string;
  48175. /**
  48176. * Add fallbacks to the effect fallbacks list.
  48177. * @param defines defines the Base texture to use.
  48178. * @param fallbacks defines the current fallback list.
  48179. * @param currentRank defines the current fallback rank.
  48180. * @returns the new fallback rank.
  48181. */
  48182. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48183. /**
  48184. * Add the required uniforms to the current list.
  48185. * @param uniforms defines the current uniform list.
  48186. */
  48187. static AddUniforms(uniforms: string[]): void;
  48188. /**
  48189. * Add the required uniforms to the current buffer.
  48190. * @param uniformBuffer defines the current uniform buffer.
  48191. */
  48192. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48193. /**
  48194. * Add the required samplers to the current list.
  48195. * @param samplers defines the current sampler list.
  48196. */
  48197. static AddSamplers(samplers: string[]): void;
  48198. /**
  48199. * Makes a duplicate of the current configuration into another one.
  48200. * @param anisotropicConfiguration define the config where to copy the info
  48201. */
  48202. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48203. /**
  48204. * Serializes this anisotropy configuration.
  48205. * @returns - An object with the serialized config.
  48206. */
  48207. serialize(): any;
  48208. /**
  48209. * Parses a anisotropy Configuration from a serialized object.
  48210. * @param source - Serialized object.
  48211. * @param scene Defines the scene we are parsing for
  48212. * @param rootUrl Defines the rootUrl to load from
  48213. */
  48214. parse(source: any, scene: Scene, rootUrl: string): void;
  48215. }
  48216. }
  48217. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48218. import { Scene } from "babylonjs/scene";
  48219. /**
  48220. * @hidden
  48221. */
  48222. export interface IMaterialBRDFDefines {
  48223. BRDF_V_HEIGHT_CORRELATED: boolean;
  48224. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48225. SPHERICAL_HARMONICS: boolean;
  48226. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48227. /** @hidden */
  48228. _areMiscDirty: boolean;
  48229. }
  48230. /**
  48231. * Define the code related to the BRDF parameters of the pbr material.
  48232. */
  48233. export class PBRBRDFConfiguration {
  48234. /**
  48235. * Default value used for the energy conservation.
  48236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48237. */
  48238. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48239. /**
  48240. * Default value used for the Smith Visibility Height Correlated mode.
  48241. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48242. */
  48243. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48244. /**
  48245. * Default value used for the IBL diffuse part.
  48246. * This can help switching back to the polynomials mode globally which is a tiny bit
  48247. * less GPU intensive at the drawback of a lower quality.
  48248. */
  48249. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48250. /**
  48251. * Default value used for activating energy conservation for the specular workflow.
  48252. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48253. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48254. */
  48255. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48256. private _useEnergyConservation;
  48257. /**
  48258. * Defines if the material uses energy conservation.
  48259. */
  48260. useEnergyConservation: boolean;
  48261. private _useSmithVisibilityHeightCorrelated;
  48262. /**
  48263. * LEGACY Mode set to false
  48264. * Defines if the material uses height smith correlated visibility term.
  48265. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48266. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48267. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48268. * Not relying on height correlated will also disable energy conservation.
  48269. */
  48270. useSmithVisibilityHeightCorrelated: boolean;
  48271. private _useSphericalHarmonics;
  48272. /**
  48273. * LEGACY Mode set to false
  48274. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48275. * diffuse part of the IBL.
  48276. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48277. * to the ground truth.
  48278. */
  48279. useSphericalHarmonics: boolean;
  48280. private _useSpecularGlossinessInputEnergyConservation;
  48281. /**
  48282. * Defines if the material uses energy conservation, when the specular workflow is active.
  48283. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48284. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48285. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48286. */
  48287. useSpecularGlossinessInputEnergyConservation: boolean;
  48288. /** @hidden */
  48289. private _internalMarkAllSubMeshesAsMiscDirty;
  48290. /** @hidden */
  48291. _markAllSubMeshesAsMiscDirty(): void;
  48292. /**
  48293. * Instantiate a new istance of clear coat configuration.
  48294. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48295. */
  48296. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48297. /**
  48298. * Checks to see if a texture is used in the material.
  48299. * @param defines the list of "defines" to update.
  48300. */
  48301. prepareDefines(defines: IMaterialBRDFDefines): void;
  48302. /**
  48303. * Get the current class name of the texture useful for serialization or dynamic coding.
  48304. * @returns "PBRClearCoatConfiguration"
  48305. */
  48306. getClassName(): string;
  48307. /**
  48308. * Makes a duplicate of the current configuration into another one.
  48309. * @param brdfConfiguration define the config where to copy the info
  48310. */
  48311. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48312. /**
  48313. * Serializes this BRDF configuration.
  48314. * @returns - An object with the serialized config.
  48315. */
  48316. serialize(): any;
  48317. /**
  48318. * Parses a anisotropy Configuration from a serialized object.
  48319. * @param source - Serialized object.
  48320. * @param scene Defines the scene we are parsing for
  48321. * @param rootUrl Defines the rootUrl to load from
  48322. */
  48323. parse(source: any, scene: Scene, rootUrl: string): void;
  48324. }
  48325. }
  48326. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48327. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48328. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48329. import { Color3 } from "babylonjs/Maths/math.color";
  48330. import { Scene } from "babylonjs/scene";
  48331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48332. import { Nullable } from "babylonjs/types";
  48333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48334. /**
  48335. * @hidden
  48336. */
  48337. export interface IMaterialSheenDefines {
  48338. SHEEN: boolean;
  48339. SHEEN_TEXTURE: boolean;
  48340. SHEEN_TEXTUREDIRECTUV: number;
  48341. SHEEN_LINKWITHALBEDO: boolean;
  48342. /** @hidden */
  48343. _areTexturesDirty: boolean;
  48344. }
  48345. /**
  48346. * Define the code related to the Sheen parameters of the pbr material.
  48347. */
  48348. export class PBRSheenConfiguration {
  48349. private _isEnabled;
  48350. /**
  48351. * Defines if the material uses sheen.
  48352. */
  48353. isEnabled: boolean;
  48354. private _linkSheenWithAlbedo;
  48355. /**
  48356. * Defines if the sheen is linked to the sheen color.
  48357. */
  48358. linkSheenWithAlbedo: boolean;
  48359. /**
  48360. * Defines the sheen intensity.
  48361. */
  48362. intensity: number;
  48363. /**
  48364. * Defines the sheen color.
  48365. */
  48366. color: Color3;
  48367. private _texture;
  48368. /**
  48369. * Stores the sheen tint values in a texture.
  48370. * rgb is tint
  48371. * a is a intensity
  48372. */
  48373. texture: Nullable<BaseTexture>;
  48374. /** @hidden */
  48375. private _internalMarkAllSubMeshesAsTexturesDirty;
  48376. /** @hidden */
  48377. _markAllSubMeshesAsTexturesDirty(): void;
  48378. /**
  48379. * Instantiate a new istance of clear coat configuration.
  48380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48381. */
  48382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48383. /**
  48384. * Specifies that the submesh is ready to be used.
  48385. * @param defines the list of "defines" to update.
  48386. * @param scene defines the scene the material belongs to.
  48387. * @returns - boolean indicating that the submesh is ready or not.
  48388. */
  48389. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48390. /**
  48391. * Checks to see if a texture is used in the material.
  48392. * @param defines the list of "defines" to update.
  48393. * @param scene defines the scene the material belongs to.
  48394. */
  48395. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48396. /**
  48397. * Binds the material data.
  48398. * @param uniformBuffer defines the Uniform buffer to fill in.
  48399. * @param scene defines the scene the material belongs to.
  48400. * @param isFrozen defines wether the material is frozen or not.
  48401. */
  48402. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48403. /**
  48404. * Checks to see if a texture is used in the material.
  48405. * @param texture - Base texture to use.
  48406. * @returns - Boolean specifying if a texture is used in the material.
  48407. */
  48408. hasTexture(texture: BaseTexture): boolean;
  48409. /**
  48410. * Returns an array of the actively used textures.
  48411. * @param activeTextures Array of BaseTextures
  48412. */
  48413. getActiveTextures(activeTextures: BaseTexture[]): void;
  48414. /**
  48415. * Returns the animatable textures.
  48416. * @param animatables Array of animatable textures.
  48417. */
  48418. getAnimatables(animatables: IAnimatable[]): void;
  48419. /**
  48420. * Disposes the resources of the material.
  48421. * @param forceDisposeTextures - Forces the disposal of all textures.
  48422. */
  48423. dispose(forceDisposeTextures?: boolean): void;
  48424. /**
  48425. * Get the current class name of the texture useful for serialization or dynamic coding.
  48426. * @returns "PBRSheenConfiguration"
  48427. */
  48428. getClassName(): string;
  48429. /**
  48430. * Add fallbacks to the effect fallbacks list.
  48431. * @param defines defines the Base texture to use.
  48432. * @param fallbacks defines the current fallback list.
  48433. * @param currentRank defines the current fallback rank.
  48434. * @returns the new fallback rank.
  48435. */
  48436. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48437. /**
  48438. * Add the required uniforms to the current list.
  48439. * @param uniforms defines the current uniform list.
  48440. */
  48441. static AddUniforms(uniforms: string[]): void;
  48442. /**
  48443. * Add the required uniforms to the current buffer.
  48444. * @param uniformBuffer defines the current uniform buffer.
  48445. */
  48446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48447. /**
  48448. * Add the required samplers to the current list.
  48449. * @param samplers defines the current sampler list.
  48450. */
  48451. static AddSamplers(samplers: string[]): void;
  48452. /**
  48453. * Makes a duplicate of the current configuration into another one.
  48454. * @param sheenConfiguration define the config where to copy the info
  48455. */
  48456. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48457. /**
  48458. * Serializes this BRDF configuration.
  48459. * @returns - An object with the serialized config.
  48460. */
  48461. serialize(): any;
  48462. /**
  48463. * Parses a anisotropy Configuration from a serialized object.
  48464. * @param source - Serialized object.
  48465. * @param scene Defines the scene we are parsing for
  48466. * @param rootUrl Defines the rootUrl to load from
  48467. */
  48468. parse(source: any, scene: Scene, rootUrl: string): void;
  48469. }
  48470. }
  48471. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48472. import { Nullable } from "babylonjs/types";
  48473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48474. import { Color3 } from "babylonjs/Maths/math.color";
  48475. import { SmartArray } from "babylonjs/Misc/smartArray";
  48476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48478. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48480. import { Engine } from "babylonjs/Engines/engine";
  48481. import { Scene } from "babylonjs/scene";
  48482. /**
  48483. * @hidden
  48484. */
  48485. export interface IMaterialSubSurfaceDefines {
  48486. SUBSURFACE: boolean;
  48487. SS_REFRACTION: boolean;
  48488. SS_TRANSLUCENCY: boolean;
  48489. SS_SCATERRING: boolean;
  48490. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48491. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48492. SS_REFRACTIONMAP_3D: boolean;
  48493. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48494. SS_LODINREFRACTIONALPHA: boolean;
  48495. SS_GAMMAREFRACTION: boolean;
  48496. SS_RGBDREFRACTION: boolean;
  48497. SS_LINEARSPECULARREFRACTION: boolean;
  48498. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48499. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48500. /** @hidden */
  48501. _areTexturesDirty: boolean;
  48502. }
  48503. /**
  48504. * Define the code related to the sub surface parameters of the pbr material.
  48505. */
  48506. export class PBRSubSurfaceConfiguration {
  48507. private _isRefractionEnabled;
  48508. /**
  48509. * Defines if the refraction is enabled in the material.
  48510. */
  48511. isRefractionEnabled: boolean;
  48512. private _isTranslucencyEnabled;
  48513. /**
  48514. * Defines if the translucency is enabled in the material.
  48515. */
  48516. isTranslucencyEnabled: boolean;
  48517. private _isScatteringEnabled;
  48518. /**
  48519. * Defines the refraction intensity of the material.
  48520. * The refraction when enabled replaces the Diffuse part of the material.
  48521. * The intensity helps transitionning between diffuse and refraction.
  48522. */
  48523. refractionIntensity: number;
  48524. /**
  48525. * Defines the translucency intensity of the material.
  48526. * When translucency has been enabled, this defines how much of the "translucency"
  48527. * is addded to the diffuse part of the material.
  48528. */
  48529. translucencyIntensity: number;
  48530. /**
  48531. * Defines the scattering intensity of the material.
  48532. * When scattering has been enabled, this defines how much of the "scattered light"
  48533. * is addded to the diffuse part of the material.
  48534. */
  48535. scatteringIntensity: number;
  48536. private _thicknessTexture;
  48537. /**
  48538. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48539. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48540. * 0 would mean minimumThickness
  48541. * 1 would mean maximumThickness
  48542. * The other channels might be use as a mask to vary the different effects intensity.
  48543. */
  48544. thicknessTexture: Nullable<BaseTexture>;
  48545. private _refractionTexture;
  48546. /**
  48547. * Defines the texture to use for refraction.
  48548. */
  48549. refractionTexture: Nullable<BaseTexture>;
  48550. private _indexOfRefraction;
  48551. /**
  48552. * Defines the index of refraction used in the material.
  48553. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48554. */
  48555. indexOfRefraction: number;
  48556. private _invertRefractionY;
  48557. /**
  48558. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48559. */
  48560. invertRefractionY: boolean;
  48561. private _linkRefractionWithTransparency;
  48562. /**
  48563. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48564. * Materials half opaque for instance using refraction could benefit from this control.
  48565. */
  48566. linkRefractionWithTransparency: boolean;
  48567. /**
  48568. * Defines the minimum thickness stored in the thickness map.
  48569. * If no thickness map is defined, this value will be used to simulate thickness.
  48570. */
  48571. minimumThickness: number;
  48572. /**
  48573. * Defines the maximum thickness stored in the thickness map.
  48574. */
  48575. maximumThickness: number;
  48576. /**
  48577. * Defines the volume tint of the material.
  48578. * This is used for both translucency and scattering.
  48579. */
  48580. tintColor: Color3;
  48581. /**
  48582. * Defines the distance at which the tint color should be found in the media.
  48583. * This is used for refraction only.
  48584. */
  48585. tintColorAtDistance: number;
  48586. /**
  48587. * Defines how far each channel transmit through the media.
  48588. * It is defined as a color to simplify it selection.
  48589. */
  48590. diffusionDistance: Color3;
  48591. private _useMaskFromThicknessTexture;
  48592. /**
  48593. * Stores the intensity of the different subsurface effects in the thickness texture.
  48594. * * the green channel is the translucency intensity.
  48595. * * the blue channel is the scattering intensity.
  48596. * * the alpha channel is the refraction intensity.
  48597. */
  48598. useMaskFromThicknessTexture: boolean;
  48599. /** @hidden */
  48600. private _internalMarkAllSubMeshesAsTexturesDirty;
  48601. /** @hidden */
  48602. _markAllSubMeshesAsTexturesDirty(): void;
  48603. /**
  48604. * Instantiate a new istance of sub surface configuration.
  48605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48606. */
  48607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48608. /**
  48609. * Gets wehter the submesh is ready to be used or not.
  48610. * @param defines the list of "defines" to update.
  48611. * @param scene defines the scene the material belongs to.
  48612. * @returns - boolean indicating that the submesh is ready or not.
  48613. */
  48614. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48615. /**
  48616. * Checks to see if a texture is used in the material.
  48617. * @param defines the list of "defines" to update.
  48618. * @param scene defines the scene to the material belongs to.
  48619. */
  48620. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48621. /**
  48622. * Binds the material data.
  48623. * @param uniformBuffer defines the Uniform buffer to fill in.
  48624. * @param scene defines the scene the material belongs to.
  48625. * @param engine defines the engine the material belongs to.
  48626. * @param isFrozen defines wether the material is frozen or not.
  48627. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48628. */
  48629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48630. /**
  48631. * Unbinds the material from the mesh.
  48632. * @param activeEffect defines the effect that should be unbound from.
  48633. * @returns true if unbound, otherwise false
  48634. */
  48635. unbind(activeEffect: Effect): boolean;
  48636. /**
  48637. * Returns the texture used for refraction or null if none is used.
  48638. * @param scene defines the scene the material belongs to.
  48639. * @returns - Refraction texture if present. If no refraction texture and refraction
  48640. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48641. */
  48642. private _getRefractionTexture;
  48643. /**
  48644. * Returns true if alpha blending should be disabled.
  48645. */
  48646. readonly disableAlphaBlending: boolean;
  48647. /**
  48648. * Fills the list of render target textures.
  48649. * @param renderTargets the list of render targets to update
  48650. */
  48651. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48652. /**
  48653. * Checks to see if a texture is used in the material.
  48654. * @param texture - Base texture to use.
  48655. * @returns - Boolean specifying if a texture is used in the material.
  48656. */
  48657. hasTexture(texture: BaseTexture): boolean;
  48658. /**
  48659. * Gets a boolean indicating that current material needs to register RTT
  48660. * @returns true if this uses a render target otherwise false.
  48661. */
  48662. hasRenderTargetTextures(): boolean;
  48663. /**
  48664. * Returns an array of the actively used textures.
  48665. * @param activeTextures Array of BaseTextures
  48666. */
  48667. getActiveTextures(activeTextures: BaseTexture[]): void;
  48668. /**
  48669. * Returns the animatable textures.
  48670. * @param animatables Array of animatable textures.
  48671. */
  48672. getAnimatables(animatables: IAnimatable[]): void;
  48673. /**
  48674. * Disposes the resources of the material.
  48675. * @param forceDisposeTextures - Forces the disposal of all textures.
  48676. */
  48677. dispose(forceDisposeTextures?: boolean): void;
  48678. /**
  48679. * Get the current class name of the texture useful for serialization or dynamic coding.
  48680. * @returns "PBRSubSurfaceConfiguration"
  48681. */
  48682. getClassName(): string;
  48683. /**
  48684. * Add fallbacks to the effect fallbacks list.
  48685. * @param defines defines the Base texture to use.
  48686. * @param fallbacks defines the current fallback list.
  48687. * @param currentRank defines the current fallback rank.
  48688. * @returns the new fallback rank.
  48689. */
  48690. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48691. /**
  48692. * Add the required uniforms to the current list.
  48693. * @param uniforms defines the current uniform list.
  48694. */
  48695. static AddUniforms(uniforms: string[]): void;
  48696. /**
  48697. * Add the required samplers to the current list.
  48698. * @param samplers defines the current sampler list.
  48699. */
  48700. static AddSamplers(samplers: string[]): void;
  48701. /**
  48702. * Add the required uniforms to the current buffer.
  48703. * @param uniformBuffer defines the current uniform buffer.
  48704. */
  48705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48706. /**
  48707. * Makes a duplicate of the current configuration into another one.
  48708. * @param configuration define the config where to copy the info
  48709. */
  48710. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48711. /**
  48712. * Serializes this Sub Surface configuration.
  48713. * @returns - An object with the serialized config.
  48714. */
  48715. serialize(): any;
  48716. /**
  48717. * Parses a anisotropy Configuration from a serialized object.
  48718. * @param source - Serialized object.
  48719. * @param scene Defines the scene we are parsing for
  48720. * @param rootUrl Defines the rootUrl to load from
  48721. */
  48722. parse(source: any, scene: Scene, rootUrl: string): void;
  48723. }
  48724. }
  48725. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48726. /** @hidden */
  48727. export var pbrFragmentDeclaration: {
  48728. name: string;
  48729. shader: string;
  48730. };
  48731. }
  48732. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48733. /** @hidden */
  48734. export var pbrUboDeclaration: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48740. /** @hidden */
  48741. export var pbrFragmentExtraDeclaration: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48747. /** @hidden */
  48748. export var pbrFragmentSamplersDeclaration: {
  48749. name: string;
  48750. shader: string;
  48751. };
  48752. }
  48753. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48754. /** @hidden */
  48755. export var pbrHelperFunctions: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48761. /** @hidden */
  48762. export var harmonicsFunctions: {
  48763. name: string;
  48764. shader: string;
  48765. };
  48766. }
  48767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48768. /** @hidden */
  48769. export var pbrDirectLightingSetupFunctions: {
  48770. name: string;
  48771. shader: string;
  48772. };
  48773. }
  48774. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48775. /** @hidden */
  48776. export var pbrDirectLightingFalloffFunctions: {
  48777. name: string;
  48778. shader: string;
  48779. };
  48780. }
  48781. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48782. /** @hidden */
  48783. export var pbrBRDFFunctions: {
  48784. name: string;
  48785. shader: string;
  48786. };
  48787. }
  48788. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48789. /** @hidden */
  48790. export var pbrDirectLightingFunctions: {
  48791. name: string;
  48792. shader: string;
  48793. };
  48794. }
  48795. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48796. /** @hidden */
  48797. export var pbrIBLFunctions: {
  48798. name: string;
  48799. shader: string;
  48800. };
  48801. }
  48802. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48803. /** @hidden */
  48804. export var pbrDebug: {
  48805. name: string;
  48806. shader: string;
  48807. };
  48808. }
  48809. declare module "babylonjs/Shaders/pbr.fragment" {
  48810. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48814. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48821. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48825. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48826. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48827. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48828. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48829. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48830. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48831. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48833. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48834. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48835. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48836. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48837. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48838. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48839. /** @hidden */
  48840. export var pbrPixelShader: {
  48841. name: string;
  48842. shader: string;
  48843. };
  48844. }
  48845. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48846. /** @hidden */
  48847. export var pbrVertexDeclaration: {
  48848. name: string;
  48849. shader: string;
  48850. };
  48851. }
  48852. declare module "babylonjs/Shaders/pbr.vertex" {
  48853. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48854. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48858. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48859. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48860. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48861. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48862. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48863. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48868. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48870. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48871. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48872. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48873. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48874. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48875. /** @hidden */
  48876. export var pbrVertexShader: {
  48877. name: string;
  48878. shader: string;
  48879. };
  48880. }
  48881. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48882. import { Nullable } from "babylonjs/types";
  48883. import { Scene } from "babylonjs/scene";
  48884. import { Matrix } from "babylonjs/Maths/math.vector";
  48885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48887. import { Mesh } from "babylonjs/Meshes/mesh";
  48888. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48889. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48890. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48891. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48892. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48893. import { Color3 } from "babylonjs/Maths/math.color";
  48894. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48895. import { Material } from "babylonjs/Materials/material";
  48896. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48897. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48900. import "babylonjs/Shaders/pbr.fragment";
  48901. import "babylonjs/Shaders/pbr.vertex";
  48902. /**
  48903. * Manages the defines for the PBR Material.
  48904. * @hidden
  48905. */
  48906. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48907. PBR: boolean;
  48908. MAINUV1: boolean;
  48909. MAINUV2: boolean;
  48910. UV1: boolean;
  48911. UV2: boolean;
  48912. ALBEDO: boolean;
  48913. ALBEDODIRECTUV: number;
  48914. VERTEXCOLOR: boolean;
  48915. AMBIENT: boolean;
  48916. AMBIENTDIRECTUV: number;
  48917. AMBIENTINGRAYSCALE: boolean;
  48918. OPACITY: boolean;
  48919. VERTEXALPHA: boolean;
  48920. OPACITYDIRECTUV: number;
  48921. OPACITYRGB: boolean;
  48922. ALPHATEST: boolean;
  48923. DEPTHPREPASS: boolean;
  48924. ALPHABLEND: boolean;
  48925. ALPHAFROMALBEDO: boolean;
  48926. ALPHATESTVALUE: string;
  48927. SPECULAROVERALPHA: boolean;
  48928. RADIANCEOVERALPHA: boolean;
  48929. ALPHAFRESNEL: boolean;
  48930. LINEARALPHAFRESNEL: boolean;
  48931. PREMULTIPLYALPHA: boolean;
  48932. EMISSIVE: boolean;
  48933. EMISSIVEDIRECTUV: number;
  48934. REFLECTIVITY: boolean;
  48935. REFLECTIVITYDIRECTUV: number;
  48936. SPECULARTERM: boolean;
  48937. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48938. MICROSURFACEAUTOMATIC: boolean;
  48939. LODBASEDMICROSFURACE: boolean;
  48940. MICROSURFACEMAP: boolean;
  48941. MICROSURFACEMAPDIRECTUV: number;
  48942. METALLICWORKFLOW: boolean;
  48943. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48944. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48945. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48946. AOSTOREINMETALMAPRED: boolean;
  48947. ENVIRONMENTBRDF: boolean;
  48948. ENVIRONMENTBRDF_RGBD: boolean;
  48949. NORMAL: boolean;
  48950. TANGENT: boolean;
  48951. BUMP: boolean;
  48952. BUMPDIRECTUV: number;
  48953. OBJECTSPACE_NORMALMAP: boolean;
  48954. PARALLAX: boolean;
  48955. PARALLAXOCCLUSION: boolean;
  48956. NORMALXYSCALE: boolean;
  48957. LIGHTMAP: boolean;
  48958. LIGHTMAPDIRECTUV: number;
  48959. USELIGHTMAPASSHADOWMAP: boolean;
  48960. GAMMALIGHTMAP: boolean;
  48961. RGBDLIGHTMAP: boolean;
  48962. REFLECTION: boolean;
  48963. REFLECTIONMAP_3D: boolean;
  48964. REFLECTIONMAP_SPHERICAL: boolean;
  48965. REFLECTIONMAP_PLANAR: boolean;
  48966. REFLECTIONMAP_CUBIC: boolean;
  48967. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48968. REFLECTIONMAP_PROJECTION: boolean;
  48969. REFLECTIONMAP_SKYBOX: boolean;
  48970. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48971. REFLECTIONMAP_EXPLICIT: boolean;
  48972. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48973. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48974. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48975. INVERTCUBICMAP: boolean;
  48976. USESPHERICALFROMREFLECTIONMAP: boolean;
  48977. USEIRRADIANCEMAP: boolean;
  48978. SPHERICAL_HARMONICS: boolean;
  48979. USESPHERICALINVERTEX: boolean;
  48980. REFLECTIONMAP_OPPOSITEZ: boolean;
  48981. LODINREFLECTIONALPHA: boolean;
  48982. GAMMAREFLECTION: boolean;
  48983. RGBDREFLECTION: boolean;
  48984. LINEARSPECULARREFLECTION: boolean;
  48985. RADIANCEOCCLUSION: boolean;
  48986. HORIZONOCCLUSION: boolean;
  48987. INSTANCES: boolean;
  48988. NUM_BONE_INFLUENCERS: number;
  48989. BonesPerMesh: number;
  48990. BONETEXTURE: boolean;
  48991. NONUNIFORMSCALING: boolean;
  48992. MORPHTARGETS: boolean;
  48993. MORPHTARGETS_NORMAL: boolean;
  48994. MORPHTARGETS_TANGENT: boolean;
  48995. MORPHTARGETS_UV: boolean;
  48996. NUM_MORPH_INFLUENCERS: number;
  48997. IMAGEPROCESSING: boolean;
  48998. VIGNETTE: boolean;
  48999. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49000. VIGNETTEBLENDMODEOPAQUE: boolean;
  49001. TONEMAPPING: boolean;
  49002. TONEMAPPING_ACES: boolean;
  49003. CONTRAST: boolean;
  49004. COLORCURVES: boolean;
  49005. COLORGRADING: boolean;
  49006. COLORGRADING3D: boolean;
  49007. SAMPLER3DGREENDEPTH: boolean;
  49008. SAMPLER3DBGRMAP: boolean;
  49009. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49010. EXPOSURE: boolean;
  49011. MULTIVIEW: boolean;
  49012. USEPHYSICALLIGHTFALLOFF: boolean;
  49013. USEGLTFLIGHTFALLOFF: boolean;
  49014. TWOSIDEDLIGHTING: boolean;
  49015. SHADOWFLOAT: boolean;
  49016. CLIPPLANE: boolean;
  49017. CLIPPLANE2: boolean;
  49018. CLIPPLANE3: boolean;
  49019. CLIPPLANE4: boolean;
  49020. POINTSIZE: boolean;
  49021. FOG: boolean;
  49022. LOGARITHMICDEPTH: boolean;
  49023. FORCENORMALFORWARD: boolean;
  49024. SPECULARAA: boolean;
  49025. CLEARCOAT: boolean;
  49026. CLEARCOAT_DEFAULTIOR: boolean;
  49027. CLEARCOAT_TEXTURE: boolean;
  49028. CLEARCOAT_TEXTUREDIRECTUV: number;
  49029. CLEARCOAT_BUMP: boolean;
  49030. CLEARCOAT_BUMPDIRECTUV: number;
  49031. CLEARCOAT_TINT: boolean;
  49032. CLEARCOAT_TINT_TEXTURE: boolean;
  49033. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49034. ANISOTROPIC: boolean;
  49035. ANISOTROPIC_TEXTURE: boolean;
  49036. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49037. BRDF_V_HEIGHT_CORRELATED: boolean;
  49038. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49039. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49040. SHEEN: boolean;
  49041. SHEEN_TEXTURE: boolean;
  49042. SHEEN_TEXTUREDIRECTUV: number;
  49043. SHEEN_LINKWITHALBEDO: boolean;
  49044. SUBSURFACE: boolean;
  49045. SS_REFRACTION: boolean;
  49046. SS_TRANSLUCENCY: boolean;
  49047. SS_SCATERRING: boolean;
  49048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49050. SS_REFRACTIONMAP_3D: boolean;
  49051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49052. SS_LODINREFRACTIONALPHA: boolean;
  49053. SS_GAMMAREFRACTION: boolean;
  49054. SS_RGBDREFRACTION: boolean;
  49055. SS_LINEARSPECULARREFRACTION: boolean;
  49056. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49057. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49058. UNLIT: boolean;
  49059. DEBUGMODE: number;
  49060. /**
  49061. * Initializes the PBR Material defines.
  49062. */
  49063. constructor();
  49064. /**
  49065. * Resets the PBR Material defines.
  49066. */
  49067. reset(): void;
  49068. }
  49069. /**
  49070. * The Physically based material base class of BJS.
  49071. *
  49072. * This offers the main features of a standard PBR material.
  49073. * For more information, please refer to the documentation :
  49074. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49075. */
  49076. export abstract class PBRBaseMaterial extends PushMaterial {
  49077. /**
  49078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49079. */
  49080. static readonly PBRMATERIAL_OPAQUE: number;
  49081. /**
  49082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49083. */
  49084. static readonly PBRMATERIAL_ALPHATEST: number;
  49085. /**
  49086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49087. */
  49088. static readonly PBRMATERIAL_ALPHABLEND: number;
  49089. /**
  49090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49091. * They are also discarded below the alpha cutoff threshold to improve performances.
  49092. */
  49093. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49094. /**
  49095. * Defines the default value of how much AO map is occluding the analytical lights
  49096. * (point spot...).
  49097. */
  49098. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49099. /**
  49100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49101. */
  49102. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49103. /**
  49104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49105. * to enhance interoperability with other engines.
  49106. */
  49107. static readonly LIGHTFALLOFF_GLTF: number;
  49108. /**
  49109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49110. * to enhance interoperability with other materials.
  49111. */
  49112. static readonly LIGHTFALLOFF_STANDARD: number;
  49113. /**
  49114. * Intensity of the direct lights e.g. the four lights available in your scene.
  49115. * This impacts both the direct diffuse and specular highlights.
  49116. */
  49117. protected _directIntensity: number;
  49118. /**
  49119. * Intensity of the emissive part of the material.
  49120. * This helps controlling the emissive effect without modifying the emissive color.
  49121. */
  49122. protected _emissiveIntensity: number;
  49123. /**
  49124. * Intensity of the environment e.g. how much the environment will light the object
  49125. * either through harmonics for rough material or through the refelction for shiny ones.
  49126. */
  49127. protected _environmentIntensity: number;
  49128. /**
  49129. * This is a special control allowing the reduction of the specular highlights coming from the
  49130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49131. */
  49132. protected _specularIntensity: number;
  49133. /**
  49134. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49135. */
  49136. private _lightingInfos;
  49137. /**
  49138. * Debug Control allowing disabling the bump map on this material.
  49139. */
  49140. protected _disableBumpMap: boolean;
  49141. /**
  49142. * AKA Diffuse Texture in standard nomenclature.
  49143. */
  49144. protected _albedoTexture: Nullable<BaseTexture>;
  49145. /**
  49146. * AKA Occlusion Texture in other nomenclature.
  49147. */
  49148. protected _ambientTexture: Nullable<BaseTexture>;
  49149. /**
  49150. * AKA Occlusion Texture Intensity in other nomenclature.
  49151. */
  49152. protected _ambientTextureStrength: number;
  49153. /**
  49154. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49155. * 1 means it completely occludes it
  49156. * 0 mean it has no impact
  49157. */
  49158. protected _ambientTextureImpactOnAnalyticalLights: number;
  49159. /**
  49160. * Stores the alpha values in a texture.
  49161. */
  49162. protected _opacityTexture: Nullable<BaseTexture>;
  49163. /**
  49164. * Stores the reflection values in a texture.
  49165. */
  49166. protected _reflectionTexture: Nullable<BaseTexture>;
  49167. /**
  49168. * Stores the emissive values in a texture.
  49169. */
  49170. protected _emissiveTexture: Nullable<BaseTexture>;
  49171. /**
  49172. * AKA Specular texture in other nomenclature.
  49173. */
  49174. protected _reflectivityTexture: Nullable<BaseTexture>;
  49175. /**
  49176. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49177. */
  49178. protected _metallicTexture: Nullable<BaseTexture>;
  49179. /**
  49180. * Specifies the metallic scalar of the metallic/roughness workflow.
  49181. * Can also be used to scale the metalness values of the metallic texture.
  49182. */
  49183. protected _metallic: Nullable<number>;
  49184. /**
  49185. * Specifies the roughness scalar of the metallic/roughness workflow.
  49186. * Can also be used to scale the roughness values of the metallic texture.
  49187. */
  49188. protected _roughness: Nullable<number>;
  49189. /**
  49190. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49191. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49192. */
  49193. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49194. /**
  49195. * Stores surface normal data used to displace a mesh in a texture.
  49196. */
  49197. protected _bumpTexture: Nullable<BaseTexture>;
  49198. /**
  49199. * Stores the pre-calculated light information of a mesh in a texture.
  49200. */
  49201. protected _lightmapTexture: Nullable<BaseTexture>;
  49202. /**
  49203. * The color of a material in ambient lighting.
  49204. */
  49205. protected _ambientColor: Color3;
  49206. /**
  49207. * AKA Diffuse Color in other nomenclature.
  49208. */
  49209. protected _albedoColor: Color3;
  49210. /**
  49211. * AKA Specular Color in other nomenclature.
  49212. */
  49213. protected _reflectivityColor: Color3;
  49214. /**
  49215. * The color applied when light is reflected from a material.
  49216. */
  49217. protected _reflectionColor: Color3;
  49218. /**
  49219. * The color applied when light is emitted from a material.
  49220. */
  49221. protected _emissiveColor: Color3;
  49222. /**
  49223. * AKA Glossiness in other nomenclature.
  49224. */
  49225. protected _microSurface: number;
  49226. /**
  49227. * Specifies that the material will use the light map as a show map.
  49228. */
  49229. protected _useLightmapAsShadowmap: boolean;
  49230. /**
  49231. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49232. * makes the reflect vector face the model (under horizon).
  49233. */
  49234. protected _useHorizonOcclusion: boolean;
  49235. /**
  49236. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49237. * too much the area relying on ambient texture to define their ambient occlusion.
  49238. */
  49239. protected _useRadianceOcclusion: boolean;
  49240. /**
  49241. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49242. */
  49243. protected _useAlphaFromAlbedoTexture: boolean;
  49244. /**
  49245. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49246. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49247. */
  49248. protected _useSpecularOverAlpha: boolean;
  49249. /**
  49250. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49251. */
  49252. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49253. /**
  49254. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49255. */
  49256. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49257. /**
  49258. * Specifies if the metallic texture contains the roughness information in its green channel.
  49259. */
  49260. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49261. /**
  49262. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49263. */
  49264. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49265. /**
  49266. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49267. */
  49268. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49269. /**
  49270. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49271. */
  49272. protected _useAmbientInGrayScale: boolean;
  49273. /**
  49274. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49275. * The material will try to infer what glossiness each pixel should be.
  49276. */
  49277. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49278. /**
  49279. * Defines the falloff type used in this material.
  49280. * It by default is Physical.
  49281. */
  49282. protected _lightFalloff: number;
  49283. /**
  49284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49286. */
  49287. protected _useRadianceOverAlpha: boolean;
  49288. /**
  49289. * Allows using an object space normal map (instead of tangent space).
  49290. */
  49291. protected _useObjectSpaceNormalMap: boolean;
  49292. /**
  49293. * Allows using the bump map in parallax mode.
  49294. */
  49295. protected _useParallax: boolean;
  49296. /**
  49297. * Allows using the bump map in parallax occlusion mode.
  49298. */
  49299. protected _useParallaxOcclusion: boolean;
  49300. /**
  49301. * Controls the scale bias of the parallax mode.
  49302. */
  49303. protected _parallaxScaleBias: number;
  49304. /**
  49305. * If sets to true, disables all the lights affecting the material.
  49306. */
  49307. protected _disableLighting: boolean;
  49308. /**
  49309. * Number of Simultaneous lights allowed on the material.
  49310. */
  49311. protected _maxSimultaneousLights: number;
  49312. /**
  49313. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49314. */
  49315. protected _invertNormalMapX: boolean;
  49316. /**
  49317. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49318. */
  49319. protected _invertNormalMapY: boolean;
  49320. /**
  49321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49322. */
  49323. protected _twoSidedLighting: boolean;
  49324. /**
  49325. * Defines the alpha limits in alpha test mode.
  49326. */
  49327. protected _alphaCutOff: number;
  49328. /**
  49329. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49330. */
  49331. protected _forceAlphaTest: boolean;
  49332. /**
  49333. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49334. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49335. */
  49336. protected _useAlphaFresnel: boolean;
  49337. /**
  49338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49339. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49340. */
  49341. protected _useLinearAlphaFresnel: boolean;
  49342. /**
  49343. * The transparency mode of the material.
  49344. */
  49345. protected _transparencyMode: Nullable<number>;
  49346. /**
  49347. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49348. * from cos thetav and roughness:
  49349. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49350. */
  49351. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49352. /**
  49353. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49354. */
  49355. protected _forceIrradianceInFragment: boolean;
  49356. /**
  49357. * Force normal to face away from face.
  49358. */
  49359. protected _forceNormalForward: boolean;
  49360. /**
  49361. * Enables specular anti aliasing in the PBR shader.
  49362. * It will both interacts on the Geometry for analytical and IBL lighting.
  49363. * It also prefilter the roughness map based on the bump values.
  49364. */
  49365. protected _enableSpecularAntiAliasing: boolean;
  49366. /**
  49367. * Default configuration related to image processing available in the PBR Material.
  49368. */
  49369. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49370. /**
  49371. * Keep track of the image processing observer to allow dispose and replace.
  49372. */
  49373. private _imageProcessingObserver;
  49374. /**
  49375. * Attaches a new image processing configuration to the PBR Material.
  49376. * @param configuration
  49377. */
  49378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49379. /**
  49380. * Stores the available render targets.
  49381. */
  49382. private _renderTargets;
  49383. /**
  49384. * Sets the global ambient color for the material used in lighting calculations.
  49385. */
  49386. private _globalAmbientColor;
  49387. /**
  49388. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49389. */
  49390. private _useLogarithmicDepth;
  49391. /**
  49392. * If set to true, no lighting calculations will be applied.
  49393. */
  49394. private _unlit;
  49395. private _debugMode;
  49396. /**
  49397. * @hidden
  49398. * This is reserved for the inspector.
  49399. * Defines the material debug mode.
  49400. * It helps seeing only some components of the material while troubleshooting.
  49401. */
  49402. debugMode: number;
  49403. /**
  49404. * @hidden
  49405. * This is reserved for the inspector.
  49406. * Specify from where on screen the debug mode should start.
  49407. * The value goes from -1 (full screen) to 1 (not visible)
  49408. * It helps with side by side comparison against the final render
  49409. * This defaults to -1
  49410. */
  49411. private debugLimit;
  49412. /**
  49413. * @hidden
  49414. * This is reserved for the inspector.
  49415. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49416. * You can use the factor to better multiply the final value.
  49417. */
  49418. private debugFactor;
  49419. /**
  49420. * Defines the clear coat layer parameters for the material.
  49421. */
  49422. readonly clearCoat: PBRClearCoatConfiguration;
  49423. /**
  49424. * Defines the anisotropic parameters for the material.
  49425. */
  49426. readonly anisotropy: PBRAnisotropicConfiguration;
  49427. /**
  49428. * Defines the BRDF parameters for the material.
  49429. */
  49430. readonly brdf: PBRBRDFConfiguration;
  49431. /**
  49432. * Defines the Sheen parameters for the material.
  49433. */
  49434. readonly sheen: PBRSheenConfiguration;
  49435. /**
  49436. * Defines the SubSurface parameters for the material.
  49437. */
  49438. readonly subSurface: PBRSubSurfaceConfiguration;
  49439. /**
  49440. * Custom callback helping to override the default shader used in the material.
  49441. */
  49442. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49443. protected _rebuildInParallel: boolean;
  49444. /**
  49445. * Instantiates a new PBRMaterial instance.
  49446. *
  49447. * @param name The material name
  49448. * @param scene The scene the material will be use in.
  49449. */
  49450. constructor(name: string, scene: Scene);
  49451. /**
  49452. * Gets a boolean indicating that current material needs to register RTT
  49453. */
  49454. readonly hasRenderTargetTextures: boolean;
  49455. /**
  49456. * Gets the name of the material class.
  49457. */
  49458. getClassName(): string;
  49459. /**
  49460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49461. */
  49462. /**
  49463. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49464. */
  49465. useLogarithmicDepth: boolean;
  49466. /**
  49467. * Gets the current transparency mode.
  49468. */
  49469. /**
  49470. * Sets the transparency mode of the material.
  49471. *
  49472. * | Value | Type | Description |
  49473. * | ----- | ----------------------------------- | ----------- |
  49474. * | 0 | OPAQUE | |
  49475. * | 1 | ALPHATEST | |
  49476. * | 2 | ALPHABLEND | |
  49477. * | 3 | ALPHATESTANDBLEND | |
  49478. *
  49479. */
  49480. transparencyMode: Nullable<number>;
  49481. /**
  49482. * Returns true if alpha blending should be disabled.
  49483. */
  49484. private readonly _disableAlphaBlending;
  49485. /**
  49486. * Specifies whether or not this material should be rendered in alpha blend mode.
  49487. */
  49488. needAlphaBlending(): boolean;
  49489. /**
  49490. * Specifies if the mesh will require alpha blending.
  49491. * @param mesh - BJS mesh.
  49492. */
  49493. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49494. /**
  49495. * Specifies whether or not this material should be rendered in alpha test mode.
  49496. */
  49497. needAlphaTesting(): boolean;
  49498. /**
  49499. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49500. */
  49501. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49502. /**
  49503. * Gets the texture used for the alpha test.
  49504. */
  49505. getAlphaTestTexture(): Nullable<BaseTexture>;
  49506. /**
  49507. * Specifies that the submesh is ready to be used.
  49508. * @param mesh - BJS mesh.
  49509. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49510. * @param useInstances - Specifies that instances should be used.
  49511. * @returns - boolean indicating that the submesh is ready or not.
  49512. */
  49513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49514. /**
  49515. * Specifies if the material uses metallic roughness workflow.
  49516. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49517. */
  49518. isMetallicWorkflow(): boolean;
  49519. private _prepareEffect;
  49520. private _prepareDefines;
  49521. /**
  49522. * Force shader compilation
  49523. */
  49524. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49525. clipPlane: boolean;
  49526. }>): void;
  49527. /**
  49528. * Initializes the uniform buffer layout for the shader.
  49529. */
  49530. buildUniformLayout(): void;
  49531. /**
  49532. * Unbinds the material from the mesh
  49533. */
  49534. unbind(): void;
  49535. /**
  49536. * Binds the submesh data.
  49537. * @param world - The world matrix.
  49538. * @param mesh - The BJS mesh.
  49539. * @param subMesh - A submesh of the BJS mesh.
  49540. */
  49541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49542. /**
  49543. * Returns the animatable textures.
  49544. * @returns - Array of animatable textures.
  49545. */
  49546. getAnimatables(): IAnimatable[];
  49547. /**
  49548. * Returns the texture used for reflections.
  49549. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49550. */
  49551. private _getReflectionTexture;
  49552. /**
  49553. * Returns an array of the actively used textures.
  49554. * @returns - Array of BaseTextures
  49555. */
  49556. getActiveTextures(): BaseTexture[];
  49557. /**
  49558. * Checks to see if a texture is used in the material.
  49559. * @param texture - Base texture to use.
  49560. * @returns - Boolean specifying if a texture is used in the material.
  49561. */
  49562. hasTexture(texture: BaseTexture): boolean;
  49563. /**
  49564. * Disposes the resources of the material.
  49565. * @param forceDisposeEffect - Forces the disposal of effects.
  49566. * @param forceDisposeTextures - Forces the disposal of all textures.
  49567. */
  49568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49572. import { Nullable } from "babylonjs/types";
  49573. import { Scene } from "babylonjs/scene";
  49574. import { Color3 } from "babylonjs/Maths/math.color";
  49575. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49576. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49578. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49579. /**
  49580. * The Physically based material of BJS.
  49581. *
  49582. * This offers the main features of a standard PBR material.
  49583. * For more information, please refer to the documentation :
  49584. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49585. */
  49586. export class PBRMaterial extends PBRBaseMaterial {
  49587. /**
  49588. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49589. */
  49590. static readonly PBRMATERIAL_OPAQUE: number;
  49591. /**
  49592. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49593. */
  49594. static readonly PBRMATERIAL_ALPHATEST: number;
  49595. /**
  49596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49597. */
  49598. static readonly PBRMATERIAL_ALPHABLEND: number;
  49599. /**
  49600. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49601. * They are also discarded below the alpha cutoff threshold to improve performances.
  49602. */
  49603. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49604. /**
  49605. * Defines the default value of how much AO map is occluding the analytical lights
  49606. * (point spot...).
  49607. */
  49608. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49609. /**
  49610. * Intensity of the direct lights e.g. the four lights available in your scene.
  49611. * This impacts both the direct diffuse and specular highlights.
  49612. */
  49613. directIntensity: number;
  49614. /**
  49615. * Intensity of the emissive part of the material.
  49616. * This helps controlling the emissive effect without modifying the emissive color.
  49617. */
  49618. emissiveIntensity: number;
  49619. /**
  49620. * Intensity of the environment e.g. how much the environment will light the object
  49621. * either through harmonics for rough material or through the refelction for shiny ones.
  49622. */
  49623. environmentIntensity: number;
  49624. /**
  49625. * This is a special control allowing the reduction of the specular highlights coming from the
  49626. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49627. */
  49628. specularIntensity: number;
  49629. /**
  49630. * Debug Control allowing disabling the bump map on this material.
  49631. */
  49632. disableBumpMap: boolean;
  49633. /**
  49634. * AKA Diffuse Texture in standard nomenclature.
  49635. */
  49636. albedoTexture: BaseTexture;
  49637. /**
  49638. * AKA Occlusion Texture in other nomenclature.
  49639. */
  49640. ambientTexture: BaseTexture;
  49641. /**
  49642. * AKA Occlusion Texture Intensity in other nomenclature.
  49643. */
  49644. ambientTextureStrength: number;
  49645. /**
  49646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49647. * 1 means it completely occludes it
  49648. * 0 mean it has no impact
  49649. */
  49650. ambientTextureImpactOnAnalyticalLights: number;
  49651. /**
  49652. * Stores the alpha values in a texture.
  49653. */
  49654. opacityTexture: BaseTexture;
  49655. /**
  49656. * Stores the reflection values in a texture.
  49657. */
  49658. reflectionTexture: Nullable<BaseTexture>;
  49659. /**
  49660. * Stores the emissive values in a texture.
  49661. */
  49662. emissiveTexture: BaseTexture;
  49663. /**
  49664. * AKA Specular texture in other nomenclature.
  49665. */
  49666. reflectivityTexture: BaseTexture;
  49667. /**
  49668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49669. */
  49670. metallicTexture: BaseTexture;
  49671. /**
  49672. * Specifies the metallic scalar of the metallic/roughness workflow.
  49673. * Can also be used to scale the metalness values of the metallic texture.
  49674. */
  49675. metallic: Nullable<number>;
  49676. /**
  49677. * Specifies the roughness scalar of the metallic/roughness workflow.
  49678. * Can also be used to scale the roughness values of the metallic texture.
  49679. */
  49680. roughness: Nullable<number>;
  49681. /**
  49682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49684. */
  49685. microSurfaceTexture: BaseTexture;
  49686. /**
  49687. * Stores surface normal data used to displace a mesh in a texture.
  49688. */
  49689. bumpTexture: BaseTexture;
  49690. /**
  49691. * Stores the pre-calculated light information of a mesh in a texture.
  49692. */
  49693. lightmapTexture: BaseTexture;
  49694. /**
  49695. * Stores the refracted light information in a texture.
  49696. */
  49697. refractionTexture: Nullable<BaseTexture>;
  49698. /**
  49699. * The color of a material in ambient lighting.
  49700. */
  49701. ambientColor: Color3;
  49702. /**
  49703. * AKA Diffuse Color in other nomenclature.
  49704. */
  49705. albedoColor: Color3;
  49706. /**
  49707. * AKA Specular Color in other nomenclature.
  49708. */
  49709. reflectivityColor: Color3;
  49710. /**
  49711. * The color reflected from the material.
  49712. */
  49713. reflectionColor: Color3;
  49714. /**
  49715. * The color emitted from the material.
  49716. */
  49717. emissiveColor: Color3;
  49718. /**
  49719. * AKA Glossiness in other nomenclature.
  49720. */
  49721. microSurface: number;
  49722. /**
  49723. * source material index of refraction (IOR)' / 'destination material IOR.
  49724. */
  49725. indexOfRefraction: number;
  49726. /**
  49727. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49728. */
  49729. invertRefractionY: boolean;
  49730. /**
  49731. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49732. * Materials half opaque for instance using refraction could benefit from this control.
  49733. */
  49734. linkRefractionWithTransparency: boolean;
  49735. /**
  49736. * If true, the light map contains occlusion information instead of lighting info.
  49737. */
  49738. useLightmapAsShadowmap: boolean;
  49739. /**
  49740. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49741. */
  49742. useAlphaFromAlbedoTexture: boolean;
  49743. /**
  49744. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49745. */
  49746. forceAlphaTest: boolean;
  49747. /**
  49748. * Defines the alpha limits in alpha test mode.
  49749. */
  49750. alphaCutOff: number;
  49751. /**
  49752. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49753. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49754. */
  49755. useSpecularOverAlpha: boolean;
  49756. /**
  49757. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49758. */
  49759. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49760. /**
  49761. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49762. */
  49763. useRoughnessFromMetallicTextureAlpha: boolean;
  49764. /**
  49765. * Specifies if the metallic texture contains the roughness information in its green channel.
  49766. */
  49767. useRoughnessFromMetallicTextureGreen: boolean;
  49768. /**
  49769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49770. */
  49771. useMetallnessFromMetallicTextureBlue: boolean;
  49772. /**
  49773. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49774. */
  49775. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49776. /**
  49777. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49778. */
  49779. useAmbientInGrayScale: boolean;
  49780. /**
  49781. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49782. * The material will try to infer what glossiness each pixel should be.
  49783. */
  49784. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49785. /**
  49786. * BJS is using an harcoded light falloff based on a manually sets up range.
  49787. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49788. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49789. */
  49790. /**
  49791. * BJS is using an harcoded light falloff based on a manually sets up range.
  49792. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49793. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49794. */
  49795. usePhysicalLightFalloff: boolean;
  49796. /**
  49797. * In order to support the falloff compatibility with gltf, a special mode has been added
  49798. * to reproduce the gltf light falloff.
  49799. */
  49800. /**
  49801. * In order to support the falloff compatibility with gltf, a special mode has been added
  49802. * to reproduce the gltf light falloff.
  49803. */
  49804. useGLTFLightFalloff: boolean;
  49805. /**
  49806. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49807. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49808. */
  49809. useRadianceOverAlpha: boolean;
  49810. /**
  49811. * Allows using an object space normal map (instead of tangent space).
  49812. */
  49813. useObjectSpaceNormalMap: boolean;
  49814. /**
  49815. * Allows using the bump map in parallax mode.
  49816. */
  49817. useParallax: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax occlusion mode.
  49820. */
  49821. useParallaxOcclusion: boolean;
  49822. /**
  49823. * Controls the scale bias of the parallax mode.
  49824. */
  49825. parallaxScaleBias: number;
  49826. /**
  49827. * If sets to true, disables all the lights affecting the material.
  49828. */
  49829. disableLighting: boolean;
  49830. /**
  49831. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49832. */
  49833. forceIrradianceInFragment: boolean;
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49840. */
  49841. invertNormalMapX: boolean;
  49842. /**
  49843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49844. */
  49845. invertNormalMapY: boolean;
  49846. /**
  49847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49848. */
  49849. twoSidedLighting: boolean;
  49850. /**
  49851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49853. */
  49854. useAlphaFresnel: boolean;
  49855. /**
  49856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49858. */
  49859. useLinearAlphaFresnel: boolean;
  49860. /**
  49861. * Let user defines the brdf lookup texture used for IBL.
  49862. * A default 8bit version is embedded but you could point at :
  49863. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49864. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49865. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49866. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49867. */
  49868. environmentBRDFTexture: Nullable<BaseTexture>;
  49869. /**
  49870. * Force normal to face away from face.
  49871. */
  49872. forceNormalForward: boolean;
  49873. /**
  49874. * Enables specular anti aliasing in the PBR shader.
  49875. * It will both interacts on the Geometry for analytical and IBL lighting.
  49876. * It also prefilter the roughness map based on the bump values.
  49877. */
  49878. enableSpecularAntiAliasing: boolean;
  49879. /**
  49880. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49881. * makes the reflect vector face the model (under horizon).
  49882. */
  49883. useHorizonOcclusion: boolean;
  49884. /**
  49885. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49886. * too much the area relying on ambient texture to define their ambient occlusion.
  49887. */
  49888. useRadianceOcclusion: boolean;
  49889. /**
  49890. * If set to true, no lighting calculations will be applied.
  49891. */
  49892. unlit: boolean;
  49893. /**
  49894. * Gets the image processing configuration used either in this material.
  49895. */
  49896. /**
  49897. * Sets the Default image processing configuration used either in the this material.
  49898. *
  49899. * If sets to null, the scene one is in use.
  49900. */
  49901. imageProcessingConfiguration: ImageProcessingConfiguration;
  49902. /**
  49903. * Gets wether the color curves effect is enabled.
  49904. */
  49905. /**
  49906. * Sets wether the color curves effect is enabled.
  49907. */
  49908. cameraColorCurvesEnabled: boolean;
  49909. /**
  49910. * Gets wether the color grading effect is enabled.
  49911. */
  49912. /**
  49913. * Gets wether the color grading effect is enabled.
  49914. */
  49915. cameraColorGradingEnabled: boolean;
  49916. /**
  49917. * Gets wether tonemapping is enabled or not.
  49918. */
  49919. /**
  49920. * Sets wether tonemapping is enabled or not
  49921. */
  49922. cameraToneMappingEnabled: boolean;
  49923. /**
  49924. * The camera exposure used on this material.
  49925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49926. * This corresponds to a photographic exposure.
  49927. */
  49928. /**
  49929. * The camera exposure used on this material.
  49930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49931. * This corresponds to a photographic exposure.
  49932. */
  49933. cameraExposure: number;
  49934. /**
  49935. * Gets The camera contrast used on this material.
  49936. */
  49937. /**
  49938. * Sets The camera contrast used on this material.
  49939. */
  49940. cameraContrast: number;
  49941. /**
  49942. * Gets the Color Grading 2D Lookup Texture.
  49943. */
  49944. /**
  49945. * Sets the Color Grading 2D Lookup Texture.
  49946. */
  49947. cameraColorGradingTexture: Nullable<BaseTexture>;
  49948. /**
  49949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49951. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49953. */
  49954. /**
  49955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49957. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49959. */
  49960. cameraColorCurves: Nullable<ColorCurves>;
  49961. /**
  49962. * Instantiates a new PBRMaterial instance.
  49963. *
  49964. * @param name The material name
  49965. * @param scene The scene the material will be use in.
  49966. */
  49967. constructor(name: string, scene: Scene);
  49968. /**
  49969. * Returns the name of this material class.
  49970. */
  49971. getClassName(): string;
  49972. /**
  49973. * Makes a duplicate of the current material.
  49974. * @param name - name to use for the new material.
  49975. */
  49976. clone(name: string): PBRMaterial;
  49977. /**
  49978. * Serializes this PBR Material.
  49979. * @returns - An object with the serialized material.
  49980. */
  49981. serialize(): any;
  49982. /**
  49983. * Parses a PBR Material from a serialized object.
  49984. * @param source - Serialized object.
  49985. * @param scene - BJS scene instance.
  49986. * @param rootUrl - url for the scene object
  49987. * @returns - PBRMaterial
  49988. */
  49989. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49990. }
  49991. }
  49992. declare module "babylonjs/Misc/dds" {
  49993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49994. import { Engine } from "babylonjs/Engines/engine";
  49995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49996. import { Nullable } from "babylonjs/types";
  49997. import { Scene } from "babylonjs/scene";
  49998. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49999. /**
  50000. * Direct draw surface info
  50001. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50002. */
  50003. export interface DDSInfo {
  50004. /**
  50005. * Width of the texture
  50006. */
  50007. width: number;
  50008. /**
  50009. * Width of the texture
  50010. */
  50011. height: number;
  50012. /**
  50013. * Number of Mipmaps for the texture
  50014. * @see https://en.wikipedia.org/wiki/Mipmap
  50015. */
  50016. mipmapCount: number;
  50017. /**
  50018. * If the textures format is a known fourCC format
  50019. * @see https://www.fourcc.org/
  50020. */
  50021. isFourCC: boolean;
  50022. /**
  50023. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50024. */
  50025. isRGB: boolean;
  50026. /**
  50027. * If the texture is a lumincance format
  50028. */
  50029. isLuminance: boolean;
  50030. /**
  50031. * If this is a cube texture
  50032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50033. */
  50034. isCube: boolean;
  50035. /**
  50036. * If the texture is a compressed format eg. FOURCC_DXT1
  50037. */
  50038. isCompressed: boolean;
  50039. /**
  50040. * The dxgiFormat of the texture
  50041. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50042. */
  50043. dxgiFormat: number;
  50044. /**
  50045. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50046. */
  50047. textureType: number;
  50048. /**
  50049. * Sphericle polynomial created for the dds texture
  50050. */
  50051. sphericalPolynomial?: SphericalPolynomial;
  50052. }
  50053. /**
  50054. * Class used to provide DDS decompression tools
  50055. */
  50056. export class DDSTools {
  50057. /**
  50058. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50059. */
  50060. static StoreLODInAlphaChannel: boolean;
  50061. /**
  50062. * Gets DDS information from an array buffer
  50063. * @param arrayBuffer defines the array buffer to read data from
  50064. * @returns the DDS information
  50065. */
  50066. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50067. private static _FloatView;
  50068. private static _Int32View;
  50069. private static _ToHalfFloat;
  50070. private static _FromHalfFloat;
  50071. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50072. private static _GetHalfFloatRGBAArrayBuffer;
  50073. private static _GetFloatRGBAArrayBuffer;
  50074. private static _GetFloatAsUIntRGBAArrayBuffer;
  50075. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50076. private static _GetRGBAArrayBuffer;
  50077. private static _ExtractLongWordOrder;
  50078. private static _GetRGBArrayBuffer;
  50079. private static _GetLuminanceArrayBuffer;
  50080. /**
  50081. * Uploads DDS Levels to a Babylon Texture
  50082. * @hidden
  50083. */
  50084. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50085. }
  50086. module "babylonjs/Engines/engine" {
  50087. interface Engine {
  50088. /**
  50089. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50090. * @param rootUrl defines the url where the file to load is located
  50091. * @param scene defines the current scene
  50092. * @param lodScale defines scale to apply to the mip map selection
  50093. * @param lodOffset defines offset to apply to the mip map selection
  50094. * @param onLoad defines an optional callback raised when the texture is loaded
  50095. * @param onError defines an optional callback raised if there is an issue to load the texture
  50096. * @param format defines the format of the data
  50097. * @param forcedExtension defines the extension to use to pick the right loader
  50098. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50099. * @returns the cube texture as an InternalTexture
  50100. */
  50101. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  50102. }
  50103. }
  50104. }
  50105. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50106. import { Nullable } from "babylonjs/types";
  50107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50108. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50109. /**
  50110. * Implementation of the DDS Texture Loader.
  50111. * @hidden
  50112. */
  50113. export class _DDSTextureLoader implements IInternalTextureLoader {
  50114. /**
  50115. * Defines wether the loader supports cascade loading the different faces.
  50116. */
  50117. readonly supportCascades: boolean;
  50118. /**
  50119. * This returns if the loader support the current file information.
  50120. * @param extension defines the file extension of the file being loaded
  50121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50122. * @param fallback defines the fallback internal texture if any
  50123. * @param isBase64 defines whether the texture is encoded as a base64
  50124. * @param isBuffer defines whether the texture data are stored as a buffer
  50125. * @returns true if the loader can load the specified file
  50126. */
  50127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50128. /**
  50129. * Transform the url before loading if required.
  50130. * @param rootUrl the url of the texture
  50131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50132. * @returns the transformed texture
  50133. */
  50134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50135. /**
  50136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50137. * @param rootUrl the url of the texture
  50138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50139. * @returns the fallback texture
  50140. */
  50141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50142. /**
  50143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50144. * @param data contains the texture data
  50145. * @param texture defines the BabylonJS internal texture
  50146. * @param createPolynomials will be true if polynomials have been requested
  50147. * @param onLoad defines the callback to trigger once the texture is ready
  50148. * @param onError defines the callback to trigger in case of error
  50149. */
  50150. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50151. /**
  50152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50153. * @param data contains the texture data
  50154. * @param texture defines the BabylonJS internal texture
  50155. * @param callback defines the method to call once ready to upload
  50156. */
  50157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50158. }
  50159. }
  50160. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50161. import { Nullable } from "babylonjs/types";
  50162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50163. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50164. /**
  50165. * Implementation of the ENV Texture Loader.
  50166. * @hidden
  50167. */
  50168. export class _ENVTextureLoader implements IInternalTextureLoader {
  50169. /**
  50170. * Defines wether the loader supports cascade loading the different faces.
  50171. */
  50172. readonly supportCascades: boolean;
  50173. /**
  50174. * This returns if the loader support the current file information.
  50175. * @param extension defines the file extension of the file being loaded
  50176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50177. * @param fallback defines the fallback internal texture if any
  50178. * @param isBase64 defines whether the texture is encoded as a base64
  50179. * @param isBuffer defines whether the texture data are stored as a buffer
  50180. * @returns true if the loader can load the specified file
  50181. */
  50182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50183. /**
  50184. * Transform the url before loading if required.
  50185. * @param rootUrl the url of the texture
  50186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50187. * @returns the transformed texture
  50188. */
  50189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50190. /**
  50191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50192. * @param rootUrl the url of the texture
  50193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50194. * @returns the fallback texture
  50195. */
  50196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50197. /**
  50198. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50199. * @param data contains the texture data
  50200. * @param texture defines the BabylonJS internal texture
  50201. * @param createPolynomials will be true if polynomials have been requested
  50202. * @param onLoad defines the callback to trigger once the texture is ready
  50203. * @param onError defines the callback to trigger in case of error
  50204. */
  50205. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50206. /**
  50207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50208. * @param data contains the texture data
  50209. * @param texture defines the BabylonJS internal texture
  50210. * @param callback defines the method to call once ready to upload
  50211. */
  50212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Misc/khronosTextureContainer" {
  50216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50217. /**
  50218. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50219. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50220. */
  50221. export class KhronosTextureContainer {
  50222. /** contents of the KTX container file */
  50223. arrayBuffer: any;
  50224. private static HEADER_LEN;
  50225. private static COMPRESSED_2D;
  50226. private static COMPRESSED_3D;
  50227. private static TEX_2D;
  50228. private static TEX_3D;
  50229. /**
  50230. * Gets the openGL type
  50231. */
  50232. glType: number;
  50233. /**
  50234. * Gets the openGL type size
  50235. */
  50236. glTypeSize: number;
  50237. /**
  50238. * Gets the openGL format
  50239. */
  50240. glFormat: number;
  50241. /**
  50242. * Gets the openGL internal format
  50243. */
  50244. glInternalFormat: number;
  50245. /**
  50246. * Gets the base internal format
  50247. */
  50248. glBaseInternalFormat: number;
  50249. /**
  50250. * Gets image width in pixel
  50251. */
  50252. pixelWidth: number;
  50253. /**
  50254. * Gets image height in pixel
  50255. */
  50256. pixelHeight: number;
  50257. /**
  50258. * Gets image depth in pixels
  50259. */
  50260. pixelDepth: number;
  50261. /**
  50262. * Gets the number of array elements
  50263. */
  50264. numberOfArrayElements: number;
  50265. /**
  50266. * Gets the number of faces
  50267. */
  50268. numberOfFaces: number;
  50269. /**
  50270. * Gets the number of mipmap levels
  50271. */
  50272. numberOfMipmapLevels: number;
  50273. /**
  50274. * Gets the bytes of key value data
  50275. */
  50276. bytesOfKeyValueData: number;
  50277. /**
  50278. * Gets the load type
  50279. */
  50280. loadType: number;
  50281. /**
  50282. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50283. */
  50284. isInvalid: boolean;
  50285. /**
  50286. * Creates a new KhronosTextureContainer
  50287. * @param arrayBuffer contents of the KTX container file
  50288. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50289. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50290. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50291. */
  50292. constructor(
  50293. /** contents of the KTX container file */
  50294. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50295. /**
  50296. * Uploads KTX content to a Babylon Texture.
  50297. * It is assumed that the texture has already been created & is currently bound
  50298. * @hidden
  50299. */
  50300. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50301. private _upload2DCompressedLevels;
  50302. }
  50303. }
  50304. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50305. import { Nullable } from "babylonjs/types";
  50306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50307. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50308. /**
  50309. * Implementation of the KTX Texture Loader.
  50310. * @hidden
  50311. */
  50312. export class _KTXTextureLoader implements IInternalTextureLoader {
  50313. /**
  50314. * Defines wether the loader supports cascade loading the different faces.
  50315. */
  50316. readonly supportCascades: boolean;
  50317. /**
  50318. * This returns if the loader support the current file information.
  50319. * @param extension defines the file extension of the file being loaded
  50320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50321. * @param fallback defines the fallback internal texture if any
  50322. * @param isBase64 defines whether the texture is encoded as a base64
  50323. * @param isBuffer defines whether the texture data are stored as a buffer
  50324. * @returns true if the loader can load the specified file
  50325. */
  50326. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50327. /**
  50328. * Transform the url before loading if required.
  50329. * @param rootUrl the url of the texture
  50330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50331. * @returns the transformed texture
  50332. */
  50333. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50334. /**
  50335. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50336. * @param rootUrl the url of the texture
  50337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50338. * @returns the fallback texture
  50339. */
  50340. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50341. /**
  50342. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50343. * @param data contains the texture data
  50344. * @param texture defines the BabylonJS internal texture
  50345. * @param createPolynomials will be true if polynomials have been requested
  50346. * @param onLoad defines the callback to trigger once the texture is ready
  50347. * @param onError defines the callback to trigger in case of error
  50348. */
  50349. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50350. /**
  50351. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50352. * @param data contains the texture data
  50353. * @param texture defines the BabylonJS internal texture
  50354. * @param callback defines the method to call once ready to upload
  50355. */
  50356. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50357. }
  50358. }
  50359. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50360. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50361. import { Scene } from "babylonjs/scene";
  50362. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50363. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50364. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50365. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50366. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50367. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50369. /**
  50370. * Options for the default xr helper
  50371. */
  50372. export class WebXRDefaultExperienceOptions {
  50373. /**
  50374. * Floor meshes that should be used for teleporting
  50375. */
  50376. floorMeshes: Array<AbstractMesh>;
  50377. }
  50378. /**
  50379. * Default experience which provides a similar setup to the previous webVRExperience
  50380. */
  50381. export class WebXRDefaultExperience {
  50382. /**
  50383. * Base experience
  50384. */
  50385. baseExperience: WebXRExperienceHelper;
  50386. /**
  50387. * Input experience extension
  50388. */
  50389. input: WebXRInput;
  50390. /**
  50391. * Loads the controller models
  50392. */
  50393. controllerModelLoader: WebXRControllerModelLoader;
  50394. /**
  50395. * Enables laser pointer and selection
  50396. */
  50397. pointerSelection: WebXRControllerPointerSelection;
  50398. /**
  50399. * Enables teleportation
  50400. */
  50401. teleportation: WebXRControllerTeleportation;
  50402. /**
  50403. * Enables ui for enetering/exiting xr
  50404. */
  50405. enterExitUI: WebXREnterExitUI;
  50406. /**
  50407. * Default output canvas xr should render to
  50408. */
  50409. outputCanvas: WebXRManagedOutputCanvas;
  50410. /**
  50411. * Creates the default xr experience
  50412. * @param scene scene
  50413. * @param options options for basic configuration
  50414. * @returns resulting WebXRDefaultExperience
  50415. */
  50416. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50417. private constructor();
  50418. /**
  50419. * DIsposes of the experience helper
  50420. */
  50421. dispose(): void;
  50422. }
  50423. }
  50424. declare module "babylonjs/Helpers/sceneHelpers" {
  50425. import { Nullable } from "babylonjs/types";
  50426. import { Mesh } from "babylonjs/Meshes/mesh";
  50427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50428. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50429. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50430. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50431. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50432. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50433. import "babylonjs/Meshes/Builders/boxBuilder";
  50434. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50435. /** @hidden */
  50436. export var _forceSceneHelpersToBundle: boolean;
  50437. module "babylonjs/scene" {
  50438. interface Scene {
  50439. /**
  50440. * Creates a default light for the scene.
  50441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50442. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50443. */
  50444. createDefaultLight(replace?: boolean): void;
  50445. /**
  50446. * Creates a default camera for the scene.
  50447. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50448. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50449. * @param replace has default false, when true replaces the active camera in the scene
  50450. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50451. */
  50452. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50453. /**
  50454. * Creates a default camera and a default light.
  50455. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50456. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50457. * @param replace has the default false, when true replaces the active camera/light in the scene
  50458. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50459. */
  50460. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50461. /**
  50462. * Creates a new sky box
  50463. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50464. * @param environmentTexture defines the texture to use as environment texture
  50465. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50466. * @param scale defines the overall scale of the skybox
  50467. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50468. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50469. * @returns a new mesh holding the sky box
  50470. */
  50471. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50472. /**
  50473. * Creates a new environment
  50474. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50475. * @param options defines the options you can use to configure the environment
  50476. * @returns the new EnvironmentHelper
  50477. */
  50478. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50479. /**
  50480. * Creates a new VREXperienceHelper
  50481. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50482. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50483. * @returns a new VREXperienceHelper
  50484. */
  50485. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50486. /**
  50487. * Creates a new WebXRDefaultExperience
  50488. * @see http://doc.babylonjs.com/how_to/webxr
  50489. * @param options experience options
  50490. * @returns a promise for a new WebXRDefaultExperience
  50491. */
  50492. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50493. }
  50494. }
  50495. }
  50496. declare module "babylonjs/Helpers/videoDome" {
  50497. import { Scene } from "babylonjs/scene";
  50498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50499. import { Mesh } from "babylonjs/Meshes/mesh";
  50500. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50501. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50502. import "babylonjs/Meshes/Builders/sphereBuilder";
  50503. /**
  50504. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50505. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50506. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50507. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50508. */
  50509. export class VideoDome extends TransformNode {
  50510. /**
  50511. * Define the video source as a Monoscopic panoramic 360 video.
  50512. */
  50513. static readonly MODE_MONOSCOPIC: number;
  50514. /**
  50515. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50516. */
  50517. static readonly MODE_TOPBOTTOM: number;
  50518. /**
  50519. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50520. */
  50521. static readonly MODE_SIDEBYSIDE: number;
  50522. private _halfDome;
  50523. private _useDirectMapping;
  50524. /**
  50525. * The video texture being displayed on the sphere
  50526. */
  50527. protected _videoTexture: VideoTexture;
  50528. /**
  50529. * Gets the video texture being displayed on the sphere
  50530. */
  50531. readonly videoTexture: VideoTexture;
  50532. /**
  50533. * The skybox material
  50534. */
  50535. protected _material: BackgroundMaterial;
  50536. /**
  50537. * The surface used for the skybox
  50538. */
  50539. protected _mesh: Mesh;
  50540. /**
  50541. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50542. */
  50543. private _halfDomeMask;
  50544. /**
  50545. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50546. * Also see the options.resolution property.
  50547. */
  50548. fovMultiplier: number;
  50549. private _videoMode;
  50550. /**
  50551. * Gets or set the current video mode for the video. It can be:
  50552. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50553. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50554. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50555. */
  50556. videoMode: number;
  50557. /**
  50558. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50559. *
  50560. */
  50561. /**
  50562. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50563. */
  50564. halfDome: boolean;
  50565. /**
  50566. * Oberserver used in Stereoscopic VR Mode.
  50567. */
  50568. private _onBeforeCameraRenderObserver;
  50569. /**
  50570. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50571. * @param name Element's name, child elements will append suffixes for their own names.
  50572. * @param urlsOrVideo defines the url(s) or the video element to use
  50573. * @param options An object containing optional or exposed sub element properties
  50574. */
  50575. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50576. resolution?: number;
  50577. clickToPlay?: boolean;
  50578. autoPlay?: boolean;
  50579. loop?: boolean;
  50580. size?: number;
  50581. poster?: string;
  50582. faceForward?: boolean;
  50583. useDirectMapping?: boolean;
  50584. halfDomeMode?: boolean;
  50585. }, scene: Scene);
  50586. private _changeVideoMode;
  50587. /**
  50588. * Releases resources associated with this node.
  50589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50591. */
  50592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50593. }
  50594. }
  50595. declare module "babylonjs/Helpers/index" {
  50596. export * from "babylonjs/Helpers/environmentHelper";
  50597. export * from "babylonjs/Helpers/photoDome";
  50598. export * from "babylonjs/Helpers/sceneHelpers";
  50599. export * from "babylonjs/Helpers/videoDome";
  50600. }
  50601. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50602. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50603. import { IDisposable } from "babylonjs/scene";
  50604. import { Engine } from "babylonjs/Engines/engine";
  50605. /**
  50606. * This class can be used to get instrumentation data from a Babylon engine
  50607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50608. */
  50609. export class EngineInstrumentation implements IDisposable {
  50610. /**
  50611. * Define the instrumented engine.
  50612. */
  50613. engine: Engine;
  50614. private _captureGPUFrameTime;
  50615. private _gpuFrameTimeToken;
  50616. private _gpuFrameTime;
  50617. private _captureShaderCompilationTime;
  50618. private _shaderCompilationTime;
  50619. private _onBeginFrameObserver;
  50620. private _onEndFrameObserver;
  50621. private _onBeforeShaderCompilationObserver;
  50622. private _onAfterShaderCompilationObserver;
  50623. /**
  50624. * Gets the perf counter used for GPU frame time
  50625. */
  50626. readonly gpuFrameTimeCounter: PerfCounter;
  50627. /**
  50628. * Gets the GPU frame time capture status
  50629. */
  50630. /**
  50631. * Enable or disable the GPU frame time capture
  50632. */
  50633. captureGPUFrameTime: boolean;
  50634. /**
  50635. * Gets the perf counter used for shader compilation time
  50636. */
  50637. readonly shaderCompilationTimeCounter: PerfCounter;
  50638. /**
  50639. * Gets the shader compilation time capture status
  50640. */
  50641. /**
  50642. * Enable or disable the shader compilation time capture
  50643. */
  50644. captureShaderCompilationTime: boolean;
  50645. /**
  50646. * Instantiates a new engine instrumentation.
  50647. * This class can be used to get instrumentation data from a Babylon engine
  50648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50649. * @param engine Defines the engine to instrument
  50650. */
  50651. constructor(
  50652. /**
  50653. * Define the instrumented engine.
  50654. */
  50655. engine: Engine);
  50656. /**
  50657. * Dispose and release associated resources.
  50658. */
  50659. dispose(): void;
  50660. }
  50661. }
  50662. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50663. import { Scene, IDisposable } from "babylonjs/scene";
  50664. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50665. /**
  50666. * This class can be used to get instrumentation data from a Babylon engine
  50667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50668. */
  50669. export class SceneInstrumentation implements IDisposable {
  50670. /**
  50671. * Defines the scene to instrument
  50672. */
  50673. scene: Scene;
  50674. private _captureActiveMeshesEvaluationTime;
  50675. private _activeMeshesEvaluationTime;
  50676. private _captureRenderTargetsRenderTime;
  50677. private _renderTargetsRenderTime;
  50678. private _captureFrameTime;
  50679. private _frameTime;
  50680. private _captureRenderTime;
  50681. private _renderTime;
  50682. private _captureInterFrameTime;
  50683. private _interFrameTime;
  50684. private _captureParticlesRenderTime;
  50685. private _particlesRenderTime;
  50686. private _captureSpritesRenderTime;
  50687. private _spritesRenderTime;
  50688. private _capturePhysicsTime;
  50689. private _physicsTime;
  50690. private _captureAnimationsTime;
  50691. private _animationsTime;
  50692. private _captureCameraRenderTime;
  50693. private _cameraRenderTime;
  50694. private _onBeforeActiveMeshesEvaluationObserver;
  50695. private _onAfterActiveMeshesEvaluationObserver;
  50696. private _onBeforeRenderTargetsRenderObserver;
  50697. private _onAfterRenderTargetsRenderObserver;
  50698. private _onAfterRenderObserver;
  50699. private _onBeforeDrawPhaseObserver;
  50700. private _onAfterDrawPhaseObserver;
  50701. private _onBeforeAnimationsObserver;
  50702. private _onBeforeParticlesRenderingObserver;
  50703. private _onAfterParticlesRenderingObserver;
  50704. private _onBeforeSpritesRenderingObserver;
  50705. private _onAfterSpritesRenderingObserver;
  50706. private _onBeforePhysicsObserver;
  50707. private _onAfterPhysicsObserver;
  50708. private _onAfterAnimationsObserver;
  50709. private _onBeforeCameraRenderObserver;
  50710. private _onAfterCameraRenderObserver;
  50711. /**
  50712. * Gets the perf counter used for active meshes evaluation time
  50713. */
  50714. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50715. /**
  50716. * Gets the active meshes evaluation time capture status
  50717. */
  50718. /**
  50719. * Enable or disable the active meshes evaluation time capture
  50720. */
  50721. captureActiveMeshesEvaluationTime: boolean;
  50722. /**
  50723. * Gets the perf counter used for render targets render time
  50724. */
  50725. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50726. /**
  50727. * Gets the render targets render time capture status
  50728. */
  50729. /**
  50730. * Enable or disable the render targets render time capture
  50731. */
  50732. captureRenderTargetsRenderTime: boolean;
  50733. /**
  50734. * Gets the perf counter used for particles render time
  50735. */
  50736. readonly particlesRenderTimeCounter: PerfCounter;
  50737. /**
  50738. * Gets the particles render time capture status
  50739. */
  50740. /**
  50741. * Enable or disable the particles render time capture
  50742. */
  50743. captureParticlesRenderTime: boolean;
  50744. /**
  50745. * Gets the perf counter used for sprites render time
  50746. */
  50747. readonly spritesRenderTimeCounter: PerfCounter;
  50748. /**
  50749. * Gets the sprites render time capture status
  50750. */
  50751. /**
  50752. * Enable or disable the sprites render time capture
  50753. */
  50754. captureSpritesRenderTime: boolean;
  50755. /**
  50756. * Gets the perf counter used for physics time
  50757. */
  50758. readonly physicsTimeCounter: PerfCounter;
  50759. /**
  50760. * Gets the physics time capture status
  50761. */
  50762. /**
  50763. * Enable or disable the physics time capture
  50764. */
  50765. capturePhysicsTime: boolean;
  50766. /**
  50767. * Gets the perf counter used for animations time
  50768. */
  50769. readonly animationsTimeCounter: PerfCounter;
  50770. /**
  50771. * Gets the animations time capture status
  50772. */
  50773. /**
  50774. * Enable or disable the animations time capture
  50775. */
  50776. captureAnimationsTime: boolean;
  50777. /**
  50778. * Gets the perf counter used for frame time capture
  50779. */
  50780. readonly frameTimeCounter: PerfCounter;
  50781. /**
  50782. * Gets the frame time capture status
  50783. */
  50784. /**
  50785. * Enable or disable the frame time capture
  50786. */
  50787. captureFrameTime: boolean;
  50788. /**
  50789. * Gets the perf counter used for inter-frames time capture
  50790. */
  50791. readonly interFrameTimeCounter: PerfCounter;
  50792. /**
  50793. * Gets the inter-frames time capture status
  50794. */
  50795. /**
  50796. * Enable or disable the inter-frames time capture
  50797. */
  50798. captureInterFrameTime: boolean;
  50799. /**
  50800. * Gets the perf counter used for render time capture
  50801. */
  50802. readonly renderTimeCounter: PerfCounter;
  50803. /**
  50804. * Gets the render time capture status
  50805. */
  50806. /**
  50807. * Enable or disable the render time capture
  50808. */
  50809. captureRenderTime: boolean;
  50810. /**
  50811. * Gets the perf counter used for camera render time capture
  50812. */
  50813. readonly cameraRenderTimeCounter: PerfCounter;
  50814. /**
  50815. * Gets the camera render time capture status
  50816. */
  50817. /**
  50818. * Enable or disable the camera render time capture
  50819. */
  50820. captureCameraRenderTime: boolean;
  50821. /**
  50822. * Gets the perf counter used for draw calls
  50823. */
  50824. readonly drawCallsCounter: PerfCounter;
  50825. /**
  50826. * Instantiates a new scene instrumentation.
  50827. * This class can be used to get instrumentation data from a Babylon engine
  50828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50829. * @param scene Defines the scene to instrument
  50830. */
  50831. constructor(
  50832. /**
  50833. * Defines the scene to instrument
  50834. */
  50835. scene: Scene);
  50836. /**
  50837. * Dispose and release associated resources.
  50838. */
  50839. dispose(): void;
  50840. }
  50841. }
  50842. declare module "babylonjs/Instrumentation/index" {
  50843. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50844. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50845. export * from "babylonjs/Instrumentation/timeToken";
  50846. }
  50847. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50848. /** @hidden */
  50849. export var glowMapGenerationPixelShader: {
  50850. name: string;
  50851. shader: string;
  50852. };
  50853. }
  50854. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50862. /** @hidden */
  50863. export var glowMapGenerationVertexShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module "babylonjs/Layers/effectLayer" {
  50869. import { Observable } from "babylonjs/Misc/observable";
  50870. import { Nullable } from "babylonjs/types";
  50871. import { Camera } from "babylonjs/Cameras/camera";
  50872. import { Scene } from "babylonjs/scene";
  50873. import { ISize } from "babylonjs/Maths/math.size";
  50874. import { Color4 } from "babylonjs/Maths/math.color";
  50875. import { Engine } from "babylonjs/Engines/engine";
  50876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50882. import { Effect } from "babylonjs/Materials/effect";
  50883. import { Material } from "babylonjs/Materials/material";
  50884. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50885. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50886. /**
  50887. * Effect layer options. This helps customizing the behaviour
  50888. * of the effect layer.
  50889. */
  50890. export interface IEffectLayerOptions {
  50891. /**
  50892. * Multiplication factor apply to the canvas size to compute the render target size
  50893. * used to generated the objects (the smaller the faster).
  50894. */
  50895. mainTextureRatio: number;
  50896. /**
  50897. * Enforces a fixed size texture to ensure effect stability across devices.
  50898. */
  50899. mainTextureFixedSize?: number;
  50900. /**
  50901. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50902. */
  50903. alphaBlendingMode: number;
  50904. /**
  50905. * The camera attached to the layer.
  50906. */
  50907. camera: Nullable<Camera>;
  50908. /**
  50909. * The rendering group to draw the layer in.
  50910. */
  50911. renderingGroupId: number;
  50912. }
  50913. /**
  50914. * The effect layer Helps adding post process effect blended with the main pass.
  50915. *
  50916. * This can be for instance use to generate glow or higlight effects on the scene.
  50917. *
  50918. * The effect layer class can not be used directly and is intented to inherited from to be
  50919. * customized per effects.
  50920. */
  50921. export abstract class EffectLayer {
  50922. private _vertexBuffers;
  50923. private _indexBuffer;
  50924. private _cachedDefines;
  50925. private _effectLayerMapGenerationEffect;
  50926. private _effectLayerOptions;
  50927. private _mergeEffect;
  50928. protected _scene: Scene;
  50929. protected _engine: Engine;
  50930. protected _maxSize: number;
  50931. protected _mainTextureDesiredSize: ISize;
  50932. protected _mainTexture: RenderTargetTexture;
  50933. protected _shouldRender: boolean;
  50934. protected _postProcesses: PostProcess[];
  50935. protected _textures: BaseTexture[];
  50936. protected _emissiveTextureAndColor: {
  50937. texture: Nullable<BaseTexture>;
  50938. color: Color4;
  50939. };
  50940. /**
  50941. * The name of the layer
  50942. */
  50943. name: string;
  50944. /**
  50945. * The clear color of the texture used to generate the glow map.
  50946. */
  50947. neutralColor: Color4;
  50948. /**
  50949. * Specifies wether the highlight layer is enabled or not.
  50950. */
  50951. isEnabled: boolean;
  50952. /**
  50953. * Gets the camera attached to the layer.
  50954. */
  50955. readonly camera: Nullable<Camera>;
  50956. /**
  50957. * Gets the rendering group id the layer should render in.
  50958. */
  50959. renderingGroupId: number;
  50960. /**
  50961. * An event triggered when the effect layer has been disposed.
  50962. */
  50963. onDisposeObservable: Observable<EffectLayer>;
  50964. /**
  50965. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50966. */
  50967. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50968. /**
  50969. * An event triggered when the generated texture is being merged in the scene.
  50970. */
  50971. onBeforeComposeObservable: Observable<EffectLayer>;
  50972. /**
  50973. * An event triggered when the generated texture has been merged in the scene.
  50974. */
  50975. onAfterComposeObservable: Observable<EffectLayer>;
  50976. /**
  50977. * An event triggered when the efffect layer changes its size.
  50978. */
  50979. onSizeChangedObservable: Observable<EffectLayer>;
  50980. /** @hidden */
  50981. static _SceneComponentInitialization: (scene: Scene) => void;
  50982. /**
  50983. * Instantiates a new effect Layer and references it in the scene.
  50984. * @param name The name of the layer
  50985. * @param scene The scene to use the layer in
  50986. */
  50987. constructor(
  50988. /** The Friendly of the effect in the scene */
  50989. name: string, scene: Scene);
  50990. /**
  50991. * Get the effect name of the layer.
  50992. * @return The effect name
  50993. */
  50994. abstract getEffectName(): string;
  50995. /**
  50996. * Checks for the readiness of the element composing the layer.
  50997. * @param subMesh the mesh to check for
  50998. * @param useInstances specify wether or not to use instances to render the mesh
  50999. * @return true if ready otherwise, false
  51000. */
  51001. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51002. /**
  51003. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51004. * @returns true if the effect requires stencil during the main canvas render pass.
  51005. */
  51006. abstract needStencil(): boolean;
  51007. /**
  51008. * Create the merge effect. This is the shader use to blit the information back
  51009. * to the main canvas at the end of the scene rendering.
  51010. * @returns The effect containing the shader used to merge the effect on the main canvas
  51011. */
  51012. protected abstract _createMergeEffect(): Effect;
  51013. /**
  51014. * Creates the render target textures and post processes used in the effect layer.
  51015. */
  51016. protected abstract _createTextureAndPostProcesses(): void;
  51017. /**
  51018. * Implementation specific of rendering the generating effect on the main canvas.
  51019. * @param effect The effect used to render through
  51020. */
  51021. protected abstract _internalRender(effect: Effect): void;
  51022. /**
  51023. * Sets the required values for both the emissive texture and and the main color.
  51024. */
  51025. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51026. /**
  51027. * Free any resources and references associated to a mesh.
  51028. * Internal use
  51029. * @param mesh The mesh to free.
  51030. */
  51031. abstract _disposeMesh(mesh: Mesh): void;
  51032. /**
  51033. * Serializes this layer (Glow or Highlight for example)
  51034. * @returns a serialized layer object
  51035. */
  51036. abstract serialize?(): any;
  51037. /**
  51038. * Initializes the effect layer with the required options.
  51039. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51040. */
  51041. protected _init(options: Partial<IEffectLayerOptions>): void;
  51042. /**
  51043. * Generates the index buffer of the full screen quad blending to the main canvas.
  51044. */
  51045. private _generateIndexBuffer;
  51046. /**
  51047. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51048. */
  51049. private _generateVertexBuffer;
  51050. /**
  51051. * Sets the main texture desired size which is the closest power of two
  51052. * of the engine canvas size.
  51053. */
  51054. private _setMainTextureSize;
  51055. /**
  51056. * Creates the main texture for the effect layer.
  51057. */
  51058. protected _createMainTexture(): void;
  51059. /**
  51060. * Adds specific effects defines.
  51061. * @param defines The defines to add specifics to.
  51062. */
  51063. protected _addCustomEffectDefines(defines: string[]): void;
  51064. /**
  51065. * Checks for the readiness of the element composing the layer.
  51066. * @param subMesh the mesh to check for
  51067. * @param useInstances specify wether or not to use instances to render the mesh
  51068. * @param emissiveTexture the associated emissive texture used to generate the glow
  51069. * @return true if ready otherwise, false
  51070. */
  51071. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51072. /**
  51073. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51074. */
  51075. render(): void;
  51076. /**
  51077. * Determine if a given mesh will be used in the current effect.
  51078. * @param mesh mesh to test
  51079. * @returns true if the mesh will be used
  51080. */
  51081. hasMesh(mesh: AbstractMesh): boolean;
  51082. /**
  51083. * Returns true if the layer contains information to display, otherwise false.
  51084. * @returns true if the glow layer should be rendered
  51085. */
  51086. shouldRender(): boolean;
  51087. /**
  51088. * Returns true if the mesh should render, otherwise false.
  51089. * @param mesh The mesh to render
  51090. * @returns true if it should render otherwise false
  51091. */
  51092. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51093. /**
  51094. * Returns true if the mesh can be rendered, otherwise false.
  51095. * @param mesh The mesh to render
  51096. * @param material The material used on the mesh
  51097. * @returns true if it can be rendered otherwise false
  51098. */
  51099. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51100. /**
  51101. * Returns true if the mesh should render, otherwise false.
  51102. * @param mesh The mesh to render
  51103. * @returns true if it should render otherwise false
  51104. */
  51105. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51106. /**
  51107. * Renders the submesh passed in parameter to the generation map.
  51108. */
  51109. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51110. /**
  51111. * Rebuild the required buffers.
  51112. * @hidden Internal use only.
  51113. */
  51114. _rebuild(): void;
  51115. /**
  51116. * Dispose only the render target textures and post process.
  51117. */
  51118. private _disposeTextureAndPostProcesses;
  51119. /**
  51120. * Dispose the highlight layer and free resources.
  51121. */
  51122. dispose(): void;
  51123. /**
  51124. * Gets the class name of the effect layer
  51125. * @returns the string with the class name of the effect layer
  51126. */
  51127. getClassName(): string;
  51128. /**
  51129. * Creates an effect layer from parsed effect layer data
  51130. * @param parsedEffectLayer defines effect layer data
  51131. * @param scene defines the current scene
  51132. * @param rootUrl defines the root URL containing the effect layer information
  51133. * @returns a parsed effect Layer
  51134. */
  51135. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51136. }
  51137. }
  51138. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51139. import { Scene } from "babylonjs/scene";
  51140. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51141. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51142. import { AbstractScene } from "babylonjs/abstractScene";
  51143. module "babylonjs/abstractScene" {
  51144. interface AbstractScene {
  51145. /**
  51146. * The list of effect layers (highlights/glow) added to the scene
  51147. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51148. * @see http://doc.babylonjs.com/how_to/glow_layer
  51149. */
  51150. effectLayers: Array<EffectLayer>;
  51151. /**
  51152. * Removes the given effect layer from this scene.
  51153. * @param toRemove defines the effect layer to remove
  51154. * @returns the index of the removed effect layer
  51155. */
  51156. removeEffectLayer(toRemove: EffectLayer): number;
  51157. /**
  51158. * Adds the given effect layer to this scene
  51159. * @param newEffectLayer defines the effect layer to add
  51160. */
  51161. addEffectLayer(newEffectLayer: EffectLayer): void;
  51162. }
  51163. }
  51164. /**
  51165. * Defines the layer scene component responsible to manage any effect layers
  51166. * in a given scene.
  51167. */
  51168. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51169. /**
  51170. * The component name helpfull to identify the component in the list of scene components.
  51171. */
  51172. readonly name: string;
  51173. /**
  51174. * The scene the component belongs to.
  51175. */
  51176. scene: Scene;
  51177. private _engine;
  51178. private _renderEffects;
  51179. private _needStencil;
  51180. private _previousStencilState;
  51181. /**
  51182. * Creates a new instance of the component for the given scene
  51183. * @param scene Defines the scene to register the component in
  51184. */
  51185. constructor(scene: Scene);
  51186. /**
  51187. * Registers the component in a given scene
  51188. */
  51189. register(): void;
  51190. /**
  51191. * Rebuilds the elements related to this component in case of
  51192. * context lost for instance.
  51193. */
  51194. rebuild(): void;
  51195. /**
  51196. * Serializes the component data to the specified json object
  51197. * @param serializationObject The object to serialize to
  51198. */
  51199. serialize(serializationObject: any): void;
  51200. /**
  51201. * Adds all the elements from the container to the scene
  51202. * @param container the container holding the elements
  51203. */
  51204. addFromContainer(container: AbstractScene): void;
  51205. /**
  51206. * Removes all the elements in the container from the scene
  51207. * @param container contains the elements to remove
  51208. * @param dispose if the removed element should be disposed (default: false)
  51209. */
  51210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51211. /**
  51212. * Disposes the component and the associated ressources.
  51213. */
  51214. dispose(): void;
  51215. private _isReadyForMesh;
  51216. private _renderMainTexture;
  51217. private _setStencil;
  51218. private _setStencilBack;
  51219. private _draw;
  51220. private _drawCamera;
  51221. private _drawRenderingGroup;
  51222. }
  51223. }
  51224. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51225. /** @hidden */
  51226. export var glowMapMergePixelShader: {
  51227. name: string;
  51228. shader: string;
  51229. };
  51230. }
  51231. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51232. /** @hidden */
  51233. export var glowMapMergeVertexShader: {
  51234. name: string;
  51235. shader: string;
  51236. };
  51237. }
  51238. declare module "babylonjs/Layers/glowLayer" {
  51239. import { Nullable } from "babylonjs/types";
  51240. import { Camera } from "babylonjs/Cameras/camera";
  51241. import { Scene } from "babylonjs/scene";
  51242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51244. import { Mesh } from "babylonjs/Meshes/mesh";
  51245. import { Texture } from "babylonjs/Materials/Textures/texture";
  51246. import { Effect } from "babylonjs/Materials/effect";
  51247. import { Material } from "babylonjs/Materials/material";
  51248. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51249. import { Color4 } from "babylonjs/Maths/math.color";
  51250. import "babylonjs/Shaders/glowMapMerge.fragment";
  51251. import "babylonjs/Shaders/glowMapMerge.vertex";
  51252. import "babylonjs/Layers/effectLayerSceneComponent";
  51253. module "babylonjs/abstractScene" {
  51254. interface AbstractScene {
  51255. /**
  51256. * Return a the first highlight layer of the scene with a given name.
  51257. * @param name The name of the highlight layer to look for.
  51258. * @return The highlight layer if found otherwise null.
  51259. */
  51260. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51261. }
  51262. }
  51263. /**
  51264. * Glow layer options. This helps customizing the behaviour
  51265. * of the glow layer.
  51266. */
  51267. export interface IGlowLayerOptions {
  51268. /**
  51269. * Multiplication factor apply to the canvas size to compute the render target size
  51270. * used to generated the glowing objects (the smaller the faster).
  51271. */
  51272. mainTextureRatio: number;
  51273. /**
  51274. * Enforces a fixed size texture to ensure resize independant blur.
  51275. */
  51276. mainTextureFixedSize?: number;
  51277. /**
  51278. * How big is the kernel of the blur texture.
  51279. */
  51280. blurKernelSize: number;
  51281. /**
  51282. * The camera attached to the layer.
  51283. */
  51284. camera: Nullable<Camera>;
  51285. /**
  51286. * Enable MSAA by chosing the number of samples.
  51287. */
  51288. mainTextureSamples?: number;
  51289. /**
  51290. * The rendering group to draw the layer in.
  51291. */
  51292. renderingGroupId: number;
  51293. }
  51294. /**
  51295. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51296. *
  51297. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51298. * glowy meshes to your scene.
  51299. *
  51300. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51301. */
  51302. export class GlowLayer extends EffectLayer {
  51303. /**
  51304. * Effect Name of the layer.
  51305. */
  51306. static readonly EffectName: string;
  51307. /**
  51308. * The default blur kernel size used for the glow.
  51309. */
  51310. static DefaultBlurKernelSize: number;
  51311. /**
  51312. * The default texture size ratio used for the glow.
  51313. */
  51314. static DefaultTextureRatio: number;
  51315. /**
  51316. * Sets the kernel size of the blur.
  51317. */
  51318. /**
  51319. * Gets the kernel size of the blur.
  51320. */
  51321. blurKernelSize: number;
  51322. /**
  51323. * Sets the glow intensity.
  51324. */
  51325. /**
  51326. * Gets the glow intensity.
  51327. */
  51328. intensity: number;
  51329. private _options;
  51330. private _intensity;
  51331. private _horizontalBlurPostprocess1;
  51332. private _verticalBlurPostprocess1;
  51333. private _horizontalBlurPostprocess2;
  51334. private _verticalBlurPostprocess2;
  51335. private _blurTexture1;
  51336. private _blurTexture2;
  51337. private _postProcesses1;
  51338. private _postProcesses2;
  51339. private _includedOnlyMeshes;
  51340. private _excludedMeshes;
  51341. /**
  51342. * Callback used to let the user override the color selection on a per mesh basis
  51343. */
  51344. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51345. /**
  51346. * Callback used to let the user override the texture selection on a per mesh basis
  51347. */
  51348. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51349. /**
  51350. * Instantiates a new glow Layer and references it to the scene.
  51351. * @param name The name of the layer
  51352. * @param scene The scene to use the layer in
  51353. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51354. */
  51355. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51356. /**
  51357. * Get the effect name of the layer.
  51358. * @return The effect name
  51359. */
  51360. getEffectName(): string;
  51361. /**
  51362. * Create the merge effect. This is the shader use to blit the information back
  51363. * to the main canvas at the end of the scene rendering.
  51364. */
  51365. protected _createMergeEffect(): Effect;
  51366. /**
  51367. * Creates the render target textures and post processes used in the glow layer.
  51368. */
  51369. protected _createTextureAndPostProcesses(): void;
  51370. /**
  51371. * Checks for the readiness of the element composing the layer.
  51372. * @param subMesh the mesh to check for
  51373. * @param useInstances specify wether or not to use instances to render the mesh
  51374. * @param emissiveTexture the associated emissive texture used to generate the glow
  51375. * @return true if ready otherwise, false
  51376. */
  51377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51378. /**
  51379. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51380. */
  51381. needStencil(): boolean;
  51382. /**
  51383. * Returns true if the mesh can be rendered, otherwise false.
  51384. * @param mesh The mesh to render
  51385. * @param material The material used on the mesh
  51386. * @returns true if it can be rendered otherwise false
  51387. */
  51388. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51389. /**
  51390. * Implementation specific of rendering the generating effect on the main canvas.
  51391. * @param effect The effect used to render through
  51392. */
  51393. protected _internalRender(effect: Effect): void;
  51394. /**
  51395. * Sets the required values for both the emissive texture and and the main color.
  51396. */
  51397. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51398. /**
  51399. * Returns true if the mesh should render, otherwise false.
  51400. * @param mesh The mesh to render
  51401. * @returns true if it should render otherwise false
  51402. */
  51403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51404. /**
  51405. * Adds specific effects defines.
  51406. * @param defines The defines to add specifics to.
  51407. */
  51408. protected _addCustomEffectDefines(defines: string[]): void;
  51409. /**
  51410. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51411. * @param mesh The mesh to exclude from the glow layer
  51412. */
  51413. addExcludedMesh(mesh: Mesh): void;
  51414. /**
  51415. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51416. * @param mesh The mesh to remove
  51417. */
  51418. removeExcludedMesh(mesh: Mesh): void;
  51419. /**
  51420. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51421. * @param mesh The mesh to include in the glow layer
  51422. */
  51423. addIncludedOnlyMesh(mesh: Mesh): void;
  51424. /**
  51425. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51426. * @param mesh The mesh to remove
  51427. */
  51428. removeIncludedOnlyMesh(mesh: Mesh): void;
  51429. /**
  51430. * Determine if a given mesh will be used in the glow layer
  51431. * @param mesh The mesh to test
  51432. * @returns true if the mesh will be highlighted by the current glow layer
  51433. */
  51434. hasMesh(mesh: AbstractMesh): boolean;
  51435. /**
  51436. * Free any resources and references associated to a mesh.
  51437. * Internal use
  51438. * @param mesh The mesh to free.
  51439. * @hidden
  51440. */
  51441. _disposeMesh(mesh: Mesh): void;
  51442. /**
  51443. * Gets the class name of the effect layer
  51444. * @returns the string with the class name of the effect layer
  51445. */
  51446. getClassName(): string;
  51447. /**
  51448. * Serializes this glow layer
  51449. * @returns a serialized glow layer object
  51450. */
  51451. serialize(): any;
  51452. /**
  51453. * Creates a Glow Layer from parsed glow layer data
  51454. * @param parsedGlowLayer defines glow layer data
  51455. * @param scene defines the current scene
  51456. * @param rootUrl defines the root URL containing the glow layer information
  51457. * @returns a parsed Glow Layer
  51458. */
  51459. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51460. }
  51461. }
  51462. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51463. /** @hidden */
  51464. export var glowBlurPostProcessPixelShader: {
  51465. name: string;
  51466. shader: string;
  51467. };
  51468. }
  51469. declare module "babylonjs/Layers/highlightLayer" {
  51470. import { Observable } from "babylonjs/Misc/observable";
  51471. import { Nullable } from "babylonjs/types";
  51472. import { Camera } from "babylonjs/Cameras/camera";
  51473. import { Scene } from "babylonjs/scene";
  51474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51476. import { Mesh } from "babylonjs/Meshes/mesh";
  51477. import { Effect } from "babylonjs/Materials/effect";
  51478. import { Material } from "babylonjs/Materials/material";
  51479. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51480. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51481. import "babylonjs/Shaders/glowMapMerge.fragment";
  51482. import "babylonjs/Shaders/glowMapMerge.vertex";
  51483. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51484. module "babylonjs/abstractScene" {
  51485. interface AbstractScene {
  51486. /**
  51487. * Return a the first highlight layer of the scene with a given name.
  51488. * @param name The name of the highlight layer to look for.
  51489. * @return The highlight layer if found otherwise null.
  51490. */
  51491. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51492. }
  51493. }
  51494. /**
  51495. * Highlight layer options. This helps customizing the behaviour
  51496. * of the highlight layer.
  51497. */
  51498. export interface IHighlightLayerOptions {
  51499. /**
  51500. * Multiplication factor apply to the canvas size to compute the render target size
  51501. * used to generated the glowing objects (the smaller the faster).
  51502. */
  51503. mainTextureRatio: number;
  51504. /**
  51505. * Enforces a fixed size texture to ensure resize independant blur.
  51506. */
  51507. mainTextureFixedSize?: number;
  51508. /**
  51509. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51510. * of the picture to blur (the smaller the faster).
  51511. */
  51512. blurTextureSizeRatio: number;
  51513. /**
  51514. * How big in texel of the blur texture is the vertical blur.
  51515. */
  51516. blurVerticalSize: number;
  51517. /**
  51518. * How big in texel of the blur texture is the horizontal blur.
  51519. */
  51520. blurHorizontalSize: number;
  51521. /**
  51522. * Alpha blending mode used to apply the blur. Default is combine.
  51523. */
  51524. alphaBlendingMode: number;
  51525. /**
  51526. * The camera attached to the layer.
  51527. */
  51528. camera: Nullable<Camera>;
  51529. /**
  51530. * Should we display highlight as a solid stroke?
  51531. */
  51532. isStroke?: boolean;
  51533. /**
  51534. * The rendering group to draw the layer in.
  51535. */
  51536. renderingGroupId: number;
  51537. }
  51538. /**
  51539. * The highlight layer Helps adding a glow effect around a mesh.
  51540. *
  51541. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51542. * glowy meshes to your scene.
  51543. *
  51544. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51545. */
  51546. export class HighlightLayer extends EffectLayer {
  51547. name: string;
  51548. /**
  51549. * Effect Name of the highlight layer.
  51550. */
  51551. static readonly EffectName: string;
  51552. /**
  51553. * The neutral color used during the preparation of the glow effect.
  51554. * This is black by default as the blend operation is a blend operation.
  51555. */
  51556. static NeutralColor: Color4;
  51557. /**
  51558. * Stencil value used for glowing meshes.
  51559. */
  51560. static GlowingMeshStencilReference: number;
  51561. /**
  51562. * Stencil value used for the other meshes in the scene.
  51563. */
  51564. static NormalMeshStencilReference: number;
  51565. /**
  51566. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51567. */
  51568. innerGlow: boolean;
  51569. /**
  51570. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51571. */
  51572. outerGlow: boolean;
  51573. /**
  51574. * Specifies the horizontal size of the blur.
  51575. */
  51576. /**
  51577. * Gets the horizontal size of the blur.
  51578. */
  51579. blurHorizontalSize: number;
  51580. /**
  51581. * Specifies the vertical size of the blur.
  51582. */
  51583. /**
  51584. * Gets the vertical size of the blur.
  51585. */
  51586. blurVerticalSize: number;
  51587. /**
  51588. * An event triggered when the highlight layer is being blurred.
  51589. */
  51590. onBeforeBlurObservable: Observable<HighlightLayer>;
  51591. /**
  51592. * An event triggered when the highlight layer has been blurred.
  51593. */
  51594. onAfterBlurObservable: Observable<HighlightLayer>;
  51595. private _instanceGlowingMeshStencilReference;
  51596. private _options;
  51597. private _downSamplePostprocess;
  51598. private _horizontalBlurPostprocess;
  51599. private _verticalBlurPostprocess;
  51600. private _blurTexture;
  51601. private _meshes;
  51602. private _excludedMeshes;
  51603. /**
  51604. * Instantiates a new highlight Layer and references it to the scene..
  51605. * @param name The name of the layer
  51606. * @param scene The scene to use the layer in
  51607. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51608. */
  51609. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51610. /**
  51611. * Get the effect name of the layer.
  51612. * @return The effect name
  51613. */
  51614. getEffectName(): string;
  51615. /**
  51616. * Create the merge effect. This is the shader use to blit the information back
  51617. * to the main canvas at the end of the scene rendering.
  51618. */
  51619. protected _createMergeEffect(): Effect;
  51620. /**
  51621. * Creates the render target textures and post processes used in the highlight layer.
  51622. */
  51623. protected _createTextureAndPostProcesses(): void;
  51624. /**
  51625. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51626. */
  51627. needStencil(): boolean;
  51628. /**
  51629. * Checks for the readiness of the element composing the layer.
  51630. * @param subMesh the mesh to check for
  51631. * @param useInstances specify wether or not to use instances to render the mesh
  51632. * @param emissiveTexture the associated emissive texture used to generate the glow
  51633. * @return true if ready otherwise, false
  51634. */
  51635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51636. /**
  51637. * Implementation specific of rendering the generating effect on the main canvas.
  51638. * @param effect The effect used to render through
  51639. */
  51640. protected _internalRender(effect: Effect): void;
  51641. /**
  51642. * Returns true if the layer contains information to display, otherwise false.
  51643. */
  51644. shouldRender(): boolean;
  51645. /**
  51646. * Returns true if the mesh should render, otherwise false.
  51647. * @param mesh The mesh to render
  51648. * @returns true if it should render otherwise false
  51649. */
  51650. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51651. /**
  51652. * Sets the required values for both the emissive texture and and the main color.
  51653. */
  51654. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51655. /**
  51656. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51657. * @param mesh The mesh to exclude from the highlight layer
  51658. */
  51659. addExcludedMesh(mesh: Mesh): void;
  51660. /**
  51661. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51662. * @param mesh The mesh to highlight
  51663. */
  51664. removeExcludedMesh(mesh: Mesh): void;
  51665. /**
  51666. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51667. * @param mesh mesh to test
  51668. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51669. */
  51670. hasMesh(mesh: AbstractMesh): boolean;
  51671. /**
  51672. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51673. * @param mesh The mesh to highlight
  51674. * @param color The color of the highlight
  51675. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51676. */
  51677. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51678. /**
  51679. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51680. * @param mesh The mesh to highlight
  51681. */
  51682. removeMesh(mesh: Mesh): void;
  51683. /**
  51684. * Force the stencil to the normal expected value for none glowing parts
  51685. */
  51686. private _defaultStencilReference;
  51687. /**
  51688. * Free any resources and references associated to a mesh.
  51689. * Internal use
  51690. * @param mesh The mesh to free.
  51691. * @hidden
  51692. */
  51693. _disposeMesh(mesh: Mesh): void;
  51694. /**
  51695. * Dispose the highlight layer and free resources.
  51696. */
  51697. dispose(): void;
  51698. /**
  51699. * Gets the class name of the effect layer
  51700. * @returns the string with the class name of the effect layer
  51701. */
  51702. getClassName(): string;
  51703. /**
  51704. * Serializes this Highlight layer
  51705. * @returns a serialized Highlight layer object
  51706. */
  51707. serialize(): any;
  51708. /**
  51709. * Creates a Highlight layer from parsed Highlight layer data
  51710. * @param parsedHightlightLayer defines the Highlight layer data
  51711. * @param scene defines the current scene
  51712. * @param rootUrl defines the root URL containing the Highlight layer information
  51713. * @returns a parsed Highlight layer
  51714. */
  51715. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51716. }
  51717. }
  51718. declare module "babylonjs/Layers/layerSceneComponent" {
  51719. import { Scene } from "babylonjs/scene";
  51720. import { ISceneComponent } from "babylonjs/sceneComponent";
  51721. import { Layer } from "babylonjs/Layers/layer";
  51722. import { AbstractScene } from "babylonjs/abstractScene";
  51723. module "babylonjs/abstractScene" {
  51724. interface AbstractScene {
  51725. /**
  51726. * The list of layers (background and foreground) of the scene
  51727. */
  51728. layers: Array<Layer>;
  51729. }
  51730. }
  51731. /**
  51732. * Defines the layer scene component responsible to manage any layers
  51733. * in a given scene.
  51734. */
  51735. export class LayerSceneComponent implements ISceneComponent {
  51736. /**
  51737. * The component name helpfull to identify the component in the list of scene components.
  51738. */
  51739. readonly name: string;
  51740. /**
  51741. * The scene the component belongs to.
  51742. */
  51743. scene: Scene;
  51744. private _engine;
  51745. /**
  51746. * Creates a new instance of the component for the given scene
  51747. * @param scene Defines the scene to register the component in
  51748. */
  51749. constructor(scene: Scene);
  51750. /**
  51751. * Registers the component in a given scene
  51752. */
  51753. register(): void;
  51754. /**
  51755. * Rebuilds the elements related to this component in case of
  51756. * context lost for instance.
  51757. */
  51758. rebuild(): void;
  51759. /**
  51760. * Disposes the component and the associated ressources.
  51761. */
  51762. dispose(): void;
  51763. private _draw;
  51764. private _drawCameraPredicate;
  51765. private _drawCameraBackground;
  51766. private _drawCameraForeground;
  51767. private _drawRenderTargetPredicate;
  51768. private _drawRenderTargetBackground;
  51769. private _drawRenderTargetForeground;
  51770. /**
  51771. * Adds all the elements from the container to the scene
  51772. * @param container the container holding the elements
  51773. */
  51774. addFromContainer(container: AbstractScene): void;
  51775. /**
  51776. * Removes all the elements in the container from the scene
  51777. * @param container contains the elements to remove
  51778. * @param dispose if the removed element should be disposed (default: false)
  51779. */
  51780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51781. }
  51782. }
  51783. declare module "babylonjs/Shaders/layer.fragment" {
  51784. /** @hidden */
  51785. export var layerPixelShader: {
  51786. name: string;
  51787. shader: string;
  51788. };
  51789. }
  51790. declare module "babylonjs/Shaders/layer.vertex" {
  51791. /** @hidden */
  51792. export var layerVertexShader: {
  51793. name: string;
  51794. shader: string;
  51795. };
  51796. }
  51797. declare module "babylonjs/Layers/layer" {
  51798. import { Observable } from "babylonjs/Misc/observable";
  51799. import { Nullable } from "babylonjs/types";
  51800. import { Scene } from "babylonjs/scene";
  51801. import { Vector2 } from "babylonjs/Maths/math.vector";
  51802. import { Color4 } from "babylonjs/Maths/math.color";
  51803. import { Texture } from "babylonjs/Materials/Textures/texture";
  51804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51805. import "babylonjs/Shaders/layer.fragment";
  51806. import "babylonjs/Shaders/layer.vertex";
  51807. /**
  51808. * This represents a full screen 2d layer.
  51809. * This can be useful to display a picture in the background of your scene for instance.
  51810. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51811. */
  51812. export class Layer {
  51813. /**
  51814. * Define the name of the layer.
  51815. */
  51816. name: string;
  51817. /**
  51818. * Define the texture the layer should display.
  51819. */
  51820. texture: Nullable<Texture>;
  51821. /**
  51822. * Is the layer in background or foreground.
  51823. */
  51824. isBackground: boolean;
  51825. /**
  51826. * Define the color of the layer (instead of texture).
  51827. */
  51828. color: Color4;
  51829. /**
  51830. * Define the scale of the layer in order to zoom in out of the texture.
  51831. */
  51832. scale: Vector2;
  51833. /**
  51834. * Define an offset for the layer in order to shift the texture.
  51835. */
  51836. offset: Vector2;
  51837. /**
  51838. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51839. */
  51840. alphaBlendingMode: number;
  51841. /**
  51842. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51843. * Alpha test will not mix with the background color in case of transparency.
  51844. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51845. */
  51846. alphaTest: boolean;
  51847. /**
  51848. * Define a mask to restrict the layer to only some of the scene cameras.
  51849. */
  51850. layerMask: number;
  51851. /**
  51852. * Define the list of render target the layer is visible into.
  51853. */
  51854. renderTargetTextures: RenderTargetTexture[];
  51855. /**
  51856. * Define if the layer is only used in renderTarget or if it also
  51857. * renders in the main frame buffer of the canvas.
  51858. */
  51859. renderOnlyInRenderTargetTextures: boolean;
  51860. private _scene;
  51861. private _vertexBuffers;
  51862. private _indexBuffer;
  51863. private _effect;
  51864. private _alphaTestEffect;
  51865. /**
  51866. * An event triggered when the layer is disposed.
  51867. */
  51868. onDisposeObservable: Observable<Layer>;
  51869. private _onDisposeObserver;
  51870. /**
  51871. * Back compatibility with callback before the onDisposeObservable existed.
  51872. * The set callback will be triggered when the layer has been disposed.
  51873. */
  51874. onDispose: () => void;
  51875. /**
  51876. * An event triggered before rendering the scene
  51877. */
  51878. onBeforeRenderObservable: Observable<Layer>;
  51879. private _onBeforeRenderObserver;
  51880. /**
  51881. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51882. * The set callback will be triggered just before rendering the layer.
  51883. */
  51884. onBeforeRender: () => void;
  51885. /**
  51886. * An event triggered after rendering the scene
  51887. */
  51888. onAfterRenderObservable: Observable<Layer>;
  51889. private _onAfterRenderObserver;
  51890. /**
  51891. * Back compatibility with callback before the onAfterRenderObservable existed.
  51892. * The set callback will be triggered just after rendering the layer.
  51893. */
  51894. onAfterRender: () => void;
  51895. /**
  51896. * Instantiates a new layer.
  51897. * This represents a full screen 2d layer.
  51898. * This can be useful to display a picture in the background of your scene for instance.
  51899. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51900. * @param name Define the name of the layer in the scene
  51901. * @param imgUrl Define the url of the texture to display in the layer
  51902. * @param scene Define the scene the layer belongs to
  51903. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51904. * @param color Defines a color for the layer
  51905. */
  51906. constructor(
  51907. /**
  51908. * Define the name of the layer.
  51909. */
  51910. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51911. private _createIndexBuffer;
  51912. /** @hidden */
  51913. _rebuild(): void;
  51914. /**
  51915. * Renders the layer in the scene.
  51916. */
  51917. render(): void;
  51918. /**
  51919. * Disposes and releases the associated ressources.
  51920. */
  51921. dispose(): void;
  51922. }
  51923. }
  51924. declare module "babylonjs/Layers/index" {
  51925. export * from "babylonjs/Layers/effectLayer";
  51926. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51927. export * from "babylonjs/Layers/glowLayer";
  51928. export * from "babylonjs/Layers/highlightLayer";
  51929. export * from "babylonjs/Layers/layer";
  51930. export * from "babylonjs/Layers/layerSceneComponent";
  51931. }
  51932. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51933. /** @hidden */
  51934. export var lensFlarePixelShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51940. /** @hidden */
  51941. export var lensFlareVertexShader: {
  51942. name: string;
  51943. shader: string;
  51944. };
  51945. }
  51946. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51947. import { Scene } from "babylonjs/scene";
  51948. import { Vector3 } from "babylonjs/Maths/math.vector";
  51949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51950. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51951. import "babylonjs/Shaders/lensFlare.fragment";
  51952. import "babylonjs/Shaders/lensFlare.vertex";
  51953. import { Viewport } from "babylonjs/Maths/math.viewport";
  51954. /**
  51955. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51956. * It is usually composed of several `lensFlare`.
  51957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51958. */
  51959. export class LensFlareSystem {
  51960. /**
  51961. * Define the name of the lens flare system
  51962. */
  51963. name: string;
  51964. /**
  51965. * List of lens flares used in this system.
  51966. */
  51967. lensFlares: LensFlare[];
  51968. /**
  51969. * Define a limit from the border the lens flare can be visible.
  51970. */
  51971. borderLimit: number;
  51972. /**
  51973. * Define a viewport border we do not want to see the lens flare in.
  51974. */
  51975. viewportBorder: number;
  51976. /**
  51977. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51978. */
  51979. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51980. /**
  51981. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51982. */
  51983. layerMask: number;
  51984. /**
  51985. * Define the id of the lens flare system in the scene.
  51986. * (equal to name by default)
  51987. */
  51988. id: string;
  51989. private _scene;
  51990. private _emitter;
  51991. private _vertexBuffers;
  51992. private _indexBuffer;
  51993. private _effect;
  51994. private _positionX;
  51995. private _positionY;
  51996. private _isEnabled;
  51997. /** @hidden */
  51998. static _SceneComponentInitialization: (scene: Scene) => void;
  51999. /**
  52000. * Instantiates a lens flare system.
  52001. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52002. * It is usually composed of several `lensFlare`.
  52003. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52004. * @param name Define the name of the lens flare system in the scene
  52005. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52006. * @param scene Define the scene the lens flare system belongs to
  52007. */
  52008. constructor(
  52009. /**
  52010. * Define the name of the lens flare system
  52011. */
  52012. name: string, emitter: any, scene: Scene);
  52013. /**
  52014. * Define if the lens flare system is enabled.
  52015. */
  52016. isEnabled: boolean;
  52017. /**
  52018. * Get the scene the effects belongs to.
  52019. * @returns the scene holding the lens flare system
  52020. */
  52021. getScene(): Scene;
  52022. /**
  52023. * Get the emitter of the lens flare system.
  52024. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52025. * @returns the emitter of the lens flare system
  52026. */
  52027. getEmitter(): any;
  52028. /**
  52029. * Set the emitter of the lens flare system.
  52030. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52031. * @param newEmitter Define the new emitter of the system
  52032. */
  52033. setEmitter(newEmitter: any): void;
  52034. /**
  52035. * Get the lens flare system emitter position.
  52036. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52037. * @returns the position
  52038. */
  52039. getEmitterPosition(): Vector3;
  52040. /**
  52041. * @hidden
  52042. */
  52043. computeEffectivePosition(globalViewport: Viewport): boolean;
  52044. /** @hidden */
  52045. _isVisible(): boolean;
  52046. /**
  52047. * @hidden
  52048. */
  52049. render(): boolean;
  52050. /**
  52051. * Dispose and release the lens flare with its associated resources.
  52052. */
  52053. dispose(): void;
  52054. /**
  52055. * Parse a lens flare system from a JSON repressentation
  52056. * @param parsedLensFlareSystem Define the JSON to parse
  52057. * @param scene Define the scene the parsed system should be instantiated in
  52058. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52059. * @returns the parsed system
  52060. */
  52061. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52062. /**
  52063. * Serialize the current Lens Flare System into a JSON representation.
  52064. * @returns the serialized JSON
  52065. */
  52066. serialize(): any;
  52067. }
  52068. }
  52069. declare module "babylonjs/LensFlares/lensFlare" {
  52070. import { Nullable } from "babylonjs/types";
  52071. import { Color3 } from "babylonjs/Maths/math.color";
  52072. import { Texture } from "babylonjs/Materials/Textures/texture";
  52073. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52074. /**
  52075. * This represents one of the lens effect in a `lensFlareSystem`.
  52076. * It controls one of the indiviual texture used in the effect.
  52077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52078. */
  52079. export class LensFlare {
  52080. /**
  52081. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52082. */
  52083. size: number;
  52084. /**
  52085. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52086. */
  52087. position: number;
  52088. /**
  52089. * Define the lens color.
  52090. */
  52091. color: Color3;
  52092. /**
  52093. * Define the lens texture.
  52094. */
  52095. texture: Nullable<Texture>;
  52096. /**
  52097. * Define the alpha mode to render this particular lens.
  52098. */
  52099. alphaMode: number;
  52100. private _system;
  52101. /**
  52102. * Creates a new Lens Flare.
  52103. * This represents one of the lens effect in a `lensFlareSystem`.
  52104. * It controls one of the indiviual texture used in the effect.
  52105. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52106. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52107. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52108. * @param color Define the lens color
  52109. * @param imgUrl Define the lens texture url
  52110. * @param system Define the `lensFlareSystem` this flare is part of
  52111. * @returns The newly created Lens Flare
  52112. */
  52113. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52114. /**
  52115. * Instantiates a new Lens Flare.
  52116. * This represents one of the lens effect in a `lensFlareSystem`.
  52117. * It controls one of the indiviual texture used in the effect.
  52118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52119. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52120. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52121. * @param color Define the lens color
  52122. * @param imgUrl Define the lens texture url
  52123. * @param system Define the `lensFlareSystem` this flare is part of
  52124. */
  52125. constructor(
  52126. /**
  52127. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52128. */
  52129. size: number,
  52130. /**
  52131. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52132. */
  52133. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52134. /**
  52135. * Dispose and release the lens flare with its associated resources.
  52136. */
  52137. dispose(): void;
  52138. }
  52139. }
  52140. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52141. import { Nullable } from "babylonjs/types";
  52142. import { Scene } from "babylonjs/scene";
  52143. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52144. import { AbstractScene } from "babylonjs/abstractScene";
  52145. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52146. module "babylonjs/abstractScene" {
  52147. interface AbstractScene {
  52148. /**
  52149. * The list of lens flare system added to the scene
  52150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52151. */
  52152. lensFlareSystems: Array<LensFlareSystem>;
  52153. /**
  52154. * Removes the given lens flare system from this scene.
  52155. * @param toRemove The lens flare system to remove
  52156. * @returns The index of the removed lens flare system
  52157. */
  52158. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52159. /**
  52160. * Adds the given lens flare system to this scene
  52161. * @param newLensFlareSystem The lens flare system to add
  52162. */
  52163. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52164. /**
  52165. * Gets a lens flare system using its name
  52166. * @param name defines the name to look for
  52167. * @returns the lens flare system or null if not found
  52168. */
  52169. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52170. /**
  52171. * Gets a lens flare system using its id
  52172. * @param id defines the id to look for
  52173. * @returns the lens flare system or null if not found
  52174. */
  52175. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52176. }
  52177. }
  52178. /**
  52179. * Defines the lens flare scene component responsible to manage any lens flares
  52180. * in a given scene.
  52181. */
  52182. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52183. /**
  52184. * The component name helpfull to identify the component in the list of scene components.
  52185. */
  52186. readonly name: string;
  52187. /**
  52188. * The scene the component belongs to.
  52189. */
  52190. scene: Scene;
  52191. /**
  52192. * Creates a new instance of the component for the given scene
  52193. * @param scene Defines the scene to register the component in
  52194. */
  52195. constructor(scene: Scene);
  52196. /**
  52197. * Registers the component in a given scene
  52198. */
  52199. register(): void;
  52200. /**
  52201. * Rebuilds the elements related to this component in case of
  52202. * context lost for instance.
  52203. */
  52204. rebuild(): void;
  52205. /**
  52206. * Adds all the elements from the container to the scene
  52207. * @param container the container holding the elements
  52208. */
  52209. addFromContainer(container: AbstractScene): void;
  52210. /**
  52211. * Removes all the elements in the container from the scene
  52212. * @param container contains the elements to remove
  52213. * @param dispose if the removed element should be disposed (default: false)
  52214. */
  52215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52216. /**
  52217. * Serializes the component data to the specified json object
  52218. * @param serializationObject The object to serialize to
  52219. */
  52220. serialize(serializationObject: any): void;
  52221. /**
  52222. * Disposes the component and the associated ressources.
  52223. */
  52224. dispose(): void;
  52225. private _draw;
  52226. }
  52227. }
  52228. declare module "babylonjs/LensFlares/index" {
  52229. export * from "babylonjs/LensFlares/lensFlare";
  52230. export * from "babylonjs/LensFlares/lensFlareSystem";
  52231. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52232. }
  52233. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52234. import { Scene } from "babylonjs/scene";
  52235. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52236. import { AbstractScene } from "babylonjs/abstractScene";
  52237. /**
  52238. * Defines the shadow generator component responsible to manage any shadow generators
  52239. * in a given scene.
  52240. */
  52241. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52242. /**
  52243. * The component name helpfull to identify the component in the list of scene components.
  52244. */
  52245. readonly name: string;
  52246. /**
  52247. * The scene the component belongs to.
  52248. */
  52249. scene: Scene;
  52250. /**
  52251. * Creates a new instance of the component for the given scene
  52252. * @param scene Defines the scene to register the component in
  52253. */
  52254. constructor(scene: Scene);
  52255. /**
  52256. * Registers the component in a given scene
  52257. */
  52258. register(): void;
  52259. /**
  52260. * Rebuilds the elements related to this component in case of
  52261. * context lost for instance.
  52262. */
  52263. rebuild(): void;
  52264. /**
  52265. * Serializes the component data to the specified json object
  52266. * @param serializationObject The object to serialize to
  52267. */
  52268. serialize(serializationObject: any): void;
  52269. /**
  52270. * Adds all the elements from the container to the scene
  52271. * @param container the container holding the elements
  52272. */
  52273. addFromContainer(container: AbstractScene): void;
  52274. /**
  52275. * Removes all the elements in the container from the scene
  52276. * @param container contains the elements to remove
  52277. * @param dispose if the removed element should be disposed (default: false)
  52278. */
  52279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52280. /**
  52281. * Rebuilds the elements related to this component in case of
  52282. * context lost for instance.
  52283. */
  52284. dispose(): void;
  52285. private _gatherRenderTargets;
  52286. }
  52287. }
  52288. declare module "babylonjs/Lights/Shadows/index" {
  52289. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52290. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52291. }
  52292. declare module "babylonjs/Lights/pointLight" {
  52293. import { Scene } from "babylonjs/scene";
  52294. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52296. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52297. import { Effect } from "babylonjs/Materials/effect";
  52298. /**
  52299. * A point light is a light defined by an unique point in world space.
  52300. * The light is emitted in every direction from this point.
  52301. * A good example of a point light is a standard light bulb.
  52302. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52303. */
  52304. export class PointLight extends ShadowLight {
  52305. private _shadowAngle;
  52306. /**
  52307. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52308. * This specifies what angle the shadow will use to be created.
  52309. *
  52310. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52311. */
  52312. /**
  52313. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52314. * This specifies what angle the shadow will use to be created.
  52315. *
  52316. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52317. */
  52318. shadowAngle: number;
  52319. /**
  52320. * Gets the direction if it has been set.
  52321. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52322. */
  52323. /**
  52324. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52325. */
  52326. direction: Vector3;
  52327. /**
  52328. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52329. * A PointLight emits the light in every direction.
  52330. * It can cast shadows.
  52331. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52332. * ```javascript
  52333. * var pointLight = new PointLight("pl", camera.position, scene);
  52334. * ```
  52335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52336. * @param name The light friendly name
  52337. * @param position The position of the point light in the scene
  52338. * @param scene The scene the lights belongs to
  52339. */
  52340. constructor(name: string, position: Vector3, scene: Scene);
  52341. /**
  52342. * Returns the string "PointLight"
  52343. * @returns the class name
  52344. */
  52345. getClassName(): string;
  52346. /**
  52347. * Returns the integer 0.
  52348. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52349. */
  52350. getTypeID(): number;
  52351. /**
  52352. * Specifies wether or not the shadowmap should be a cube texture.
  52353. * @returns true if the shadowmap needs to be a cube texture.
  52354. */
  52355. needCube(): boolean;
  52356. /**
  52357. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52360. */
  52361. getShadowDirection(faceIndex?: number): Vector3;
  52362. /**
  52363. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52364. * - fov = PI / 2
  52365. * - aspect ratio : 1.0
  52366. * - z-near and far equal to the active camera minZ and maxZ.
  52367. * Returns the PointLight.
  52368. */
  52369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52370. protected _buildUniformLayout(): void;
  52371. /**
  52372. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52373. * @param effect The effect to update
  52374. * @param lightIndex The index of the light in the effect to update
  52375. * @returns The point light
  52376. */
  52377. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52378. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52379. /**
  52380. * Prepares the list of defines specific to the light type.
  52381. * @param defines the list of defines
  52382. * @param lightIndex defines the index of the light for the effect
  52383. */
  52384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Lights/index" {
  52388. export * from "babylonjs/Lights/light";
  52389. export * from "babylonjs/Lights/shadowLight";
  52390. export * from "babylonjs/Lights/Shadows/index";
  52391. export * from "babylonjs/Lights/directionalLight";
  52392. export * from "babylonjs/Lights/hemisphericLight";
  52393. export * from "babylonjs/Lights/pointLight";
  52394. export * from "babylonjs/Lights/spotLight";
  52395. }
  52396. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52397. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52398. /**
  52399. * Header information of HDR texture files.
  52400. */
  52401. export interface HDRInfo {
  52402. /**
  52403. * The height of the texture in pixels.
  52404. */
  52405. height: number;
  52406. /**
  52407. * The width of the texture in pixels.
  52408. */
  52409. width: number;
  52410. /**
  52411. * The index of the beginning of the data in the binary file.
  52412. */
  52413. dataPosition: number;
  52414. }
  52415. /**
  52416. * This groups tools to convert HDR texture to native colors array.
  52417. */
  52418. export class HDRTools {
  52419. private static Ldexp;
  52420. private static Rgbe2float;
  52421. private static readStringLine;
  52422. /**
  52423. * Reads header information from an RGBE texture stored in a native array.
  52424. * More information on this format are available here:
  52425. * https://en.wikipedia.org/wiki/RGBE_image_format
  52426. *
  52427. * @param uint8array The binary file stored in native array.
  52428. * @return The header information.
  52429. */
  52430. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52431. /**
  52432. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52433. * This RGBE texture needs to store the information as a panorama.
  52434. *
  52435. * More information on this format are available here:
  52436. * https://en.wikipedia.org/wiki/RGBE_image_format
  52437. *
  52438. * @param buffer The binary file stored in an array buffer.
  52439. * @param size The expected size of the extracted cubemap.
  52440. * @return The Cube Map information.
  52441. */
  52442. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52443. /**
  52444. * Returns the pixels data extracted from an RGBE texture.
  52445. * This pixels will be stored left to right up to down in the R G B order in one array.
  52446. *
  52447. * More information on this format are available here:
  52448. * https://en.wikipedia.org/wiki/RGBE_image_format
  52449. *
  52450. * @param uint8array The binary file stored in an array buffer.
  52451. * @param hdrInfo The header information of the file.
  52452. * @return The pixels data in RGB right to left up to down order.
  52453. */
  52454. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52455. private static RGBE_ReadPixels_RLE;
  52456. }
  52457. }
  52458. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52459. import { Nullable } from "babylonjs/types";
  52460. import { Scene } from "babylonjs/scene";
  52461. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52463. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52464. /**
  52465. * This represents a texture coming from an HDR input.
  52466. *
  52467. * The only supported format is currently panorama picture stored in RGBE format.
  52468. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52469. */
  52470. export class HDRCubeTexture extends BaseTexture {
  52471. private static _facesMapping;
  52472. private _generateHarmonics;
  52473. private _noMipmap;
  52474. private _textureMatrix;
  52475. private _size;
  52476. private _onLoad;
  52477. private _onError;
  52478. /**
  52479. * The texture URL.
  52480. */
  52481. url: string;
  52482. /**
  52483. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52484. */
  52485. coordinatesMode: number;
  52486. protected _isBlocking: boolean;
  52487. /**
  52488. * Sets wether or not the texture is blocking during loading.
  52489. */
  52490. /**
  52491. * Gets wether or not the texture is blocking during loading.
  52492. */
  52493. isBlocking: boolean;
  52494. protected _rotationY: number;
  52495. /**
  52496. * Sets texture matrix rotation angle around Y axis in radians.
  52497. */
  52498. /**
  52499. * Gets texture matrix rotation angle around Y axis radians.
  52500. */
  52501. rotationY: number;
  52502. /**
  52503. * Gets or sets the center of the bounding box associated with the cube texture
  52504. * It must define where the camera used to render the texture was set
  52505. */
  52506. boundingBoxPosition: Vector3;
  52507. private _boundingBoxSize;
  52508. /**
  52509. * Gets or sets the size of the bounding box associated with the cube texture
  52510. * When defined, the cubemap will switch to local mode
  52511. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52512. * @example https://www.babylonjs-playground.com/#RNASML
  52513. */
  52514. boundingBoxSize: Vector3;
  52515. /**
  52516. * Instantiates an HDRTexture from the following parameters.
  52517. *
  52518. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52519. * @param scene The scene the texture will be used in
  52520. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52521. * @param noMipmap Forces to not generate the mipmap if true
  52522. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52523. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  52524. * @param reserved Reserved flag for internal use.
  52525. */
  52526. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52527. /**
  52528. * Get the current class name of the texture useful for serialization or dynamic coding.
  52529. * @returns "HDRCubeTexture"
  52530. */
  52531. getClassName(): string;
  52532. /**
  52533. * Occurs when the file is raw .hdr file.
  52534. */
  52535. private loadTexture;
  52536. clone(): HDRCubeTexture;
  52537. delayLoad(): void;
  52538. /**
  52539. * Get the texture reflection matrix used to rotate/transform the reflection.
  52540. * @returns the reflection matrix
  52541. */
  52542. getReflectionTextureMatrix(): Matrix;
  52543. /**
  52544. * Set the texture reflection matrix used to rotate/transform the reflection.
  52545. * @param value Define the reflection matrix to set
  52546. */
  52547. setReflectionTextureMatrix(value: Matrix): void;
  52548. /**
  52549. * Parses a JSON representation of an HDR Texture in order to create the texture
  52550. * @param parsedTexture Define the JSON representation
  52551. * @param scene Define the scene the texture should be created in
  52552. * @param rootUrl Define the root url in case we need to load relative dependencies
  52553. * @returns the newly created texture after parsing
  52554. */
  52555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52556. serialize(): any;
  52557. }
  52558. }
  52559. declare module "babylonjs/Physics/physicsEngine" {
  52560. import { Nullable } from "babylonjs/types";
  52561. import { Vector3 } from "babylonjs/Maths/math.vector";
  52562. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52563. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52564. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52565. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52566. /**
  52567. * Class used to control physics engine
  52568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52569. */
  52570. export class PhysicsEngine implements IPhysicsEngine {
  52571. private _physicsPlugin;
  52572. /**
  52573. * Global value used to control the smallest number supported by the simulation
  52574. */
  52575. static Epsilon: number;
  52576. private _impostors;
  52577. private _joints;
  52578. /**
  52579. * Gets the gravity vector used by the simulation
  52580. */
  52581. gravity: Vector3;
  52582. /**
  52583. * Factory used to create the default physics plugin.
  52584. * @returns The default physics plugin
  52585. */
  52586. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52587. /**
  52588. * Creates a new Physics Engine
  52589. * @param gravity defines the gravity vector used by the simulation
  52590. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52591. */
  52592. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52593. /**
  52594. * Sets the gravity vector used by the simulation
  52595. * @param gravity defines the gravity vector to use
  52596. */
  52597. setGravity(gravity: Vector3): void;
  52598. /**
  52599. * Set the time step of the physics engine.
  52600. * Default is 1/60.
  52601. * To slow it down, enter 1/600 for example.
  52602. * To speed it up, 1/30
  52603. * @param newTimeStep defines the new timestep to apply to this world.
  52604. */
  52605. setTimeStep(newTimeStep?: number): void;
  52606. /**
  52607. * Get the time step of the physics engine.
  52608. * @returns the current time step
  52609. */
  52610. getTimeStep(): number;
  52611. /**
  52612. * Release all resources
  52613. */
  52614. dispose(): void;
  52615. /**
  52616. * Gets the name of the current physics plugin
  52617. * @returns the name of the plugin
  52618. */
  52619. getPhysicsPluginName(): string;
  52620. /**
  52621. * Adding a new impostor for the impostor tracking.
  52622. * This will be done by the impostor itself.
  52623. * @param impostor the impostor to add
  52624. */
  52625. addImpostor(impostor: PhysicsImpostor): void;
  52626. /**
  52627. * Remove an impostor from the engine.
  52628. * This impostor and its mesh will not longer be updated by the physics engine.
  52629. * @param impostor the impostor to remove
  52630. */
  52631. removeImpostor(impostor: PhysicsImpostor): void;
  52632. /**
  52633. * Add a joint to the physics engine
  52634. * @param mainImpostor defines the main impostor to which the joint is added.
  52635. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52636. * @param joint defines the joint that will connect both impostors.
  52637. */
  52638. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52639. /**
  52640. * Removes a joint from the simulation
  52641. * @param mainImpostor defines the impostor used with the joint
  52642. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52643. * @param joint defines the joint to remove
  52644. */
  52645. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52646. /**
  52647. * Called by the scene. No need to call it.
  52648. * @param delta defines the timespam between frames
  52649. */
  52650. _step(delta: number): void;
  52651. /**
  52652. * Gets the current plugin used to run the simulation
  52653. * @returns current plugin
  52654. */
  52655. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52656. /**
  52657. * Gets the list of physic impostors
  52658. * @returns an array of PhysicsImpostor
  52659. */
  52660. getImpostors(): Array<PhysicsImpostor>;
  52661. /**
  52662. * Gets the impostor for a physics enabled object
  52663. * @param object defines the object impersonated by the impostor
  52664. * @returns the PhysicsImpostor or null if not found
  52665. */
  52666. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52667. /**
  52668. * Gets the impostor for a physics body object
  52669. * @param body defines physics body used by the impostor
  52670. * @returns the PhysicsImpostor or null if not found
  52671. */
  52672. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52673. /**
  52674. * Does a raycast in the physics world
  52675. * @param from when should the ray start?
  52676. * @param to when should the ray end?
  52677. * @returns PhysicsRaycastResult
  52678. */
  52679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52680. }
  52681. }
  52682. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52683. import { Nullable } from "babylonjs/types";
  52684. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52686. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52687. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52688. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52689. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52690. /** @hidden */
  52691. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52692. private _useDeltaForWorldStep;
  52693. world: any;
  52694. name: string;
  52695. private _physicsMaterials;
  52696. private _fixedTimeStep;
  52697. private _cannonRaycastResult;
  52698. private _raycastResult;
  52699. private _physicsBodysToRemoveAfterStep;
  52700. BJSCANNON: any;
  52701. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52702. setGravity(gravity: Vector3): void;
  52703. setTimeStep(timeStep: number): void;
  52704. getTimeStep(): number;
  52705. executeStep(delta: number): void;
  52706. private _removeMarkedPhysicsBodiesFromWorld;
  52707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52710. private _processChildMeshes;
  52711. removePhysicsBody(impostor: PhysicsImpostor): void;
  52712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52714. private _addMaterial;
  52715. private _checkWithEpsilon;
  52716. private _createShape;
  52717. private _createHeightmap;
  52718. private _minus90X;
  52719. private _plus90X;
  52720. private _tmpPosition;
  52721. private _tmpDeltaPosition;
  52722. private _tmpUnityRotation;
  52723. private _updatePhysicsBodyTransformation;
  52724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52725. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52726. isSupported(): boolean;
  52727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52732. getBodyMass(impostor: PhysicsImpostor): number;
  52733. getBodyFriction(impostor: PhysicsImpostor): number;
  52734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52735. getBodyRestitution(impostor: PhysicsImpostor): number;
  52736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52737. sleepBody(impostor: PhysicsImpostor): void;
  52738. wakeUpBody(impostor: PhysicsImpostor): void;
  52739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52740. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52743. getRadius(impostor: PhysicsImpostor): number;
  52744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52745. dispose(): void;
  52746. private _extendNamespace;
  52747. /**
  52748. * Does a raycast in the physics world
  52749. * @param from when should the ray start?
  52750. * @param to when should the ray end?
  52751. * @returns PhysicsRaycastResult
  52752. */
  52753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52754. }
  52755. }
  52756. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52757. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52758. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52759. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52761. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52762. import { Nullable } from "babylonjs/types";
  52763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52764. /** @hidden */
  52765. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52766. world: any;
  52767. name: string;
  52768. BJSOIMO: any;
  52769. private _raycastResult;
  52770. constructor(iterations?: number, oimoInjection?: any);
  52771. setGravity(gravity: Vector3): void;
  52772. setTimeStep(timeStep: number): void;
  52773. getTimeStep(): number;
  52774. private _tmpImpostorsArray;
  52775. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52776. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52777. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52778. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52779. private _tmpPositionVector;
  52780. removePhysicsBody(impostor: PhysicsImpostor): void;
  52781. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52782. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52783. isSupported(): boolean;
  52784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52785. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52786. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52790. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52791. getBodyMass(impostor: PhysicsImpostor): number;
  52792. getBodyFriction(impostor: PhysicsImpostor): number;
  52793. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52794. getBodyRestitution(impostor: PhysicsImpostor): number;
  52795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52796. sleepBody(impostor: PhysicsImpostor): void;
  52797. wakeUpBody(impostor: PhysicsImpostor): void;
  52798. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52799. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52801. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52802. getRadius(impostor: PhysicsImpostor): number;
  52803. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52804. dispose(): void;
  52805. /**
  52806. * Does a raycast in the physics world
  52807. * @param from when should the ray start?
  52808. * @param to when should the ray end?
  52809. * @returns PhysicsRaycastResult
  52810. */
  52811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52812. }
  52813. }
  52814. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52815. import { Nullable } from "babylonjs/types";
  52816. import { Scene } from "babylonjs/scene";
  52817. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52818. import { Color4 } from "babylonjs/Maths/math.color";
  52819. import { Mesh } from "babylonjs/Meshes/mesh";
  52820. /**
  52821. * Class containing static functions to help procedurally build meshes
  52822. */
  52823. export class RibbonBuilder {
  52824. /**
  52825. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52826. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52827. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52828. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52829. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  52830. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  52831. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  52832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52835. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  52836. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52837. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  52838. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52840. * @param name defines the name of the mesh
  52841. * @param options defines the options used to create the mesh
  52842. * @param scene defines the hosting scene
  52843. * @returns the ribbon mesh
  52844. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52846. */
  52847. static CreateRibbon(name: string, options: {
  52848. pathArray: Vector3[][];
  52849. closeArray?: boolean;
  52850. closePath?: boolean;
  52851. offset?: number;
  52852. updatable?: boolean;
  52853. sideOrientation?: number;
  52854. frontUVs?: Vector4;
  52855. backUVs?: Vector4;
  52856. instance?: Mesh;
  52857. invertUV?: boolean;
  52858. uvs?: Vector2[];
  52859. colors?: Color4[];
  52860. }, scene?: Nullable<Scene>): Mesh;
  52861. }
  52862. }
  52863. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52864. import { Nullable } from "babylonjs/types";
  52865. import { Scene } from "babylonjs/scene";
  52866. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52867. import { Mesh } from "babylonjs/Meshes/mesh";
  52868. /**
  52869. * Class containing static functions to help procedurally build meshes
  52870. */
  52871. export class ShapeBuilder {
  52872. /**
  52873. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52874. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  52875. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52876. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  52877. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52878. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  52879. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  52880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52885. * @param name defines the name of the mesh
  52886. * @param options defines the options used to create the mesh
  52887. * @param scene defines the hosting scene
  52888. * @returns the extruded shape mesh
  52889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52891. */
  52892. static ExtrudeShape(name: string, options: {
  52893. shape: Vector3[];
  52894. path: Vector3[];
  52895. scale?: number;
  52896. rotation?: number;
  52897. cap?: number;
  52898. updatable?: boolean;
  52899. sideOrientation?: number;
  52900. frontUVs?: Vector4;
  52901. backUVs?: Vector4;
  52902. instance?: Mesh;
  52903. invertUV?: boolean;
  52904. }, scene?: Nullable<Scene>): Mesh;
  52905. /**
  52906. * Creates an custom extruded shape mesh.
  52907. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52908. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  52909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52910. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  52911. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52912. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  52913. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52914. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52915. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52916. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  52917. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  52918. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52923. * @param name defines the name of the mesh
  52924. * @param options defines the options used to create the mesh
  52925. * @param scene defines the hosting scene
  52926. * @returns the custom extruded shape mesh
  52927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52930. */
  52931. static ExtrudeShapeCustom(name: string, options: {
  52932. shape: Vector3[];
  52933. path: Vector3[];
  52934. scaleFunction?: any;
  52935. rotationFunction?: any;
  52936. ribbonCloseArray?: boolean;
  52937. ribbonClosePath?: boolean;
  52938. cap?: number;
  52939. updatable?: boolean;
  52940. sideOrientation?: number;
  52941. frontUVs?: Vector4;
  52942. backUVs?: Vector4;
  52943. instance?: Mesh;
  52944. invertUV?: boolean;
  52945. }, scene?: Nullable<Scene>): Mesh;
  52946. private static _ExtrudeShapeGeneric;
  52947. }
  52948. }
  52949. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52950. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52951. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52952. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52953. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52954. import { Nullable } from "babylonjs/types";
  52955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52956. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52957. /**
  52958. * AmmoJS Physics plugin
  52959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52960. * @see https://github.com/kripken/ammo.js/
  52961. */
  52962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52963. private _useDeltaForWorldStep;
  52964. /**
  52965. * Reference to the Ammo library
  52966. */
  52967. bjsAMMO: any;
  52968. /**
  52969. * Created ammoJS world which physics bodies are added to
  52970. */
  52971. world: any;
  52972. /**
  52973. * Name of the plugin
  52974. */
  52975. name: string;
  52976. private _timeStep;
  52977. private _fixedTimeStep;
  52978. private _maxSteps;
  52979. private _tmpQuaternion;
  52980. private _tmpAmmoTransform;
  52981. private _tmpAmmoQuaternion;
  52982. private _tmpAmmoConcreteContactResultCallback;
  52983. private _collisionConfiguration;
  52984. private _dispatcher;
  52985. private _overlappingPairCache;
  52986. private _solver;
  52987. private _softBodySolver;
  52988. private _tmpAmmoVectorA;
  52989. private _tmpAmmoVectorB;
  52990. private _tmpAmmoVectorC;
  52991. private _tmpAmmoVectorD;
  52992. private _tmpContactCallbackResult;
  52993. private _tmpAmmoVectorRCA;
  52994. private _tmpAmmoVectorRCB;
  52995. private _raycastResult;
  52996. private static readonly DISABLE_COLLISION_FLAG;
  52997. private static readonly KINEMATIC_FLAG;
  52998. private static readonly DISABLE_DEACTIVATION_FLAG;
  52999. /**
  53000. * Initializes the ammoJS plugin
  53001. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53002. * @param ammoInjection can be used to inject your own ammo reference
  53003. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53004. */
  53005. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53006. /**
  53007. * Sets the gravity of the physics world (m/(s^2))
  53008. * @param gravity Gravity to set
  53009. */
  53010. setGravity(gravity: Vector3): void;
  53011. /**
  53012. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53013. * @param timeStep timestep to use in seconds
  53014. */
  53015. setTimeStep(timeStep: number): void;
  53016. /**
  53017. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  53018. * @param fixedTimeStep fixedTimeStep to use in seconds
  53019. */
  53020. setFixedTimeStep(fixedTimeStep: number): void;
  53021. /**
  53022. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53023. * @param maxSteps the maximum number of steps by the physics engine per frame
  53024. */
  53025. setMaxSteps(maxSteps: number): void;
  53026. /**
  53027. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53028. * @returns the current timestep in seconds
  53029. */
  53030. getTimeStep(): number;
  53031. private _isImpostorInContact;
  53032. private _isImpostorPairInContact;
  53033. private _stepSimulation;
  53034. /**
  53035. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53036. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53037. * After the step the babylon meshes are set to the position of the physics imposters
  53038. * @param delta amount of time to step forward
  53039. * @param impostors array of imposters to update before/after the step
  53040. */
  53041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53042. /**
  53043. * Update babylon mesh to match physics world object
  53044. * @param impostor imposter to match
  53045. */
  53046. private _afterSoftStep;
  53047. /**
  53048. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53049. * @param impostor imposter to match
  53050. */
  53051. private _ropeStep;
  53052. /**
  53053. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53054. * @param impostor imposter to match
  53055. */
  53056. private _softbodyOrClothStep;
  53057. private _tmpVector;
  53058. private _tmpMatrix;
  53059. /**
  53060. * Applies an impulse on the imposter
  53061. * @param impostor imposter to apply impulse to
  53062. * @param force amount of force to be applied to the imposter
  53063. * @param contactPoint the location to apply the impulse on the imposter
  53064. */
  53065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53066. /**
  53067. * Applies a force on the imposter
  53068. * @param impostor imposter to apply force
  53069. * @param force amount of force to be applied to the imposter
  53070. * @param contactPoint the location to apply the force on the imposter
  53071. */
  53072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53073. /**
  53074. * Creates a physics body using the plugin
  53075. * @param impostor the imposter to create the physics body on
  53076. */
  53077. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53078. /**
  53079. * Removes the physics body from the imposter and disposes of the body's memory
  53080. * @param impostor imposter to remove the physics body from
  53081. */
  53082. removePhysicsBody(impostor: PhysicsImpostor): void;
  53083. /**
  53084. * Generates a joint
  53085. * @param impostorJoint the imposter joint to create the joint with
  53086. */
  53087. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53088. /**
  53089. * Removes a joint
  53090. * @param impostorJoint the imposter joint to remove the joint from
  53091. */
  53092. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53093. private _addMeshVerts;
  53094. /**
  53095. * Initialise the soft body vertices to match its object's (mesh) vertices
  53096. * Softbody vertices (nodes) are in world space and to match this
  53097. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53098. * @param impostor to create the softbody for
  53099. */
  53100. private _softVertexData;
  53101. /**
  53102. * Create an impostor's soft body
  53103. * @param impostor to create the softbody for
  53104. */
  53105. private _createSoftbody;
  53106. /**
  53107. * Create cloth for an impostor
  53108. * @param impostor to create the softbody for
  53109. */
  53110. private _createCloth;
  53111. /**
  53112. * Create rope for an impostor
  53113. * @param impostor to create the softbody for
  53114. */
  53115. private _createRope;
  53116. private _addHullVerts;
  53117. private _createShape;
  53118. /**
  53119. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53120. * @param impostor imposter containing the physics body and babylon object
  53121. */
  53122. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53123. /**
  53124. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53125. * @param impostor imposter containing the physics body and babylon object
  53126. * @param newPosition new position
  53127. * @param newRotation new rotation
  53128. */
  53129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53130. /**
  53131. * If this plugin is supported
  53132. * @returns true if its supported
  53133. */
  53134. isSupported(): boolean;
  53135. /**
  53136. * Sets the linear velocity of the physics body
  53137. * @param impostor imposter to set the velocity on
  53138. * @param velocity velocity to set
  53139. */
  53140. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53141. /**
  53142. * Sets the angular velocity of the physics body
  53143. * @param impostor imposter to set the velocity on
  53144. * @param velocity velocity to set
  53145. */
  53146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53147. /**
  53148. * gets the linear velocity
  53149. * @param impostor imposter to get linear velocity from
  53150. * @returns linear velocity
  53151. */
  53152. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53153. /**
  53154. * gets the angular velocity
  53155. * @param impostor imposter to get angular velocity from
  53156. * @returns angular velocity
  53157. */
  53158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53159. /**
  53160. * Sets the mass of physics body
  53161. * @param impostor imposter to set the mass on
  53162. * @param mass mass to set
  53163. */
  53164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53165. /**
  53166. * Gets the mass of the physics body
  53167. * @param impostor imposter to get the mass from
  53168. * @returns mass
  53169. */
  53170. getBodyMass(impostor: PhysicsImpostor): number;
  53171. /**
  53172. * Gets friction of the impostor
  53173. * @param impostor impostor to get friction from
  53174. * @returns friction value
  53175. */
  53176. getBodyFriction(impostor: PhysicsImpostor): number;
  53177. /**
  53178. * Sets friction of the impostor
  53179. * @param impostor impostor to set friction on
  53180. * @param friction friction value
  53181. */
  53182. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53183. /**
  53184. * Gets restitution of the impostor
  53185. * @param impostor impostor to get restitution from
  53186. * @returns restitution value
  53187. */
  53188. getBodyRestitution(impostor: PhysicsImpostor): number;
  53189. /**
  53190. * Sets resitution of the impostor
  53191. * @param impostor impostor to set resitution on
  53192. * @param restitution resitution value
  53193. */
  53194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53195. /**
  53196. * Gets pressure inside the impostor
  53197. * @param impostor impostor to get pressure from
  53198. * @returns pressure value
  53199. */
  53200. getBodyPressure(impostor: PhysicsImpostor): number;
  53201. /**
  53202. * Sets pressure inside a soft body impostor
  53203. * Cloth and rope must remain 0 pressure
  53204. * @param impostor impostor to set pressure on
  53205. * @param pressure pressure value
  53206. */
  53207. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53208. /**
  53209. * Gets stiffness of the impostor
  53210. * @param impostor impostor to get stiffness from
  53211. * @returns pressure value
  53212. */
  53213. getBodyStiffness(impostor: PhysicsImpostor): number;
  53214. /**
  53215. * Sets stiffness of the impostor
  53216. * @param impostor impostor to set stiffness on
  53217. * @param stiffness stiffness value from 0 to 1
  53218. */
  53219. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53220. /**
  53221. * Gets velocityIterations of the impostor
  53222. * @param impostor impostor to get velocity iterations from
  53223. * @returns velocityIterations value
  53224. */
  53225. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53226. /**
  53227. * Sets velocityIterations of the impostor
  53228. * @param impostor impostor to set velocity iterations on
  53229. * @param velocityIterations velocityIterations value
  53230. */
  53231. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53232. /**
  53233. * Gets positionIterations of the impostor
  53234. * @param impostor impostor to get position iterations from
  53235. * @returns positionIterations value
  53236. */
  53237. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53238. /**
  53239. * Sets positionIterations of the impostor
  53240. * @param impostor impostor to set position on
  53241. * @param positionIterations positionIterations value
  53242. */
  53243. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53244. /**
  53245. * Append an anchor to a cloth object
  53246. * @param impostor is the cloth impostor to add anchor to
  53247. * @param otherImpostor is the rigid impostor to anchor to
  53248. * @param width ratio across width from 0 to 1
  53249. * @param height ratio up height from 0 to 1
  53250. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53251. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53252. */
  53253. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53254. /**
  53255. * Append an hook to a rope object
  53256. * @param impostor is the rope impostor to add hook to
  53257. * @param otherImpostor is the rigid impostor to hook to
  53258. * @param length ratio along the rope from 0 to 1
  53259. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53260. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53261. */
  53262. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53263. /**
  53264. * Sleeps the physics body and stops it from being active
  53265. * @param impostor impostor to sleep
  53266. */
  53267. sleepBody(impostor: PhysicsImpostor): void;
  53268. /**
  53269. * Activates the physics body
  53270. * @param impostor impostor to activate
  53271. */
  53272. wakeUpBody(impostor: PhysicsImpostor): void;
  53273. /**
  53274. * Updates the distance parameters of the joint
  53275. * @param joint joint to update
  53276. * @param maxDistance maximum distance of the joint
  53277. * @param minDistance minimum distance of the joint
  53278. */
  53279. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53280. /**
  53281. * Sets a motor on the joint
  53282. * @param joint joint to set motor on
  53283. * @param speed speed of the motor
  53284. * @param maxForce maximum force of the motor
  53285. * @param motorIndex index of the motor
  53286. */
  53287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53288. /**
  53289. * Sets the motors limit
  53290. * @param joint joint to set limit on
  53291. * @param upperLimit upper limit
  53292. * @param lowerLimit lower limit
  53293. */
  53294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53295. /**
  53296. * Syncs the position and rotation of a mesh with the impostor
  53297. * @param mesh mesh to sync
  53298. * @param impostor impostor to update the mesh with
  53299. */
  53300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53301. /**
  53302. * Gets the radius of the impostor
  53303. * @param impostor impostor to get radius from
  53304. * @returns the radius
  53305. */
  53306. getRadius(impostor: PhysicsImpostor): number;
  53307. /**
  53308. * Gets the box size of the impostor
  53309. * @param impostor impostor to get box size from
  53310. * @param result the resulting box size
  53311. */
  53312. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53313. /**
  53314. * Disposes of the impostor
  53315. */
  53316. dispose(): void;
  53317. /**
  53318. * Does a raycast in the physics world
  53319. * @param from when should the ray start?
  53320. * @param to when should the ray end?
  53321. * @returns PhysicsRaycastResult
  53322. */
  53323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53324. }
  53325. }
  53326. declare module "babylonjs/Probes/reflectionProbe" {
  53327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53328. import { Vector3 } from "babylonjs/Maths/math.vector";
  53329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53330. import { Nullable } from "babylonjs/types";
  53331. import { Scene } from "babylonjs/scene";
  53332. module "babylonjs/abstractScene" {
  53333. interface AbstractScene {
  53334. /**
  53335. * The list of reflection probes added to the scene
  53336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53337. */
  53338. reflectionProbes: Array<ReflectionProbe>;
  53339. /**
  53340. * Removes the given reflection probe from this scene.
  53341. * @param toRemove The reflection probe to remove
  53342. * @returns The index of the removed reflection probe
  53343. */
  53344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53345. /**
  53346. * Adds the given reflection probe to this scene.
  53347. * @param newReflectionProbe The reflection probe to add
  53348. */
  53349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53350. }
  53351. }
  53352. /**
  53353. * Class used to generate realtime reflection / refraction cube textures
  53354. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53355. */
  53356. export class ReflectionProbe {
  53357. /** defines the name of the probe */
  53358. name: string;
  53359. private _scene;
  53360. private _renderTargetTexture;
  53361. private _projectionMatrix;
  53362. private _viewMatrix;
  53363. private _target;
  53364. private _add;
  53365. private _attachedMesh;
  53366. private _invertYAxis;
  53367. /** Gets or sets probe position (center of the cube map) */
  53368. position: Vector3;
  53369. /**
  53370. * Creates a new reflection probe
  53371. * @param name defines the name of the probe
  53372. * @param size defines the texture resolution (for each face)
  53373. * @param scene defines the hosting scene
  53374. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53375. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53376. */
  53377. constructor(
  53378. /** defines the name of the probe */
  53379. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53380. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53381. samples: number;
  53382. /** Gets or sets the refresh rate to use (on every frame by default) */
  53383. refreshRate: number;
  53384. /**
  53385. * Gets the hosting scene
  53386. * @returns a Scene
  53387. */
  53388. getScene(): Scene;
  53389. /** Gets the internal CubeTexture used to render to */
  53390. readonly cubeTexture: RenderTargetTexture;
  53391. /** Gets the list of meshes to render */
  53392. readonly renderList: Nullable<AbstractMesh[]>;
  53393. /**
  53394. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53395. * @param mesh defines the mesh to attach to
  53396. */
  53397. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53398. /**
  53399. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53400. * @param renderingGroupId The rendering group id corresponding to its index
  53401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53402. */
  53403. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53404. /**
  53405. * Clean all associated resources
  53406. */
  53407. dispose(): void;
  53408. /**
  53409. * Converts the reflection probe information to a readable string for debug purpose.
  53410. * @param fullDetails Supports for multiple levels of logging within scene loading
  53411. * @returns the human readable reflection probe info
  53412. */
  53413. toString(fullDetails?: boolean): string;
  53414. /**
  53415. * Get the class name of the relfection probe.
  53416. * @returns "ReflectionProbe"
  53417. */
  53418. getClassName(): string;
  53419. /**
  53420. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53421. * @returns The JSON representation of the texture
  53422. */
  53423. serialize(): any;
  53424. /**
  53425. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53426. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53427. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53428. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53429. * @returns The parsed reflection probe if successful
  53430. */
  53431. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53432. }
  53433. }
  53434. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53435. /** @hidden */
  53436. export var _BabylonLoaderRegistered: boolean;
  53437. }
  53438. declare module "babylonjs/Loading/Plugins/index" {
  53439. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53440. }
  53441. declare module "babylonjs/Loading/index" {
  53442. export * from "babylonjs/Loading/loadingScreen";
  53443. export * from "babylonjs/Loading/Plugins/index";
  53444. export * from "babylonjs/Loading/sceneLoader";
  53445. export * from "babylonjs/Loading/sceneLoaderFlags";
  53446. }
  53447. declare module "babylonjs/Materials/Background/index" {
  53448. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53449. }
  53450. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53451. import { Scene } from "babylonjs/scene";
  53452. import { Color3 } from "babylonjs/Maths/math.color";
  53453. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53455. /**
  53456. * The Physically based simple base material of BJS.
  53457. *
  53458. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53459. * It is used as the base class for both the specGloss and metalRough conventions.
  53460. */
  53461. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53462. /**
  53463. * Number of Simultaneous lights allowed on the material.
  53464. */
  53465. maxSimultaneousLights: number;
  53466. /**
  53467. * If sets to true, disables all the lights affecting the material.
  53468. */
  53469. disableLighting: boolean;
  53470. /**
  53471. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53472. */
  53473. environmentTexture: BaseTexture;
  53474. /**
  53475. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53476. */
  53477. invertNormalMapX: boolean;
  53478. /**
  53479. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53480. */
  53481. invertNormalMapY: boolean;
  53482. /**
  53483. * Normal map used in the model.
  53484. */
  53485. normalTexture: BaseTexture;
  53486. /**
  53487. * Emissivie color used to self-illuminate the model.
  53488. */
  53489. emissiveColor: Color3;
  53490. /**
  53491. * Emissivie texture used to self-illuminate the model.
  53492. */
  53493. emissiveTexture: BaseTexture;
  53494. /**
  53495. * Occlusion Channel Strenght.
  53496. */
  53497. occlusionStrength: number;
  53498. /**
  53499. * Occlusion Texture of the material (adding extra occlusion effects).
  53500. */
  53501. occlusionTexture: BaseTexture;
  53502. /**
  53503. * Defines the alpha limits in alpha test mode.
  53504. */
  53505. alphaCutOff: number;
  53506. /**
  53507. * Gets the current double sided mode.
  53508. */
  53509. /**
  53510. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53511. */
  53512. doubleSided: boolean;
  53513. /**
  53514. * Stores the pre-calculated light information of a mesh in a texture.
  53515. */
  53516. lightmapTexture: BaseTexture;
  53517. /**
  53518. * If true, the light map contains occlusion information instead of lighting info.
  53519. */
  53520. useLightmapAsShadowmap: boolean;
  53521. /**
  53522. * Instantiates a new PBRMaterial instance.
  53523. *
  53524. * @param name The material name
  53525. * @param scene The scene the material will be use in.
  53526. */
  53527. constructor(name: string, scene: Scene);
  53528. getClassName(): string;
  53529. }
  53530. }
  53531. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53532. import { Scene } from "babylonjs/scene";
  53533. import { Color3 } from "babylonjs/Maths/math.color";
  53534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53535. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53536. /**
  53537. * The PBR material of BJS following the metal roughness convention.
  53538. *
  53539. * This fits to the PBR convention in the GLTF definition:
  53540. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53541. */
  53542. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53543. /**
  53544. * The base color has two different interpretations depending on the value of metalness.
  53545. * When the material is a metal, the base color is the specific measured reflectance value
  53546. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53547. * of the material.
  53548. */
  53549. baseColor: Color3;
  53550. /**
  53551. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53552. * well as opacity information in the alpha channel.
  53553. */
  53554. baseTexture: BaseTexture;
  53555. /**
  53556. * Specifies the metallic scalar value of the material.
  53557. * Can also be used to scale the metalness values of the metallic texture.
  53558. */
  53559. metallic: number;
  53560. /**
  53561. * Specifies the roughness scalar value of the material.
  53562. * Can also be used to scale the roughness values of the metallic texture.
  53563. */
  53564. roughness: number;
  53565. /**
  53566. * Texture containing both the metallic value in the B channel and the
  53567. * roughness value in the G channel to keep better precision.
  53568. */
  53569. metallicRoughnessTexture: BaseTexture;
  53570. /**
  53571. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53572. *
  53573. * @param name The material name
  53574. * @param scene The scene the material will be use in.
  53575. */
  53576. constructor(name: string, scene: Scene);
  53577. /**
  53578. * Return the currrent class name of the material.
  53579. */
  53580. getClassName(): string;
  53581. /**
  53582. * Makes a duplicate of the current material.
  53583. * @param name - name to use for the new material.
  53584. */
  53585. clone(name: string): PBRMetallicRoughnessMaterial;
  53586. /**
  53587. * Serialize the material to a parsable JSON object.
  53588. */
  53589. serialize(): any;
  53590. /**
  53591. * Parses a JSON object correponding to the serialize function.
  53592. */
  53593. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53594. }
  53595. }
  53596. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53597. import { Scene } from "babylonjs/scene";
  53598. import { Color3 } from "babylonjs/Maths/math.color";
  53599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53600. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53601. /**
  53602. * The PBR material of BJS following the specular glossiness convention.
  53603. *
  53604. * This fits to the PBR convention in the GLTF definition:
  53605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53606. */
  53607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53608. /**
  53609. * Specifies the diffuse color of the material.
  53610. */
  53611. diffuseColor: Color3;
  53612. /**
  53613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53614. * channel.
  53615. */
  53616. diffuseTexture: BaseTexture;
  53617. /**
  53618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53619. */
  53620. specularColor: Color3;
  53621. /**
  53622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53623. */
  53624. glossiness: number;
  53625. /**
  53626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53627. */
  53628. specularGlossinessTexture: BaseTexture;
  53629. /**
  53630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53631. *
  53632. * @param name The material name
  53633. * @param scene The scene the material will be use in.
  53634. */
  53635. constructor(name: string, scene: Scene);
  53636. /**
  53637. * Return the currrent class name of the material.
  53638. */
  53639. getClassName(): string;
  53640. /**
  53641. * Makes a duplicate of the current material.
  53642. * @param name - name to use for the new material.
  53643. */
  53644. clone(name: string): PBRSpecularGlossinessMaterial;
  53645. /**
  53646. * Serialize the material to a parsable JSON object.
  53647. */
  53648. serialize(): any;
  53649. /**
  53650. * Parses a JSON object correponding to the serialize function.
  53651. */
  53652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53653. }
  53654. }
  53655. declare module "babylonjs/Materials/PBR/index" {
  53656. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53657. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53658. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53659. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53660. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53661. }
  53662. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53663. import { Nullable } from "babylonjs/types";
  53664. import { Scene } from "babylonjs/scene";
  53665. import { Matrix } from "babylonjs/Maths/math.vector";
  53666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53667. /**
  53668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53669. * It can help converting any input color in a desired output one. This can then be used to create effects
  53670. * from sepia, black and white to sixties or futuristic rendering...
  53671. *
  53672. * The only supported format is currently 3dl.
  53673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53674. */
  53675. export class ColorGradingTexture extends BaseTexture {
  53676. /**
  53677. * The current texture matrix. (will always be identity in color grading texture)
  53678. */
  53679. private _textureMatrix;
  53680. /**
  53681. * The texture URL.
  53682. */
  53683. url: string;
  53684. /**
  53685. * Empty line regex stored for GC.
  53686. */
  53687. private static _noneEmptyLineRegex;
  53688. private _engine;
  53689. /**
  53690. * Instantiates a ColorGradingTexture from the following parameters.
  53691. *
  53692. * @param url The location of the color gradind data (currently only supporting 3dl)
  53693. * @param scene The scene the texture will be used in
  53694. */
  53695. constructor(url: string, scene: Scene);
  53696. /**
  53697. * Returns the texture matrix used in most of the material.
  53698. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53699. */
  53700. getTextureMatrix(): Matrix;
  53701. /**
  53702. * Occurs when the file being loaded is a .3dl LUT file.
  53703. */
  53704. private load3dlTexture;
  53705. /**
  53706. * Starts the loading process of the texture.
  53707. */
  53708. private loadTexture;
  53709. /**
  53710. * Clones the color gradind texture.
  53711. */
  53712. clone(): ColorGradingTexture;
  53713. /**
  53714. * Called during delayed load for textures.
  53715. */
  53716. delayLoad(): void;
  53717. /**
  53718. * Parses a color grading texture serialized by Babylon.
  53719. * @param parsedTexture The texture information being parsedTexture
  53720. * @param scene The scene to load the texture in
  53721. * @param rootUrl The root url of the data assets to load
  53722. * @return A color gradind texture
  53723. */
  53724. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53725. /**
  53726. * Serializes the LUT texture to json format.
  53727. */
  53728. serialize(): any;
  53729. }
  53730. }
  53731. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53733. import { Scene } from "babylonjs/scene";
  53734. import { Nullable } from "babylonjs/types";
  53735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53736. /**
  53737. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53738. */
  53739. export class EquiRectangularCubeTexture extends BaseTexture {
  53740. /** The six faces of the cube. */
  53741. private static _FacesMapping;
  53742. private _noMipmap;
  53743. private _onLoad;
  53744. private _onError;
  53745. /** The size of the cubemap. */
  53746. private _size;
  53747. /** The buffer of the image. */
  53748. private _buffer;
  53749. /** The width of the input image. */
  53750. private _width;
  53751. /** The height of the input image. */
  53752. private _height;
  53753. /** The URL to the image. */
  53754. url: string;
  53755. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53756. coordinatesMode: number;
  53757. /**
  53758. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53759. * @param url The location of the image
  53760. * @param scene The scene the texture will be used in
  53761. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53762. * @param noMipmap Forces to not generate the mipmap if true
  53763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53765. * @param onLoad — defines a callback called when texture is loaded
  53766. * @param onError — defines a callback called if there is an error
  53767. */
  53768. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53769. /**
  53770. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53771. */
  53772. private loadImage;
  53773. /**
  53774. * Convert the image buffer into a cubemap and create a CubeTexture.
  53775. */
  53776. private loadTexture;
  53777. /**
  53778. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53779. * @param buffer The ArrayBuffer that should be converted.
  53780. * @returns The buffer as Float32Array.
  53781. */
  53782. private getFloat32ArrayFromArrayBuffer;
  53783. /**
  53784. * Get the current class name of the texture useful for serialization or dynamic coding.
  53785. * @returns "EquiRectangularCubeTexture"
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53790. * @returns A clone of the current EquiRectangularCubeTexture.
  53791. */
  53792. clone(): EquiRectangularCubeTexture;
  53793. }
  53794. }
  53795. declare module "babylonjs/Misc/tga" {
  53796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53797. /**
  53798. * Based on jsTGALoader - Javascript loader for TGA file
  53799. * By Vincent Thibault
  53800. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53801. */
  53802. export class TGATools {
  53803. private static _TYPE_INDEXED;
  53804. private static _TYPE_RGB;
  53805. private static _TYPE_GREY;
  53806. private static _TYPE_RLE_INDEXED;
  53807. private static _TYPE_RLE_RGB;
  53808. private static _TYPE_RLE_GREY;
  53809. private static _ORIGIN_MASK;
  53810. private static _ORIGIN_SHIFT;
  53811. private static _ORIGIN_BL;
  53812. private static _ORIGIN_BR;
  53813. private static _ORIGIN_UL;
  53814. private static _ORIGIN_UR;
  53815. /**
  53816. * Gets the header of a TGA file
  53817. * @param data defines the TGA data
  53818. * @returns the header
  53819. */
  53820. static GetTGAHeader(data: Uint8Array): any;
  53821. /**
  53822. * Uploads TGA content to a Babylon Texture
  53823. * @hidden
  53824. */
  53825. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53826. /** @hidden */
  53827. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53828. /** @hidden */
  53829. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53830. /** @hidden */
  53831. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53832. /** @hidden */
  53833. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53834. /** @hidden */
  53835. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53836. /** @hidden */
  53837. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53838. }
  53839. }
  53840. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53841. import { Nullable } from "babylonjs/types";
  53842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53843. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53844. /**
  53845. * Implementation of the TGA Texture Loader.
  53846. * @hidden
  53847. */
  53848. export class _TGATextureLoader implements IInternalTextureLoader {
  53849. /**
  53850. * Defines wether the loader supports cascade loading the different faces.
  53851. */
  53852. readonly supportCascades: boolean;
  53853. /**
  53854. * This returns if the loader support the current file information.
  53855. * @param extension defines the file extension of the file being loaded
  53856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53857. * @param fallback defines the fallback internal texture if any
  53858. * @param isBase64 defines whether the texture is encoded as a base64
  53859. * @param isBuffer defines whether the texture data are stored as a buffer
  53860. * @returns true if the loader can load the specified file
  53861. */
  53862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53863. /**
  53864. * Transform the url before loading if required.
  53865. * @param rootUrl the url of the texture
  53866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53867. * @returns the transformed texture
  53868. */
  53869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53870. /**
  53871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53872. * @param rootUrl the url of the texture
  53873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53874. * @returns the fallback texture
  53875. */
  53876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53877. /**
  53878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53879. * @param data contains the texture data
  53880. * @param texture defines the BabylonJS internal texture
  53881. * @param createPolynomials will be true if polynomials have been requested
  53882. * @param onLoad defines the callback to trigger once the texture is ready
  53883. * @param onError defines the callback to trigger in case of error
  53884. */
  53885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53886. /**
  53887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53888. * @param data contains the texture data
  53889. * @param texture defines the BabylonJS internal texture
  53890. * @param callback defines the method to call once ready to upload
  53891. */
  53892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53893. }
  53894. }
  53895. declare module "babylonjs/Misc/basis" {
  53896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53897. /**
  53898. * Info about the .basis files
  53899. */
  53900. class BasisFileInfo {
  53901. /**
  53902. * If the file has alpha
  53903. */
  53904. hasAlpha: boolean;
  53905. /**
  53906. * Info about each image of the basis file
  53907. */
  53908. images: Array<{
  53909. levels: Array<{
  53910. width: number;
  53911. height: number;
  53912. transcodedPixels: ArrayBufferView;
  53913. }>;
  53914. }>;
  53915. }
  53916. /**
  53917. * Result of transcoding a basis file
  53918. */
  53919. class TranscodeResult {
  53920. /**
  53921. * Info about the .basis file
  53922. */
  53923. fileInfo: BasisFileInfo;
  53924. /**
  53925. * Format to use when loading the file
  53926. */
  53927. format: number;
  53928. }
  53929. /**
  53930. * Configuration options for the Basis transcoder
  53931. */
  53932. export class BasisTranscodeConfiguration {
  53933. /**
  53934. * Supported compression formats used to determine the supported output format of the transcoder
  53935. */
  53936. supportedCompressionFormats?: {
  53937. /**
  53938. * etc1 compression format
  53939. */
  53940. etc1?: boolean;
  53941. /**
  53942. * s3tc compression format
  53943. */
  53944. s3tc?: boolean;
  53945. /**
  53946. * pvrtc compression format
  53947. */
  53948. pvrtc?: boolean;
  53949. /**
  53950. * etc2 compression format
  53951. */
  53952. etc2?: boolean;
  53953. };
  53954. /**
  53955. * If mipmap levels should be loaded for transcoded images (Default: true)
  53956. */
  53957. loadMipmapLevels?: boolean;
  53958. /**
  53959. * Index of a single image to load (Default: all images)
  53960. */
  53961. loadSingleImage?: number;
  53962. }
  53963. /**
  53964. * Used to load .Basis files
  53965. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53966. */
  53967. export class BasisTools {
  53968. private static _IgnoreSupportedFormats;
  53969. /**
  53970. * URL to use when loading the basis transcoder
  53971. */
  53972. static JSModuleURL: string;
  53973. /**
  53974. * URL to use when loading the wasm module for the transcoder
  53975. */
  53976. static WasmModuleURL: string;
  53977. /**
  53978. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53979. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53980. * @returns internal format corresponding to the Basis format
  53981. */
  53982. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53983. private static _WorkerPromise;
  53984. private static _Worker;
  53985. private static _actionId;
  53986. private static _CreateWorkerAsync;
  53987. /**
  53988. * Transcodes a loaded image file to compressed pixel data
  53989. * @param imageData image data to transcode
  53990. * @param config configuration options for the transcoding
  53991. * @returns a promise resulting in the transcoded image
  53992. */
  53993. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53994. /**
  53995. * Loads a texture from the transcode result
  53996. * @param texture texture load to
  53997. * @param transcodeResult the result of transcoding the basis file to load from
  53998. */
  53999. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54003. import { Nullable } from "babylonjs/types";
  54004. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54005. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54006. /**
  54007. * Loader for .basis file format
  54008. */
  54009. export class _BasisTextureLoader implements IInternalTextureLoader {
  54010. /**
  54011. * Defines whether the loader supports cascade loading the different faces.
  54012. */
  54013. readonly supportCascades: boolean;
  54014. /**
  54015. * This returns if the loader support the current file information.
  54016. * @param extension defines the file extension of the file being loaded
  54017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54018. * @param fallback defines the fallback internal texture if any
  54019. * @param isBase64 defines whether the texture is encoded as a base64
  54020. * @param isBuffer defines whether the texture data are stored as a buffer
  54021. * @returns true if the loader can load the specified file
  54022. */
  54023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54024. /**
  54025. * Transform the url before loading if required.
  54026. * @param rootUrl the url of the texture
  54027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54028. * @returns the transformed texture
  54029. */
  54030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54031. /**
  54032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54033. * @param rootUrl the url of the texture
  54034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54035. * @returns the fallback texture
  54036. */
  54037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54038. /**
  54039. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54040. * @param data contains the texture data
  54041. * @param texture defines the BabylonJS internal texture
  54042. * @param createPolynomials will be true if polynomials have been requested
  54043. * @param onLoad defines the callback to trigger once the texture is ready
  54044. * @param onError defines the callback to trigger in case of error
  54045. */
  54046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54047. /**
  54048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54049. * @param data contains the texture data
  54050. * @param texture defines the BabylonJS internal texture
  54051. * @param callback defines the method to call once ready to upload
  54052. */
  54053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54057. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54058. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54059. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54060. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54061. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54062. }
  54063. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54064. import { Scene } from "babylonjs/scene";
  54065. import { Texture } from "babylonjs/Materials/Textures/texture";
  54066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54067. /**
  54068. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  54069. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54071. */
  54072. export class CustomProceduralTexture extends ProceduralTexture {
  54073. private _animate;
  54074. private _time;
  54075. private _config;
  54076. private _texturePath;
  54077. /**
  54078. * Instantiates a new Custom Procedural Texture.
  54079. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  54080. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54081. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54082. * @param name Define the name of the texture
  54083. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54084. * @param size Define the size of the texture to create
  54085. * @param scene Define the scene the texture belongs to
  54086. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54087. * @param generateMipMaps Define if the texture should creates mip maps or not
  54088. */
  54089. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54090. private _loadJson;
  54091. /**
  54092. * Is the texture ready to be used ? (rendered at least once)
  54093. * @returns true if ready, otherwise, false.
  54094. */
  54095. isReady(): boolean;
  54096. /**
  54097. * Render the texture to its associated render target.
  54098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54099. */
  54100. render(useCameraPostProcess?: boolean): void;
  54101. /**
  54102. * Update the list of dependant textures samplers in the shader.
  54103. */
  54104. updateTextures(): void;
  54105. /**
  54106. * Update the uniform values of the procedural texture in the shader.
  54107. */
  54108. updateShaderUniforms(): void;
  54109. /**
  54110. * Define if the texture animates or not.
  54111. */
  54112. animate: boolean;
  54113. }
  54114. }
  54115. declare module "babylonjs/Shaders/noise.fragment" {
  54116. /** @hidden */
  54117. export var noisePixelShader: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54123. import { Nullable } from "babylonjs/types";
  54124. import { Scene } from "babylonjs/scene";
  54125. import { Texture } from "babylonjs/Materials/Textures/texture";
  54126. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54127. import "babylonjs/Shaders/noise.fragment";
  54128. /**
  54129. * Class used to generate noise procedural textures
  54130. */
  54131. export class NoiseProceduralTexture extends ProceduralTexture {
  54132. private _time;
  54133. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54134. brightness: number;
  54135. /** Defines the number of octaves to process */
  54136. octaves: number;
  54137. /** Defines the level of persistence (0.8 by default) */
  54138. persistence: number;
  54139. /** Gets or sets animation speed factor (default is 1) */
  54140. animationSpeedFactor: number;
  54141. /**
  54142. * Creates a new NoiseProceduralTexture
  54143. * @param name defines the name fo the texture
  54144. * @param size defines the size of the texture (default is 256)
  54145. * @param scene defines the hosting scene
  54146. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54147. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54148. */
  54149. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54150. private _updateShaderUniforms;
  54151. protected _getDefines(): string;
  54152. /** Generate the current state of the procedural texture */
  54153. render(useCameraPostProcess?: boolean): void;
  54154. /**
  54155. * Serializes this noise procedural texture
  54156. * @returns a serialized noise procedural texture object
  54157. */
  54158. serialize(): any;
  54159. /**
  54160. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54161. * @param parsedTexture defines parsed texture data
  54162. * @param scene defines the current scene
  54163. * @param rootUrl defines the root URL containing noise procedural texture information
  54164. * @returns a parsed NoiseProceduralTexture
  54165. */
  54166. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54167. }
  54168. }
  54169. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54170. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54171. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54172. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54173. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54174. }
  54175. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54176. import { Nullable } from "babylonjs/types";
  54177. import { Scene } from "babylonjs/scene";
  54178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54180. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54181. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54182. /**
  54183. * Raw cube texture where the raw buffers are passed in
  54184. */
  54185. export class RawCubeTexture extends CubeTexture {
  54186. /**
  54187. * Creates a cube texture where the raw buffers are passed in.
  54188. * @param scene defines the scene the texture is attached to
  54189. * @param data defines the array of data to use to create each face
  54190. * @param size defines the size of the textures
  54191. * @param format defines the format of the data
  54192. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54193. * @param generateMipMaps defines if the engine should generate the mip levels
  54194. * @param invertY defines if data must be stored with Y axis inverted
  54195. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54196. * @param compression defines the compression used (null by default)
  54197. */
  54198. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54199. /**
  54200. * Updates the raw cube texture.
  54201. * @param data defines the data to store
  54202. * @param format defines the data format
  54203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54204. * @param invertY defines if data must be stored with Y axis inverted
  54205. * @param compression defines the compression used (null by default)
  54206. * @param level defines which level of the texture to update
  54207. */
  54208. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54209. /**
  54210. * Updates a raw cube texture with RGBD encoded data.
  54211. * @param data defines the array of data [mipmap][face] to use to create each face
  54212. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54213. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54214. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54215. * @returns a promsie that resolves when the operation is complete
  54216. */
  54217. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54218. /**
  54219. * Clones the raw cube texture.
  54220. * @return a new cube texture
  54221. */
  54222. clone(): CubeTexture;
  54223. /** @hidden */
  54224. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54225. }
  54226. }
  54227. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54228. import { Scene } from "babylonjs/scene";
  54229. import { Texture } from "babylonjs/Materials/Textures/texture";
  54230. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54231. /**
  54232. * Class used to store 3D textures containing user data
  54233. */
  54234. export class RawTexture3D extends Texture {
  54235. /** Gets or sets the texture format to use */
  54236. format: number;
  54237. private _engine;
  54238. /**
  54239. * Create a new RawTexture3D
  54240. * @param data defines the data of the texture
  54241. * @param width defines the width of the texture
  54242. * @param height defines the height of the texture
  54243. * @param depth defines the depth of the texture
  54244. * @param format defines the texture format to use
  54245. * @param scene defines the hosting scene
  54246. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54247. * @param invertY defines if texture must be stored with Y axis inverted
  54248. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54250. */
  54251. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54252. /** Gets or sets the texture format to use */
  54253. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54254. /**
  54255. * Update the texture with new data
  54256. * @param data defines the data to store in the texture
  54257. */
  54258. update(data: ArrayBufferView): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54262. import { Scene } from "babylonjs/scene";
  54263. import { Plane } from "babylonjs/Maths/math.plane";
  54264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54265. /**
  54266. * Creates a refraction texture used by refraction channel of the standard material.
  54267. * It is like a mirror but to see through a material.
  54268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54269. */
  54270. export class RefractionTexture extends RenderTargetTexture {
  54271. /**
  54272. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54273. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  54274. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54275. */
  54276. refractionPlane: Plane;
  54277. /**
  54278. * Define how deep under the surface we should see.
  54279. */
  54280. depth: number;
  54281. /**
  54282. * Creates a refraction texture used by refraction channel of the standard material.
  54283. * It is like a mirror but to see through a material.
  54284. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54285. * @param name Define the texture name
  54286. * @param size Define the size of the underlying texture
  54287. * @param scene Define the scene the refraction belongs to
  54288. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54289. */
  54290. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54291. /**
  54292. * Clone the refraction texture.
  54293. * @returns the cloned texture
  54294. */
  54295. clone(): RefractionTexture;
  54296. /**
  54297. * Serialize the texture to a JSON representation you could use in Parse later on
  54298. * @returns the serialized JSON representation
  54299. */
  54300. serialize(): any;
  54301. }
  54302. }
  54303. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54304. import { Nullable } from "babylonjs/types";
  54305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54306. import { Matrix } from "babylonjs/Maths/math.vector";
  54307. import { Engine } from "babylonjs/Engines/engine";
  54308. import { Scene } from "babylonjs/scene";
  54309. /**
  54310. * Defines the options related to the creation of an HtmlElementTexture
  54311. */
  54312. export interface IHtmlElementTextureOptions {
  54313. /**
  54314. * Defines wether mip maps should be created or not.
  54315. */
  54316. generateMipMaps?: boolean;
  54317. /**
  54318. * Defines the sampling mode of the texture.
  54319. */
  54320. samplingMode?: number;
  54321. /**
  54322. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54323. */
  54324. engine: Nullable<Engine>;
  54325. /**
  54326. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54327. */
  54328. scene: Nullable<Scene>;
  54329. }
  54330. /**
  54331. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54332. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54333. * is automatically managed.
  54334. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54335. * in your application.
  54336. *
  54337. * As the update is not automatic, you need to call them manually.
  54338. */
  54339. export class HtmlElementTexture extends BaseTexture {
  54340. /**
  54341. * The texture URL.
  54342. */
  54343. element: HTMLVideoElement | HTMLCanvasElement;
  54344. private static readonly DefaultOptions;
  54345. private _textureMatrix;
  54346. private _engine;
  54347. private _isVideo;
  54348. private _generateMipMaps;
  54349. private _samplingMode;
  54350. /**
  54351. * Instantiates a HtmlElementTexture from the following parameters.
  54352. *
  54353. * @param name Defines the name of the texture
  54354. * @param element Defines the video or canvas the texture is filled with
  54355. * @param options Defines the other none mandatory texture creation options
  54356. */
  54357. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54358. private _createInternalTexture;
  54359. /**
  54360. * Returns the texture matrix used in most of the material.
  54361. */
  54362. getTextureMatrix(): Matrix;
  54363. /**
  54364. * Updates the content of the texture.
  54365. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54366. */
  54367. update(invertY?: Nullable<boolean>): void;
  54368. }
  54369. }
  54370. declare module "babylonjs/Materials/Textures/index" {
  54371. export * from "babylonjs/Materials/Textures/baseTexture";
  54372. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54373. export * from "babylonjs/Materials/Textures/cubeTexture";
  54374. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54375. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54376. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54377. export * from "babylonjs/Materials/Textures/internalTexture";
  54378. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54379. export * from "babylonjs/Materials/Textures/Loaders/index";
  54380. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54381. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54382. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54383. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54384. export * from "babylonjs/Materials/Textures/rawTexture";
  54385. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54386. export * from "babylonjs/Materials/Textures/refractionTexture";
  54387. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54388. export * from "babylonjs/Materials/Textures/texture";
  54389. export * from "babylonjs/Materials/Textures/videoTexture";
  54390. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54391. }
  54392. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54393. /**
  54394. * Enum used to define the target of a block
  54395. */
  54396. export enum NodeMaterialBlockTargets {
  54397. /** Vertex shader */
  54398. Vertex = 1,
  54399. /** Fragment shader */
  54400. Fragment = 2,
  54401. /** Neutral */
  54402. Neutral = 4,
  54403. /** Vertex and Fragment */
  54404. VertexAndFragment = 3
  54405. }
  54406. }
  54407. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54408. /**
  54409. * Defines the kind of connection point for node based material
  54410. */
  54411. export enum NodeMaterialBlockConnectionPointTypes {
  54412. /** Float */
  54413. Float = 1,
  54414. /** Int */
  54415. Int = 2,
  54416. /** Vector2 */
  54417. Vector2 = 4,
  54418. /** Vector3 */
  54419. Vector3 = 8,
  54420. /** Vector4 */
  54421. Vector4 = 16,
  54422. /** Color3 */
  54423. Color3 = 32,
  54424. /** Color4 */
  54425. Color4 = 64,
  54426. /** Matrix */
  54427. Matrix = 128,
  54428. /** Detect type based on connection */
  54429. AutoDetect = 1024,
  54430. /** Output type that will be defined by input type */
  54431. BasedOnInput = 2048
  54432. }
  54433. }
  54434. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54435. /**
  54436. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54437. */
  54438. export enum NodeMaterialBlockConnectionPointMode {
  54439. /** Value is an uniform */
  54440. Uniform = 0,
  54441. /** Value is a mesh attribute */
  54442. Attribute = 1,
  54443. /** Value is a varying between vertex and fragment shaders */
  54444. Varying = 2,
  54445. /** Mode is undefined */
  54446. Undefined = 3
  54447. }
  54448. }
  54449. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54450. /**
  54451. * Enum used to define system values e.g. values automatically provided by the system
  54452. */
  54453. export enum NodeMaterialSystemValues {
  54454. /** World */
  54455. World = 1,
  54456. /** View */
  54457. View = 2,
  54458. /** Projection */
  54459. Projection = 3,
  54460. /** ViewProjection */
  54461. ViewProjection = 4,
  54462. /** WorldView */
  54463. WorldView = 5,
  54464. /** WorldViewProjection */
  54465. WorldViewProjection = 6,
  54466. /** CameraPosition */
  54467. CameraPosition = 7,
  54468. /** Fog Color */
  54469. FogColor = 8
  54470. }
  54471. }
  54472. declare module "babylonjs/Materials/Node/Enums/index" {
  54473. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54474. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54475. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54476. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54477. }
  54478. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54480. /**
  54481. * Root class for all node material optimizers
  54482. */
  54483. export class NodeMaterialOptimizer {
  54484. /**
  54485. * Function used to optimize a NodeMaterial graph
  54486. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54487. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54488. */
  54489. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54490. }
  54491. }
  54492. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54496. import { Scene } from "babylonjs/scene";
  54497. /**
  54498. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54499. */
  54500. export class TransformBlock extends NodeMaterialBlock {
  54501. /**
  54502. * Defines the value to use to complement W value to transform it to a Vector4
  54503. */
  54504. complementW: number;
  54505. /**
  54506. * Defines the value to use to complement z value to transform it to a Vector4
  54507. */
  54508. complementZ: number;
  54509. /**
  54510. * Creates a new TransformBlock
  54511. * @param name defines the block name
  54512. */
  54513. constructor(name: string);
  54514. /**
  54515. * Gets the current class name
  54516. * @returns the class name
  54517. */
  54518. getClassName(): string;
  54519. /**
  54520. * Gets the vector input
  54521. */
  54522. readonly vector: NodeMaterialConnectionPoint;
  54523. /**
  54524. * Gets the output component
  54525. */
  54526. readonly output: NodeMaterialConnectionPoint;
  54527. /**
  54528. * Gets the matrix transform input
  54529. */
  54530. readonly transform: NodeMaterialConnectionPoint;
  54531. protected _buildBlock(state: NodeMaterialBuildState): this;
  54532. serialize(): any;
  54533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54534. protected _dumpPropertiesCode(): string;
  54535. }
  54536. }
  54537. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54541. /**
  54542. * Block used to output the vertex position
  54543. */
  54544. export class VertexOutputBlock extends NodeMaterialBlock {
  54545. /**
  54546. * Creates a new VertexOutputBlock
  54547. * @param name defines the block name
  54548. */
  54549. constructor(name: string);
  54550. /**
  54551. * Gets the current class name
  54552. * @returns the class name
  54553. */
  54554. getClassName(): string;
  54555. /**
  54556. * Gets the vector input component
  54557. */
  54558. readonly vector: NodeMaterialConnectionPoint;
  54559. protected _buildBlock(state: NodeMaterialBuildState): this;
  54560. }
  54561. }
  54562. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54566. /**
  54567. * Block used to output the final color
  54568. */
  54569. export class FragmentOutputBlock extends NodeMaterialBlock {
  54570. /**
  54571. * Create a new FragmentOutputBlock
  54572. * @param name defines the block name
  54573. */
  54574. constructor(name: string);
  54575. /**
  54576. * Gets the current class name
  54577. * @returns the class name
  54578. */
  54579. getClassName(): string;
  54580. /**
  54581. * Gets the rgba input component
  54582. */
  54583. readonly rgba: NodeMaterialConnectionPoint;
  54584. /**
  54585. * Gets the rgb input component
  54586. */
  54587. readonly rgb: NodeMaterialConnectionPoint;
  54588. /**
  54589. * Gets the a input component
  54590. */
  54591. readonly a: NodeMaterialConnectionPoint;
  54592. protected _buildBlock(state: NodeMaterialBuildState): this;
  54593. }
  54594. }
  54595. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54596. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54598. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54601. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54602. import { Effect } from "babylonjs/Materials/effect";
  54603. import { Mesh } from "babylonjs/Meshes/mesh";
  54604. import { Nullable } from "babylonjs/types";
  54605. import { Scene } from "babylonjs/scene";
  54606. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54607. /**
  54608. * Block used to read a reflection texture from a sampler
  54609. */
  54610. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54611. private _define3DName;
  54612. private _defineCubicName;
  54613. private _defineExplicitName;
  54614. private _defineProjectionName;
  54615. private _defineLocalCubicName;
  54616. private _defineSphericalName;
  54617. private _definePlanarName;
  54618. private _defineEquirectangularName;
  54619. private _defineMirroredEquirectangularFixedName;
  54620. private _defineEquirectangularFixedName;
  54621. private _defineSkyboxName;
  54622. private _cubeSamplerName;
  54623. private _2DSamplerName;
  54624. private _positionUVWName;
  54625. private _directionWName;
  54626. private _reflectionCoordsName;
  54627. private _reflection2DCoordsName;
  54628. private _reflectionColorName;
  54629. private _reflectionMatrixName;
  54630. /**
  54631. * Gets or sets the texture associated with the node
  54632. */
  54633. texture: Nullable<BaseTexture>;
  54634. /**
  54635. * Create a new TextureBlock
  54636. * @param name defines the block name
  54637. */
  54638. constructor(name: string);
  54639. /**
  54640. * Gets the current class name
  54641. * @returns the class name
  54642. */
  54643. getClassName(): string;
  54644. /**
  54645. * Gets the world position input component
  54646. */
  54647. readonly position: NodeMaterialConnectionPoint;
  54648. /**
  54649. * Gets the world position input component
  54650. */
  54651. readonly worldPosition: NodeMaterialConnectionPoint;
  54652. /**
  54653. * Gets the world normal input component
  54654. */
  54655. readonly worldNormal: NodeMaterialConnectionPoint;
  54656. /**
  54657. * Gets the world input component
  54658. */
  54659. readonly world: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the camera (or eye) position component
  54662. */
  54663. readonly cameraPosition: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the view input component
  54666. */
  54667. readonly view: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the rgb output component
  54670. */
  54671. readonly rgb: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the r output component
  54674. */
  54675. readonly r: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the g output component
  54678. */
  54679. readonly g: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the b output component
  54682. */
  54683. readonly b: NodeMaterialConnectionPoint;
  54684. autoConfigure(material: NodeMaterial): void;
  54685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54686. isReady(): boolean;
  54687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54688. private _injectVertexCode;
  54689. private _writeOutput;
  54690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54691. serialize(): any;
  54692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54693. }
  54694. }
  54695. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54697. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54698. import { Scene } from "babylonjs/scene";
  54699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54700. import { Matrix } from "babylonjs/Maths/math.vector";
  54701. import { Mesh } from "babylonjs/Meshes/mesh";
  54702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54703. import { Observable } from "babylonjs/Misc/observable";
  54704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54705. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54706. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54707. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54708. import { Nullable } from "babylonjs/types";
  54709. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54710. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54711. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54712. /**
  54713. * Interface used to configure the node material editor
  54714. */
  54715. export interface INodeMaterialEditorOptions {
  54716. /** Define the URl to load node editor script */
  54717. editorURL?: string;
  54718. }
  54719. /** @hidden */
  54720. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54721. /** BONES */
  54722. NUM_BONE_INFLUENCERS: number;
  54723. BonesPerMesh: number;
  54724. BONETEXTURE: boolean;
  54725. /** MORPH TARGETS */
  54726. MORPHTARGETS: boolean;
  54727. MORPHTARGETS_NORMAL: boolean;
  54728. MORPHTARGETS_TANGENT: boolean;
  54729. MORPHTARGETS_UV: boolean;
  54730. NUM_MORPH_INFLUENCERS: number;
  54731. /** IMAGE PROCESSING */
  54732. IMAGEPROCESSING: boolean;
  54733. VIGNETTE: boolean;
  54734. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54735. VIGNETTEBLENDMODEOPAQUE: boolean;
  54736. TONEMAPPING: boolean;
  54737. TONEMAPPING_ACES: boolean;
  54738. CONTRAST: boolean;
  54739. EXPOSURE: boolean;
  54740. COLORCURVES: boolean;
  54741. COLORGRADING: boolean;
  54742. COLORGRADING3D: boolean;
  54743. SAMPLER3DGREENDEPTH: boolean;
  54744. SAMPLER3DBGRMAP: boolean;
  54745. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54746. /** MISC. */
  54747. BUMPDIRECTUV: number;
  54748. constructor();
  54749. setValue(name: string, value: boolean): void;
  54750. }
  54751. /**
  54752. * Class used to configure NodeMaterial
  54753. */
  54754. export interface INodeMaterialOptions {
  54755. /**
  54756. * Defines if blocks should emit comments
  54757. */
  54758. emitComments: boolean;
  54759. }
  54760. /**
  54761. * Class used to create a node based material built by assembling shader blocks
  54762. */
  54763. export class NodeMaterial extends PushMaterial {
  54764. private static _BuildIdGenerator;
  54765. private _options;
  54766. private _vertexCompilationState;
  54767. private _fragmentCompilationState;
  54768. private _sharedData;
  54769. private _buildId;
  54770. private _buildWasSuccessful;
  54771. private _cachedWorldViewMatrix;
  54772. private _cachedWorldViewProjectionMatrix;
  54773. private _optimizers;
  54774. private _animationFrame;
  54775. /** Define the URl to load node editor script */
  54776. static EditorURL: string;
  54777. private BJSNODEMATERIALEDITOR;
  54778. /** Get the inspector from bundle or global */
  54779. private _getGlobalNodeMaterialEditor;
  54780. /**
  54781. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  54782. */
  54783. ignoreAlpha: boolean;
  54784. /**
  54785. * Defines the maximum number of lights that can be used in the material
  54786. */
  54787. maxSimultaneousLights: number;
  54788. /**
  54789. * Observable raised when the material is built
  54790. */
  54791. onBuildObservable: Observable<NodeMaterial>;
  54792. /**
  54793. * Gets or sets the root nodes of the material vertex shader
  54794. */
  54795. _vertexOutputNodes: NodeMaterialBlock[];
  54796. /**
  54797. * Gets or sets the root nodes of the material fragment (pixel) shader
  54798. */
  54799. _fragmentOutputNodes: NodeMaterialBlock[];
  54800. /** Gets or sets options to control the node material overall behavior */
  54801. options: INodeMaterialOptions;
  54802. /**
  54803. * Default configuration related to image processing available in the standard Material.
  54804. */
  54805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54806. /**
  54807. * Gets the image processing configuration used either in this material.
  54808. */
  54809. /**
  54810. * Sets the Default image processing configuration used either in the this material.
  54811. *
  54812. * If sets to null, the scene one is in use.
  54813. */
  54814. imageProcessingConfiguration: ImageProcessingConfiguration;
  54815. /**
  54816. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54817. */
  54818. attachedBlocks: NodeMaterialBlock[];
  54819. /**
  54820. * Create a new node based material
  54821. * @param name defines the material name
  54822. * @param scene defines the hosting scene
  54823. * @param options defines creation option
  54824. */
  54825. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54826. /**
  54827. * Gets the current class name of the material e.g. "NodeMaterial"
  54828. * @returns the class name
  54829. */
  54830. getClassName(): string;
  54831. /**
  54832. * Keep track of the image processing observer to allow dispose and replace.
  54833. */
  54834. private _imageProcessingObserver;
  54835. /**
  54836. * Attaches a new image processing configuration to the Standard Material.
  54837. * @param configuration
  54838. */
  54839. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54840. /**
  54841. * Get a block by its name
  54842. * @param name defines the name of the block to retrieve
  54843. * @returns the required block or null if not found
  54844. */
  54845. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54846. /**
  54847. * Get a block by its name
  54848. * @param predicate defines the predicate used to find the good candidate
  54849. * @returns the required block or null if not found
  54850. */
  54851. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54852. /**
  54853. * Get an input block by its name
  54854. * @param predicate defines the predicate used to find the good candidate
  54855. * @returns the required input block or null if not found
  54856. */
  54857. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54858. /**
  54859. * Gets the list of input blocks attached to this material
  54860. * @returns an array of InputBlocks
  54861. */
  54862. getInputBlocks(): InputBlock[];
  54863. /**
  54864. * Adds a new optimizer to the list of optimizers
  54865. * @param optimizer defines the optimizers to add
  54866. * @returns the current material
  54867. */
  54868. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54869. /**
  54870. * Remove an optimizer from the list of optimizers
  54871. * @param optimizer defines the optimizers to remove
  54872. * @returns the current material
  54873. */
  54874. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54875. /**
  54876. * Add a new block to the list of output nodes
  54877. * @param node defines the node to add
  54878. * @returns the current material
  54879. */
  54880. addOutputNode(node: NodeMaterialBlock): this;
  54881. /**
  54882. * Remove a block from the list of root nodes
  54883. * @param node defines the node to remove
  54884. * @returns the current material
  54885. */
  54886. removeOutputNode(node: NodeMaterialBlock): this;
  54887. private _addVertexOutputNode;
  54888. private _removeVertexOutputNode;
  54889. private _addFragmentOutputNode;
  54890. private _removeFragmentOutputNode;
  54891. /**
  54892. * Specifies if the material will require alpha blending
  54893. * @returns a boolean specifying if alpha blending is needed
  54894. */
  54895. needAlphaBlending(): boolean;
  54896. /**
  54897. * Specifies if this material should be rendered in alpha test mode
  54898. * @returns a boolean specifying if an alpha test is needed.
  54899. */
  54900. needAlphaTesting(): boolean;
  54901. private _initializeBlock;
  54902. private _resetDualBlocks;
  54903. /**
  54904. * Build the material and generates the inner effect
  54905. * @param verbose defines if the build should log activity
  54906. */
  54907. build(verbose?: boolean): void;
  54908. /**
  54909. * Runs an otpimization phase to try to improve the shader code
  54910. */
  54911. optimize(): void;
  54912. private _prepareDefinesForAttributes;
  54913. /**
  54914. * Get if the submesh is ready to be used and all its information available.
  54915. * Child classes can use it to update shaders
  54916. * @param mesh defines the mesh to check
  54917. * @param subMesh defines which submesh to check
  54918. * @param useInstances specifies that instances should be used
  54919. * @returns a boolean indicating that the submesh is ready or not
  54920. */
  54921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54922. /**
  54923. * Get a string representing the shaders built by the current node graph
  54924. */
  54925. readonly compiledShaders: string;
  54926. /**
  54927. * Binds the world matrix to the material
  54928. * @param world defines the world transformation matrix
  54929. */
  54930. bindOnlyWorldMatrix(world: Matrix): void;
  54931. /**
  54932. * Binds the submesh to this material by preparing the effect and shader to draw
  54933. * @param world defines the world transformation matrix
  54934. * @param mesh defines the mesh containing the submesh
  54935. * @param subMesh defines the submesh to bind the material to
  54936. */
  54937. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54938. /**
  54939. * Gets the active textures from the material
  54940. * @returns an array of textures
  54941. */
  54942. getActiveTextures(): BaseTexture[];
  54943. /**
  54944. * Gets the list of texture blocks
  54945. * @returns an array of texture blocks
  54946. */
  54947. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54948. /**
  54949. * Specifies if the material uses a texture
  54950. * @param texture defines the texture to check against the material
  54951. * @returns a boolean specifying if the material uses the texture
  54952. */
  54953. hasTexture(texture: BaseTexture): boolean;
  54954. /**
  54955. * Disposes the material
  54956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54958. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54959. */
  54960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54961. /** Creates the node editor window. */
  54962. private _createNodeEditor;
  54963. /**
  54964. * Launch the node material editor
  54965. * @param config Define the configuration of the editor
  54966. * @return a promise fulfilled when the node editor is visible
  54967. */
  54968. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54969. /**
  54970. * Clear the current material
  54971. */
  54972. clear(): void;
  54973. /**
  54974. * Clear the current material and set it to a default state
  54975. */
  54976. setToDefault(): void;
  54977. /**
  54978. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54979. * @param url defines the url to load from
  54980. * @returns a promise that will fullfil when the material is fully loaded
  54981. */
  54982. loadAsync(url: string): Promise<unknown>;
  54983. private _gatherBlocks;
  54984. /**
  54985. * Generate a string containing the code declaration required to create an equivalent of this material
  54986. * @returns a string
  54987. */
  54988. generateCode(): string;
  54989. /**
  54990. * Serializes this material in a JSON representation
  54991. * @returns the serialized material object
  54992. */
  54993. serialize(): any;
  54994. private _restoreConnections;
  54995. /**
  54996. * Clear the current graph and load a new one from a serialization object
  54997. * @param source defines the JSON representation of the material
  54998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54999. */
  55000. loadFromSerialization(source: any, rootUrl?: string): void;
  55001. /**
  55002. * Creates a node material from parsed material data
  55003. * @param source defines the JSON representation of the material
  55004. * @param scene defines the hosting scene
  55005. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55006. * @returns a new node material
  55007. */
  55008. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55009. /**
  55010. * Creates a new node material set to default basic configuration
  55011. * @param name defines the name of the material
  55012. * @param scene defines the hosting scene
  55013. * @returns a new NodeMaterial
  55014. */
  55015. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55016. }
  55017. }
  55018. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55021. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55024. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55025. import { Effect } from "babylonjs/Materials/effect";
  55026. import { Mesh } from "babylonjs/Meshes/mesh";
  55027. import { Nullable } from "babylonjs/types";
  55028. import { Texture } from "babylonjs/Materials/Textures/texture";
  55029. import { Scene } from "babylonjs/scene";
  55030. /**
  55031. * Block used to read a texture from a sampler
  55032. */
  55033. export class TextureBlock extends NodeMaterialBlock {
  55034. private _defineName;
  55035. private _samplerName;
  55036. private _transformedUVName;
  55037. private _textureTransformName;
  55038. private _textureInfoName;
  55039. private _mainUVName;
  55040. private _mainUVDefineName;
  55041. /**
  55042. * Gets or sets the texture associated with the node
  55043. */
  55044. texture: Nullable<Texture>;
  55045. /**
  55046. * Create a new TextureBlock
  55047. * @param name defines the block name
  55048. */
  55049. constructor(name: string);
  55050. /**
  55051. * Gets the current class name
  55052. * @returns the class name
  55053. */
  55054. getClassName(): string;
  55055. /**
  55056. * Gets the uv input component
  55057. */
  55058. readonly uv: NodeMaterialConnectionPoint;
  55059. /**
  55060. * Gets the rgba output component
  55061. */
  55062. readonly rgba: NodeMaterialConnectionPoint;
  55063. /**
  55064. * Gets the rgb output component
  55065. */
  55066. readonly rgb: NodeMaterialConnectionPoint;
  55067. /**
  55068. * Gets the r output component
  55069. */
  55070. readonly r: NodeMaterialConnectionPoint;
  55071. /**
  55072. * Gets the g output component
  55073. */
  55074. readonly g: NodeMaterialConnectionPoint;
  55075. /**
  55076. * Gets the b output component
  55077. */
  55078. readonly b: NodeMaterialConnectionPoint;
  55079. /**
  55080. * Gets the a output component
  55081. */
  55082. readonly a: NodeMaterialConnectionPoint;
  55083. readonly target: NodeMaterialBlockTargets;
  55084. autoConfigure(material: NodeMaterial): void;
  55085. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55087. isReady(): boolean;
  55088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55089. private readonly _isMixed;
  55090. private _injectVertexCode;
  55091. private _writeOutput;
  55092. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55093. protected _dumpPropertiesCode(): string;
  55094. serialize(): any;
  55095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55096. }
  55097. }
  55098. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55101. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55102. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55103. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55104. import { Scene } from "babylonjs/scene";
  55105. /**
  55106. * Class used to store shared data between 2 NodeMaterialBuildState
  55107. */
  55108. export class NodeMaterialBuildStateSharedData {
  55109. /**
  55110. * Gets the list of emitted varyings
  55111. */
  55112. temps: string[];
  55113. /**
  55114. * Gets the list of emitted varyings
  55115. */
  55116. varyings: string[];
  55117. /**
  55118. * Gets the varying declaration string
  55119. */
  55120. varyingDeclaration: string;
  55121. /**
  55122. * Input blocks
  55123. */
  55124. inputBlocks: InputBlock[];
  55125. /**
  55126. * Input blocks
  55127. */
  55128. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55129. /**
  55130. * Bindable blocks (Blocks that need to set data to the effect)
  55131. */
  55132. bindableBlocks: NodeMaterialBlock[];
  55133. /**
  55134. * List of blocks that can provide a compilation fallback
  55135. */
  55136. blocksWithFallbacks: NodeMaterialBlock[];
  55137. /**
  55138. * List of blocks that can provide a define update
  55139. */
  55140. blocksWithDefines: NodeMaterialBlock[];
  55141. /**
  55142. * List of blocks that can provide a repeatable content
  55143. */
  55144. repeatableContentBlocks: NodeMaterialBlock[];
  55145. /**
  55146. * List of blocks that can provide a dynamic list of uniforms
  55147. */
  55148. dynamicUniformBlocks: NodeMaterialBlock[];
  55149. /**
  55150. * List of blocks that can block the isReady function for the material
  55151. */
  55152. blockingBlocks: NodeMaterialBlock[];
  55153. /**
  55154. * Gets the list of animated inputs
  55155. */
  55156. animatedInputs: InputBlock[];
  55157. /**
  55158. * Build Id used to avoid multiple recompilations
  55159. */
  55160. buildId: number;
  55161. /** List of emitted variables */
  55162. variableNames: {
  55163. [key: string]: number;
  55164. };
  55165. /** List of emitted defines */
  55166. defineNames: {
  55167. [key: string]: number;
  55168. };
  55169. /** Should emit comments? */
  55170. emitComments: boolean;
  55171. /** Emit build activity */
  55172. verbose: boolean;
  55173. /** Gets or sets the hosting scene */
  55174. scene: Scene;
  55175. /**
  55176. * Gets the compilation hints emitted at compilation time
  55177. */
  55178. hints: {
  55179. needWorldViewMatrix: boolean;
  55180. needWorldViewProjectionMatrix: boolean;
  55181. needAlphaBlending: boolean;
  55182. needAlphaTesting: boolean;
  55183. };
  55184. /**
  55185. * List of compilation checks
  55186. */
  55187. checks: {
  55188. emitVertex: boolean;
  55189. emitFragment: boolean;
  55190. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55191. };
  55192. /** Creates a new shared data */
  55193. constructor();
  55194. /**
  55195. * Emits console errors and exceptions if there is a failing check
  55196. */
  55197. emitErrors(): void;
  55198. }
  55199. }
  55200. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55201. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55202. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55203. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55204. /**
  55205. * Class used to store node based material build state
  55206. */
  55207. export class NodeMaterialBuildState {
  55208. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55209. supportUniformBuffers: boolean;
  55210. /**
  55211. * Gets the list of emitted attributes
  55212. */
  55213. attributes: string[];
  55214. /**
  55215. * Gets the list of emitted uniforms
  55216. */
  55217. uniforms: string[];
  55218. /**
  55219. * Gets the list of emitted constants
  55220. */
  55221. constants: string[];
  55222. /**
  55223. * Gets the list of emitted uniform buffers
  55224. */
  55225. uniformBuffers: string[];
  55226. /**
  55227. * Gets the list of emitted samplers
  55228. */
  55229. samplers: string[];
  55230. /**
  55231. * Gets the list of emitted functions
  55232. */
  55233. functions: {
  55234. [key: string]: string;
  55235. };
  55236. /**
  55237. * Gets the list of emitted extensions
  55238. */
  55239. extensions: {
  55240. [key: string]: string;
  55241. };
  55242. /**
  55243. * Gets the target of the compilation state
  55244. */
  55245. target: NodeMaterialBlockTargets;
  55246. /**
  55247. * Gets the list of emitted counters
  55248. */
  55249. counters: {
  55250. [key: string]: number;
  55251. };
  55252. /**
  55253. * Shared data between multiple NodeMaterialBuildState instances
  55254. */
  55255. sharedData: NodeMaterialBuildStateSharedData;
  55256. /** @hidden */
  55257. _vertexState: NodeMaterialBuildState;
  55258. /** @hidden */
  55259. _attributeDeclaration: string;
  55260. /** @hidden */
  55261. _uniformDeclaration: string;
  55262. /** @hidden */
  55263. _constantDeclaration: string;
  55264. /** @hidden */
  55265. _samplerDeclaration: string;
  55266. /** @hidden */
  55267. _varyingTransfer: string;
  55268. private _repeatableContentAnchorIndex;
  55269. /** @hidden */
  55270. _builtCompilationString: string;
  55271. /**
  55272. * Gets the emitted compilation strings
  55273. */
  55274. compilationString: string;
  55275. /**
  55276. * Finalize the compilation strings
  55277. * @param state defines the current compilation state
  55278. */
  55279. finalize(state: NodeMaterialBuildState): void;
  55280. /** @hidden */
  55281. readonly _repeatableContentAnchor: string;
  55282. /** @hidden */
  55283. _getFreeVariableName(prefix: string): string;
  55284. /** @hidden */
  55285. _getFreeDefineName(prefix: string): string;
  55286. /** @hidden */
  55287. _excludeVariableName(name: string): void;
  55288. /** @hidden */
  55289. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55290. /** @hidden */
  55291. _emitExtension(name: string, extension: string): void;
  55292. /** @hidden */
  55293. _emitFunction(name: string, code: string, comments: string): void;
  55294. /** @hidden */
  55295. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55296. replaceStrings?: {
  55297. search: RegExp;
  55298. replace: string;
  55299. }[];
  55300. repeatKey?: string;
  55301. }): string;
  55302. /** @hidden */
  55303. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55304. repeatKey?: string;
  55305. removeAttributes?: boolean;
  55306. removeUniforms?: boolean;
  55307. removeVaryings?: boolean;
  55308. removeIfDef?: boolean;
  55309. replaceStrings?: {
  55310. search: RegExp;
  55311. replace: string;
  55312. }[];
  55313. }, storeKey?: string): void;
  55314. /** @hidden */
  55315. _registerTempVariable(name: string): boolean;
  55316. /** @hidden */
  55317. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55318. /** @hidden */
  55319. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55320. }
  55321. }
  55322. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55323. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55325. import { Nullable } from "babylonjs/types";
  55326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55327. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55328. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55330. import { Mesh } from "babylonjs/Meshes/mesh";
  55331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55332. import { Scene } from "babylonjs/scene";
  55333. /**
  55334. * Defines a block that can be used inside a node based material
  55335. */
  55336. export class NodeMaterialBlock {
  55337. private _buildId;
  55338. private _buildTarget;
  55339. private _target;
  55340. private _isFinalMerger;
  55341. private _isInput;
  55342. /** @hidden */
  55343. _codeVariableName: string;
  55344. /** @hidden */
  55345. _inputs: NodeMaterialConnectionPoint[];
  55346. /** @hidden */
  55347. _outputs: NodeMaterialConnectionPoint[];
  55348. /** @hidden */
  55349. _preparationId: number;
  55350. /**
  55351. * Gets or sets the name of the block
  55352. */
  55353. name: string;
  55354. /**
  55355. * Gets or sets the unique id of the node
  55356. */
  55357. uniqueId: number;
  55358. /**
  55359. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55360. */
  55361. readonly isFinalMerger: boolean;
  55362. /**
  55363. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55364. */
  55365. readonly isInput: boolean;
  55366. /**
  55367. * Gets or sets the build Id
  55368. */
  55369. buildId: number;
  55370. /**
  55371. * Gets or sets the target of the block
  55372. */
  55373. target: NodeMaterialBlockTargets;
  55374. /**
  55375. * Gets the list of input points
  55376. */
  55377. readonly inputs: NodeMaterialConnectionPoint[];
  55378. /** Gets the list of output points */
  55379. readonly outputs: NodeMaterialConnectionPoint[];
  55380. /**
  55381. * Find an input by its name
  55382. * @param name defines the name of the input to look for
  55383. * @returns the input or null if not found
  55384. */
  55385. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55386. /**
  55387. * Find an output by its name
  55388. * @param name defines the name of the outputto look for
  55389. * @returns the output or null if not found
  55390. */
  55391. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55392. /**
  55393. * Creates a new NodeMaterialBlock
  55394. * @param name defines the block name
  55395. * @param target defines the target of that block (Vertex by default)
  55396. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55397. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55398. */
  55399. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55400. /**
  55401. * Initialize the block and prepare the context for build
  55402. * @param state defines the state that will be used for the build
  55403. */
  55404. initialize(state: NodeMaterialBuildState): void;
  55405. /**
  55406. * Bind data to effect. Will only be called for blocks with isBindable === true
  55407. * @param effect defines the effect to bind data to
  55408. * @param nodeMaterial defines the hosting NodeMaterial
  55409. * @param mesh defines the mesh that will be rendered
  55410. */
  55411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55412. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55413. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55414. protected _writeFloat(value: number): string;
  55415. /**
  55416. * Gets the current class name e.g. "NodeMaterialBlock"
  55417. * @returns the class name
  55418. */
  55419. getClassName(): string;
  55420. /**
  55421. * Register a new input. Must be called inside a block constructor
  55422. * @param name defines the connection point name
  55423. * @param type defines the connection point type
  55424. * @param isOptional defines a boolean indicating that this input can be omitted
  55425. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55426. * @returns the current block
  55427. */
  55428. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55429. /**
  55430. * Register a new output. Must be called inside a block constructor
  55431. * @param name defines the connection point name
  55432. * @param type defines the connection point type
  55433. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55434. * @returns the current block
  55435. */
  55436. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55437. /**
  55438. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55439. * @param forOutput defines an optional connection point to check compatibility with
  55440. * @returns the first available input or null
  55441. */
  55442. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55443. /**
  55444. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55445. * @param forBlock defines an optional block to check compatibility with
  55446. * @returns the first available input or null
  55447. */
  55448. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55449. /**
  55450. * Gets the sibling of the given output
  55451. * @param current defines the current output
  55452. * @returns the next output in the list or null
  55453. */
  55454. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55455. /**
  55456. * Connect current block with another block
  55457. * @param other defines the block to connect with
  55458. * @param options define the various options to help pick the right connections
  55459. * @returns the current block
  55460. */
  55461. connectTo(other: NodeMaterialBlock, options?: {
  55462. input?: string;
  55463. output?: string;
  55464. outputSwizzle?: string;
  55465. }): this | undefined;
  55466. protected _buildBlock(state: NodeMaterialBuildState): void;
  55467. /**
  55468. * Add uniforms, samplers and uniform buffers at compilation time
  55469. * @param state defines the state to update
  55470. * @param nodeMaterial defines the node material requesting the update
  55471. * @param defines defines the material defines to update
  55472. */
  55473. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55474. /**
  55475. * Add potential fallbacks if shader compilation fails
  55476. * @param mesh defines the mesh to be rendered
  55477. * @param fallbacks defines the current prioritized list of fallbacks
  55478. */
  55479. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55480. /**
  55481. * Initialize defines for shader compilation
  55482. * @param mesh defines the mesh to be rendered
  55483. * @param nodeMaterial defines the node material requesting the update
  55484. * @param defines defines the material defines to update
  55485. * @param useInstances specifies that instances should be used
  55486. */
  55487. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55488. /**
  55489. * Update defines for shader compilation
  55490. * @param mesh defines the mesh to be rendered
  55491. * @param nodeMaterial defines the node material requesting the update
  55492. * @param defines defines the material defines to update
  55493. * @param useInstances specifies that instances should be used
  55494. */
  55495. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55496. /**
  55497. * Lets the block try to connect some inputs automatically
  55498. * @param material defines the hosting NodeMaterial
  55499. */
  55500. autoConfigure(material: NodeMaterial): void;
  55501. /**
  55502. * Function called when a block is declared as repeatable content generator
  55503. * @param vertexShaderState defines the current compilation state for the vertex shader
  55504. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55505. * @param mesh defines the mesh to be rendered
  55506. * @param defines defines the material defines to update
  55507. */
  55508. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55509. /**
  55510. * Checks if the block is ready
  55511. * @param mesh defines the mesh to be rendered
  55512. * @param nodeMaterial defines the node material requesting the update
  55513. * @param defines defines the material defines to update
  55514. * @param useInstances specifies that instances should be used
  55515. * @returns true if the block is ready
  55516. */
  55517. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55518. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55519. private _processBuild;
  55520. /**
  55521. * Compile the current node and generate the shader code
  55522. * @param state defines the current compilation state (uniforms, samplers, current string)
  55523. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55524. * @returns true if already built
  55525. */
  55526. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55527. protected _inputRename(name: string): string;
  55528. protected _outputRename(name: string): string;
  55529. protected _dumpPropertiesCode(): string;
  55530. /** @hidden */
  55531. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55532. /**
  55533. * Clone the current block to a new identical block
  55534. * @param scene defines the hosting scene
  55535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55536. * @returns a copy of the current block
  55537. */
  55538. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55539. /**
  55540. * Serializes this block in a JSON representation
  55541. * @returns the serialized block object
  55542. */
  55543. serialize(): any;
  55544. /** @hidden */
  55545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55546. }
  55547. }
  55548. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55549. /**
  55550. * Enum defining the type of animations supported by InputBlock
  55551. */
  55552. export enum AnimatedInputBlockTypes {
  55553. /** No animation */
  55554. None = 0,
  55555. /** Time based animation. Will only work for floats */
  55556. Time = 1
  55557. }
  55558. }
  55559. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55561. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55562. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55563. import { Nullable } from "babylonjs/types";
  55564. import { Effect } from "babylonjs/Materials/effect";
  55565. import { Matrix } from "babylonjs/Maths/math.vector";
  55566. import { Scene } from "babylonjs/scene";
  55567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55569. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55570. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55571. /**
  55572. * Block used to expose an input value
  55573. */
  55574. export class InputBlock extends NodeMaterialBlock {
  55575. private _mode;
  55576. private _associatedVariableName;
  55577. private _storedValue;
  55578. private _valueCallback;
  55579. private _type;
  55580. private _animationType;
  55581. /** Gets or set a value used to limit the range of float values */
  55582. min: number;
  55583. /** Gets or set a value used to limit the range of float values */
  55584. max: number;
  55585. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55586. matrixMode: number;
  55587. /** @hidden */
  55588. _systemValue: Nullable<NodeMaterialSystemValues>;
  55589. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55590. visibleInInspector: boolean;
  55591. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55592. isConstant: boolean;
  55593. /**
  55594. * Gets or sets the connection point type (default is float)
  55595. */
  55596. readonly type: NodeMaterialBlockConnectionPointTypes;
  55597. /**
  55598. * Creates a new InputBlock
  55599. * @param name defines the block name
  55600. * @param target defines the target of that block (Vertex by default)
  55601. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55602. */
  55603. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55604. /**
  55605. * Gets the output component
  55606. */
  55607. readonly output: NodeMaterialConnectionPoint;
  55608. /**
  55609. * Set the source of this connection point to a vertex attribute
  55610. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55611. * @returns the current connection point
  55612. */
  55613. setAsAttribute(attributeName?: string): InputBlock;
  55614. /**
  55615. * Set the source of this connection point to a system value
  55616. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55617. * @returns the current connection point
  55618. */
  55619. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55620. /**
  55621. * Gets or sets the value of that point.
  55622. * Please note that this value will be ignored if valueCallback is defined
  55623. */
  55624. value: any;
  55625. /**
  55626. * Gets or sets a callback used to get the value of that point.
  55627. * Please note that setting this value will force the connection point to ignore the value property
  55628. */
  55629. valueCallback: () => any;
  55630. /**
  55631. * Gets or sets the associated variable name in the shader
  55632. */
  55633. associatedVariableName: string;
  55634. /** Gets or sets the type of animation applied to the input */
  55635. animationType: AnimatedInputBlockTypes;
  55636. /**
  55637. * Gets a boolean indicating that this connection point not defined yet
  55638. */
  55639. readonly isUndefined: boolean;
  55640. /**
  55641. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55642. * In this case the connection point name must be the name of the uniform to use.
  55643. * Can only be set on inputs
  55644. */
  55645. isUniform: boolean;
  55646. /**
  55647. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55648. * In this case the connection point name must be the name of the attribute to use
  55649. * Can only be set on inputs
  55650. */
  55651. isAttribute: boolean;
  55652. /**
  55653. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55654. * Can only be set on exit points
  55655. */
  55656. isVarying: boolean;
  55657. /**
  55658. * Gets a boolean indicating that the current connection point is a system value
  55659. */
  55660. readonly isSystemValue: boolean;
  55661. /**
  55662. * Gets or sets the current well known value or null if not defined as a system value
  55663. */
  55664. systemValue: Nullable<NodeMaterialSystemValues>;
  55665. /**
  55666. * Gets the current class name
  55667. * @returns the class name
  55668. */
  55669. getClassName(): string;
  55670. /**
  55671. * Animate the input if animationType !== None
  55672. * @param scene defines the rendering scene
  55673. */
  55674. animate(scene: Scene): void;
  55675. private _emitDefine;
  55676. initialize(state: NodeMaterialBuildState): void;
  55677. /**
  55678. * Set the input block to its default value (based on its type)
  55679. */
  55680. setDefaultValue(): void;
  55681. protected _dumpPropertiesCode(): string;
  55682. private _emitConstant;
  55683. private _emit;
  55684. /** @hidden */
  55685. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55686. /** @hidden */
  55687. _transmit(effect: Effect, scene: Scene): void;
  55688. protected _buildBlock(state: NodeMaterialBuildState): void;
  55689. serialize(): any;
  55690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55691. }
  55692. }
  55693. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55694. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55695. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55696. import { Nullable } from "babylonjs/types";
  55697. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55699. /**
  55700. * Defines a connection point for a block
  55701. */
  55702. export class NodeMaterialConnectionPoint {
  55703. /** @hidden */
  55704. _ownerBlock: NodeMaterialBlock;
  55705. /** @hidden */
  55706. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55707. private _endpoints;
  55708. private _associatedVariableName;
  55709. /** @hidden */
  55710. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55711. /** @hidden */
  55712. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55713. private _type;
  55714. /** @hidden */
  55715. _enforceAssociatedVariableName: boolean;
  55716. /**
  55717. * Gets or sets the additional types supported byt this connection point
  55718. */
  55719. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55720. /**
  55721. * Gets or sets the associated variable name in the shader
  55722. */
  55723. associatedVariableName: string;
  55724. /**
  55725. * Gets or sets the connection point type (default is float)
  55726. */
  55727. type: NodeMaterialBlockConnectionPointTypes;
  55728. /**
  55729. * Gets or sets the connection point name
  55730. */
  55731. name: string;
  55732. /**
  55733. * Gets or sets a boolean indicating that this connection point can be omitted
  55734. */
  55735. isOptional: boolean;
  55736. /**
  55737. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55738. */
  55739. define: string;
  55740. /** Gets or sets the target of that connection point */
  55741. target: NodeMaterialBlockTargets;
  55742. /**
  55743. * Gets a boolean indicating that the current point is connected
  55744. */
  55745. readonly isConnected: boolean;
  55746. /**
  55747. * Gets a boolean indicating that the current point is connected to an input block
  55748. */
  55749. readonly isConnectedToInputBlock: boolean;
  55750. /**
  55751. * Gets a the connected input block (if any)
  55752. */
  55753. readonly connectInputBlock: Nullable<InputBlock>;
  55754. /** Get the other side of the connection (if any) */
  55755. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55756. /** Get the block that owns this connection point */
  55757. readonly ownerBlock: NodeMaterialBlock;
  55758. /** Get the block connected on the other side of this connection (if any) */
  55759. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55760. /** Get the block connected on the endpoints of this connection (if any) */
  55761. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55762. /** Gets the list of connected endpoints */
  55763. readonly endpoints: NodeMaterialConnectionPoint[];
  55764. /** Gets a boolean indicating if that output point is connected to at least one input */
  55765. readonly hasEndpoints: boolean;
  55766. /**
  55767. * Creates a new connection point
  55768. * @param name defines the connection point name
  55769. * @param ownerBlock defines the block hosting this connection point
  55770. */
  55771. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55772. /**
  55773. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55774. * @returns the class name
  55775. */
  55776. getClassName(): string;
  55777. /**
  55778. * Gets an boolean indicating if the current point can be connected to another point
  55779. * @param connectionPoint defines the other connection point
  55780. * @returns true if the connection is possible
  55781. */
  55782. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55783. /**
  55784. * Connect this point to another connection point
  55785. * @param connectionPoint defines the other connection point
  55786. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55787. * @returns the current connection point
  55788. */
  55789. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55790. /**
  55791. * Disconnect this point from one of his endpoint
  55792. * @param endpoint defines the other connection point
  55793. * @returns the current connection point
  55794. */
  55795. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55796. /**
  55797. * Serializes this point in a JSON representation
  55798. * @returns the serialized point object
  55799. */
  55800. serialize(): any;
  55801. }
  55802. }
  55803. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55807. import { Mesh } from "babylonjs/Meshes/mesh";
  55808. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55810. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55811. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55812. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55813. /**
  55814. * Block used to add support for vertex skinning (bones)
  55815. */
  55816. export class BonesBlock extends NodeMaterialBlock {
  55817. /**
  55818. * Creates a new BonesBlock
  55819. * @param name defines the block name
  55820. */
  55821. constructor(name: string);
  55822. /**
  55823. * Initialize the block and prepare the context for build
  55824. * @param state defines the state that will be used for the build
  55825. */
  55826. initialize(state: NodeMaterialBuildState): void;
  55827. /**
  55828. * Gets the current class name
  55829. * @returns the class name
  55830. */
  55831. getClassName(): string;
  55832. /**
  55833. * Gets the matrix indices input component
  55834. */
  55835. readonly matricesIndices: NodeMaterialConnectionPoint;
  55836. /**
  55837. * Gets the matrix weights input component
  55838. */
  55839. readonly matricesWeights: NodeMaterialConnectionPoint;
  55840. /**
  55841. * Gets the extra matrix indices input component
  55842. */
  55843. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55844. /**
  55845. * Gets the extra matrix weights input component
  55846. */
  55847. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55848. /**
  55849. * Gets the world input component
  55850. */
  55851. readonly world: NodeMaterialConnectionPoint;
  55852. /**
  55853. * Gets the output component
  55854. */
  55855. readonly output: NodeMaterialConnectionPoint;
  55856. autoConfigure(material: NodeMaterial): void;
  55857. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55858. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55859. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55860. protected _buildBlock(state: NodeMaterialBuildState): this;
  55861. }
  55862. }
  55863. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55868. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55869. /**
  55870. * Block used to add support for instances
  55871. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55872. */
  55873. export class InstancesBlock extends NodeMaterialBlock {
  55874. /**
  55875. * Creates a new InstancesBlock
  55876. * @param name defines the block name
  55877. */
  55878. constructor(name: string);
  55879. /**
  55880. * Gets the current class name
  55881. * @returns the class name
  55882. */
  55883. getClassName(): string;
  55884. /**
  55885. * Gets the first world row input component
  55886. */
  55887. readonly world0: NodeMaterialConnectionPoint;
  55888. /**
  55889. * Gets the second world row input component
  55890. */
  55891. readonly world1: NodeMaterialConnectionPoint;
  55892. /**
  55893. * Gets the third world row input component
  55894. */
  55895. readonly world2: NodeMaterialConnectionPoint;
  55896. /**
  55897. * Gets the forth world row input component
  55898. */
  55899. readonly world3: NodeMaterialConnectionPoint;
  55900. /**
  55901. * Gets the world input component
  55902. */
  55903. readonly world: NodeMaterialConnectionPoint;
  55904. /**
  55905. * Gets the output component
  55906. */
  55907. readonly output: NodeMaterialConnectionPoint;
  55908. autoConfigure(material: NodeMaterial): void;
  55909. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55910. protected _buildBlock(state: NodeMaterialBuildState): this;
  55911. }
  55912. }
  55913. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55918. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55919. import { Effect } from "babylonjs/Materials/effect";
  55920. import { Mesh } from "babylonjs/Meshes/mesh";
  55921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55923. /**
  55924. * Block used to add morph targets support to vertex shader
  55925. */
  55926. export class MorphTargetsBlock extends NodeMaterialBlock {
  55927. private _repeatableContentAnchor;
  55928. private _repeatebleContentGenerated;
  55929. /**
  55930. * Create a new MorphTargetsBlock
  55931. * @param name defines the block name
  55932. */
  55933. constructor(name: string);
  55934. /**
  55935. * Gets the current class name
  55936. * @returns the class name
  55937. */
  55938. getClassName(): string;
  55939. /**
  55940. * Gets the position input component
  55941. */
  55942. readonly position: NodeMaterialConnectionPoint;
  55943. /**
  55944. * Gets the normal input component
  55945. */
  55946. readonly normal: NodeMaterialConnectionPoint;
  55947. /**
  55948. * Gets the tangent input component
  55949. */
  55950. readonly tangent: NodeMaterialConnectionPoint;
  55951. /**
  55952. * Gets the tangent input component
  55953. */
  55954. readonly uv: NodeMaterialConnectionPoint;
  55955. /**
  55956. * Gets the position output component
  55957. */
  55958. readonly positionOutput: NodeMaterialConnectionPoint;
  55959. /**
  55960. * Gets the normal output component
  55961. */
  55962. readonly normalOutput: NodeMaterialConnectionPoint;
  55963. /**
  55964. * Gets the tangent output component
  55965. */
  55966. readonly tangentOutput: NodeMaterialConnectionPoint;
  55967. /**
  55968. * Gets the tangent output component
  55969. */
  55970. readonly uvOutput: NodeMaterialConnectionPoint;
  55971. initialize(state: NodeMaterialBuildState): void;
  55972. autoConfigure(material: NodeMaterial): void;
  55973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55975. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55976. protected _buildBlock(state: NodeMaterialBuildState): this;
  55977. }
  55978. }
  55979. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55983. import { Nullable } from "babylonjs/types";
  55984. import { Scene } from "babylonjs/scene";
  55985. import { Effect } from "babylonjs/Materials/effect";
  55986. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55987. import { Mesh } from "babylonjs/Meshes/mesh";
  55988. import { Light } from "babylonjs/Lights/light";
  55989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55990. /**
  55991. * Block used to get data information from a light
  55992. */
  55993. export class LightInformationBlock extends NodeMaterialBlock {
  55994. private _lightDataUniformName;
  55995. private _lightColorUniformName;
  55996. private _lightTypeDefineName;
  55997. /**
  55998. * Gets or sets the light associated with this block
  55999. */
  56000. light: Nullable<Light>;
  56001. /**
  56002. * Creates a new LightInformationBlock
  56003. * @param name defines the block name
  56004. */
  56005. constructor(name: string);
  56006. /**
  56007. * Gets the current class name
  56008. * @returns the class name
  56009. */
  56010. getClassName(): string;
  56011. /**
  56012. * Gets the world position input component
  56013. */
  56014. readonly worldPosition: NodeMaterialConnectionPoint;
  56015. /**
  56016. * Gets the direction output component
  56017. */
  56018. readonly direction: NodeMaterialConnectionPoint;
  56019. /**
  56020. * Gets the direction output component
  56021. */
  56022. readonly color: NodeMaterialConnectionPoint;
  56023. /**
  56024. * Gets the direction output component
  56025. */
  56026. readonly intensity: NodeMaterialConnectionPoint;
  56027. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56029. protected _buildBlock(state: NodeMaterialBuildState): this;
  56030. serialize(): any;
  56031. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56032. }
  56033. }
  56034. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56035. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56036. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56037. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56038. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56039. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56040. }
  56041. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56046. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56047. import { Effect } from "babylonjs/Materials/effect";
  56048. import { Mesh } from "babylonjs/Meshes/mesh";
  56049. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56050. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56051. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56052. /**
  56053. * Block used to add image processing support to fragment shader
  56054. */
  56055. export class ImageProcessingBlock extends NodeMaterialBlock {
  56056. /**
  56057. * Create a new ImageProcessingBlock
  56058. * @param name defines the block name
  56059. */
  56060. constructor(name: string);
  56061. /**
  56062. * Gets the current class name
  56063. * @returns the class name
  56064. */
  56065. getClassName(): string;
  56066. /**
  56067. * Gets the color input component
  56068. */
  56069. readonly color: NodeMaterialConnectionPoint;
  56070. /**
  56071. * Gets the output component
  56072. */
  56073. readonly output: NodeMaterialConnectionPoint;
  56074. /**
  56075. * Initialize the block and prepare the context for build
  56076. * @param state defines the state that will be used for the build
  56077. */
  56078. initialize(state: NodeMaterialBuildState): void;
  56079. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56081. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56082. protected _buildBlock(state: NodeMaterialBuildState): this;
  56083. }
  56084. }
  56085. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56089. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56091. import { Effect } from "babylonjs/Materials/effect";
  56092. import { Mesh } from "babylonjs/Meshes/mesh";
  56093. import { Scene } from "babylonjs/scene";
  56094. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56095. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56096. /**
  56097. * Block used to pertub normals based on a normal map
  56098. */
  56099. export class PerturbNormalBlock extends NodeMaterialBlock {
  56100. private _tangentSpaceParameterName;
  56101. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56102. invertX: boolean;
  56103. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56104. invertY: boolean;
  56105. /**
  56106. * Create a new PerturbNormalBlock
  56107. * @param name defines the block name
  56108. */
  56109. constructor(name: string);
  56110. /**
  56111. * Gets the current class name
  56112. * @returns the class name
  56113. */
  56114. getClassName(): string;
  56115. /**
  56116. * Gets the world position input component
  56117. */
  56118. readonly worldPosition: NodeMaterialConnectionPoint;
  56119. /**
  56120. * Gets the world normal input component
  56121. */
  56122. readonly worldNormal: NodeMaterialConnectionPoint;
  56123. /**
  56124. * Gets the uv input component
  56125. */
  56126. readonly uv: NodeMaterialConnectionPoint;
  56127. /**
  56128. * Gets the normal map color input component
  56129. */
  56130. readonly normalMapColor: NodeMaterialConnectionPoint;
  56131. /**
  56132. * Gets the strength input component
  56133. */
  56134. readonly strength: NodeMaterialConnectionPoint;
  56135. /**
  56136. * Gets the output component
  56137. */
  56138. readonly output: NodeMaterialConnectionPoint;
  56139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56141. autoConfigure(material: NodeMaterial): void;
  56142. protected _buildBlock(state: NodeMaterialBuildState): this;
  56143. protected _dumpPropertiesCode(): string;
  56144. serialize(): any;
  56145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56146. }
  56147. }
  56148. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56151. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56152. /**
  56153. * Block used to discard a pixel if a value is smaller than a cutoff
  56154. */
  56155. export class DiscardBlock extends NodeMaterialBlock {
  56156. /**
  56157. * Create a new DiscardBlock
  56158. * @param name defines the block name
  56159. */
  56160. constructor(name: string);
  56161. /**
  56162. * Gets the current class name
  56163. * @returns the class name
  56164. */
  56165. getClassName(): string;
  56166. /**
  56167. * Gets the color input component
  56168. */
  56169. readonly value: NodeMaterialConnectionPoint;
  56170. /**
  56171. * Gets the cutoff input component
  56172. */
  56173. readonly cutoff: NodeMaterialConnectionPoint;
  56174. protected _buildBlock(state: NodeMaterialBuildState): this;
  56175. }
  56176. }
  56177. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56178. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56179. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56180. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56181. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56182. }
  56183. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56186. import { Mesh } from "babylonjs/Meshes/mesh";
  56187. import { Effect } from "babylonjs/Materials/effect";
  56188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56190. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56191. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56192. /**
  56193. * Block used to add support for scene fog
  56194. */
  56195. export class FogBlock extends NodeMaterialBlock {
  56196. private _fogDistanceName;
  56197. private _fogParameters;
  56198. /**
  56199. * Create a new FogBlock
  56200. * @param name defines the block name
  56201. */
  56202. constructor(name: string);
  56203. /**
  56204. * Gets the current class name
  56205. * @returns the class name
  56206. */
  56207. getClassName(): string;
  56208. /**
  56209. * Gets the world position input component
  56210. */
  56211. readonly worldPosition: NodeMaterialConnectionPoint;
  56212. /**
  56213. * Gets the view input component
  56214. */
  56215. readonly view: NodeMaterialConnectionPoint;
  56216. /**
  56217. * Gets the color input component
  56218. */
  56219. readonly input: NodeMaterialConnectionPoint;
  56220. /**
  56221. * Gets the fog color input component
  56222. */
  56223. readonly fogColor: NodeMaterialConnectionPoint;
  56224. /**
  56225. * Gets the output component
  56226. */
  56227. readonly output: NodeMaterialConnectionPoint;
  56228. autoConfigure(material: NodeMaterial): void;
  56229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56230. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56231. protected _buildBlock(state: NodeMaterialBuildState): this;
  56232. }
  56233. }
  56234. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56239. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56240. import { Effect } from "babylonjs/Materials/effect";
  56241. import { Mesh } from "babylonjs/Meshes/mesh";
  56242. import { Light } from "babylonjs/Lights/light";
  56243. import { Nullable } from "babylonjs/types";
  56244. import { Scene } from "babylonjs/scene";
  56245. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56246. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56247. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56248. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56249. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56250. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56251. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56252. /**
  56253. * Block used to add light in the fragment shader
  56254. */
  56255. export class LightBlock extends NodeMaterialBlock {
  56256. private _lightId;
  56257. /**
  56258. * Gets or sets the light associated with this block
  56259. */
  56260. light: Nullable<Light>;
  56261. /**
  56262. * Create a new LightBlock
  56263. * @param name defines the block name
  56264. */
  56265. constructor(name: string);
  56266. /**
  56267. * Gets the current class name
  56268. * @returns the class name
  56269. */
  56270. getClassName(): string;
  56271. /**
  56272. * Gets the world position input component
  56273. */
  56274. readonly worldPosition: NodeMaterialConnectionPoint;
  56275. /**
  56276. * Gets the world normal input component
  56277. */
  56278. readonly worldNormal: NodeMaterialConnectionPoint;
  56279. /**
  56280. * Gets the camera (or eye) position component
  56281. */
  56282. readonly cameraPosition: NodeMaterialConnectionPoint;
  56283. /**
  56284. * Gets the diffuse output component
  56285. */
  56286. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56287. /**
  56288. * Gets the specular output component
  56289. */
  56290. readonly specularOutput: NodeMaterialConnectionPoint;
  56291. autoConfigure(material: NodeMaterial): void;
  56292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56293. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56295. private _injectVertexCode;
  56296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56297. serialize(): any;
  56298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56299. }
  56300. }
  56301. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56302. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56303. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56304. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56305. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56306. }
  56307. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56308. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56309. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56310. }
  56311. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56315. /**
  56316. * Block used to multiply 2 values
  56317. */
  56318. export class MultiplyBlock extends NodeMaterialBlock {
  56319. /**
  56320. * Creates a new MultiplyBlock
  56321. * @param name defines the block name
  56322. */
  56323. constructor(name: string);
  56324. /**
  56325. * Gets the current class name
  56326. * @returns the class name
  56327. */
  56328. getClassName(): string;
  56329. /**
  56330. * Gets the left operand input component
  56331. */
  56332. readonly left: NodeMaterialConnectionPoint;
  56333. /**
  56334. * Gets the right operand input component
  56335. */
  56336. readonly right: NodeMaterialConnectionPoint;
  56337. /**
  56338. * Gets the output component
  56339. */
  56340. readonly output: NodeMaterialConnectionPoint;
  56341. protected _buildBlock(state: NodeMaterialBuildState): this;
  56342. }
  56343. }
  56344. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56348. /**
  56349. * Block used to add 2 vectors
  56350. */
  56351. export class AddBlock extends NodeMaterialBlock {
  56352. /**
  56353. * Creates a new AddBlock
  56354. * @param name defines the block name
  56355. */
  56356. constructor(name: string);
  56357. /**
  56358. * Gets the current class name
  56359. * @returns the class name
  56360. */
  56361. getClassName(): string;
  56362. /**
  56363. * Gets the left operand input component
  56364. */
  56365. readonly left: NodeMaterialConnectionPoint;
  56366. /**
  56367. * Gets the right operand input component
  56368. */
  56369. readonly right: NodeMaterialConnectionPoint;
  56370. /**
  56371. * Gets the output component
  56372. */
  56373. readonly output: NodeMaterialConnectionPoint;
  56374. protected _buildBlock(state: NodeMaterialBuildState): this;
  56375. }
  56376. }
  56377. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56381. /**
  56382. * Block used to scale a vector by a float
  56383. */
  56384. export class ScaleBlock extends NodeMaterialBlock {
  56385. /**
  56386. * Creates a new ScaleBlock
  56387. * @param name defines the block name
  56388. */
  56389. constructor(name: string);
  56390. /**
  56391. * Gets the current class name
  56392. * @returns the class name
  56393. */
  56394. getClassName(): string;
  56395. /**
  56396. * Gets the input component
  56397. */
  56398. readonly input: NodeMaterialConnectionPoint;
  56399. /**
  56400. * Gets the factor input component
  56401. */
  56402. readonly factor: NodeMaterialConnectionPoint;
  56403. /**
  56404. * Gets the output component
  56405. */
  56406. readonly output: NodeMaterialConnectionPoint;
  56407. protected _buildBlock(state: NodeMaterialBuildState): this;
  56408. }
  56409. }
  56410. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56414. import { Scene } from "babylonjs/scene";
  56415. /**
  56416. * Block used to clamp a float
  56417. */
  56418. export class ClampBlock extends NodeMaterialBlock {
  56419. /** Gets or sets the minimum range */
  56420. minimum: number;
  56421. /** Gets or sets the maximum range */
  56422. maximum: number;
  56423. /**
  56424. * Creates a new ClampBlock
  56425. * @param name defines the block name
  56426. */
  56427. constructor(name: string);
  56428. /**
  56429. * Gets the current class name
  56430. * @returns the class name
  56431. */
  56432. getClassName(): string;
  56433. /**
  56434. * Gets the value input component
  56435. */
  56436. readonly value: NodeMaterialConnectionPoint;
  56437. /**
  56438. * Gets the output component
  56439. */
  56440. readonly output: NodeMaterialConnectionPoint;
  56441. protected _buildBlock(state: NodeMaterialBuildState): this;
  56442. protected _dumpPropertiesCode(): string;
  56443. serialize(): any;
  56444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56445. }
  56446. }
  56447. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56451. /**
  56452. * Block used to apply a cross product between 2 vectors
  56453. */
  56454. export class CrossBlock extends NodeMaterialBlock {
  56455. /**
  56456. * Creates a new CrossBlock
  56457. * @param name defines the block name
  56458. */
  56459. constructor(name: string);
  56460. /**
  56461. * Gets the current class name
  56462. * @returns the class name
  56463. */
  56464. getClassName(): string;
  56465. /**
  56466. * Gets the left operand input component
  56467. */
  56468. readonly left: NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the right operand input component
  56471. */
  56472. readonly right: NodeMaterialConnectionPoint;
  56473. /**
  56474. * Gets the output component
  56475. */
  56476. readonly output: NodeMaterialConnectionPoint;
  56477. protected _buildBlock(state: NodeMaterialBuildState): this;
  56478. }
  56479. }
  56480. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56484. /**
  56485. * Block used to apply a dot product between 2 vectors
  56486. */
  56487. export class DotBlock extends NodeMaterialBlock {
  56488. /**
  56489. * Creates a new DotBlock
  56490. * @param name defines the block name
  56491. */
  56492. constructor(name: string);
  56493. /**
  56494. * Gets the current class name
  56495. * @returns the class name
  56496. */
  56497. getClassName(): string;
  56498. /**
  56499. * Gets the left operand input component
  56500. */
  56501. readonly left: NodeMaterialConnectionPoint;
  56502. /**
  56503. * Gets the right operand input component
  56504. */
  56505. readonly right: NodeMaterialConnectionPoint;
  56506. /**
  56507. * Gets the output component
  56508. */
  56509. readonly output: NodeMaterialConnectionPoint;
  56510. protected _buildBlock(state: NodeMaterialBuildState): this;
  56511. }
  56512. }
  56513. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56517. import { Vector2 } from "babylonjs/Maths/math.vector";
  56518. import { Scene } from "babylonjs/scene";
  56519. /**
  56520. * Block used to remap a float from a range to a new one
  56521. */
  56522. export class RemapBlock extends NodeMaterialBlock {
  56523. /**
  56524. * Gets or sets the source range
  56525. */
  56526. sourceRange: Vector2;
  56527. /**
  56528. * Gets or sets the target range
  56529. */
  56530. targetRange: Vector2;
  56531. /**
  56532. * Creates a new RemapBlock
  56533. * @param name defines the block name
  56534. */
  56535. constructor(name: string);
  56536. /**
  56537. * Gets the current class name
  56538. * @returns the class name
  56539. */
  56540. getClassName(): string;
  56541. /**
  56542. * Gets the input component
  56543. */
  56544. readonly input: NodeMaterialConnectionPoint;
  56545. /**
  56546. * Gets the source min input component
  56547. */
  56548. readonly sourceMin: NodeMaterialConnectionPoint;
  56549. /**
  56550. * Gets the source max input component
  56551. */
  56552. readonly sourceMax: NodeMaterialConnectionPoint;
  56553. /**
  56554. * Gets the target min input component
  56555. */
  56556. readonly targetMin: NodeMaterialConnectionPoint;
  56557. /**
  56558. * Gets the target max input component
  56559. */
  56560. readonly targetMax: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the output component
  56563. */
  56564. readonly output: NodeMaterialConnectionPoint;
  56565. protected _buildBlock(state: NodeMaterialBuildState): this;
  56566. protected _dumpPropertiesCode(): string;
  56567. serialize(): any;
  56568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56569. }
  56570. }
  56571. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56575. /**
  56576. * Block used to normalize a vector
  56577. */
  56578. export class NormalizeBlock extends NodeMaterialBlock {
  56579. /**
  56580. * Creates a new NormalizeBlock
  56581. * @param name defines the block name
  56582. */
  56583. constructor(name: string);
  56584. /**
  56585. * Gets the current class name
  56586. * @returns the class name
  56587. */
  56588. getClassName(): string;
  56589. /**
  56590. * Gets the input component
  56591. */
  56592. readonly input: NodeMaterialConnectionPoint;
  56593. /**
  56594. * Gets the output component
  56595. */
  56596. readonly output: NodeMaterialConnectionPoint;
  56597. protected _buildBlock(state: NodeMaterialBuildState): this;
  56598. }
  56599. }
  56600. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56604. import { Scene } from "babylonjs/scene";
  56605. /**
  56606. * Operations supported by the Trigonometry block
  56607. */
  56608. export enum TrigonometryBlockOperations {
  56609. /** Cos */
  56610. Cos = 0,
  56611. /** Sin */
  56612. Sin = 1,
  56613. /** Abs */
  56614. Abs = 2,
  56615. /** Exp */
  56616. Exp = 3,
  56617. /** Exp2 */
  56618. Exp2 = 4,
  56619. /** Round */
  56620. Round = 5,
  56621. /** Floor */
  56622. Floor = 6,
  56623. /** Ceiling */
  56624. Ceiling = 7,
  56625. /** Square root */
  56626. Sqrt = 8
  56627. }
  56628. /**
  56629. * Block used to apply trigonometry operation to floats
  56630. */
  56631. export class TrigonometryBlock extends NodeMaterialBlock {
  56632. /**
  56633. * Gets or sets the operation applied by the block
  56634. */
  56635. operation: TrigonometryBlockOperations;
  56636. /**
  56637. * Creates a new TrigonometryBlock
  56638. * @param name defines the block name
  56639. */
  56640. constructor(name: string);
  56641. /**
  56642. * Gets the current class name
  56643. * @returns the class name
  56644. */
  56645. getClassName(): string;
  56646. /**
  56647. * Gets the input component
  56648. */
  56649. readonly input: NodeMaterialConnectionPoint;
  56650. /**
  56651. * Gets the output component
  56652. */
  56653. readonly output: NodeMaterialConnectionPoint;
  56654. protected _buildBlock(state: NodeMaterialBuildState): this;
  56655. serialize(): any;
  56656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56657. }
  56658. }
  56659. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56663. /**
  56664. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56665. */
  56666. export class ColorMergerBlock extends NodeMaterialBlock {
  56667. /**
  56668. * Create a new ColorMergerBlock
  56669. * @param name defines the block name
  56670. */
  56671. constructor(name: string);
  56672. /**
  56673. * Gets the current class name
  56674. * @returns the class name
  56675. */
  56676. getClassName(): string;
  56677. /**
  56678. * Gets the r component (input)
  56679. */
  56680. readonly r: NodeMaterialConnectionPoint;
  56681. /**
  56682. * Gets the g component (input)
  56683. */
  56684. readonly g: NodeMaterialConnectionPoint;
  56685. /**
  56686. * Gets the b component (input)
  56687. */
  56688. readonly b: NodeMaterialConnectionPoint;
  56689. /**
  56690. * Gets the a component (input)
  56691. */
  56692. readonly a: NodeMaterialConnectionPoint;
  56693. /**
  56694. * Gets the rgba component (output)
  56695. */
  56696. readonly rgba: NodeMaterialConnectionPoint;
  56697. /**
  56698. * Gets the rgb component (output)
  56699. */
  56700. readonly rgb: NodeMaterialConnectionPoint;
  56701. protected _buildBlock(state: NodeMaterialBuildState): this;
  56702. }
  56703. }
  56704. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56708. /**
  56709. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56710. */
  56711. export class VectorMergerBlock extends NodeMaterialBlock {
  56712. /**
  56713. * Create a new VectorMergerBlock
  56714. * @param name defines the block name
  56715. */
  56716. constructor(name: string);
  56717. /**
  56718. * Gets the current class name
  56719. * @returns the class name
  56720. */
  56721. getClassName(): string;
  56722. /**
  56723. * Gets the x component (input)
  56724. */
  56725. readonly x: NodeMaterialConnectionPoint;
  56726. /**
  56727. * Gets the y component (input)
  56728. */
  56729. readonly y: NodeMaterialConnectionPoint;
  56730. /**
  56731. * Gets the z component (input)
  56732. */
  56733. readonly z: NodeMaterialConnectionPoint;
  56734. /**
  56735. * Gets the w component (input)
  56736. */
  56737. readonly w: NodeMaterialConnectionPoint;
  56738. /**
  56739. * Gets the xyzw component (output)
  56740. */
  56741. readonly xyzw: NodeMaterialConnectionPoint;
  56742. /**
  56743. * Gets the xyz component (output)
  56744. */
  56745. readonly xyz: NodeMaterialConnectionPoint;
  56746. /**
  56747. * Gets the xy component (output)
  56748. */
  56749. readonly xy: NodeMaterialConnectionPoint;
  56750. protected _buildBlock(state: NodeMaterialBuildState): this;
  56751. }
  56752. }
  56753. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56757. /**
  56758. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56759. */
  56760. export class ColorSplitterBlock extends NodeMaterialBlock {
  56761. /**
  56762. * Create a new ColorSplitterBlock
  56763. * @param name defines the block name
  56764. */
  56765. constructor(name: string);
  56766. /**
  56767. * Gets the current class name
  56768. * @returns the class name
  56769. */
  56770. getClassName(): string;
  56771. /**
  56772. * Gets the rgba component (input)
  56773. */
  56774. readonly rgba: NodeMaterialConnectionPoint;
  56775. /**
  56776. * Gets the rgb component (input)
  56777. */
  56778. readonly rgbIn: NodeMaterialConnectionPoint;
  56779. /**
  56780. * Gets the rgb component (output)
  56781. */
  56782. readonly rgbOut: NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the r component (output)
  56785. */
  56786. readonly r: NodeMaterialConnectionPoint;
  56787. /**
  56788. * Gets the g component (output)
  56789. */
  56790. readonly g: NodeMaterialConnectionPoint;
  56791. /**
  56792. * Gets the b component (output)
  56793. */
  56794. readonly b: NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the a component (output)
  56797. */
  56798. readonly a: NodeMaterialConnectionPoint;
  56799. protected _inputRename(name: string): string;
  56800. protected _outputRename(name: string): string;
  56801. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56802. }
  56803. }
  56804. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56808. /**
  56809. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56810. */
  56811. export class VectorSplitterBlock extends NodeMaterialBlock {
  56812. /**
  56813. * Create a new VectorSplitterBlock
  56814. * @param name defines the block name
  56815. */
  56816. constructor(name: string);
  56817. /**
  56818. * Gets the current class name
  56819. * @returns the class name
  56820. */
  56821. getClassName(): string;
  56822. /**
  56823. * Gets the xyzw component (input)
  56824. */
  56825. readonly xyzw: NodeMaterialConnectionPoint;
  56826. /**
  56827. * Gets the xyz component (input)
  56828. */
  56829. readonly xyzIn: NodeMaterialConnectionPoint;
  56830. /**
  56831. * Gets the xy component (input)
  56832. */
  56833. readonly xyIn: NodeMaterialConnectionPoint;
  56834. /**
  56835. * Gets the xyz component (output)
  56836. */
  56837. readonly xyzOut: NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the xy component (output)
  56840. */
  56841. readonly xyOut: NodeMaterialConnectionPoint;
  56842. /**
  56843. * Gets the x component (output)
  56844. */
  56845. readonly x: NodeMaterialConnectionPoint;
  56846. /**
  56847. * Gets the y component (output)
  56848. */
  56849. readonly y: NodeMaterialConnectionPoint;
  56850. /**
  56851. * Gets the z component (output)
  56852. */
  56853. readonly z: NodeMaterialConnectionPoint;
  56854. /**
  56855. * Gets the w component (output)
  56856. */
  56857. readonly w: NodeMaterialConnectionPoint;
  56858. protected _inputRename(name: string): string;
  56859. protected _outputRename(name: string): string;
  56860. protected _buildBlock(state: NodeMaterialBuildState): this;
  56861. }
  56862. }
  56863. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56867. /**
  56868. * Block used to lerp 2 values
  56869. */
  56870. export class LerpBlock extends NodeMaterialBlock {
  56871. /**
  56872. * Creates a new LerpBlock
  56873. * @param name defines the block name
  56874. */
  56875. constructor(name: string);
  56876. /**
  56877. * Gets the current class name
  56878. * @returns the class name
  56879. */
  56880. getClassName(): string;
  56881. /**
  56882. * Gets the left operand input component
  56883. */
  56884. readonly left: NodeMaterialConnectionPoint;
  56885. /**
  56886. * Gets the right operand input component
  56887. */
  56888. readonly right: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the gradient operand input component
  56891. */
  56892. readonly gradient: NodeMaterialConnectionPoint;
  56893. /**
  56894. * Gets the output component
  56895. */
  56896. readonly output: NodeMaterialConnectionPoint;
  56897. protected _buildBlock(state: NodeMaterialBuildState): this;
  56898. }
  56899. }
  56900. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56904. /**
  56905. * Block used to divide 2 vectors
  56906. */
  56907. export class DivideBlock extends NodeMaterialBlock {
  56908. /**
  56909. * Creates a new DivideBlock
  56910. * @param name defines the block name
  56911. */
  56912. constructor(name: string);
  56913. /**
  56914. * Gets the current class name
  56915. * @returns the class name
  56916. */
  56917. getClassName(): string;
  56918. /**
  56919. * Gets the left operand input component
  56920. */
  56921. readonly left: NodeMaterialConnectionPoint;
  56922. /**
  56923. * Gets the right operand input component
  56924. */
  56925. readonly right: NodeMaterialConnectionPoint;
  56926. /**
  56927. * Gets the output component
  56928. */
  56929. readonly output: NodeMaterialConnectionPoint;
  56930. protected _buildBlock(state: NodeMaterialBuildState): this;
  56931. }
  56932. }
  56933. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56937. /**
  56938. * Block used to subtract 2 vectors
  56939. */
  56940. export class SubtractBlock extends NodeMaterialBlock {
  56941. /**
  56942. * Creates a new SubtractBlock
  56943. * @param name defines the block name
  56944. */
  56945. constructor(name: string);
  56946. /**
  56947. * Gets the current class name
  56948. * @returns the class name
  56949. */
  56950. getClassName(): string;
  56951. /**
  56952. * Gets the left operand input component
  56953. */
  56954. readonly left: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the right operand input component
  56957. */
  56958. readonly right: NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the output component
  56961. */
  56962. readonly output: NodeMaterialConnectionPoint;
  56963. protected _buildBlock(state: NodeMaterialBuildState): this;
  56964. }
  56965. }
  56966. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56970. /**
  56971. * Block used to step a value
  56972. */
  56973. export class StepBlock extends NodeMaterialBlock {
  56974. /**
  56975. * Creates a new AddBlock
  56976. * @param name defines the block name
  56977. */
  56978. constructor(name: string);
  56979. /**
  56980. * Gets the current class name
  56981. * @returns the class name
  56982. */
  56983. getClassName(): string;
  56984. /**
  56985. * Gets the value operand input component
  56986. */
  56987. readonly value: NodeMaterialConnectionPoint;
  56988. /**
  56989. * Gets the edge operand input component
  56990. */
  56991. readonly edge: NodeMaterialConnectionPoint;
  56992. /**
  56993. * Gets the output component
  56994. */
  56995. readonly output: NodeMaterialConnectionPoint;
  56996. protected _buildBlock(state: NodeMaterialBuildState): this;
  56997. }
  56998. }
  56999. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57003. /**
  57004. * Block used to get the opposite (1 - x) of a value
  57005. */
  57006. export class OneMinusBlock extends NodeMaterialBlock {
  57007. /**
  57008. * Creates a new OneMinusBlock
  57009. * @param name defines the block name
  57010. */
  57011. constructor(name: string);
  57012. /**
  57013. * Gets the current class name
  57014. * @returns the class name
  57015. */
  57016. getClassName(): string;
  57017. /**
  57018. * Gets the input component
  57019. */
  57020. readonly input: NodeMaterialConnectionPoint;
  57021. /**
  57022. * Gets the output component
  57023. */
  57024. readonly output: NodeMaterialConnectionPoint;
  57025. protected _buildBlock(state: NodeMaterialBuildState): this;
  57026. }
  57027. }
  57028. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57032. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57033. /**
  57034. * Block used to get the view direction
  57035. */
  57036. export class ViewDirectionBlock extends NodeMaterialBlock {
  57037. /**
  57038. * Creates a new ViewDirectionBlock
  57039. * @param name defines the block name
  57040. */
  57041. constructor(name: string);
  57042. /**
  57043. * Gets the current class name
  57044. * @returns the class name
  57045. */
  57046. getClassName(): string;
  57047. /**
  57048. * Gets the world position component
  57049. */
  57050. readonly worldPosition: NodeMaterialConnectionPoint;
  57051. /**
  57052. * Gets the camera position component
  57053. */
  57054. readonly cameraPosition: NodeMaterialConnectionPoint;
  57055. /**
  57056. * Gets the output component
  57057. */
  57058. readonly output: NodeMaterialConnectionPoint;
  57059. autoConfigure(material: NodeMaterial): void;
  57060. protected _buildBlock(state: NodeMaterialBuildState): this;
  57061. }
  57062. }
  57063. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57067. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57068. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57069. /**
  57070. * Block used to compute fresnel value
  57071. */
  57072. export class FresnelBlock extends NodeMaterialBlock {
  57073. /**
  57074. * Create a new FresnelBlock
  57075. * @param name defines the block name
  57076. */
  57077. constructor(name: string);
  57078. /**
  57079. * Gets the current class name
  57080. * @returns the class name
  57081. */
  57082. getClassName(): string;
  57083. /**
  57084. * Gets the world normal input component
  57085. */
  57086. readonly worldNormal: NodeMaterialConnectionPoint;
  57087. /**
  57088. * Gets the view direction input component
  57089. */
  57090. readonly viewDirection: NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the bias input component
  57093. */
  57094. readonly bias: NodeMaterialConnectionPoint;
  57095. /**
  57096. * Gets the camera (or eye) position component
  57097. */
  57098. readonly power: NodeMaterialConnectionPoint;
  57099. /**
  57100. * Gets the fresnel output component
  57101. */
  57102. readonly fresnel: NodeMaterialConnectionPoint;
  57103. autoConfigure(material: NodeMaterial): void;
  57104. protected _buildBlock(state: NodeMaterialBuildState): this;
  57105. }
  57106. }
  57107. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57111. /**
  57112. * Block used to get the max of 2 values
  57113. */
  57114. export class MaxBlock extends NodeMaterialBlock {
  57115. /**
  57116. * Creates a new MaxBlock
  57117. * @param name defines the block name
  57118. */
  57119. constructor(name: string);
  57120. /**
  57121. * Gets the current class name
  57122. * @returns the class name
  57123. */
  57124. getClassName(): string;
  57125. /**
  57126. * Gets the left operand input component
  57127. */
  57128. readonly left: NodeMaterialConnectionPoint;
  57129. /**
  57130. * Gets the right operand input component
  57131. */
  57132. readonly right: NodeMaterialConnectionPoint;
  57133. /**
  57134. * Gets the output component
  57135. */
  57136. readonly output: NodeMaterialConnectionPoint;
  57137. protected _buildBlock(state: NodeMaterialBuildState): this;
  57138. }
  57139. }
  57140. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57144. /**
  57145. * Block used to get the min of 2 values
  57146. */
  57147. export class MinBlock extends NodeMaterialBlock {
  57148. /**
  57149. * Creates a new MinBlock
  57150. * @param name defines the block name
  57151. */
  57152. constructor(name: string);
  57153. /**
  57154. * Gets the current class name
  57155. * @returns the class name
  57156. */
  57157. getClassName(): string;
  57158. /**
  57159. * Gets the left operand input component
  57160. */
  57161. readonly left: NodeMaterialConnectionPoint;
  57162. /**
  57163. * Gets the right operand input component
  57164. */
  57165. readonly right: NodeMaterialConnectionPoint;
  57166. /**
  57167. * Gets the output component
  57168. */
  57169. readonly output: NodeMaterialConnectionPoint;
  57170. protected _buildBlock(state: NodeMaterialBuildState): this;
  57171. }
  57172. }
  57173. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57177. /**
  57178. * Block used to get the distance between 2 values
  57179. */
  57180. export class DistanceBlock extends NodeMaterialBlock {
  57181. /**
  57182. * Creates a new DistanceBlock
  57183. * @param name defines the block name
  57184. */
  57185. constructor(name: string);
  57186. /**
  57187. * Gets the current class name
  57188. * @returns the class name
  57189. */
  57190. getClassName(): string;
  57191. /**
  57192. * Gets the left operand input component
  57193. */
  57194. readonly left: NodeMaterialConnectionPoint;
  57195. /**
  57196. * Gets the right operand input component
  57197. */
  57198. readonly right: NodeMaterialConnectionPoint;
  57199. /**
  57200. * Gets the output component
  57201. */
  57202. readonly output: NodeMaterialConnectionPoint;
  57203. protected _buildBlock(state: NodeMaterialBuildState): this;
  57204. }
  57205. }
  57206. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57210. /**
  57211. * Block used to get the length of a vector
  57212. */
  57213. export class LengthBlock extends NodeMaterialBlock {
  57214. /**
  57215. * Creates a new LengthBlock
  57216. * @param name defines the block name
  57217. */
  57218. constructor(name: string);
  57219. /**
  57220. * Gets the current class name
  57221. * @returns the class name
  57222. */
  57223. getClassName(): string;
  57224. /**
  57225. * Gets the value input component
  57226. */
  57227. readonly value: NodeMaterialConnectionPoint;
  57228. /**
  57229. * Gets the output component
  57230. */
  57231. readonly output: NodeMaterialConnectionPoint;
  57232. protected _buildBlock(state: NodeMaterialBuildState): this;
  57233. }
  57234. }
  57235. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57239. /**
  57240. * Block used to get negative version of a value (i.e. x * -1)
  57241. */
  57242. export class NegateBlock extends NodeMaterialBlock {
  57243. /**
  57244. * Creates a new NegateBlock
  57245. * @param name defines the block name
  57246. */
  57247. constructor(name: string);
  57248. /**
  57249. * Gets the current class name
  57250. * @returns the class name
  57251. */
  57252. getClassName(): string;
  57253. /**
  57254. * Gets the value input component
  57255. */
  57256. readonly value: NodeMaterialConnectionPoint;
  57257. /**
  57258. * Gets the output component
  57259. */
  57260. readonly output: NodeMaterialConnectionPoint;
  57261. protected _buildBlock(state: NodeMaterialBuildState): this;
  57262. }
  57263. }
  57264. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57268. /**
  57269. * Block used to get the value of the first parameter raised to the power of the second
  57270. */
  57271. export class PowBlock extends NodeMaterialBlock {
  57272. /**
  57273. * Creates a new PowBlock
  57274. * @param name defines the block name
  57275. */
  57276. constructor(name: string);
  57277. /**
  57278. * Gets the current class name
  57279. * @returns the class name
  57280. */
  57281. getClassName(): string;
  57282. /**
  57283. * Gets the value operand input component
  57284. */
  57285. readonly value: NodeMaterialConnectionPoint;
  57286. /**
  57287. * Gets the power operand input component
  57288. */
  57289. readonly power: NodeMaterialConnectionPoint;
  57290. /**
  57291. * Gets the output component
  57292. */
  57293. readonly output: NodeMaterialConnectionPoint;
  57294. protected _buildBlock(state: NodeMaterialBuildState): this;
  57295. }
  57296. }
  57297. declare module "babylonjs/Materials/Node/Blocks/index" {
  57298. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57299. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57300. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57301. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57302. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57303. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57304. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57305. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57306. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57307. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57308. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57309. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57310. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57311. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57312. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57313. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57314. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57315. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57316. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57317. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57318. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57319. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57320. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57321. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57322. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57323. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57324. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57325. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57326. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57327. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57328. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57329. }
  57330. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57331. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57332. }
  57333. declare module "babylonjs/Materials/Node/index" {
  57334. export * from "babylonjs/Materials/Node/Enums/index";
  57335. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57336. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57337. export * from "babylonjs/Materials/Node/nodeMaterial";
  57338. export * from "babylonjs/Materials/Node/Blocks/index";
  57339. export * from "babylonjs/Materials/Node/Optimizers/index";
  57340. }
  57341. declare module "babylonjs/Materials/effectRenderer" {
  57342. import { Nullable } from "babylonjs/types";
  57343. import { Texture } from "babylonjs/Materials/Textures/texture";
  57344. import { Engine } from "babylonjs/Engines/engine";
  57345. import { Viewport } from "babylonjs/Maths/math.viewport";
  57346. import { Observable } from "babylonjs/Misc/observable";
  57347. import { Effect } from "babylonjs/Materials/effect";
  57348. import "babylonjs/Shaders/postprocess.vertex";
  57349. /**
  57350. * Effect Render Options
  57351. */
  57352. export interface IEffectRendererOptions {
  57353. /**
  57354. * Defines the vertices positions.
  57355. */
  57356. positions?: number[];
  57357. /**
  57358. * Defines the indices.
  57359. */
  57360. indices?: number[];
  57361. }
  57362. /**
  57363. * Helper class to render one or more effects
  57364. */
  57365. export class EffectRenderer {
  57366. private engine;
  57367. private static _DefaultOptions;
  57368. private _vertexBuffers;
  57369. private _indexBuffer;
  57370. private _ringBufferIndex;
  57371. private _ringScreenBuffer;
  57372. private _fullscreenViewport;
  57373. private _getNextFrameBuffer;
  57374. /**
  57375. * Creates an effect renderer
  57376. * @param engine the engine to use for rendering
  57377. * @param options defines the options of the effect renderer
  57378. */
  57379. constructor(engine: Engine, options?: IEffectRendererOptions);
  57380. /**
  57381. * Sets the current viewport in normalized coordinates 0-1
  57382. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57383. */
  57384. setViewport(viewport?: Viewport): void;
  57385. /**
  57386. * Binds the embedded attributes buffer to the effect.
  57387. * @param effect Defines the effect to bind the attributes for
  57388. */
  57389. bindBuffers(effect: Effect): void;
  57390. /**
  57391. * Sets the current effect wrapper to use during draw.
  57392. * The effect needs to be ready before calling this api.
  57393. * This also sets the default full screen position attribute.
  57394. * @param effectWrapper Defines the effect to draw with
  57395. */
  57396. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57397. /**
  57398. * Draws a full screen quad.
  57399. */
  57400. draw(): void;
  57401. /**
  57402. * renders one or more effects to a specified texture
  57403. * @param effectWrappers list of effects to renderer
  57404. * @param outputTexture texture to draw to, if null it will render to the screen
  57405. */
  57406. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57407. /**
  57408. * Disposes of the effect renderer
  57409. */
  57410. dispose(): void;
  57411. }
  57412. /**
  57413. * Options to create an EffectWrapper
  57414. */
  57415. interface EffectWrapperCreationOptions {
  57416. /**
  57417. * Engine to use to create the effect
  57418. */
  57419. engine: Engine;
  57420. /**
  57421. * Fragment shader for the effect
  57422. */
  57423. fragmentShader: string;
  57424. /**
  57425. * Vertex shader for the effect
  57426. */
  57427. vertexShader?: string;
  57428. /**
  57429. * Attributes to use in the shader
  57430. */
  57431. attributeNames?: Array<string>;
  57432. /**
  57433. * Uniforms to use in the shader
  57434. */
  57435. uniformNames?: Array<string>;
  57436. /**
  57437. * Texture sampler names to use in the shader
  57438. */
  57439. samplerNames?: Array<string>;
  57440. /**
  57441. * The friendly name of the effect displayed in Spector.
  57442. */
  57443. name?: string;
  57444. }
  57445. /**
  57446. * Wraps an effect to be used for rendering
  57447. */
  57448. export class EffectWrapper {
  57449. /**
  57450. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57451. */
  57452. onApplyObservable: Observable<{}>;
  57453. /**
  57454. * The underlying effect
  57455. */
  57456. effect: Effect;
  57457. /**
  57458. * Creates an effect to be renderer
  57459. * @param creationOptions options to create the effect
  57460. */
  57461. constructor(creationOptions: EffectWrapperCreationOptions);
  57462. /**
  57463. * Disposes of the effect wrapper
  57464. */
  57465. dispose(): void;
  57466. }
  57467. }
  57468. declare module "babylonjs/Materials/index" {
  57469. export * from "babylonjs/Materials/Background/index";
  57470. export * from "babylonjs/Materials/colorCurves";
  57471. export * from "babylonjs/Materials/effect";
  57472. export * from "babylonjs/Materials/fresnelParameters";
  57473. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57474. export * from "babylonjs/Materials/material";
  57475. export * from "babylonjs/Materials/materialDefines";
  57476. export * from "babylonjs/Materials/materialHelper";
  57477. export * from "babylonjs/Materials/multiMaterial";
  57478. export * from "babylonjs/Materials/PBR/index";
  57479. export * from "babylonjs/Materials/pushMaterial";
  57480. export * from "babylonjs/Materials/shaderMaterial";
  57481. export * from "babylonjs/Materials/standardMaterial";
  57482. export * from "babylonjs/Materials/Textures/index";
  57483. export * from "babylonjs/Materials/uniformBuffer";
  57484. export * from "babylonjs/Materials/materialFlags";
  57485. export * from "babylonjs/Materials/Node/index";
  57486. export * from "babylonjs/Materials/effectRenderer";
  57487. }
  57488. declare module "babylonjs/Maths/index" {
  57489. export * from "babylonjs/Maths/math.scalar";
  57490. export * from "babylonjs/Maths/math";
  57491. export * from "babylonjs/Maths/sphericalPolynomial";
  57492. }
  57493. declare module "babylonjs/Misc/workerPool" {
  57494. import { IDisposable } from "babylonjs/scene";
  57495. /**
  57496. * Helper class to push actions to a pool of workers.
  57497. */
  57498. export class WorkerPool implements IDisposable {
  57499. private _workerInfos;
  57500. private _pendingActions;
  57501. /**
  57502. * Constructor
  57503. * @param workers Array of workers to use for actions
  57504. */
  57505. constructor(workers: Array<Worker>);
  57506. /**
  57507. * Terminates all workers and clears any pending actions.
  57508. */
  57509. dispose(): void;
  57510. /**
  57511. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57512. * pended until a worker has completed its action.
  57513. * @param action The action to perform. Call onComplete when the action is complete.
  57514. */
  57515. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57516. private _execute;
  57517. }
  57518. }
  57519. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57520. import { IDisposable } from "babylonjs/scene";
  57521. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57522. /**
  57523. * Configuration for Draco compression
  57524. */
  57525. export interface IDracoCompressionConfiguration {
  57526. /**
  57527. * Configuration for the decoder.
  57528. */
  57529. decoder: {
  57530. /**
  57531. * The url to the WebAssembly module.
  57532. */
  57533. wasmUrl?: string;
  57534. /**
  57535. * The url to the WebAssembly binary.
  57536. */
  57537. wasmBinaryUrl?: string;
  57538. /**
  57539. * The url to the fallback JavaScript module.
  57540. */
  57541. fallbackUrl?: string;
  57542. };
  57543. }
  57544. /**
  57545. * Draco compression (https://google.github.io/draco/)
  57546. *
  57547. * This class wraps the Draco module.
  57548. *
  57549. * **Encoder**
  57550. *
  57551. * The encoder is not currently implemented.
  57552. *
  57553. * **Decoder**
  57554. *
  57555. * 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.
  57556. *
  57557. * To update the configuration, use the following code:
  57558. * ```javascript
  57559. * DracoCompression.Configuration = {
  57560. * decoder: {
  57561. * wasmUrl: "<url to the WebAssembly library>",
  57562. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57563. * fallbackUrl: "<url to the fallback JavaScript library>",
  57564. * }
  57565. * };
  57566. * ```
  57567. *
  57568. * 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.
  57569. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57570. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57571. *
  57572. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57573. * ```javascript
  57574. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57575. * ```
  57576. *
  57577. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57578. */
  57579. export class DracoCompression implements IDisposable {
  57580. private _workerPoolPromise?;
  57581. private _decoderModulePromise?;
  57582. /**
  57583. * The configuration. Defaults to the following urls:
  57584. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57585. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57586. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57587. */
  57588. static Configuration: IDracoCompressionConfiguration;
  57589. /**
  57590. * Returns true if the decoder configuration is available.
  57591. */
  57592. static readonly DecoderAvailable: boolean;
  57593. /**
  57594. * Default number of workers to create when creating the draco compression object.
  57595. */
  57596. static DefaultNumWorkers: number;
  57597. private static GetDefaultNumWorkers;
  57598. private static _Default;
  57599. /**
  57600. * Default instance for the draco compression object.
  57601. */
  57602. static readonly Default: DracoCompression;
  57603. /**
  57604. * Constructor
  57605. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57606. */
  57607. constructor(numWorkers?: number);
  57608. /**
  57609. * Stop all async operations and release resources.
  57610. */
  57611. dispose(): void;
  57612. /**
  57613. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57614. * @returns a promise that resolves when ready
  57615. */
  57616. whenReadyAsync(): Promise<void>;
  57617. /**
  57618. * Decode Draco compressed mesh data to vertex data.
  57619. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57620. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57621. * @returns A promise that resolves with the decoded vertex data
  57622. */
  57623. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57624. [kind: string]: number;
  57625. }): Promise<VertexData>;
  57626. }
  57627. }
  57628. declare module "babylonjs/Meshes/Compression/index" {
  57629. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57630. }
  57631. declare module "babylonjs/Meshes/csg" {
  57632. import { Nullable } from "babylonjs/types";
  57633. import { Scene } from "babylonjs/scene";
  57634. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57635. import { Mesh } from "babylonjs/Meshes/mesh";
  57636. import { Material } from "babylonjs/Materials/material";
  57637. /**
  57638. * Class for building Constructive Solid Geometry
  57639. */
  57640. export class CSG {
  57641. private polygons;
  57642. /**
  57643. * The world matrix
  57644. */
  57645. matrix: Matrix;
  57646. /**
  57647. * Stores the position
  57648. */
  57649. position: Vector3;
  57650. /**
  57651. * Stores the rotation
  57652. */
  57653. rotation: Vector3;
  57654. /**
  57655. * Stores the rotation quaternion
  57656. */
  57657. rotationQuaternion: Nullable<Quaternion>;
  57658. /**
  57659. * Stores the scaling vector
  57660. */
  57661. scaling: Vector3;
  57662. /**
  57663. * Convert the Mesh to CSG
  57664. * @param mesh The Mesh to convert to CSG
  57665. * @returns A new CSG from the Mesh
  57666. */
  57667. static FromMesh(mesh: Mesh): CSG;
  57668. /**
  57669. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57670. * @param polygons Polygons used to construct a CSG solid
  57671. */
  57672. private static FromPolygons;
  57673. /**
  57674. * Clones, or makes a deep copy, of the CSG
  57675. * @returns A new CSG
  57676. */
  57677. clone(): CSG;
  57678. /**
  57679. * Unions this CSG with another CSG
  57680. * @param csg The CSG to union against this CSG
  57681. * @returns The unioned CSG
  57682. */
  57683. union(csg: CSG): CSG;
  57684. /**
  57685. * Unions this CSG with another CSG in place
  57686. * @param csg The CSG to union against this CSG
  57687. */
  57688. unionInPlace(csg: CSG): void;
  57689. /**
  57690. * Subtracts this CSG with another CSG
  57691. * @param csg The CSG to subtract against this CSG
  57692. * @returns A new CSG
  57693. */
  57694. subtract(csg: CSG): CSG;
  57695. /**
  57696. * Subtracts this CSG with another CSG in place
  57697. * @param csg The CSG to subtact against this CSG
  57698. */
  57699. subtractInPlace(csg: CSG): void;
  57700. /**
  57701. * Intersect this CSG with another CSG
  57702. * @param csg The CSG to intersect against this CSG
  57703. * @returns A new CSG
  57704. */
  57705. intersect(csg: CSG): CSG;
  57706. /**
  57707. * Intersects this CSG with another CSG in place
  57708. * @param csg The CSG to intersect against this CSG
  57709. */
  57710. intersectInPlace(csg: CSG): void;
  57711. /**
  57712. * Return a new CSG solid with solid and empty space switched. This solid is
  57713. * not modified.
  57714. * @returns A new CSG solid with solid and empty space switched
  57715. */
  57716. inverse(): CSG;
  57717. /**
  57718. * Inverses the CSG in place
  57719. */
  57720. inverseInPlace(): void;
  57721. /**
  57722. * This is used to keep meshes transformations so they can be restored
  57723. * when we build back a Babylon Mesh
  57724. * NB : All CSG operations are performed in world coordinates
  57725. * @param csg The CSG to copy the transform attributes from
  57726. * @returns This CSG
  57727. */
  57728. copyTransformAttributes(csg: CSG): CSG;
  57729. /**
  57730. * Build Raw mesh from CSG
  57731. * Coordinates here are in world space
  57732. * @param name The name of the mesh geometry
  57733. * @param scene The Scene
  57734. * @param keepSubMeshes Specifies if the submeshes should be kept
  57735. * @returns A new Mesh
  57736. */
  57737. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57738. /**
  57739. * Build Mesh from CSG taking material and transforms into account
  57740. * @param name The name of the Mesh
  57741. * @param material The material of the Mesh
  57742. * @param scene The Scene
  57743. * @param keepSubMeshes Specifies if submeshes should be kept
  57744. * @returns The new Mesh
  57745. */
  57746. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57747. }
  57748. }
  57749. declare module "babylonjs/Meshes/trailMesh" {
  57750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57751. import { Mesh } from "babylonjs/Meshes/mesh";
  57752. import { Scene } from "babylonjs/scene";
  57753. /**
  57754. * Class used to create a trail following a mesh
  57755. */
  57756. export class TrailMesh extends Mesh {
  57757. private _generator;
  57758. private _autoStart;
  57759. private _running;
  57760. private _diameter;
  57761. private _length;
  57762. private _sectionPolygonPointsCount;
  57763. private _sectionVectors;
  57764. private _sectionNormalVectors;
  57765. private _beforeRenderObserver;
  57766. /**
  57767. * @constructor
  57768. * @param name The value used by scene.getMeshByName() to do a lookup.
  57769. * @param generator The mesh to generate a trail.
  57770. * @param scene The scene to add this mesh to.
  57771. * @param diameter Diameter of trailing mesh. Default is 1.
  57772. * @param length Length of trailing mesh. Default is 60.
  57773. * @param autoStart Automatically start trailing mesh. Default true.
  57774. */
  57775. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57776. /**
  57777. * "TrailMesh"
  57778. * @returns "TrailMesh"
  57779. */
  57780. getClassName(): string;
  57781. private _createMesh;
  57782. /**
  57783. * Start trailing mesh.
  57784. */
  57785. start(): void;
  57786. /**
  57787. * Stop trailing mesh.
  57788. */
  57789. stop(): void;
  57790. /**
  57791. * Update trailing mesh geometry.
  57792. */
  57793. update(): void;
  57794. /**
  57795. * Returns a new TrailMesh object.
  57796. * @param name is a string, the name given to the new mesh
  57797. * @param newGenerator use new generator object for cloned trail mesh
  57798. * @returns a new mesh
  57799. */
  57800. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57801. /**
  57802. * Serializes this trail mesh
  57803. * @param serializationObject object to write serialization to
  57804. */
  57805. serialize(serializationObject: any): void;
  57806. /**
  57807. * Parses a serialized trail mesh
  57808. * @param parsedMesh the serialized mesh
  57809. * @param scene the scene to create the trail mesh in
  57810. * @returns the created trail mesh
  57811. */
  57812. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57813. }
  57814. }
  57815. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57816. import { Nullable } from "babylonjs/types";
  57817. import { Scene } from "babylonjs/scene";
  57818. import { Vector4 } from "babylonjs/Maths/math.vector";
  57819. import { Color4 } from "babylonjs/Maths/math.color";
  57820. import { Mesh } from "babylonjs/Meshes/mesh";
  57821. /**
  57822. * Class containing static functions to help procedurally build meshes
  57823. */
  57824. export class TiledBoxBuilder {
  57825. /**
  57826. * Creates a box mesh
  57827. * 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)
  57828. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57832. * @param name defines the name of the mesh
  57833. * @param options defines the options used to create the mesh
  57834. * @param scene defines the hosting scene
  57835. * @returns the box mesh
  57836. */
  57837. static CreateTiledBox(name: string, options: {
  57838. pattern?: number;
  57839. width?: number;
  57840. height?: number;
  57841. depth?: number;
  57842. tileSize?: number;
  57843. tileWidth?: number;
  57844. tileHeight?: number;
  57845. alignHorizontal?: number;
  57846. alignVertical?: number;
  57847. faceUV?: Vector4[];
  57848. faceColors?: Color4[];
  57849. sideOrientation?: number;
  57850. updatable?: boolean;
  57851. }, scene?: Nullable<Scene>): Mesh;
  57852. }
  57853. }
  57854. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57855. import { Vector4 } from "babylonjs/Maths/math.vector";
  57856. import { Mesh } from "babylonjs/Meshes/mesh";
  57857. /**
  57858. * Class containing static functions to help procedurally build meshes
  57859. */
  57860. export class TorusKnotBuilder {
  57861. /**
  57862. * Creates a torus knot mesh
  57863. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57864. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57865. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57866. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57870. * @param name defines the name of the mesh
  57871. * @param options defines the options used to create the mesh
  57872. * @param scene defines the hosting scene
  57873. * @returns the torus knot mesh
  57874. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57875. */
  57876. static CreateTorusKnot(name: string, options: {
  57877. radius?: number;
  57878. tube?: number;
  57879. radialSegments?: number;
  57880. tubularSegments?: number;
  57881. p?: number;
  57882. q?: number;
  57883. updatable?: boolean;
  57884. sideOrientation?: number;
  57885. frontUVs?: Vector4;
  57886. backUVs?: Vector4;
  57887. }, scene: any): Mesh;
  57888. }
  57889. }
  57890. declare module "babylonjs/Meshes/polygonMesh" {
  57891. import { Scene } from "babylonjs/scene";
  57892. import { Vector2 } from "babylonjs/Maths/math.vector";
  57893. import { Mesh } from "babylonjs/Meshes/mesh";
  57894. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57895. import { Path2 } from "babylonjs/Maths/math.path";
  57896. /**
  57897. * Polygon
  57898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57899. */
  57900. export class Polygon {
  57901. /**
  57902. * Creates a rectangle
  57903. * @param xmin bottom X coord
  57904. * @param ymin bottom Y coord
  57905. * @param xmax top X coord
  57906. * @param ymax top Y coord
  57907. * @returns points that make the resulting rectation
  57908. */
  57909. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57910. /**
  57911. * Creates a circle
  57912. * @param radius radius of circle
  57913. * @param cx scale in x
  57914. * @param cy scale in y
  57915. * @param numberOfSides number of sides that make up the circle
  57916. * @returns points that make the resulting circle
  57917. */
  57918. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57919. /**
  57920. * Creates a polygon from input string
  57921. * @param input Input polygon data
  57922. * @returns the parsed points
  57923. */
  57924. static Parse(input: string): Vector2[];
  57925. /**
  57926. * Starts building a polygon from x and y coordinates
  57927. * @param x x coordinate
  57928. * @param y y coordinate
  57929. * @returns the started path2
  57930. */
  57931. static StartingAt(x: number, y: number): Path2;
  57932. }
  57933. /**
  57934. * Builds a polygon
  57935. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57936. */
  57937. export class PolygonMeshBuilder {
  57938. private _points;
  57939. private _outlinepoints;
  57940. private _holes;
  57941. private _name;
  57942. private _scene;
  57943. private _epoints;
  57944. private _eholes;
  57945. private _addToepoint;
  57946. /**
  57947. * Babylon reference to the earcut plugin.
  57948. */
  57949. bjsEarcut: any;
  57950. /**
  57951. * Creates a PolygonMeshBuilder
  57952. * @param name name of the builder
  57953. * @param contours Path of the polygon
  57954. * @param scene scene to add to when creating the mesh
  57955. * @param earcutInjection can be used to inject your own earcut reference
  57956. */
  57957. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57958. /**
  57959. * Adds a whole within the polygon
  57960. * @param hole Array of points defining the hole
  57961. * @returns this
  57962. */
  57963. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57964. /**
  57965. * Creates the polygon
  57966. * @param updatable If the mesh should be updatable
  57967. * @param depth The depth of the mesh created
  57968. * @returns the created mesh
  57969. */
  57970. build(updatable?: boolean, depth?: number): Mesh;
  57971. /**
  57972. * Creates the polygon
  57973. * @param depth The depth of the mesh created
  57974. * @returns the created VertexData
  57975. */
  57976. buildVertexData(depth?: number): VertexData;
  57977. /**
  57978. * Adds a side to the polygon
  57979. * @param positions points that make the polygon
  57980. * @param normals normals of the polygon
  57981. * @param uvs uvs of the polygon
  57982. * @param indices indices of the polygon
  57983. * @param bounds bounds of the polygon
  57984. * @param points points of the polygon
  57985. * @param depth depth of the polygon
  57986. * @param flip flip of the polygon
  57987. */
  57988. private addSide;
  57989. }
  57990. }
  57991. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57992. import { Scene } from "babylonjs/scene";
  57993. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57994. import { Color4 } from "babylonjs/Maths/math.color";
  57995. import { Mesh } from "babylonjs/Meshes/mesh";
  57996. import { Nullable } from "babylonjs/types";
  57997. /**
  57998. * Class containing static functions to help procedurally build meshes
  57999. */
  58000. export class PolygonBuilder {
  58001. /**
  58002. * Creates a polygon mesh
  58003. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58004. * * 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
  58005. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58008. * * Remember you can only change the shape positions, not their number when updating a polygon
  58009. * @param name defines the name of the mesh
  58010. * @param options defines the options used to create the mesh
  58011. * @param scene defines the hosting scene
  58012. * @param earcutInjection can be used to inject your own earcut reference
  58013. * @returns the polygon mesh
  58014. */
  58015. static CreatePolygon(name: string, options: {
  58016. shape: Vector3[];
  58017. holes?: Vector3[][];
  58018. depth?: number;
  58019. faceUV?: Vector4[];
  58020. faceColors?: Color4[];
  58021. updatable?: boolean;
  58022. sideOrientation?: number;
  58023. frontUVs?: Vector4;
  58024. backUVs?: Vector4;
  58025. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58026. /**
  58027. * Creates an extruded polygon mesh, with depth in the Y direction.
  58028. * * 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)
  58029. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58030. * @param name defines the name of the mesh
  58031. * @param options defines the options used to create the mesh
  58032. * @param scene defines the hosting scene
  58033. * @param earcutInjection can be used to inject your own earcut reference
  58034. * @returns the polygon mesh
  58035. */
  58036. static ExtrudePolygon(name: string, options: {
  58037. shape: Vector3[];
  58038. holes?: Vector3[][];
  58039. depth?: number;
  58040. faceUV?: Vector4[];
  58041. faceColors?: Color4[];
  58042. updatable?: boolean;
  58043. sideOrientation?: number;
  58044. frontUVs?: Vector4;
  58045. backUVs?: Vector4;
  58046. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58047. }
  58048. }
  58049. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58050. import { Scene } from "babylonjs/scene";
  58051. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58052. import { Mesh } from "babylonjs/Meshes/mesh";
  58053. import { Nullable } from "babylonjs/types";
  58054. /**
  58055. * Class containing static functions to help procedurally build meshes
  58056. */
  58057. export class LatheBuilder {
  58058. /**
  58059. * Creates lathe mesh.
  58060. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58061. * * 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
  58062. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58063. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58064. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58065. * * 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
  58066. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58067. * * 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
  58068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58072. * @param name defines the name of the mesh
  58073. * @param options defines the options used to create the mesh
  58074. * @param scene defines the hosting scene
  58075. * @returns the lathe mesh
  58076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58077. */
  58078. static CreateLathe(name: string, options: {
  58079. shape: Vector3[];
  58080. radius?: number;
  58081. tessellation?: number;
  58082. clip?: number;
  58083. arc?: number;
  58084. closed?: boolean;
  58085. updatable?: boolean;
  58086. sideOrientation?: number;
  58087. frontUVs?: Vector4;
  58088. backUVs?: Vector4;
  58089. cap?: number;
  58090. invertUV?: boolean;
  58091. }, scene?: Nullable<Scene>): Mesh;
  58092. }
  58093. }
  58094. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58095. import { Nullable } from "babylonjs/types";
  58096. import { Scene } from "babylonjs/scene";
  58097. import { Vector4 } from "babylonjs/Maths/math.vector";
  58098. import { Mesh } from "babylonjs/Meshes/mesh";
  58099. /**
  58100. * Class containing static functions to help procedurally build meshes
  58101. */
  58102. export class TiledPlaneBuilder {
  58103. /**
  58104. * Creates a tiled plane mesh
  58105. * * The parameter `pattern` will, depending on value, do nothing or
  58106. * * * flip (reflect about central vertical) alternate tiles across and up
  58107. * * * flip every tile on alternate rows
  58108. * * * rotate (180 degs) alternate tiles across and up
  58109. * * * rotate every tile on alternate rows
  58110. * * * flip and rotate alternate tiles across and up
  58111. * * * flip and rotate every tile on alternate rows
  58112. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58113. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58116. * * 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)
  58117. * * 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)
  58118. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58119. * @param name defines the name of the mesh
  58120. * @param options defines the options used to create the mesh
  58121. * @param scene defines the hosting scene
  58122. * @returns the box mesh
  58123. */
  58124. static CreateTiledPlane(name: string, options: {
  58125. pattern?: number;
  58126. tileSize?: number;
  58127. tileWidth?: number;
  58128. tileHeight?: number;
  58129. size?: number;
  58130. width?: number;
  58131. height?: number;
  58132. alignHorizontal?: number;
  58133. alignVertical?: number;
  58134. sideOrientation?: number;
  58135. frontUVs?: Vector4;
  58136. backUVs?: Vector4;
  58137. updatable?: boolean;
  58138. }, scene?: Nullable<Scene>): Mesh;
  58139. }
  58140. }
  58141. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58142. import { Nullable } from "babylonjs/types";
  58143. import { Scene } from "babylonjs/scene";
  58144. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58145. import { Mesh } from "babylonjs/Meshes/mesh";
  58146. /**
  58147. * Class containing static functions to help procedurally build meshes
  58148. */
  58149. export class TubeBuilder {
  58150. /**
  58151. * Creates a tube mesh.
  58152. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58153. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58154. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58155. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58156. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58157. * * 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)
  58158. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58159. * * 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
  58160. * * 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
  58161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58165. * @param name defines the name of the mesh
  58166. * @param options defines the options used to create the mesh
  58167. * @param scene defines the hosting scene
  58168. * @returns the tube mesh
  58169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58170. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58171. */
  58172. static CreateTube(name: string, options: {
  58173. path: Vector3[];
  58174. radius?: number;
  58175. tessellation?: number;
  58176. radiusFunction?: {
  58177. (i: number, distance: number): number;
  58178. };
  58179. cap?: number;
  58180. arc?: number;
  58181. updatable?: boolean;
  58182. sideOrientation?: number;
  58183. frontUVs?: Vector4;
  58184. backUVs?: Vector4;
  58185. instance?: Mesh;
  58186. invertUV?: boolean;
  58187. }, scene?: Nullable<Scene>): Mesh;
  58188. }
  58189. }
  58190. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58191. import { Scene } from "babylonjs/scene";
  58192. import { Vector4 } from "babylonjs/Maths/math.vector";
  58193. import { Mesh } from "babylonjs/Meshes/mesh";
  58194. import { Nullable } from "babylonjs/types";
  58195. /**
  58196. * Class containing static functions to help procedurally build meshes
  58197. */
  58198. export class IcoSphereBuilder {
  58199. /**
  58200. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58201. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58202. * * 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`)
  58203. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58204. * * 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
  58205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58208. * @param name defines the name of the mesh
  58209. * @param options defines the options used to create the mesh
  58210. * @param scene defines the hosting scene
  58211. * @returns the icosahedron mesh
  58212. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58213. */
  58214. static CreateIcoSphere(name: string, options: {
  58215. radius?: number;
  58216. radiusX?: number;
  58217. radiusY?: number;
  58218. radiusZ?: number;
  58219. flat?: boolean;
  58220. subdivisions?: number;
  58221. sideOrientation?: number;
  58222. frontUVs?: Vector4;
  58223. backUVs?: Vector4;
  58224. updatable?: boolean;
  58225. }, scene?: Nullable<Scene>): Mesh;
  58226. }
  58227. }
  58228. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58229. import { Vector3 } from "babylonjs/Maths/math.vector";
  58230. import { Mesh } from "babylonjs/Meshes/mesh";
  58231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58232. /**
  58233. * Class containing static functions to help procedurally build meshes
  58234. */
  58235. export class DecalBuilder {
  58236. /**
  58237. * Creates a decal mesh.
  58238. * 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
  58239. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58240. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58241. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58242. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58243. * @param name defines the name of the mesh
  58244. * @param sourceMesh defines the mesh where the decal must be applied
  58245. * @param options defines the options used to create the mesh
  58246. * @param scene defines the hosting scene
  58247. * @returns the decal mesh
  58248. * @see https://doc.babylonjs.com/how_to/decals
  58249. */
  58250. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58251. position?: Vector3;
  58252. normal?: Vector3;
  58253. size?: Vector3;
  58254. angle?: number;
  58255. }): Mesh;
  58256. }
  58257. }
  58258. declare module "babylonjs/Meshes/meshBuilder" {
  58259. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58260. import { Nullable } from "babylonjs/types";
  58261. import { Scene } from "babylonjs/scene";
  58262. import { Mesh } from "babylonjs/Meshes/mesh";
  58263. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58264. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58266. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58267. import { Plane } from "babylonjs/Maths/math.plane";
  58268. /**
  58269. * Class containing static functions to help procedurally build meshes
  58270. */
  58271. export class MeshBuilder {
  58272. /**
  58273. * Creates a box mesh
  58274. * * The parameter `size` sets the size (float) of each box side (default 1)
  58275. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58276. * * 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)
  58277. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58281. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58282. * @param name defines the name of the mesh
  58283. * @param options defines the options used to create the mesh
  58284. * @param scene defines the hosting scene
  58285. * @returns the box mesh
  58286. */
  58287. static CreateBox(name: string, options: {
  58288. size?: number;
  58289. width?: number;
  58290. height?: number;
  58291. depth?: number;
  58292. faceUV?: Vector4[];
  58293. faceColors?: Color4[];
  58294. sideOrientation?: number;
  58295. frontUVs?: Vector4;
  58296. backUVs?: Vector4;
  58297. updatable?: boolean;
  58298. }, scene?: Nullable<Scene>): Mesh;
  58299. /**
  58300. * Creates a tiled box mesh
  58301. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58303. * @param name defines the name of the mesh
  58304. * @param options defines the options used to create the mesh
  58305. * @param scene defines the hosting scene
  58306. * @returns the tiled box mesh
  58307. */
  58308. static CreateTiledBox(name: string, options: {
  58309. pattern?: number;
  58310. size?: number;
  58311. width?: number;
  58312. height?: number;
  58313. depth: number;
  58314. tileSize?: number;
  58315. tileWidth?: number;
  58316. tileHeight?: number;
  58317. faceUV?: Vector4[];
  58318. faceColors?: Color4[];
  58319. alignHorizontal?: number;
  58320. alignVertical?: number;
  58321. sideOrientation?: number;
  58322. updatable?: boolean;
  58323. }, scene?: Nullable<Scene>): Mesh;
  58324. /**
  58325. * Creates a sphere mesh
  58326. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58327. * * 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`)
  58328. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58329. * * 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
  58330. * * 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)
  58331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58334. * @param name defines the name of the mesh
  58335. * @param options defines the options used to create the mesh
  58336. * @param scene defines the hosting scene
  58337. * @returns the sphere mesh
  58338. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58339. */
  58340. static CreateSphere(name: string, options: {
  58341. segments?: number;
  58342. diameter?: number;
  58343. diameterX?: number;
  58344. diameterY?: number;
  58345. diameterZ?: number;
  58346. arc?: number;
  58347. slice?: number;
  58348. sideOrientation?: number;
  58349. frontUVs?: Vector4;
  58350. backUVs?: Vector4;
  58351. updatable?: boolean;
  58352. }, scene?: Nullable<Scene>): Mesh;
  58353. /**
  58354. * Creates a plane polygonal mesh. By default, this is a disc
  58355. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58356. * * 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
  58357. * * 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
  58358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58361. * @param name defines the name of the mesh
  58362. * @param options defines the options used to create the mesh
  58363. * @param scene defines the hosting scene
  58364. * @returns the plane polygonal mesh
  58365. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58366. */
  58367. static CreateDisc(name: string, options: {
  58368. radius?: number;
  58369. tessellation?: number;
  58370. arc?: number;
  58371. updatable?: boolean;
  58372. sideOrientation?: number;
  58373. frontUVs?: Vector4;
  58374. backUVs?: Vector4;
  58375. }, scene?: Nullable<Scene>): Mesh;
  58376. /**
  58377. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58378. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58379. * * 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`)
  58380. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58381. * * 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
  58382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58385. * @param name defines the name of the mesh
  58386. * @param options defines the options used to create the mesh
  58387. * @param scene defines the hosting scene
  58388. * @returns the icosahedron mesh
  58389. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58390. */
  58391. static CreateIcoSphere(name: string, options: {
  58392. radius?: number;
  58393. radiusX?: number;
  58394. radiusY?: number;
  58395. radiusZ?: number;
  58396. flat?: boolean;
  58397. subdivisions?: number;
  58398. sideOrientation?: number;
  58399. frontUVs?: Vector4;
  58400. backUVs?: Vector4;
  58401. updatable?: boolean;
  58402. }, scene?: Nullable<Scene>): Mesh;
  58403. /**
  58404. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58405. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58406. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58407. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58408. * * 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
  58409. * * 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
  58410. * * 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
  58411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58414. * * 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
  58415. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58416. * * 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
  58417. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58419. * @param name defines the name of the mesh
  58420. * @param options defines the options used to create the mesh
  58421. * @param scene defines the hosting scene
  58422. * @returns the ribbon mesh
  58423. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58425. */
  58426. static CreateRibbon(name: string, options: {
  58427. pathArray: Vector3[][];
  58428. closeArray?: boolean;
  58429. closePath?: boolean;
  58430. offset?: number;
  58431. updatable?: boolean;
  58432. sideOrientation?: number;
  58433. frontUVs?: Vector4;
  58434. backUVs?: Vector4;
  58435. instance?: Mesh;
  58436. invertUV?: boolean;
  58437. uvs?: Vector2[];
  58438. colors?: Color4[];
  58439. }, scene?: Nullable<Scene>): Mesh;
  58440. /**
  58441. * Creates a cylinder or a cone mesh
  58442. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58443. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58444. * * 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.
  58445. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58446. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58447. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58448. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58449. * * 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).
  58450. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58451. * * 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).
  58452. * * 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
  58453. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58454. * * 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
  58455. * * 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.
  58456. * * If `enclose` is false, a ring surface is one element.
  58457. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58458. * * 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
  58459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58462. * @param name defines the name of the mesh
  58463. * @param options defines the options used to create the mesh
  58464. * @param scene defines the hosting scene
  58465. * @returns the cylinder mesh
  58466. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58467. */
  58468. static CreateCylinder(name: string, options: {
  58469. height?: number;
  58470. diameterTop?: number;
  58471. diameterBottom?: number;
  58472. diameter?: number;
  58473. tessellation?: number;
  58474. subdivisions?: number;
  58475. arc?: number;
  58476. faceColors?: Color4[];
  58477. faceUV?: Vector4[];
  58478. updatable?: boolean;
  58479. hasRings?: boolean;
  58480. enclose?: boolean;
  58481. cap?: number;
  58482. sideOrientation?: number;
  58483. frontUVs?: Vector4;
  58484. backUVs?: Vector4;
  58485. }, scene?: Nullable<Scene>): Mesh;
  58486. /**
  58487. * Creates a torus mesh
  58488. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58489. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58490. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58494. * @param name defines the name of the mesh
  58495. * @param options defines the options used to create the mesh
  58496. * @param scene defines the hosting scene
  58497. * @returns the torus mesh
  58498. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58499. */
  58500. static CreateTorus(name: string, options: {
  58501. diameter?: number;
  58502. thickness?: number;
  58503. tessellation?: number;
  58504. updatable?: boolean;
  58505. sideOrientation?: number;
  58506. frontUVs?: Vector4;
  58507. backUVs?: Vector4;
  58508. }, scene?: Nullable<Scene>): Mesh;
  58509. /**
  58510. * Creates a torus knot mesh
  58511. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58512. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58513. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58514. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58518. * @param name defines the name of the mesh
  58519. * @param options defines the options used to create the mesh
  58520. * @param scene defines the hosting scene
  58521. * @returns the torus knot mesh
  58522. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58523. */
  58524. static CreateTorusKnot(name: string, options: {
  58525. radius?: number;
  58526. tube?: number;
  58527. radialSegments?: number;
  58528. tubularSegments?: number;
  58529. p?: number;
  58530. q?: number;
  58531. updatable?: boolean;
  58532. sideOrientation?: number;
  58533. frontUVs?: Vector4;
  58534. backUVs?: Vector4;
  58535. }, scene?: Nullable<Scene>): Mesh;
  58536. /**
  58537. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58538. * * 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
  58539. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58540. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58541. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58542. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58543. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58544. * * 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
  58545. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58548. * @param name defines the name of the new line system
  58549. * @param options defines the options used to create the line system
  58550. * @param scene defines the hosting scene
  58551. * @returns a new line system mesh
  58552. */
  58553. static CreateLineSystem(name: string, options: {
  58554. lines: Vector3[][];
  58555. updatable?: boolean;
  58556. instance?: Nullable<LinesMesh>;
  58557. colors?: Nullable<Color4[][]>;
  58558. useVertexAlpha?: boolean;
  58559. }, scene: Nullable<Scene>): LinesMesh;
  58560. /**
  58561. * Creates a line mesh
  58562. * 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
  58563. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58564. * * The parameter `points` is an array successive Vector3
  58565. * * 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
  58566. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58567. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58568. * * When updating an instance, remember that only point positions can change, not the number of points
  58569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58571. * @param name defines the name of the new line system
  58572. * @param options defines the options used to create the line system
  58573. * @param scene defines the hosting scene
  58574. * @returns a new line mesh
  58575. */
  58576. static CreateLines(name: string, options: {
  58577. points: Vector3[];
  58578. updatable?: boolean;
  58579. instance?: Nullable<LinesMesh>;
  58580. colors?: Color4[];
  58581. useVertexAlpha?: boolean;
  58582. }, scene?: Nullable<Scene>): LinesMesh;
  58583. /**
  58584. * Creates a dashed line mesh
  58585. * * 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
  58586. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58587. * * The parameter `points` is an array successive Vector3
  58588. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58589. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58590. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58591. * * 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
  58592. * * When updating an instance, remember that only point positions can change, not the number of points
  58593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58594. * @param name defines the name of the mesh
  58595. * @param options defines the options used to create the mesh
  58596. * @param scene defines the hosting scene
  58597. * @returns the dashed line mesh
  58598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58599. */
  58600. static CreateDashedLines(name: string, options: {
  58601. points: Vector3[];
  58602. dashSize?: number;
  58603. gapSize?: number;
  58604. dashNb?: number;
  58605. updatable?: boolean;
  58606. instance?: LinesMesh;
  58607. }, scene?: Nullable<Scene>): LinesMesh;
  58608. /**
  58609. * 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.
  58610. * * 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.
  58611. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58612. * * 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.
  58613. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58614. * * 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
  58615. * * 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
  58616. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58621. * @param name defines the name of the mesh
  58622. * @param options defines the options used to create the mesh
  58623. * @param scene defines the hosting scene
  58624. * @returns the extruded shape mesh
  58625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58627. */
  58628. static ExtrudeShape(name: string, options: {
  58629. shape: Vector3[];
  58630. path: Vector3[];
  58631. scale?: number;
  58632. rotation?: number;
  58633. cap?: number;
  58634. updatable?: boolean;
  58635. sideOrientation?: number;
  58636. frontUVs?: Vector4;
  58637. backUVs?: Vector4;
  58638. instance?: Mesh;
  58639. invertUV?: boolean;
  58640. }, scene?: Nullable<Scene>): Mesh;
  58641. /**
  58642. * Creates an custom extruded shape mesh.
  58643. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58644. * * 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.
  58645. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58646. * * 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
  58647. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58648. * * 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
  58649. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58650. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58651. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58652. * * 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
  58653. * * 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
  58654. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58659. * @param name defines the name of the mesh
  58660. * @param options defines the options used to create the mesh
  58661. * @param scene defines the hosting scene
  58662. * @returns the custom extruded shape mesh
  58663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58666. */
  58667. static ExtrudeShapeCustom(name: string, options: {
  58668. shape: Vector3[];
  58669. path: Vector3[];
  58670. scaleFunction?: any;
  58671. rotationFunction?: any;
  58672. ribbonCloseArray?: boolean;
  58673. ribbonClosePath?: boolean;
  58674. cap?: number;
  58675. updatable?: boolean;
  58676. sideOrientation?: number;
  58677. frontUVs?: Vector4;
  58678. backUVs?: Vector4;
  58679. instance?: Mesh;
  58680. invertUV?: boolean;
  58681. }, scene?: Nullable<Scene>): Mesh;
  58682. /**
  58683. * Creates lathe mesh.
  58684. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58685. * * 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
  58686. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58687. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58688. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58689. * * 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
  58690. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58691. * * 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
  58692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58696. * @param name defines the name of the mesh
  58697. * @param options defines the options used to create the mesh
  58698. * @param scene defines the hosting scene
  58699. * @returns the lathe mesh
  58700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58701. */
  58702. static CreateLathe(name: string, options: {
  58703. shape: Vector3[];
  58704. radius?: number;
  58705. tessellation?: number;
  58706. clip?: number;
  58707. arc?: number;
  58708. closed?: boolean;
  58709. updatable?: boolean;
  58710. sideOrientation?: number;
  58711. frontUVs?: Vector4;
  58712. backUVs?: Vector4;
  58713. cap?: number;
  58714. invertUV?: boolean;
  58715. }, scene?: Nullable<Scene>): Mesh;
  58716. /**
  58717. * Creates a tiled plane mesh
  58718. * * You can set a limited pattern arrangement with the tiles
  58719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58722. * @param name defines the name of the mesh
  58723. * @param options defines the options used to create the mesh
  58724. * @param scene defines the hosting scene
  58725. * @returns the plane mesh
  58726. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58727. */
  58728. static CreateTiledPlane(name: string, options: {
  58729. pattern?: number;
  58730. tileSize?: number;
  58731. tileWidth?: number;
  58732. tileHeight?: number;
  58733. size?: number;
  58734. width?: number;
  58735. height?: number;
  58736. alignHorizontal?: number;
  58737. alignVertical?: number;
  58738. sideOrientation?: number;
  58739. frontUVs?: Vector4;
  58740. backUVs?: Vector4;
  58741. updatable?: boolean;
  58742. }, scene?: Nullable<Scene>): Mesh;
  58743. /**
  58744. * Creates a plane mesh
  58745. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58746. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58747. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58751. * @param name defines the name of the mesh
  58752. * @param options defines the options used to create the mesh
  58753. * @param scene defines the hosting scene
  58754. * @returns the plane mesh
  58755. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58756. */
  58757. static CreatePlane(name: string, options: {
  58758. size?: number;
  58759. width?: number;
  58760. height?: number;
  58761. sideOrientation?: number;
  58762. frontUVs?: Vector4;
  58763. backUVs?: Vector4;
  58764. updatable?: boolean;
  58765. sourcePlane?: Plane;
  58766. }, scene?: Nullable<Scene>): Mesh;
  58767. /**
  58768. * Creates a ground mesh
  58769. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58770. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58772. * @param name defines the name of the mesh
  58773. * @param options defines the options used to create the mesh
  58774. * @param scene defines the hosting scene
  58775. * @returns the ground mesh
  58776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58777. */
  58778. static CreateGround(name: string, options: {
  58779. width?: number;
  58780. height?: number;
  58781. subdivisions?: number;
  58782. subdivisionsX?: number;
  58783. subdivisionsY?: number;
  58784. updatable?: boolean;
  58785. }, scene?: Nullable<Scene>): Mesh;
  58786. /**
  58787. * Creates a tiled ground mesh
  58788. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58789. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58790. * * 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
  58791. * * 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
  58792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58793. * @param name defines the name of the mesh
  58794. * @param options defines the options used to create the mesh
  58795. * @param scene defines the hosting scene
  58796. * @returns the tiled ground mesh
  58797. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58798. */
  58799. static CreateTiledGround(name: string, options: {
  58800. xmin: number;
  58801. zmin: number;
  58802. xmax: number;
  58803. zmax: number;
  58804. subdivisions?: {
  58805. w: number;
  58806. h: number;
  58807. };
  58808. precision?: {
  58809. w: number;
  58810. h: number;
  58811. };
  58812. updatable?: boolean;
  58813. }, scene?: Nullable<Scene>): Mesh;
  58814. /**
  58815. * Creates a ground mesh from a height map
  58816. * * The parameter `url` sets the URL of the height map image resource.
  58817. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58818. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58819. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58820. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58821. * * 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.
  58822. * * 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).
  58823. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58825. * @param name defines the name of the mesh
  58826. * @param url defines the url to the height map
  58827. * @param options defines the options used to create the mesh
  58828. * @param scene defines the hosting scene
  58829. * @returns the ground mesh
  58830. * @see https://doc.babylonjs.com/babylon101/height_map
  58831. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58832. */
  58833. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58834. width?: number;
  58835. height?: number;
  58836. subdivisions?: number;
  58837. minHeight?: number;
  58838. maxHeight?: number;
  58839. colorFilter?: Color3;
  58840. alphaFilter?: number;
  58841. updatable?: boolean;
  58842. onReady?: (mesh: GroundMesh) => void;
  58843. }, scene?: Nullable<Scene>): GroundMesh;
  58844. /**
  58845. * Creates a polygon mesh
  58846. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58847. * * 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
  58848. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58851. * * Remember you can only change the shape positions, not their number when updating a polygon
  58852. * @param name defines the name of the mesh
  58853. * @param options defines the options used to create the mesh
  58854. * @param scene defines the hosting scene
  58855. * @param earcutInjection can be used to inject your own earcut reference
  58856. * @returns the polygon mesh
  58857. */
  58858. static CreatePolygon(name: string, options: {
  58859. shape: Vector3[];
  58860. holes?: Vector3[][];
  58861. depth?: number;
  58862. faceUV?: Vector4[];
  58863. faceColors?: Color4[];
  58864. updatable?: boolean;
  58865. sideOrientation?: number;
  58866. frontUVs?: Vector4;
  58867. backUVs?: Vector4;
  58868. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58869. /**
  58870. * Creates an extruded polygon mesh, with depth in the Y direction.
  58871. * * 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)
  58872. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58873. * @param name defines the name of the mesh
  58874. * @param options defines the options used to create the mesh
  58875. * @param scene defines the hosting scene
  58876. * @param earcutInjection can be used to inject your own earcut reference
  58877. * @returns the polygon mesh
  58878. */
  58879. static ExtrudePolygon(name: string, options: {
  58880. shape: Vector3[];
  58881. holes?: Vector3[][];
  58882. depth?: number;
  58883. faceUV?: Vector4[];
  58884. faceColors?: Color4[];
  58885. updatable?: boolean;
  58886. sideOrientation?: number;
  58887. frontUVs?: Vector4;
  58888. backUVs?: Vector4;
  58889. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58890. /**
  58891. * Creates a tube mesh.
  58892. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58893. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58894. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58895. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58896. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58897. * * 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)
  58898. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58899. * * 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
  58900. * * 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
  58901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58903. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58905. * @param name defines the name of the mesh
  58906. * @param options defines the options used to create the mesh
  58907. * @param scene defines the hosting scene
  58908. * @returns the tube mesh
  58909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58910. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58911. */
  58912. static CreateTube(name: string, options: {
  58913. path: Vector3[];
  58914. radius?: number;
  58915. tessellation?: number;
  58916. radiusFunction?: {
  58917. (i: number, distance: number): number;
  58918. };
  58919. cap?: number;
  58920. arc?: number;
  58921. updatable?: boolean;
  58922. sideOrientation?: number;
  58923. frontUVs?: Vector4;
  58924. backUVs?: Vector4;
  58925. instance?: Mesh;
  58926. invertUV?: boolean;
  58927. }, scene?: Nullable<Scene>): Mesh;
  58928. /**
  58929. * Creates a polyhedron mesh
  58930. * * 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
  58931. * * The parameter `size` (positive float, default 1) sets the polygon size
  58932. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58933. * * 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`
  58934. * * 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
  58935. * * 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)`)
  58936. * * 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
  58937. * * 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
  58938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58941. * @param name defines the name of the mesh
  58942. * @param options defines the options used to create the mesh
  58943. * @param scene defines the hosting scene
  58944. * @returns the polyhedron mesh
  58945. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58946. */
  58947. static CreatePolyhedron(name: string, options: {
  58948. type?: number;
  58949. size?: number;
  58950. sizeX?: number;
  58951. sizeY?: number;
  58952. sizeZ?: number;
  58953. custom?: any;
  58954. faceUV?: Vector4[];
  58955. faceColors?: Color4[];
  58956. flat?: boolean;
  58957. updatable?: boolean;
  58958. sideOrientation?: number;
  58959. frontUVs?: Vector4;
  58960. backUVs?: Vector4;
  58961. }, scene?: Nullable<Scene>): Mesh;
  58962. /**
  58963. * Creates a decal mesh.
  58964. * 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
  58965. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58966. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58967. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58968. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58969. * @param name defines the name of the mesh
  58970. * @param sourceMesh defines the mesh where the decal must be applied
  58971. * @param options defines the options used to create the mesh
  58972. * @param scene defines the hosting scene
  58973. * @returns the decal mesh
  58974. * @see https://doc.babylonjs.com/how_to/decals
  58975. */
  58976. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58977. position?: Vector3;
  58978. normal?: Vector3;
  58979. size?: Vector3;
  58980. angle?: number;
  58981. }): Mesh;
  58982. }
  58983. }
  58984. declare module "babylonjs/Meshes/meshSimplification" {
  58985. import { Mesh } from "babylonjs/Meshes/mesh";
  58986. /**
  58987. * A simplifier interface for future simplification implementations
  58988. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58989. */
  58990. export interface ISimplifier {
  58991. /**
  58992. * Simplification of a given mesh according to the given settings.
  58993. * Since this requires computation, it is assumed that the function runs async.
  58994. * @param settings The settings of the simplification, including quality and distance
  58995. * @param successCallback A callback that will be called after the mesh was simplified.
  58996. * @param errorCallback in case of an error, this callback will be called. optional.
  58997. */
  58998. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58999. }
  59000. /**
  59001. * Expected simplification settings.
  59002. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59003. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59004. */
  59005. export interface ISimplificationSettings {
  59006. /**
  59007. * Gets or sets the expected quality
  59008. */
  59009. quality: number;
  59010. /**
  59011. * Gets or sets the distance when this optimized version should be used
  59012. */
  59013. distance: number;
  59014. /**
  59015. * Gets an already optimized mesh
  59016. */
  59017. optimizeMesh?: boolean;
  59018. }
  59019. /**
  59020. * Class used to specify simplification options
  59021. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59022. */
  59023. export class SimplificationSettings implements ISimplificationSettings {
  59024. /** expected quality */
  59025. quality: number;
  59026. /** distance when this optimized version should be used */
  59027. distance: number;
  59028. /** already optimized mesh */
  59029. optimizeMesh?: boolean | undefined;
  59030. /**
  59031. * Creates a SimplificationSettings
  59032. * @param quality expected quality
  59033. * @param distance distance when this optimized version should be used
  59034. * @param optimizeMesh already optimized mesh
  59035. */
  59036. constructor(
  59037. /** expected quality */
  59038. quality: number,
  59039. /** distance when this optimized version should be used */
  59040. distance: number,
  59041. /** already optimized mesh */
  59042. optimizeMesh?: boolean | undefined);
  59043. }
  59044. /**
  59045. * Interface used to define a simplification task
  59046. */
  59047. export interface ISimplificationTask {
  59048. /**
  59049. * Array of settings
  59050. */
  59051. settings: Array<ISimplificationSettings>;
  59052. /**
  59053. * Simplification type
  59054. */
  59055. simplificationType: SimplificationType;
  59056. /**
  59057. * Mesh to simplify
  59058. */
  59059. mesh: Mesh;
  59060. /**
  59061. * Callback called on success
  59062. */
  59063. successCallback?: () => void;
  59064. /**
  59065. * Defines if parallel processing can be used
  59066. */
  59067. parallelProcessing: boolean;
  59068. }
  59069. /**
  59070. * Queue used to order the simplification tasks
  59071. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59072. */
  59073. export class SimplificationQueue {
  59074. private _simplificationArray;
  59075. /**
  59076. * Gets a boolean indicating that the process is still running
  59077. */
  59078. running: boolean;
  59079. /**
  59080. * Creates a new queue
  59081. */
  59082. constructor();
  59083. /**
  59084. * Adds a new simplification task
  59085. * @param task defines a task to add
  59086. */
  59087. addTask(task: ISimplificationTask): void;
  59088. /**
  59089. * Execute next task
  59090. */
  59091. executeNext(): void;
  59092. /**
  59093. * Execute a simplification task
  59094. * @param task defines the task to run
  59095. */
  59096. runSimplification(task: ISimplificationTask): void;
  59097. private getSimplifier;
  59098. }
  59099. /**
  59100. * The implemented types of simplification
  59101. * At the moment only Quadratic Error Decimation is implemented
  59102. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59103. */
  59104. export enum SimplificationType {
  59105. /** Quadratic error decimation */
  59106. QUADRATIC = 0
  59107. }
  59108. }
  59109. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59110. import { Scene } from "babylonjs/scene";
  59111. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59112. import { ISceneComponent } from "babylonjs/sceneComponent";
  59113. module "babylonjs/scene" {
  59114. interface Scene {
  59115. /** @hidden (Backing field) */
  59116. _simplificationQueue: SimplificationQueue;
  59117. /**
  59118. * Gets or sets the simplification queue attached to the scene
  59119. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59120. */
  59121. simplificationQueue: SimplificationQueue;
  59122. }
  59123. }
  59124. module "babylonjs/Meshes/mesh" {
  59125. interface Mesh {
  59126. /**
  59127. * Simplify the mesh according to the given array of settings.
  59128. * Function will return immediately and will simplify async
  59129. * @param settings a collection of simplification settings
  59130. * @param parallelProcessing should all levels calculate parallel or one after the other
  59131. * @param simplificationType the type of simplification to run
  59132. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59133. * @returns the current mesh
  59134. */
  59135. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59136. }
  59137. }
  59138. /**
  59139. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59140. * created in a scene
  59141. */
  59142. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59143. /**
  59144. * The component name helpfull to identify the component in the list of scene components.
  59145. */
  59146. readonly name: string;
  59147. /**
  59148. * The scene the component belongs to.
  59149. */
  59150. scene: Scene;
  59151. /**
  59152. * Creates a new instance of the component for the given scene
  59153. * @param scene Defines the scene to register the component in
  59154. */
  59155. constructor(scene: Scene);
  59156. /**
  59157. * Registers the component in a given scene
  59158. */
  59159. register(): void;
  59160. /**
  59161. * Rebuilds the elements related to this component in case of
  59162. * context lost for instance.
  59163. */
  59164. rebuild(): void;
  59165. /**
  59166. * Disposes the component and the associated ressources
  59167. */
  59168. dispose(): void;
  59169. private _beforeCameraUpdate;
  59170. }
  59171. }
  59172. declare module "babylonjs/Meshes/Builders/index" {
  59173. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59174. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59175. export * from "babylonjs/Meshes/Builders/discBuilder";
  59176. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59177. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59178. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59179. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59180. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59181. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59182. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59183. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59184. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59185. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59186. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59187. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59188. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59189. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59190. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59191. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59192. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59193. }
  59194. declare module "babylonjs/Meshes/index" {
  59195. export * from "babylonjs/Meshes/abstractMesh";
  59196. export * from "babylonjs/Meshes/buffer";
  59197. export * from "babylonjs/Meshes/Compression/index";
  59198. export * from "babylonjs/Meshes/csg";
  59199. export * from "babylonjs/Meshes/geometry";
  59200. export * from "babylonjs/Meshes/groundMesh";
  59201. export * from "babylonjs/Meshes/trailMesh";
  59202. export * from "babylonjs/Meshes/instancedMesh";
  59203. export * from "babylonjs/Meshes/linesMesh";
  59204. export * from "babylonjs/Meshes/mesh";
  59205. export * from "babylonjs/Meshes/mesh.vertexData";
  59206. export * from "babylonjs/Meshes/meshBuilder";
  59207. export * from "babylonjs/Meshes/meshSimplification";
  59208. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59209. export * from "babylonjs/Meshes/polygonMesh";
  59210. export * from "babylonjs/Meshes/subMesh";
  59211. export * from "babylonjs/Meshes/meshLODLevel";
  59212. export * from "babylonjs/Meshes/transformNode";
  59213. export * from "babylonjs/Meshes/Builders/index";
  59214. export * from "babylonjs/Meshes/dataBuffer";
  59215. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59216. }
  59217. declare module "babylonjs/Morph/index" {
  59218. export * from "babylonjs/Morph/morphTarget";
  59219. export * from "babylonjs/Morph/morphTargetManager";
  59220. }
  59221. declare module "babylonjs/Navigation/INavigationEngine" {
  59222. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59223. import { Vector3 } from "babylonjs/Maths/math";
  59224. import { Mesh } from "babylonjs/Meshes/mesh";
  59225. import { Scene } from "babylonjs/scene";
  59226. /**
  59227. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59228. */
  59229. export interface INavigationEnginePlugin {
  59230. /**
  59231. * plugin name
  59232. */
  59233. name: string;
  59234. /**
  59235. * Creates a navigation mesh
  59236. * @param meshes array of all the geometry used to compute the navigatio mesh
  59237. * @param parameters bunch of parameters used to filter geometry
  59238. */
  59239. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59240. /**
  59241. * Create a navigation mesh debug mesh
  59242. * @param scene is where the mesh will be added
  59243. * @returns debug display mesh
  59244. */
  59245. createDebugNavMesh(scene: Scene): Mesh;
  59246. /**
  59247. * Get a navigation mesh constrained position, closest to the parameter position
  59248. * @param position world position
  59249. * @returns the closest point to position constrained by the navigation mesh
  59250. */
  59251. getClosestPoint(position: Vector3): Vector3;
  59252. /**
  59253. * Get a navigation mesh constrained position, within a particular radius
  59254. * @param position world position
  59255. * @param maxRadius the maximum distance to the constrained world position
  59256. * @returns the closest point to position constrained by the navigation mesh
  59257. */
  59258. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59259. /**
  59260. * Compute the final position from a segment made of destination-position
  59261. * @param position world position
  59262. * @param destination world position
  59263. * @returns the resulting point along the navmesh
  59264. */
  59265. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59266. /**
  59267. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59268. * @param start world position
  59269. * @param end world position
  59270. * @returns array containing world position composing the path
  59271. */
  59272. computePath(start: Vector3, end: Vector3): Vector3[];
  59273. /**
  59274. * If this plugin is supported
  59275. * @returns true if plugin is supported
  59276. */
  59277. isSupported(): boolean;
  59278. /**
  59279. * Create a new Crowd so you can add agents
  59280. * @param maxAgents the maximum agent count in the crowd
  59281. * @param maxAgentRadius the maximum radius an agent can have
  59282. * @param scene to attach the crowd to
  59283. * @returns the crowd you can add agents to
  59284. */
  59285. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59286. /**
  59287. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59288. * The queries will try to find a solution within those bounds
  59289. * default is (1,1,1)
  59290. * @param extent x,y,z value that define the extent around the queries point of reference
  59291. */
  59292. setDefaultQueryExtent(extent: Vector3): void;
  59293. /**
  59294. * Get the Bounding box extent specified by setDefaultQueryExtent
  59295. * @returns the box extent values
  59296. */
  59297. getDefaultQueryExtent(): Vector3;
  59298. /**
  59299. * Release all resources
  59300. */
  59301. dispose(): void;
  59302. }
  59303. /**
  59304. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59305. */
  59306. export interface ICrowd {
  59307. /**
  59308. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59309. * You can attach anything to that node. The node position is updated in the scene update tick.
  59310. * @param pos world position that will be constrained by the navigation mesh
  59311. * @param parameters agent parameters
  59312. * @param transform hooked to the agent that will be update by the scene
  59313. * @returns agent index
  59314. */
  59315. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59316. /**
  59317. * Returns the agent position in world space
  59318. * @param index agent index returned by addAgent
  59319. * @returns world space position
  59320. */
  59321. getAgentPosition(index: number): Vector3;
  59322. /**
  59323. * Gets the agent velocity in world space
  59324. * @param index agent index returned by addAgent
  59325. * @returns world space velocity
  59326. */
  59327. getAgentVelocity(index: number): Vector3;
  59328. /**
  59329. * remove a particular agent previously created
  59330. * @param index agent index returned by addAgent
  59331. */
  59332. removeAgent(index: number): void;
  59333. /**
  59334. * get the list of all agents attached to this crowd
  59335. * @returns list of agent indices
  59336. */
  59337. getAgents(): number[];
  59338. /**
  59339. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59340. * @param deltaTime in seconds
  59341. */
  59342. update(deltaTime: number): void;
  59343. /**
  59344. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59345. * @param index agent index returned by addAgent
  59346. * @param destination targeted world position
  59347. */
  59348. agentGoto(index: number, destination: Vector3): void;
  59349. /**
  59350. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59351. * The queries will try to find a solution within those bounds
  59352. * default is (1,1,1)
  59353. * @param extent x,y,z value that define the extent around the queries point of reference
  59354. */
  59355. setDefaultQueryExtent(extent: Vector3): void;
  59356. /**
  59357. * Get the Bounding box extent specified by setDefaultQueryExtent
  59358. * @returns the box extent values
  59359. */
  59360. getDefaultQueryExtent(): Vector3;
  59361. /**
  59362. * Release all resources
  59363. */
  59364. dispose(): void;
  59365. }
  59366. /**
  59367. * Configures an agent
  59368. */
  59369. export interface IAgentParameters {
  59370. /**
  59371. * Agent radius. [Limit: >= 0]
  59372. */
  59373. radius: number;
  59374. /**
  59375. * Agent height. [Limit: > 0]
  59376. */
  59377. height: number;
  59378. /**
  59379. * Maximum allowed acceleration. [Limit: >= 0]
  59380. */
  59381. maxAcceleration: number;
  59382. /**
  59383. * Maximum allowed speed. [Limit: >= 0]
  59384. */
  59385. maxSpeed: number;
  59386. /**
  59387. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59388. */
  59389. collisionQueryRange: number;
  59390. /**
  59391. * The path visibility optimization range. [Limit: > 0]
  59392. */
  59393. pathOptimizationRange: number;
  59394. /**
  59395. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59396. */
  59397. separationWeight: number;
  59398. }
  59399. /**
  59400. * Configures the navigation mesh creation
  59401. */
  59402. export interface INavMeshParameters {
  59403. /**
  59404. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59405. */
  59406. cs: number;
  59407. /**
  59408. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59409. */
  59410. ch: number;
  59411. /**
  59412. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59413. */
  59414. walkableSlopeAngle: number;
  59415. /**
  59416. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59417. * be considered walkable. [Limit: >= 3] [Units: vx]
  59418. */
  59419. walkableHeight: number;
  59420. /**
  59421. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59422. */
  59423. walkableClimb: number;
  59424. /**
  59425. * The distance to erode/shrink the walkable area of the heightfield away from
  59426. * obstructions. [Limit: >=0] [Units: vx]
  59427. */
  59428. walkableRadius: number;
  59429. /**
  59430. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59431. */
  59432. maxEdgeLen: number;
  59433. /**
  59434. * The maximum distance a simplfied contour's border edges should deviate
  59435. * the original raw contour. [Limit: >=0] [Units: vx]
  59436. */
  59437. maxSimplificationError: number;
  59438. /**
  59439. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59440. */
  59441. minRegionArea: number;
  59442. /**
  59443. * Any regions with a span count smaller than this value will, if possible,
  59444. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59445. */
  59446. mergeRegionArea: number;
  59447. /**
  59448. * The maximum number of vertices allowed for polygons generated during the
  59449. * contour to polygon conversion process. [Limit: >= 3]
  59450. */
  59451. maxVertsPerPoly: number;
  59452. /**
  59453. * Sets the sampling distance to use when generating the detail mesh.
  59454. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59455. */
  59456. detailSampleDist: number;
  59457. /**
  59458. * The maximum distance the detail mesh surface should deviate from heightfield
  59459. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59460. */
  59461. detailSampleMaxError: number;
  59462. }
  59463. }
  59464. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59465. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59466. import { Mesh } from "babylonjs/Meshes/mesh";
  59467. import { Scene } from "babylonjs/scene";
  59468. import { Vector3 } from "babylonjs/Maths/math";
  59469. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59470. /**
  59471. * RecastJS navigation plugin
  59472. */
  59473. export class RecastJSPlugin implements INavigationEnginePlugin {
  59474. /**
  59475. * Reference to the Recast library
  59476. */
  59477. bjsRECAST: any;
  59478. /**
  59479. * plugin name
  59480. */
  59481. name: string;
  59482. /**
  59483. * the first navmesh created. We might extend this to support multiple navmeshes
  59484. */
  59485. navMesh: any;
  59486. /**
  59487. * Initializes the recastJS plugin
  59488. * @param recastInjection can be used to inject your own recast reference
  59489. */
  59490. constructor(recastInjection?: any);
  59491. /**
  59492. * Creates a navigation mesh
  59493. * @param meshes array of all the geometry used to compute the navigatio mesh
  59494. * @param parameters bunch of parameters used to filter geometry
  59495. */
  59496. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59497. /**
  59498. * Create a navigation mesh debug mesh
  59499. * @param scene is where the mesh will be added
  59500. * @returns debug display mesh
  59501. */
  59502. createDebugNavMesh(scene: Scene): Mesh;
  59503. /**
  59504. * Get a navigation mesh constrained position, closest to the parameter position
  59505. * @param position world position
  59506. * @returns the closest point to position constrained by the navigation mesh
  59507. */
  59508. getClosestPoint(position: Vector3): Vector3;
  59509. /**
  59510. * Get a navigation mesh constrained position, within a particular radius
  59511. * @param position world position
  59512. * @param maxRadius the maximum distance to the constrained world position
  59513. * @returns the closest point to position constrained by the navigation mesh
  59514. */
  59515. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59516. /**
  59517. * Compute the final position from a segment made of destination-position
  59518. * @param position world position
  59519. * @param destination world position
  59520. * @returns the resulting point along the navmesh
  59521. */
  59522. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59523. /**
  59524. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59525. * @param start world position
  59526. * @param end world position
  59527. * @returns array containing world position composing the path
  59528. */
  59529. computePath(start: Vector3, end: Vector3): Vector3[];
  59530. /**
  59531. * Create a new Crowd so you can add agents
  59532. * @param maxAgents the maximum agent count in the crowd
  59533. * @param maxAgentRadius the maximum radius an agent can have
  59534. * @param scene to attach the crowd to
  59535. * @returns the crowd you can add agents to
  59536. */
  59537. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59538. /**
  59539. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59540. * The queries will try to find a solution within those bounds
  59541. * default is (1,1,1)
  59542. * @param extent x,y,z value that define the extent around the queries point of reference
  59543. */
  59544. setDefaultQueryExtent(extent: Vector3): void;
  59545. /**
  59546. * Get the Bounding box extent specified by setDefaultQueryExtent
  59547. * @returns the box extent values
  59548. */
  59549. getDefaultQueryExtent(): Vector3;
  59550. /**
  59551. * Disposes
  59552. */
  59553. dispose(): void;
  59554. /**
  59555. * If this plugin is supported
  59556. * @returns true if plugin is supported
  59557. */
  59558. isSupported(): boolean;
  59559. }
  59560. /**
  59561. * Recast detour crowd implementation
  59562. */
  59563. export class RecastJSCrowd implements ICrowd {
  59564. /**
  59565. * Recast/detour plugin
  59566. */
  59567. bjsRECASTPlugin: RecastJSPlugin;
  59568. /**
  59569. * Link to the detour crowd
  59570. */
  59571. recastCrowd: any;
  59572. /**
  59573. * One transform per agent
  59574. */
  59575. transforms: TransformNode[];
  59576. /**
  59577. * All agents created
  59578. */
  59579. agents: number[];
  59580. /**
  59581. * Link to the scene is kept to unregister the crowd from the scene
  59582. */
  59583. private _scene;
  59584. /**
  59585. * Observer for crowd updates
  59586. */
  59587. private _onBeforeAnimationsObserver;
  59588. /**
  59589. * Constructor
  59590. * @param plugin recastJS plugin
  59591. * @param maxAgents the maximum agent count in the crowd
  59592. * @param maxAgentRadius the maximum radius an agent can have
  59593. * @param scene to attach the crowd to
  59594. * @returns the crowd you can add agents to
  59595. */
  59596. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59597. /**
  59598. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59599. * You can attach anything to that node. The node position is updated in the scene update tick.
  59600. * @param pos world position that will be constrained by the navigation mesh
  59601. * @param parameters agent parameters
  59602. * @param transform hooked to the agent that will be update by the scene
  59603. * @returns agent index
  59604. */
  59605. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59606. /**
  59607. * Returns the agent position in world space
  59608. * @param index agent index returned by addAgent
  59609. * @returns world space position
  59610. */
  59611. getAgentPosition(index: number): Vector3;
  59612. /**
  59613. * Returns the agent velocity in world space
  59614. * @param index agent index returned by addAgent
  59615. * @returns world space velocity
  59616. */
  59617. getAgentVelocity(index: number): Vector3;
  59618. /**
  59619. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59620. * @param index agent index returned by addAgent
  59621. * @param destination targeted world position
  59622. */
  59623. agentGoto(index: number, destination: Vector3): void;
  59624. /**
  59625. * remove a particular agent previously created
  59626. * @param index agent index returned by addAgent
  59627. */
  59628. removeAgent(index: number): void;
  59629. /**
  59630. * get the list of all agents attached to this crowd
  59631. * @returns list of agent indices
  59632. */
  59633. getAgents(): number[];
  59634. /**
  59635. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59636. * @param deltaTime in seconds
  59637. */
  59638. update(deltaTime: number): void;
  59639. /**
  59640. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59641. * The queries will try to find a solution within those bounds
  59642. * default is (1,1,1)
  59643. * @param extent x,y,z value that define the extent around the queries point of reference
  59644. */
  59645. setDefaultQueryExtent(extent: Vector3): void;
  59646. /**
  59647. * Get the Bounding box extent specified by setDefaultQueryExtent
  59648. * @returns the box extent values
  59649. */
  59650. getDefaultQueryExtent(): Vector3;
  59651. /**
  59652. * Release all resources
  59653. */
  59654. dispose(): void;
  59655. }
  59656. }
  59657. declare module "babylonjs/Navigation/Plugins/index" {
  59658. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59659. }
  59660. declare module "babylonjs/Navigation/index" {
  59661. export * from "babylonjs/Navigation/INavigationEngine";
  59662. export * from "babylonjs/Navigation/Plugins/index";
  59663. }
  59664. declare module "babylonjs/Offline/database" {
  59665. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59666. /**
  59667. * Class used to enable access to IndexedDB
  59668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59669. */
  59670. export class Database implements IOfflineProvider {
  59671. private _callbackManifestChecked;
  59672. private _currentSceneUrl;
  59673. private _db;
  59674. private _enableSceneOffline;
  59675. private _enableTexturesOffline;
  59676. private _manifestVersionFound;
  59677. private _mustUpdateRessources;
  59678. private _hasReachedQuota;
  59679. private _isSupported;
  59680. private _idbFactory;
  59681. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59682. private static IsUASupportingBlobStorage;
  59683. /**
  59684. * Gets a boolean indicating if Database storate is enabled (off by default)
  59685. */
  59686. static IDBStorageEnabled: boolean;
  59687. /**
  59688. * Gets a boolean indicating if scene must be saved in the database
  59689. */
  59690. readonly enableSceneOffline: boolean;
  59691. /**
  59692. * Gets a boolean indicating if textures must be saved in the database
  59693. */
  59694. readonly enableTexturesOffline: boolean;
  59695. /**
  59696. * Creates a new Database
  59697. * @param urlToScene defines the url to load the scene
  59698. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59699. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59700. */
  59701. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59702. private static _ParseURL;
  59703. private static _ReturnFullUrlLocation;
  59704. private _checkManifestFile;
  59705. /**
  59706. * Open the database and make it available
  59707. * @param successCallback defines the callback to call on success
  59708. * @param errorCallback defines the callback to call on error
  59709. */
  59710. open(successCallback: () => void, errorCallback: () => void): void;
  59711. /**
  59712. * Loads an image from the database
  59713. * @param url defines the url to load from
  59714. * @param image defines the target DOM image
  59715. */
  59716. loadImage(url: string, image: HTMLImageElement): void;
  59717. private _loadImageFromDBAsync;
  59718. private _saveImageIntoDBAsync;
  59719. private _checkVersionFromDB;
  59720. private _loadVersionFromDBAsync;
  59721. private _saveVersionIntoDBAsync;
  59722. /**
  59723. * Loads a file from database
  59724. * @param url defines the URL to load from
  59725. * @param sceneLoaded defines a callback to call on success
  59726. * @param progressCallBack defines a callback to call when progress changed
  59727. * @param errorCallback defines a callback to call on error
  59728. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59729. */
  59730. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59731. private _loadFileAsync;
  59732. private _saveFileAsync;
  59733. /**
  59734. * Validates if xhr data is correct
  59735. * @param xhr defines the request to validate
  59736. * @param dataType defines the expected data type
  59737. * @returns true if data is correct
  59738. */
  59739. private static _ValidateXHRData;
  59740. }
  59741. }
  59742. declare module "babylonjs/Offline/index" {
  59743. export * from "babylonjs/Offline/database";
  59744. export * from "babylonjs/Offline/IOfflineProvider";
  59745. }
  59746. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59747. /** @hidden */
  59748. export var gpuUpdateParticlesPixelShader: {
  59749. name: string;
  59750. shader: string;
  59751. };
  59752. }
  59753. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59754. /** @hidden */
  59755. export var gpuUpdateParticlesVertexShader: {
  59756. name: string;
  59757. shader: string;
  59758. };
  59759. }
  59760. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59761. /** @hidden */
  59762. export var clipPlaneFragmentDeclaration2: {
  59763. name: string;
  59764. shader: string;
  59765. };
  59766. }
  59767. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59768. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59769. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59770. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59771. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59772. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59773. /** @hidden */
  59774. export var gpuRenderParticlesPixelShader: {
  59775. name: string;
  59776. shader: string;
  59777. };
  59778. }
  59779. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59780. /** @hidden */
  59781. export var clipPlaneVertexDeclaration2: {
  59782. name: string;
  59783. shader: string;
  59784. };
  59785. }
  59786. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59787. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59788. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59789. /** @hidden */
  59790. export var gpuRenderParticlesVertexShader: {
  59791. name: string;
  59792. shader: string;
  59793. };
  59794. }
  59795. declare module "babylonjs/Particles/gpuParticleSystem" {
  59796. import { Nullable } from "babylonjs/types";
  59797. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59798. import { Observable } from "babylonjs/Misc/observable";
  59799. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59800. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59801. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59802. import { Scene, IDisposable } from "babylonjs/scene";
  59803. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59804. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59805. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59806. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59807. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59808. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59809. /**
  59810. * This represents a GPU particle system in Babylon
  59811. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59812. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59813. */
  59814. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59815. /**
  59816. * The layer mask we are rendering the particles through.
  59817. */
  59818. layerMask: number;
  59819. private _capacity;
  59820. private _activeCount;
  59821. private _currentActiveCount;
  59822. private _accumulatedCount;
  59823. private _renderEffect;
  59824. private _updateEffect;
  59825. private _buffer0;
  59826. private _buffer1;
  59827. private _spriteBuffer;
  59828. private _updateVAO;
  59829. private _renderVAO;
  59830. private _targetIndex;
  59831. private _sourceBuffer;
  59832. private _targetBuffer;
  59833. private _engine;
  59834. private _currentRenderId;
  59835. private _started;
  59836. private _stopped;
  59837. private _timeDelta;
  59838. private _randomTexture;
  59839. private _randomTexture2;
  59840. private _attributesStrideSize;
  59841. private _updateEffectOptions;
  59842. private _randomTextureSize;
  59843. private _actualFrame;
  59844. private readonly _rawTextureWidth;
  59845. /**
  59846. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59847. */
  59848. static readonly IsSupported: boolean;
  59849. /**
  59850. * An event triggered when the system is disposed.
  59851. */
  59852. onDisposeObservable: Observable<GPUParticleSystem>;
  59853. /**
  59854. * Gets the maximum number of particles active at the same time.
  59855. * @returns The max number of active particles.
  59856. */
  59857. getCapacity(): number;
  59858. /**
  59859. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59860. * to override the particles.
  59861. */
  59862. forceDepthWrite: boolean;
  59863. /**
  59864. * Gets or set the number of active particles
  59865. */
  59866. activeParticleCount: number;
  59867. private _preWarmDone;
  59868. /**
  59869. * Is this system ready to be used/rendered
  59870. * @return true if the system is ready
  59871. */
  59872. isReady(): boolean;
  59873. /**
  59874. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59875. * @returns True if it has been started, otherwise false.
  59876. */
  59877. isStarted(): boolean;
  59878. /**
  59879. * Starts the particle system and begins to emit
  59880. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59881. */
  59882. start(delay?: number): void;
  59883. /**
  59884. * Stops the particle system.
  59885. */
  59886. stop(): void;
  59887. /**
  59888. * Remove all active particles
  59889. */
  59890. reset(): void;
  59891. /**
  59892. * Returns the string "GPUParticleSystem"
  59893. * @returns a string containing the class name
  59894. */
  59895. getClassName(): string;
  59896. private _colorGradientsTexture;
  59897. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59898. /**
  59899. * Adds a new color gradient
  59900. * @param gradient defines the gradient to use (between 0 and 1)
  59901. * @param color1 defines the color to affect to the specified gradient
  59902. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59903. * @returns the current particle system
  59904. */
  59905. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59906. /**
  59907. * Remove a specific color gradient
  59908. * @param gradient defines the gradient to remove
  59909. * @returns the current particle system
  59910. */
  59911. removeColorGradient(gradient: number): GPUParticleSystem;
  59912. private _angularSpeedGradientsTexture;
  59913. private _sizeGradientsTexture;
  59914. private _velocityGradientsTexture;
  59915. private _limitVelocityGradientsTexture;
  59916. private _dragGradientsTexture;
  59917. private _addFactorGradient;
  59918. /**
  59919. * Adds a new size gradient
  59920. * @param gradient defines the gradient to use (between 0 and 1)
  59921. * @param factor defines the size factor to affect to the specified gradient
  59922. * @returns the current particle system
  59923. */
  59924. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59925. /**
  59926. * Remove a specific size gradient
  59927. * @param gradient defines the gradient to remove
  59928. * @returns the current particle system
  59929. */
  59930. removeSizeGradient(gradient: number): GPUParticleSystem;
  59931. /**
  59932. * Adds a new angular speed gradient
  59933. * @param gradient defines the gradient to use (between 0 and 1)
  59934. * @param factor defines the angular speed to affect to the specified gradient
  59935. * @returns the current particle system
  59936. */
  59937. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59938. /**
  59939. * Remove a specific angular speed gradient
  59940. * @param gradient defines the gradient to remove
  59941. * @returns the current particle system
  59942. */
  59943. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59944. /**
  59945. * Adds a new velocity gradient
  59946. * @param gradient defines the gradient to use (between 0 and 1)
  59947. * @param factor defines the velocity to affect to the specified gradient
  59948. * @returns the current particle system
  59949. */
  59950. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59951. /**
  59952. * Remove a specific velocity gradient
  59953. * @param gradient defines the gradient to remove
  59954. * @returns the current particle system
  59955. */
  59956. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59957. /**
  59958. * Adds a new limit velocity gradient
  59959. * @param gradient defines the gradient to use (between 0 and 1)
  59960. * @param factor defines the limit velocity value to affect to the specified gradient
  59961. * @returns the current particle system
  59962. */
  59963. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59964. /**
  59965. * Remove a specific limit velocity gradient
  59966. * @param gradient defines the gradient to remove
  59967. * @returns the current particle system
  59968. */
  59969. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59970. /**
  59971. * Adds a new drag gradient
  59972. * @param gradient defines the gradient to use (between 0 and 1)
  59973. * @param factor defines the drag value to affect to the specified gradient
  59974. * @returns the current particle system
  59975. */
  59976. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59977. /**
  59978. * Remove a specific drag gradient
  59979. * @param gradient defines the gradient to remove
  59980. * @returns the current particle system
  59981. */
  59982. removeDragGradient(gradient: number): GPUParticleSystem;
  59983. /**
  59984. * Not supported by GPUParticleSystem
  59985. * @param gradient defines the gradient to use (between 0 and 1)
  59986. * @param factor defines the emit rate value to affect to the specified gradient
  59987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59988. * @returns the current particle system
  59989. */
  59990. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59991. /**
  59992. * Not supported by GPUParticleSystem
  59993. * @param gradient defines the gradient to remove
  59994. * @returns the current particle system
  59995. */
  59996. removeEmitRateGradient(gradient: number): IParticleSystem;
  59997. /**
  59998. * Not supported by GPUParticleSystem
  59999. * @param gradient defines the gradient to use (between 0 and 1)
  60000. * @param factor defines the start size value to affect to the specified gradient
  60001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60002. * @returns the current particle system
  60003. */
  60004. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60005. /**
  60006. * Not supported by GPUParticleSystem
  60007. * @param gradient defines the gradient to remove
  60008. * @returns the current particle system
  60009. */
  60010. removeStartSizeGradient(gradient: number): IParticleSystem;
  60011. /**
  60012. * Not supported by GPUParticleSystem
  60013. * @param gradient defines the gradient to use (between 0 and 1)
  60014. * @param min defines the color remap minimal range
  60015. * @param max defines the color remap maximal range
  60016. * @returns the current particle system
  60017. */
  60018. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60019. /**
  60020. * Not supported by GPUParticleSystem
  60021. * @param gradient defines the gradient to remove
  60022. * @returns the current particle system
  60023. */
  60024. removeColorRemapGradient(): IParticleSystem;
  60025. /**
  60026. * Not supported by GPUParticleSystem
  60027. * @param gradient defines the gradient to use (between 0 and 1)
  60028. * @param min defines the alpha remap minimal range
  60029. * @param max defines the alpha remap maximal range
  60030. * @returns the current particle system
  60031. */
  60032. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60033. /**
  60034. * Not supported by GPUParticleSystem
  60035. * @param gradient defines the gradient to remove
  60036. * @returns the current particle system
  60037. */
  60038. removeAlphaRemapGradient(): IParticleSystem;
  60039. /**
  60040. * Not supported by GPUParticleSystem
  60041. * @param gradient defines the gradient to use (between 0 and 1)
  60042. * @param color defines the color to affect to the specified gradient
  60043. * @returns the current particle system
  60044. */
  60045. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60046. /**
  60047. * Not supported by GPUParticleSystem
  60048. * @param gradient defines the gradient to remove
  60049. * @returns the current particle system
  60050. */
  60051. removeRampGradient(): IParticleSystem;
  60052. /**
  60053. * Not supported by GPUParticleSystem
  60054. * @returns the list of ramp gradients
  60055. */
  60056. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60057. /**
  60058. * Not supported by GPUParticleSystem
  60059. * Gets or sets a boolean indicating that ramp gradients must be used
  60060. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60061. */
  60062. useRampGradients: boolean;
  60063. /**
  60064. * Not supported by GPUParticleSystem
  60065. * @param gradient defines the gradient to use (between 0 and 1)
  60066. * @param factor defines the life time factor to affect to the specified gradient
  60067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60068. * @returns the current particle system
  60069. */
  60070. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60071. /**
  60072. * Not supported by GPUParticleSystem
  60073. * @param gradient defines the gradient to remove
  60074. * @returns the current particle system
  60075. */
  60076. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60077. /**
  60078. * Instantiates a GPU particle system.
  60079. * 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.
  60080. * @param name The name of the particle system
  60081. * @param options The options used to create the system
  60082. * @param scene The scene the particle system belongs to
  60083. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60084. */
  60085. constructor(name: string, options: Partial<{
  60086. capacity: number;
  60087. randomTextureSize: number;
  60088. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60089. protected _reset(): void;
  60090. private _createUpdateVAO;
  60091. private _createRenderVAO;
  60092. private _initialize;
  60093. /** @hidden */
  60094. _recreateUpdateEffect(): void;
  60095. /** @hidden */
  60096. _recreateRenderEffect(): void;
  60097. /**
  60098. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60099. * @param preWarm defines if we are in the pre-warmimg phase
  60100. */
  60101. animate(preWarm?: boolean): void;
  60102. private _createFactorGradientTexture;
  60103. private _createSizeGradientTexture;
  60104. private _createAngularSpeedGradientTexture;
  60105. private _createVelocityGradientTexture;
  60106. private _createLimitVelocityGradientTexture;
  60107. private _createDragGradientTexture;
  60108. private _createColorGradientTexture;
  60109. /**
  60110. * Renders the particle system in its current state
  60111. * @param preWarm defines if the system should only update the particles but not render them
  60112. * @returns the current number of particles
  60113. */
  60114. render(preWarm?: boolean): number;
  60115. /**
  60116. * Rebuilds the particle system
  60117. */
  60118. rebuild(): void;
  60119. private _releaseBuffers;
  60120. private _releaseVAOs;
  60121. /**
  60122. * Disposes the particle system and free the associated resources
  60123. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60124. */
  60125. dispose(disposeTexture?: boolean): void;
  60126. /**
  60127. * Clones the particle system.
  60128. * @param name The name of the cloned object
  60129. * @param newEmitter The new emitter to use
  60130. * @returns the cloned particle system
  60131. */
  60132. clone(name: string, newEmitter: any): GPUParticleSystem;
  60133. /**
  60134. * Serializes the particle system to a JSON object.
  60135. * @returns the JSON object
  60136. */
  60137. serialize(): any;
  60138. /**
  60139. * Parses a JSON object to create a GPU particle system.
  60140. * @param parsedParticleSystem The JSON object to parse
  60141. * @param scene The scene to create the particle system in
  60142. * @param rootUrl The root url to use to load external dependencies like texture
  60143. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60144. * @returns the parsed GPU particle system
  60145. */
  60146. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60147. }
  60148. }
  60149. declare module "babylonjs/Particles/particleSystemSet" {
  60150. import { Nullable } from "babylonjs/types";
  60151. import { Color3 } from "babylonjs/Maths/math.color";
  60152. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60154. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60155. import { Scene, IDisposable } from "babylonjs/scene";
  60156. /**
  60157. * Represents a set of particle systems working together to create a specific effect
  60158. */
  60159. export class ParticleSystemSet implements IDisposable {
  60160. private _emitterCreationOptions;
  60161. private _emitterNode;
  60162. /**
  60163. * Gets the particle system list
  60164. */
  60165. systems: IParticleSystem[];
  60166. /**
  60167. * Gets the emitter node used with this set
  60168. */
  60169. readonly emitterNode: Nullable<TransformNode>;
  60170. /**
  60171. * Creates a new emitter mesh as a sphere
  60172. * @param options defines the options used to create the sphere
  60173. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60174. * @param scene defines the hosting scene
  60175. */
  60176. setEmitterAsSphere(options: {
  60177. diameter: number;
  60178. segments: number;
  60179. color: Color3;
  60180. }, renderingGroupId: number, scene: Scene): void;
  60181. /**
  60182. * Starts all particle systems of the set
  60183. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60184. */
  60185. start(emitter?: AbstractMesh): void;
  60186. /**
  60187. * Release all associated resources
  60188. */
  60189. dispose(): void;
  60190. /**
  60191. * Serialize the set into a JSON compatible object
  60192. * @returns a JSON compatible representation of the set
  60193. */
  60194. serialize(): any;
  60195. /**
  60196. * Parse a new ParticleSystemSet from a serialized source
  60197. * @param data defines a JSON compatible representation of the set
  60198. * @param scene defines the hosting scene
  60199. * @param gpu defines if we want GPU particles or CPU particles
  60200. * @returns a new ParticleSystemSet
  60201. */
  60202. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60203. }
  60204. }
  60205. declare module "babylonjs/Particles/particleHelper" {
  60206. import { Nullable } from "babylonjs/types";
  60207. import { Scene } from "babylonjs/scene";
  60208. import { Vector3 } from "babylonjs/Maths/math.vector";
  60209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60210. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60211. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60212. /**
  60213. * This class is made for on one-liner static method to help creating particle system set.
  60214. */
  60215. export class ParticleHelper {
  60216. /**
  60217. * Gets or sets base Assets URL
  60218. */
  60219. static BaseAssetsUrl: string;
  60220. /**
  60221. * Create a default particle system that you can tweak
  60222. * @param emitter defines the emitter to use
  60223. * @param capacity defines the system capacity (default is 500 particles)
  60224. * @param scene defines the hosting scene
  60225. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60226. * @returns the new Particle system
  60227. */
  60228. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60229. /**
  60230. * This is the main static method (one-liner) of this helper to create different particle systems
  60231. * @param type This string represents the type to the particle system to create
  60232. * @param scene The scene where the particle system should live
  60233. * @param gpu If the system will use gpu
  60234. * @returns the ParticleSystemSet created
  60235. */
  60236. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60237. /**
  60238. * Static function used to export a particle system to a ParticleSystemSet variable.
  60239. * Please note that the emitter shape is not exported
  60240. * @param systems defines the particle systems to export
  60241. * @returns the created particle system set
  60242. */
  60243. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60244. }
  60245. }
  60246. declare module "babylonjs/Particles/particleSystemComponent" {
  60247. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60248. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60249. import "babylonjs/Shaders/particles.vertex";
  60250. module "babylonjs/Engines/engine" {
  60251. interface Engine {
  60252. /**
  60253. * Create an effect to use with particle systems.
  60254. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60255. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60256. * @param uniformsNames defines a list of attribute names
  60257. * @param samplers defines an array of string used to represent textures
  60258. * @param defines defines the string containing the defines to use to compile the shaders
  60259. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60260. * @param onCompiled defines a function to call when the effect creation is successful
  60261. * @param onError defines a function to call when the effect creation has failed
  60262. * @returns the new Effect
  60263. */
  60264. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60265. }
  60266. }
  60267. module "babylonjs/Meshes/mesh" {
  60268. interface Mesh {
  60269. /**
  60270. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60271. * @returns an array of IParticleSystem
  60272. */
  60273. getEmittedParticleSystems(): IParticleSystem[];
  60274. /**
  60275. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60276. * @returns an array of IParticleSystem
  60277. */
  60278. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60279. }
  60280. }
  60281. /**
  60282. * @hidden
  60283. */
  60284. export var _IDoNeedToBeInTheBuild: number;
  60285. }
  60286. declare module "babylonjs/Particles/index" {
  60287. export * from "babylonjs/Particles/baseParticleSystem";
  60288. export * from "babylonjs/Particles/EmitterTypes/index";
  60289. export * from "babylonjs/Particles/gpuParticleSystem";
  60290. export * from "babylonjs/Particles/IParticleSystem";
  60291. export * from "babylonjs/Particles/particle";
  60292. export * from "babylonjs/Particles/particleHelper";
  60293. export * from "babylonjs/Particles/particleSystem";
  60294. export * from "babylonjs/Particles/particleSystemComponent";
  60295. export * from "babylonjs/Particles/particleSystemSet";
  60296. export * from "babylonjs/Particles/solidParticle";
  60297. export * from "babylonjs/Particles/solidParticleSystem";
  60298. export * from "babylonjs/Particles/subEmitter";
  60299. }
  60300. declare module "babylonjs/Physics/physicsEngineComponent" {
  60301. import { Nullable } from "babylonjs/types";
  60302. import { Observable, Observer } from "babylonjs/Misc/observable";
  60303. import { Vector3 } from "babylonjs/Maths/math.vector";
  60304. import { Mesh } from "babylonjs/Meshes/mesh";
  60305. import { ISceneComponent } from "babylonjs/sceneComponent";
  60306. import { Scene } from "babylonjs/scene";
  60307. import { Node } from "babylonjs/node";
  60308. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60309. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60310. module "babylonjs/scene" {
  60311. interface Scene {
  60312. /** @hidden (Backing field) */
  60313. _physicsEngine: Nullable<IPhysicsEngine>;
  60314. /**
  60315. * Gets the current physics engine
  60316. * @returns a IPhysicsEngine or null if none attached
  60317. */
  60318. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60319. /**
  60320. * Enables physics to the current scene
  60321. * @param gravity defines the scene's gravity for the physics engine
  60322. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60323. * @return a boolean indicating if the physics engine was initialized
  60324. */
  60325. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60326. /**
  60327. * Disables and disposes the physics engine associated with the scene
  60328. */
  60329. disablePhysicsEngine(): void;
  60330. /**
  60331. * Gets a boolean indicating if there is an active physics engine
  60332. * @returns a boolean indicating if there is an active physics engine
  60333. */
  60334. isPhysicsEnabled(): boolean;
  60335. /**
  60336. * Deletes a physics compound impostor
  60337. * @param compound defines the compound to delete
  60338. */
  60339. deleteCompoundImpostor(compound: any): void;
  60340. /**
  60341. * An event triggered when physic simulation is about to be run
  60342. */
  60343. onBeforePhysicsObservable: Observable<Scene>;
  60344. /**
  60345. * An event triggered when physic simulation has been done
  60346. */
  60347. onAfterPhysicsObservable: Observable<Scene>;
  60348. }
  60349. }
  60350. module "babylonjs/Meshes/abstractMesh" {
  60351. interface AbstractMesh {
  60352. /** @hidden */
  60353. _physicsImpostor: Nullable<PhysicsImpostor>;
  60354. /**
  60355. * Gets or sets impostor used for physic simulation
  60356. * @see http://doc.babylonjs.com/features/physics_engine
  60357. */
  60358. physicsImpostor: Nullable<PhysicsImpostor>;
  60359. /**
  60360. * Gets the current physics impostor
  60361. * @see http://doc.babylonjs.com/features/physics_engine
  60362. * @returns a physics impostor or null
  60363. */
  60364. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60365. /** Apply a physic impulse to the mesh
  60366. * @param force defines the force to apply
  60367. * @param contactPoint defines where to apply the force
  60368. * @returns the current mesh
  60369. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60370. */
  60371. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60372. /**
  60373. * Creates a physic joint between two meshes
  60374. * @param otherMesh defines the other mesh to use
  60375. * @param pivot1 defines the pivot to use on this mesh
  60376. * @param pivot2 defines the pivot to use on the other mesh
  60377. * @param options defines additional options (can be plugin dependent)
  60378. * @returns the current mesh
  60379. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60380. */
  60381. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60382. /** @hidden */
  60383. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60384. }
  60385. }
  60386. /**
  60387. * Defines the physics engine scene component responsible to manage a physics engine
  60388. */
  60389. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60390. /**
  60391. * The component name helpful to identify the component in the list of scene components.
  60392. */
  60393. readonly name: string;
  60394. /**
  60395. * The scene the component belongs to.
  60396. */
  60397. scene: Scene;
  60398. /**
  60399. * Creates a new instance of the component for the given scene
  60400. * @param scene Defines the scene to register the component in
  60401. */
  60402. constructor(scene: Scene);
  60403. /**
  60404. * Registers the component in a given scene
  60405. */
  60406. register(): void;
  60407. /**
  60408. * Rebuilds the elements related to this component in case of
  60409. * context lost for instance.
  60410. */
  60411. rebuild(): void;
  60412. /**
  60413. * Disposes the component and the associated ressources
  60414. */
  60415. dispose(): void;
  60416. }
  60417. }
  60418. declare module "babylonjs/Physics/physicsHelper" {
  60419. import { Nullable } from "babylonjs/types";
  60420. import { Vector3 } from "babylonjs/Maths/math.vector";
  60421. import { Mesh } from "babylonjs/Meshes/mesh";
  60422. import { Scene } from "babylonjs/scene";
  60423. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60424. /**
  60425. * A helper for physics simulations
  60426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60427. */
  60428. export class PhysicsHelper {
  60429. private _scene;
  60430. private _physicsEngine;
  60431. /**
  60432. * Initializes the Physics helper
  60433. * @param scene Babylon.js scene
  60434. */
  60435. constructor(scene: Scene);
  60436. /**
  60437. * Applies a radial explosion impulse
  60438. * @param origin the origin of the explosion
  60439. * @param radiusOrEventOptions the radius or the options of radial explosion
  60440. * @param strength the explosion strength
  60441. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60442. * @returns A physics radial explosion event, or null
  60443. */
  60444. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60445. /**
  60446. * Applies a radial explosion force
  60447. * @param origin the origin of the explosion
  60448. * @param radiusOrEventOptions the radius or the options of radial explosion
  60449. * @param strength the explosion strength
  60450. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60451. * @returns A physics radial explosion event, or null
  60452. */
  60453. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60454. /**
  60455. * Creates a gravitational field
  60456. * @param origin the origin of the explosion
  60457. * @param radiusOrEventOptions the radius or the options of radial explosion
  60458. * @param strength the explosion strength
  60459. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60460. * @returns A physics gravitational field event, or null
  60461. */
  60462. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60463. /**
  60464. * Creates a physics updraft event
  60465. * @param origin the origin of the updraft
  60466. * @param radiusOrEventOptions the radius or the options of the updraft
  60467. * @param strength the strength of the updraft
  60468. * @param height the height of the updraft
  60469. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60470. * @returns A physics updraft event, or null
  60471. */
  60472. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60473. /**
  60474. * Creates a physics vortex event
  60475. * @param origin the of the vortex
  60476. * @param radiusOrEventOptions the radius or the options of the vortex
  60477. * @param strength the strength of the vortex
  60478. * @param height the height of the vortex
  60479. * @returns a Physics vortex event, or null
  60480. * A physics vortex event or null
  60481. */
  60482. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60483. }
  60484. /**
  60485. * Represents a physics radial explosion event
  60486. */
  60487. class PhysicsRadialExplosionEvent {
  60488. private _scene;
  60489. private _options;
  60490. private _sphere;
  60491. private _dataFetched;
  60492. /**
  60493. * Initializes a radial explosioin event
  60494. * @param _scene BabylonJS scene
  60495. * @param _options The options for the vortex event
  60496. */
  60497. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60498. /**
  60499. * Returns the data related to the radial explosion event (sphere).
  60500. * @returns The radial explosion event data
  60501. */
  60502. getData(): PhysicsRadialExplosionEventData;
  60503. /**
  60504. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60505. * @param impostor A physics imposter
  60506. * @param origin the origin of the explosion
  60507. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60508. */
  60509. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60510. /**
  60511. * Triggers affecterd impostors callbacks
  60512. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60513. */
  60514. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60515. /**
  60516. * Disposes the sphere.
  60517. * @param force Specifies if the sphere should be disposed by force
  60518. */
  60519. dispose(force?: boolean): void;
  60520. /*** Helpers ***/
  60521. private _prepareSphere;
  60522. private _intersectsWithSphere;
  60523. }
  60524. /**
  60525. * Represents a gravitational field event
  60526. */
  60527. class PhysicsGravitationalFieldEvent {
  60528. private _physicsHelper;
  60529. private _scene;
  60530. private _origin;
  60531. private _options;
  60532. private _tickCallback;
  60533. private _sphere;
  60534. private _dataFetched;
  60535. /**
  60536. * Initializes the physics gravitational field event
  60537. * @param _physicsHelper A physics helper
  60538. * @param _scene BabylonJS scene
  60539. * @param _origin The origin position of the gravitational field event
  60540. * @param _options The options for the vortex event
  60541. */
  60542. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60543. /**
  60544. * Returns the data related to the gravitational field event (sphere).
  60545. * @returns A gravitational field event
  60546. */
  60547. getData(): PhysicsGravitationalFieldEventData;
  60548. /**
  60549. * Enables the gravitational field.
  60550. */
  60551. enable(): void;
  60552. /**
  60553. * Disables the gravitational field.
  60554. */
  60555. disable(): void;
  60556. /**
  60557. * Disposes the sphere.
  60558. * @param force The force to dispose from the gravitational field event
  60559. */
  60560. dispose(force?: boolean): void;
  60561. private _tick;
  60562. }
  60563. /**
  60564. * Represents a physics updraft event
  60565. */
  60566. class PhysicsUpdraftEvent {
  60567. private _scene;
  60568. private _origin;
  60569. private _options;
  60570. private _physicsEngine;
  60571. private _originTop;
  60572. private _originDirection;
  60573. private _tickCallback;
  60574. private _cylinder;
  60575. private _cylinderPosition;
  60576. private _dataFetched;
  60577. /**
  60578. * Initializes the physics updraft event
  60579. * @param _scene BabylonJS scene
  60580. * @param _origin The origin position of the updraft
  60581. * @param _options The options for the updraft event
  60582. */
  60583. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60584. /**
  60585. * Returns the data related to the updraft event (cylinder).
  60586. * @returns A physics updraft event
  60587. */
  60588. getData(): PhysicsUpdraftEventData;
  60589. /**
  60590. * Enables the updraft.
  60591. */
  60592. enable(): void;
  60593. /**
  60594. * Disables the updraft.
  60595. */
  60596. disable(): void;
  60597. /**
  60598. * Disposes the cylinder.
  60599. * @param force Specifies if the updraft should be disposed by force
  60600. */
  60601. dispose(force?: boolean): void;
  60602. private getImpostorHitData;
  60603. private _tick;
  60604. /*** Helpers ***/
  60605. private _prepareCylinder;
  60606. private _intersectsWithCylinder;
  60607. }
  60608. /**
  60609. * Represents a physics vortex event
  60610. */
  60611. class PhysicsVortexEvent {
  60612. private _scene;
  60613. private _origin;
  60614. private _options;
  60615. private _physicsEngine;
  60616. private _originTop;
  60617. private _tickCallback;
  60618. private _cylinder;
  60619. private _cylinderPosition;
  60620. private _dataFetched;
  60621. /**
  60622. * Initializes the physics vortex event
  60623. * @param _scene The BabylonJS scene
  60624. * @param _origin The origin position of the vortex
  60625. * @param _options The options for the vortex event
  60626. */
  60627. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60628. /**
  60629. * Returns the data related to the vortex event (cylinder).
  60630. * @returns The physics vortex event data
  60631. */
  60632. getData(): PhysicsVortexEventData;
  60633. /**
  60634. * Enables the vortex.
  60635. */
  60636. enable(): void;
  60637. /**
  60638. * Disables the cortex.
  60639. */
  60640. disable(): void;
  60641. /**
  60642. * Disposes the sphere.
  60643. * @param force
  60644. */
  60645. dispose(force?: boolean): void;
  60646. private getImpostorHitData;
  60647. private _tick;
  60648. /*** Helpers ***/
  60649. private _prepareCylinder;
  60650. private _intersectsWithCylinder;
  60651. }
  60652. /**
  60653. * Options fot the radial explosion event
  60654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60655. */
  60656. export class PhysicsRadialExplosionEventOptions {
  60657. /**
  60658. * The radius of the sphere for the radial explosion.
  60659. */
  60660. radius: number;
  60661. /**
  60662. * The strenth of the explosion.
  60663. */
  60664. strength: number;
  60665. /**
  60666. * The strenght of the force in correspondence to the distance of the affected object
  60667. */
  60668. falloff: PhysicsRadialImpulseFalloff;
  60669. /**
  60670. * Sphere options for the radial explosion.
  60671. */
  60672. sphere: {
  60673. segments: number;
  60674. diameter: number;
  60675. };
  60676. /**
  60677. * Sphere options for the radial explosion.
  60678. */
  60679. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60680. }
  60681. /**
  60682. * Options fot the updraft event
  60683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60684. */
  60685. export class PhysicsUpdraftEventOptions {
  60686. /**
  60687. * The radius of the cylinder for the vortex
  60688. */
  60689. radius: number;
  60690. /**
  60691. * The strenth of the updraft.
  60692. */
  60693. strength: number;
  60694. /**
  60695. * The height of the cylinder for the updraft.
  60696. */
  60697. height: number;
  60698. /**
  60699. * The mode for the the updraft.
  60700. */
  60701. updraftMode: PhysicsUpdraftMode;
  60702. }
  60703. /**
  60704. * Options fot the vortex event
  60705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60706. */
  60707. export class PhysicsVortexEventOptions {
  60708. /**
  60709. * The radius of the cylinder for the vortex
  60710. */
  60711. radius: number;
  60712. /**
  60713. * The strenth of the vortex.
  60714. */
  60715. strength: number;
  60716. /**
  60717. * The height of the cylinder for the vortex.
  60718. */
  60719. height: number;
  60720. /**
  60721. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60722. */
  60723. centripetalForceThreshold: number;
  60724. /**
  60725. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60726. */
  60727. centripetalForceMultiplier: number;
  60728. /**
  60729. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60730. */
  60731. centrifugalForceMultiplier: number;
  60732. /**
  60733. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60734. */
  60735. updraftForceMultiplier: number;
  60736. }
  60737. /**
  60738. * The strenght of the force in correspondence to the distance of the affected object
  60739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60740. */
  60741. export enum PhysicsRadialImpulseFalloff {
  60742. /** Defines that impulse is constant in strength across it's whole radius */
  60743. Constant = 0,
  60744. /** Defines that impulse gets weaker if it's further from the origin */
  60745. Linear = 1
  60746. }
  60747. /**
  60748. * The strength of the force in correspondence to the distance of the affected object
  60749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60750. */
  60751. export enum PhysicsUpdraftMode {
  60752. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60753. Center = 0,
  60754. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60755. Perpendicular = 1
  60756. }
  60757. /**
  60758. * Interface for a physics hit data
  60759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60760. */
  60761. export interface PhysicsHitData {
  60762. /**
  60763. * The force applied at the contact point
  60764. */
  60765. force: Vector3;
  60766. /**
  60767. * The contact point
  60768. */
  60769. contactPoint: Vector3;
  60770. /**
  60771. * The distance from the origin to the contact point
  60772. */
  60773. distanceFromOrigin: number;
  60774. }
  60775. /**
  60776. * Interface for radial explosion event data
  60777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60778. */
  60779. export interface PhysicsRadialExplosionEventData {
  60780. /**
  60781. * A sphere used for the radial explosion event
  60782. */
  60783. sphere: Mesh;
  60784. }
  60785. /**
  60786. * Interface for gravitational field event data
  60787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60788. */
  60789. export interface PhysicsGravitationalFieldEventData {
  60790. /**
  60791. * A sphere mesh used for the gravitational field event
  60792. */
  60793. sphere: Mesh;
  60794. }
  60795. /**
  60796. * Interface for updraft event data
  60797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60798. */
  60799. export interface PhysicsUpdraftEventData {
  60800. /**
  60801. * A cylinder used for the updraft event
  60802. */
  60803. cylinder: Mesh;
  60804. }
  60805. /**
  60806. * Interface for vortex event data
  60807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60808. */
  60809. export interface PhysicsVortexEventData {
  60810. /**
  60811. * A cylinder used for the vortex event
  60812. */
  60813. cylinder: Mesh;
  60814. }
  60815. /**
  60816. * Interface for an affected physics impostor
  60817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60818. */
  60819. export interface PhysicsAffectedImpostorWithData {
  60820. /**
  60821. * The impostor affected by the effect
  60822. */
  60823. impostor: PhysicsImpostor;
  60824. /**
  60825. * The data about the hit/horce from the explosion
  60826. */
  60827. hitData: PhysicsHitData;
  60828. }
  60829. }
  60830. declare module "babylonjs/Physics/Plugins/index" {
  60831. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60832. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60833. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60834. }
  60835. declare module "babylonjs/Physics/index" {
  60836. export * from "babylonjs/Physics/IPhysicsEngine";
  60837. export * from "babylonjs/Physics/physicsEngine";
  60838. export * from "babylonjs/Physics/physicsEngineComponent";
  60839. export * from "babylonjs/Physics/physicsHelper";
  60840. export * from "babylonjs/Physics/physicsImpostor";
  60841. export * from "babylonjs/Physics/physicsJoint";
  60842. export * from "babylonjs/Physics/Plugins/index";
  60843. }
  60844. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60845. /** @hidden */
  60846. export var blackAndWhitePixelShader: {
  60847. name: string;
  60848. shader: string;
  60849. };
  60850. }
  60851. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60852. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60853. import { Camera } from "babylonjs/Cameras/camera";
  60854. import { Engine } from "babylonjs/Engines/engine";
  60855. import "babylonjs/Shaders/blackAndWhite.fragment";
  60856. /**
  60857. * Post process used to render in black and white
  60858. */
  60859. export class BlackAndWhitePostProcess extends PostProcess {
  60860. /**
  60861. * Linear about to convert he result to black and white (default: 1)
  60862. */
  60863. degree: number;
  60864. /**
  60865. * Creates a black and white post process
  60866. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60867. * @param name The name of the effect.
  60868. * @param options The required width/height ratio to downsize to before computing the render pass.
  60869. * @param camera The camera to apply the render pass to.
  60870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60871. * @param engine The engine which the post process will be applied. (default: current engine)
  60872. * @param reusable If the post process can be reused on the same frame. (default: false)
  60873. */
  60874. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60875. }
  60876. }
  60877. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60878. import { Nullable } from "babylonjs/types";
  60879. import { Camera } from "babylonjs/Cameras/camera";
  60880. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60881. import { Engine } from "babylonjs/Engines/engine";
  60882. /**
  60883. * This represents a set of one or more post processes in Babylon.
  60884. * A post process can be used to apply a shader to a texture after it is rendered.
  60885. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60886. */
  60887. export class PostProcessRenderEffect {
  60888. private _postProcesses;
  60889. private _getPostProcesses;
  60890. private _singleInstance;
  60891. private _cameras;
  60892. private _indicesForCamera;
  60893. /**
  60894. * Name of the effect
  60895. * @hidden
  60896. */
  60897. _name: string;
  60898. /**
  60899. * Instantiates a post process render effect.
  60900. * A post process can be used to apply a shader to a texture after it is rendered.
  60901. * @param engine The engine the effect is tied to
  60902. * @param name The name of the effect
  60903. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60904. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60905. */
  60906. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60907. /**
  60908. * Checks if all the post processes in the effect are supported.
  60909. */
  60910. readonly isSupported: boolean;
  60911. /**
  60912. * Updates the current state of the effect
  60913. * @hidden
  60914. */
  60915. _update(): void;
  60916. /**
  60917. * Attaches the effect on cameras
  60918. * @param cameras The camera to attach to.
  60919. * @hidden
  60920. */
  60921. _attachCameras(cameras: Camera): void;
  60922. /**
  60923. * Attaches the effect on cameras
  60924. * @param cameras The camera to attach to.
  60925. * @hidden
  60926. */
  60927. _attachCameras(cameras: Camera[]): void;
  60928. /**
  60929. * Detaches the effect on cameras
  60930. * @param cameras The camera to detatch from.
  60931. * @hidden
  60932. */
  60933. _detachCameras(cameras: Camera): void;
  60934. /**
  60935. * Detatches the effect on cameras
  60936. * @param cameras The camera to detatch from.
  60937. * @hidden
  60938. */
  60939. _detachCameras(cameras: Camera[]): void;
  60940. /**
  60941. * Enables the effect on given cameras
  60942. * @param cameras The camera to enable.
  60943. * @hidden
  60944. */
  60945. _enable(cameras: Camera): void;
  60946. /**
  60947. * Enables the effect on given cameras
  60948. * @param cameras The camera to enable.
  60949. * @hidden
  60950. */
  60951. _enable(cameras: Nullable<Camera[]>): void;
  60952. /**
  60953. * Disables the effect on the given cameras
  60954. * @param cameras The camera to disable.
  60955. * @hidden
  60956. */
  60957. _disable(cameras: Camera): void;
  60958. /**
  60959. * Disables the effect on the given cameras
  60960. * @param cameras The camera to disable.
  60961. * @hidden
  60962. */
  60963. _disable(cameras: Nullable<Camera[]>): void;
  60964. /**
  60965. * Gets a list of the post processes contained in the effect.
  60966. * @param camera The camera to get the post processes on.
  60967. * @returns The list of the post processes in the effect.
  60968. */
  60969. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60970. }
  60971. }
  60972. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60973. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60974. /** @hidden */
  60975. export var extractHighlightsPixelShader: {
  60976. name: string;
  60977. shader: string;
  60978. };
  60979. }
  60980. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60981. import { Nullable } from "babylonjs/types";
  60982. import { Camera } from "babylonjs/Cameras/camera";
  60983. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60984. import { Engine } from "babylonjs/Engines/engine";
  60985. import "babylonjs/Shaders/extractHighlights.fragment";
  60986. /**
  60987. * 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.
  60988. */
  60989. export class ExtractHighlightsPostProcess extends PostProcess {
  60990. /**
  60991. * The luminance threshold, pixels below this value will be set to black.
  60992. */
  60993. threshold: number;
  60994. /** @hidden */
  60995. _exposure: number;
  60996. /**
  60997. * Post process which has the input texture to be used when performing highlight extraction
  60998. * @hidden
  60999. */
  61000. _inputPostProcess: Nullable<PostProcess>;
  61001. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61002. }
  61003. }
  61004. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61005. /** @hidden */
  61006. export var bloomMergePixelShader: {
  61007. name: string;
  61008. shader: string;
  61009. };
  61010. }
  61011. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61012. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61013. import { Nullable } from "babylonjs/types";
  61014. import { Engine } from "babylonjs/Engines/engine";
  61015. import { Camera } from "babylonjs/Cameras/camera";
  61016. import "babylonjs/Shaders/bloomMerge.fragment";
  61017. /**
  61018. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61019. */
  61020. export class BloomMergePostProcess extends PostProcess {
  61021. /** Weight of the bloom to be added to the original input. */
  61022. weight: number;
  61023. /**
  61024. * Creates a new instance of @see BloomMergePostProcess
  61025. * @param name The name of the effect.
  61026. * @param originalFromInput Post process which's input will be used for the merge.
  61027. * @param blurred Blurred highlights post process which's output will be used.
  61028. * @param weight Weight of the bloom to be added to the original input.
  61029. * @param options The required width/height ratio to downsize to before computing the render pass.
  61030. * @param camera The camera to apply the render pass to.
  61031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61032. * @param engine The engine which the post process will be applied. (default: current engine)
  61033. * @param reusable If the post process can be reused on the same frame. (default: false)
  61034. * @param textureType Type of textures used when performing the post process. (default: 0)
  61035. * @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)
  61036. */
  61037. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61038. /** Weight of the bloom to be added to the original input. */
  61039. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61040. }
  61041. }
  61042. declare module "babylonjs/PostProcesses/bloomEffect" {
  61043. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61044. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61045. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61046. import { Camera } from "babylonjs/Cameras/camera";
  61047. import { Scene } from "babylonjs/scene";
  61048. /**
  61049. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61050. */
  61051. export class BloomEffect extends PostProcessRenderEffect {
  61052. private bloomScale;
  61053. /**
  61054. * @hidden Internal
  61055. */
  61056. _effects: Array<PostProcess>;
  61057. /**
  61058. * @hidden Internal
  61059. */
  61060. _downscale: ExtractHighlightsPostProcess;
  61061. private _blurX;
  61062. private _blurY;
  61063. private _merge;
  61064. /**
  61065. * The luminance threshold to find bright areas of the image to bloom.
  61066. */
  61067. threshold: number;
  61068. /**
  61069. * The strength of the bloom.
  61070. */
  61071. weight: number;
  61072. /**
  61073. * Specifies the size of the bloom blur kernel, relative to the final output size
  61074. */
  61075. kernel: number;
  61076. /**
  61077. * Creates a new instance of @see BloomEffect
  61078. * @param scene The scene the effect belongs to.
  61079. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61080. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61081. * @param bloomWeight The the strength of bloom.
  61082. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61083. * @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)
  61084. */
  61085. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61086. /**
  61087. * Disposes each of the internal effects for a given camera.
  61088. * @param camera The camera to dispose the effect on.
  61089. */
  61090. disposeEffects(camera: Camera): void;
  61091. /**
  61092. * @hidden Internal
  61093. */
  61094. _updateEffects(): void;
  61095. /**
  61096. * Internal
  61097. * @returns if all the contained post processes are ready.
  61098. * @hidden
  61099. */
  61100. _isReady(): boolean;
  61101. }
  61102. }
  61103. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61104. /** @hidden */
  61105. export var chromaticAberrationPixelShader: {
  61106. name: string;
  61107. shader: string;
  61108. };
  61109. }
  61110. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61111. import { Vector2 } from "babylonjs/Maths/math.vector";
  61112. import { Nullable } from "babylonjs/types";
  61113. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61114. import { Camera } from "babylonjs/Cameras/camera";
  61115. import { Engine } from "babylonjs/Engines/engine";
  61116. import "babylonjs/Shaders/chromaticAberration.fragment";
  61117. /**
  61118. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61119. */
  61120. export class ChromaticAberrationPostProcess extends PostProcess {
  61121. /**
  61122. * The amount of seperation of rgb channels (default: 30)
  61123. */
  61124. aberrationAmount: number;
  61125. /**
  61126. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61127. */
  61128. radialIntensity: number;
  61129. /**
  61130. * 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))
  61131. */
  61132. direction: Vector2;
  61133. /**
  61134. * 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))
  61135. */
  61136. centerPosition: Vector2;
  61137. /**
  61138. * Creates a new instance ChromaticAberrationPostProcess
  61139. * @param name The name of the effect.
  61140. * @param screenWidth The width of the screen to apply the effect on.
  61141. * @param screenHeight The height of the screen to apply the effect on.
  61142. * @param options The required width/height ratio to downsize to before computing the render pass.
  61143. * @param camera The camera to apply the render pass to.
  61144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61145. * @param engine The engine which the post process will be applied. (default: current engine)
  61146. * @param reusable If the post process can be reused on the same frame. (default: false)
  61147. * @param textureType Type of textures used when performing the post process. (default: 0)
  61148. * @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)
  61149. */
  61150. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61151. }
  61152. }
  61153. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61154. /** @hidden */
  61155. export var circleOfConfusionPixelShader: {
  61156. name: string;
  61157. shader: string;
  61158. };
  61159. }
  61160. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61161. import { Nullable } from "babylonjs/types";
  61162. import { Engine } from "babylonjs/Engines/engine";
  61163. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61164. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61165. import { Camera } from "babylonjs/Cameras/camera";
  61166. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61167. /**
  61168. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61169. */
  61170. export class CircleOfConfusionPostProcess extends PostProcess {
  61171. /**
  61172. * 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.
  61173. */
  61174. lensSize: number;
  61175. /**
  61176. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61177. */
  61178. fStop: number;
  61179. /**
  61180. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61181. */
  61182. focusDistance: number;
  61183. /**
  61184. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61185. */
  61186. focalLength: number;
  61187. private _depthTexture;
  61188. /**
  61189. * Creates a new instance CircleOfConfusionPostProcess
  61190. * @param name The name of the effect.
  61191. * @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.
  61192. * @param options The required width/height ratio to downsize to before computing the render pass.
  61193. * @param camera The camera to apply the render pass to.
  61194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61195. * @param engine The engine which the post process will be applied. (default: current engine)
  61196. * @param reusable If the post process can be reused on the same frame. (default: false)
  61197. * @param textureType Type of textures used when performing the post process. (default: 0)
  61198. * @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)
  61199. */
  61200. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61201. /**
  61202. * 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.
  61203. */
  61204. depthTexture: RenderTargetTexture;
  61205. }
  61206. }
  61207. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61208. /** @hidden */
  61209. export var colorCorrectionPixelShader: {
  61210. name: string;
  61211. shader: string;
  61212. };
  61213. }
  61214. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61216. import { Engine } from "babylonjs/Engines/engine";
  61217. import { Camera } from "babylonjs/Cameras/camera";
  61218. import "babylonjs/Shaders/colorCorrection.fragment";
  61219. /**
  61220. *
  61221. * This post-process allows the modification of rendered colors by using
  61222. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61223. *
  61224. * The object needs to be provided an url to a texture containing the color
  61225. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61226. * Use an image editing software to tweak the LUT to match your needs.
  61227. *
  61228. * For an example of a color LUT, see here:
  61229. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61230. * For explanations on color grading, see here:
  61231. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61232. *
  61233. */
  61234. export class ColorCorrectionPostProcess extends PostProcess {
  61235. private _colorTableTexture;
  61236. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61237. }
  61238. }
  61239. declare module "babylonjs/Shaders/convolution.fragment" {
  61240. /** @hidden */
  61241. export var convolutionPixelShader: {
  61242. name: string;
  61243. shader: string;
  61244. };
  61245. }
  61246. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61248. import { Nullable } from "babylonjs/types";
  61249. import { Camera } from "babylonjs/Cameras/camera";
  61250. import { Engine } from "babylonjs/Engines/engine";
  61251. import "babylonjs/Shaders/convolution.fragment";
  61252. /**
  61253. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61254. * input texture to perform effects such as edge detection or sharpening
  61255. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61256. */
  61257. export class ConvolutionPostProcess extends PostProcess {
  61258. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61259. kernel: number[];
  61260. /**
  61261. * Creates a new instance ConvolutionPostProcess
  61262. * @param name The name of the effect.
  61263. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61264. * @param options The required width/height ratio to downsize to before computing the render pass.
  61265. * @param camera The camera to apply the render pass to.
  61266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61267. * @param engine The engine which the post process will be applied. (default: current engine)
  61268. * @param reusable If the post process can be reused on the same frame. (default: false)
  61269. * @param textureType Type of textures used when performing the post process. (default: 0)
  61270. */
  61271. constructor(name: string,
  61272. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61273. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61274. /**
  61275. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61276. */
  61277. static EdgeDetect0Kernel: number[];
  61278. /**
  61279. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61280. */
  61281. static EdgeDetect1Kernel: number[];
  61282. /**
  61283. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61284. */
  61285. static EdgeDetect2Kernel: number[];
  61286. /**
  61287. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61288. */
  61289. static SharpenKernel: number[];
  61290. /**
  61291. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61292. */
  61293. static EmbossKernel: number[];
  61294. /**
  61295. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61296. */
  61297. static GaussianKernel: number[];
  61298. }
  61299. }
  61300. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61301. import { Nullable } from "babylonjs/types";
  61302. import { Vector2 } from "babylonjs/Maths/math.vector";
  61303. import { Camera } from "babylonjs/Cameras/camera";
  61304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61305. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61306. import { Engine } from "babylonjs/Engines/engine";
  61307. import { Scene } from "babylonjs/scene";
  61308. /**
  61309. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61310. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61311. * based on samples that have a large difference in distance than the center pixel.
  61312. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61313. */
  61314. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61315. direction: Vector2;
  61316. /**
  61317. * Creates a new instance CircleOfConfusionPostProcess
  61318. * @param name The name of the effect.
  61319. * @param scene The scene the effect belongs to.
  61320. * @param direction The direction the blur should be applied.
  61321. * @param kernel The size of the kernel used to blur.
  61322. * @param options The required width/height ratio to downsize to before computing the render pass.
  61323. * @param camera The camera to apply the render pass to.
  61324. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61325. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61327. * @param engine The engine which the post process will be applied. (default: current engine)
  61328. * @param reusable If the post process can be reused on the same frame. (default: false)
  61329. * @param textureType Type of textures used when performing the post process. (default: 0)
  61330. * @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)
  61331. */
  61332. 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);
  61333. }
  61334. }
  61335. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61336. /** @hidden */
  61337. export var depthOfFieldMergePixelShader: {
  61338. name: string;
  61339. shader: string;
  61340. };
  61341. }
  61342. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61343. import { Nullable } from "babylonjs/types";
  61344. import { Camera } from "babylonjs/Cameras/camera";
  61345. import { Effect } from "babylonjs/Materials/effect";
  61346. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61347. import { Engine } from "babylonjs/Engines/engine";
  61348. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61349. /**
  61350. * Options to be set when merging outputs from the default pipeline.
  61351. */
  61352. export class DepthOfFieldMergePostProcessOptions {
  61353. /**
  61354. * The original image to merge on top of
  61355. */
  61356. originalFromInput: PostProcess;
  61357. /**
  61358. * Parameters to perform the merge of the depth of field effect
  61359. */
  61360. depthOfField?: {
  61361. circleOfConfusion: PostProcess;
  61362. blurSteps: Array<PostProcess>;
  61363. };
  61364. /**
  61365. * Parameters to perform the merge of bloom effect
  61366. */
  61367. bloom?: {
  61368. blurred: PostProcess;
  61369. weight: number;
  61370. };
  61371. }
  61372. /**
  61373. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61374. */
  61375. export class DepthOfFieldMergePostProcess extends PostProcess {
  61376. private blurSteps;
  61377. /**
  61378. * Creates a new instance of DepthOfFieldMergePostProcess
  61379. * @param name The name of the effect.
  61380. * @param originalFromInput Post process which's input will be used for the merge.
  61381. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61382. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61383. * @param options The required width/height ratio to downsize to before computing the render pass.
  61384. * @param camera The camera to apply the render pass to.
  61385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61386. * @param engine The engine which the post process will be applied. (default: current engine)
  61387. * @param reusable If the post process can be reused on the same frame. (default: false)
  61388. * @param textureType Type of textures used when performing the post process. (default: 0)
  61389. * @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)
  61390. */
  61391. 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);
  61392. /**
  61393. * Updates the effect with the current post process compile time values and recompiles the shader.
  61394. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61395. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61396. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61397. * @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
  61398. * @param onCompiled Called when the shader has been compiled.
  61399. * @param onError Called if there is an error when compiling a shader.
  61400. */
  61401. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61402. }
  61403. }
  61404. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61405. import { Nullable } from "babylonjs/types";
  61406. import { Camera } from "babylonjs/Cameras/camera";
  61407. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61408. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61409. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61410. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61411. import { Scene } from "babylonjs/scene";
  61412. /**
  61413. * Specifies the level of max blur that should be applied when using the depth of field effect
  61414. */
  61415. export enum DepthOfFieldEffectBlurLevel {
  61416. /**
  61417. * Subtle blur
  61418. */
  61419. Low = 0,
  61420. /**
  61421. * Medium blur
  61422. */
  61423. Medium = 1,
  61424. /**
  61425. * Large blur
  61426. */
  61427. High = 2
  61428. }
  61429. /**
  61430. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61431. */
  61432. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61433. private _circleOfConfusion;
  61434. /**
  61435. * @hidden Internal, blurs from high to low
  61436. */
  61437. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61438. private _depthOfFieldBlurY;
  61439. private _dofMerge;
  61440. /**
  61441. * @hidden Internal post processes in depth of field effect
  61442. */
  61443. _effects: Array<PostProcess>;
  61444. /**
  61445. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61446. */
  61447. focalLength: number;
  61448. /**
  61449. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61450. */
  61451. fStop: number;
  61452. /**
  61453. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61454. */
  61455. focusDistance: number;
  61456. /**
  61457. * 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.
  61458. */
  61459. lensSize: number;
  61460. /**
  61461. * Creates a new instance DepthOfFieldEffect
  61462. * @param scene The scene the effect belongs to.
  61463. * @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.
  61464. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61465. * @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)
  61466. */
  61467. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61468. /**
  61469. * Get the current class name of the current effet
  61470. * @returns "DepthOfFieldEffect"
  61471. */
  61472. getClassName(): string;
  61473. /**
  61474. * 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.
  61475. */
  61476. depthTexture: RenderTargetTexture;
  61477. /**
  61478. * Disposes each of the internal effects for a given camera.
  61479. * @param camera The camera to dispose the effect on.
  61480. */
  61481. disposeEffects(camera: Camera): void;
  61482. /**
  61483. * @hidden Internal
  61484. */
  61485. _updateEffects(): void;
  61486. /**
  61487. * Internal
  61488. * @returns if all the contained post processes are ready.
  61489. * @hidden
  61490. */
  61491. _isReady(): boolean;
  61492. }
  61493. }
  61494. declare module "babylonjs/Shaders/displayPass.fragment" {
  61495. /** @hidden */
  61496. export var displayPassPixelShader: {
  61497. name: string;
  61498. shader: string;
  61499. };
  61500. }
  61501. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61502. import { Nullable } from "babylonjs/types";
  61503. import { Camera } from "babylonjs/Cameras/camera";
  61504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61505. import { Engine } from "babylonjs/Engines/engine";
  61506. import "babylonjs/Shaders/displayPass.fragment";
  61507. /**
  61508. * DisplayPassPostProcess which produces an output the same as it's input
  61509. */
  61510. export class DisplayPassPostProcess extends PostProcess {
  61511. /**
  61512. * Creates the DisplayPassPostProcess
  61513. * @param name The name of the effect.
  61514. * @param options The required width/height ratio to downsize to before computing the render pass.
  61515. * @param camera The camera to apply the render pass to.
  61516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61517. * @param engine The engine which the post process will be applied. (default: current engine)
  61518. * @param reusable If the post process can be reused on the same frame. (default: false)
  61519. */
  61520. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61521. }
  61522. }
  61523. declare module "babylonjs/Shaders/filter.fragment" {
  61524. /** @hidden */
  61525. export var filterPixelShader: {
  61526. name: string;
  61527. shader: string;
  61528. };
  61529. }
  61530. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61531. import { Nullable } from "babylonjs/types";
  61532. import { Matrix } from "babylonjs/Maths/math.vector";
  61533. import { Camera } from "babylonjs/Cameras/camera";
  61534. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61535. import { Engine } from "babylonjs/Engines/engine";
  61536. import "babylonjs/Shaders/filter.fragment";
  61537. /**
  61538. * Applies a kernel filter to the image
  61539. */
  61540. export class FilterPostProcess extends PostProcess {
  61541. /** The matrix to be applied to the image */
  61542. kernelMatrix: Matrix;
  61543. /**
  61544. *
  61545. * @param name The name of the effect.
  61546. * @param kernelMatrix The matrix to be applied to the image
  61547. * @param options The required width/height ratio to downsize to before computing the render pass.
  61548. * @param camera The camera to apply the render pass to.
  61549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61550. * @param engine The engine which the post process will be applied. (default: current engine)
  61551. * @param reusable If the post process can be reused on the same frame. (default: false)
  61552. */
  61553. constructor(name: string,
  61554. /** The matrix to be applied to the image */
  61555. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61556. }
  61557. }
  61558. declare module "babylonjs/Shaders/fxaa.fragment" {
  61559. /** @hidden */
  61560. export var fxaaPixelShader: {
  61561. name: string;
  61562. shader: string;
  61563. };
  61564. }
  61565. declare module "babylonjs/Shaders/fxaa.vertex" {
  61566. /** @hidden */
  61567. export var fxaaVertexShader: {
  61568. name: string;
  61569. shader: string;
  61570. };
  61571. }
  61572. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61573. import { Nullable } from "babylonjs/types";
  61574. import { Camera } from "babylonjs/Cameras/camera";
  61575. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61576. import { Engine } from "babylonjs/Engines/engine";
  61577. import "babylonjs/Shaders/fxaa.fragment";
  61578. import "babylonjs/Shaders/fxaa.vertex";
  61579. /**
  61580. * Fxaa post process
  61581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61582. */
  61583. export class FxaaPostProcess extends PostProcess {
  61584. /** @hidden */
  61585. texelWidth: number;
  61586. /** @hidden */
  61587. texelHeight: number;
  61588. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61589. private _getDefines;
  61590. }
  61591. }
  61592. declare module "babylonjs/Shaders/grain.fragment" {
  61593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61594. /** @hidden */
  61595. export var grainPixelShader: {
  61596. name: string;
  61597. shader: string;
  61598. };
  61599. }
  61600. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61601. import { Nullable } from "babylonjs/types";
  61602. import { Camera } from "babylonjs/Cameras/camera";
  61603. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61604. import { Engine } from "babylonjs/Engines/engine";
  61605. import "babylonjs/Shaders/grain.fragment";
  61606. /**
  61607. * The GrainPostProcess adds noise to the image at mid luminance levels
  61608. */
  61609. export class GrainPostProcess extends PostProcess {
  61610. /**
  61611. * The intensity of the grain added (default: 30)
  61612. */
  61613. intensity: number;
  61614. /**
  61615. * If the grain should be randomized on every frame
  61616. */
  61617. animated: boolean;
  61618. /**
  61619. * Creates a new instance of @see GrainPostProcess
  61620. * @param name The name of the effect.
  61621. * @param options The required width/height ratio to downsize to before computing the render pass.
  61622. * @param camera The camera to apply the render pass to.
  61623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61624. * @param engine The engine which the post process will be applied. (default: current engine)
  61625. * @param reusable If the post process can be reused on the same frame. (default: false)
  61626. * @param textureType Type of textures used when performing the post process. (default: 0)
  61627. * @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)
  61628. */
  61629. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61630. }
  61631. }
  61632. declare module "babylonjs/Shaders/highlights.fragment" {
  61633. /** @hidden */
  61634. export var highlightsPixelShader: {
  61635. name: string;
  61636. shader: string;
  61637. };
  61638. }
  61639. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61640. import { Nullable } from "babylonjs/types";
  61641. import { Camera } from "babylonjs/Cameras/camera";
  61642. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61643. import { Engine } from "babylonjs/Engines/engine";
  61644. import "babylonjs/Shaders/highlights.fragment";
  61645. /**
  61646. * Extracts highlights from the image
  61647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61648. */
  61649. export class HighlightsPostProcess extends PostProcess {
  61650. /**
  61651. * Extracts highlights from the image
  61652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61653. * @param name The name of the effect.
  61654. * @param options The required width/height ratio to downsize to before computing the render pass.
  61655. * @param camera The camera to apply the render pass to.
  61656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61657. * @param engine The engine which the post process will be applied. (default: current engine)
  61658. * @param reusable If the post process can be reused on the same frame. (default: false)
  61659. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61660. */
  61661. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61662. }
  61663. }
  61664. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61665. /** @hidden */
  61666. export var mrtFragmentDeclaration: {
  61667. name: string;
  61668. shader: string;
  61669. };
  61670. }
  61671. declare module "babylonjs/Shaders/geometry.fragment" {
  61672. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61673. /** @hidden */
  61674. export var geometryPixelShader: {
  61675. name: string;
  61676. shader: string;
  61677. };
  61678. }
  61679. declare module "babylonjs/Shaders/geometry.vertex" {
  61680. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61681. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61682. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61683. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61684. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61685. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61686. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61687. /** @hidden */
  61688. export var geometryVertexShader: {
  61689. name: string;
  61690. shader: string;
  61691. };
  61692. }
  61693. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61694. import { Matrix } from "babylonjs/Maths/math.vector";
  61695. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61696. import { Mesh } from "babylonjs/Meshes/mesh";
  61697. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61698. import { Effect } from "babylonjs/Materials/effect";
  61699. import { Scene } from "babylonjs/scene";
  61700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61701. import "babylonjs/Shaders/geometry.fragment";
  61702. import "babylonjs/Shaders/geometry.vertex";
  61703. /** @hidden */
  61704. interface ISavedTransformationMatrix {
  61705. world: Matrix;
  61706. viewProjection: Matrix;
  61707. }
  61708. /**
  61709. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61710. */
  61711. export class GeometryBufferRenderer {
  61712. /**
  61713. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61714. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61715. */
  61716. static readonly POSITION_TEXTURE_TYPE: number;
  61717. /**
  61718. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61719. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61720. */
  61721. static readonly VELOCITY_TEXTURE_TYPE: number;
  61722. /**
  61723. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61724. * in order to compute objects velocities when enableVelocity is set to "true"
  61725. * @hidden
  61726. */
  61727. _previousTransformationMatrices: {
  61728. [index: number]: ISavedTransformationMatrix;
  61729. };
  61730. /**
  61731. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61732. * in order to compute objects velocities when enableVelocity is set to "true"
  61733. * @hidden
  61734. */
  61735. _previousBonesTransformationMatrices: {
  61736. [index: number]: Float32Array;
  61737. };
  61738. /**
  61739. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61740. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61741. */
  61742. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61743. private _scene;
  61744. private _multiRenderTarget;
  61745. private _ratio;
  61746. private _enablePosition;
  61747. private _enableVelocity;
  61748. private _positionIndex;
  61749. private _velocityIndex;
  61750. protected _effect: Effect;
  61751. protected _cachedDefines: string;
  61752. /**
  61753. * Set the render list (meshes to be rendered) used in the G buffer.
  61754. */
  61755. renderList: Mesh[];
  61756. /**
  61757. * Gets wether or not G buffer are supported by the running hardware.
  61758. * This requires draw buffer supports
  61759. */
  61760. readonly isSupported: boolean;
  61761. /**
  61762. * Returns the index of the given texture type in the G-Buffer textures array
  61763. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61764. * @returns the index of the given texture type in the G-Buffer textures array
  61765. */
  61766. getTextureIndex(textureType: number): number;
  61767. /**
  61768. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61769. */
  61770. /**
  61771. * Sets whether or not objects positions are enabled for the G buffer.
  61772. */
  61773. enablePosition: boolean;
  61774. /**
  61775. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61776. */
  61777. /**
  61778. * Sets wether or not objects velocities are enabled for the G buffer.
  61779. */
  61780. enableVelocity: boolean;
  61781. /**
  61782. * Gets the scene associated with the buffer.
  61783. */
  61784. readonly scene: Scene;
  61785. /**
  61786. * Gets the ratio used by the buffer during its creation.
  61787. * How big is the buffer related to the main canvas.
  61788. */
  61789. readonly ratio: number;
  61790. /** @hidden */
  61791. static _SceneComponentInitialization: (scene: Scene) => void;
  61792. /**
  61793. * Creates a new G Buffer for the scene
  61794. * @param scene The scene the buffer belongs to
  61795. * @param ratio How big is the buffer related to the main canvas.
  61796. */
  61797. constructor(scene: Scene, ratio?: number);
  61798. /**
  61799. * Checks wether everything is ready to render a submesh to the G buffer.
  61800. * @param subMesh the submesh to check readiness for
  61801. * @param useInstances is the mesh drawn using instance or not
  61802. * @returns true if ready otherwise false
  61803. */
  61804. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61805. /**
  61806. * Gets the current underlying G Buffer.
  61807. * @returns the buffer
  61808. */
  61809. getGBuffer(): MultiRenderTarget;
  61810. /**
  61811. * Gets the number of samples used to render the buffer (anti aliasing).
  61812. */
  61813. /**
  61814. * Sets the number of samples used to render the buffer (anti aliasing).
  61815. */
  61816. samples: number;
  61817. /**
  61818. * Disposes the renderer and frees up associated resources.
  61819. */
  61820. dispose(): void;
  61821. protected _createRenderTargets(): void;
  61822. private _copyBonesTransformationMatrices;
  61823. }
  61824. }
  61825. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61826. import { Nullable } from "babylonjs/types";
  61827. import { Scene } from "babylonjs/scene";
  61828. import { ISceneComponent } from "babylonjs/sceneComponent";
  61829. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61830. module "babylonjs/scene" {
  61831. interface Scene {
  61832. /** @hidden (Backing field) */
  61833. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61834. /**
  61835. * Gets or Sets the current geometry buffer associated to the scene.
  61836. */
  61837. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61838. /**
  61839. * Enables a GeometryBufferRender and associates it with the scene
  61840. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61841. * @returns the GeometryBufferRenderer
  61842. */
  61843. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61844. /**
  61845. * Disables the GeometryBufferRender associated with the scene
  61846. */
  61847. disableGeometryBufferRenderer(): void;
  61848. }
  61849. }
  61850. /**
  61851. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61852. * in several rendering techniques.
  61853. */
  61854. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61855. /**
  61856. * The component name helpful to identify the component in the list of scene components.
  61857. */
  61858. readonly name: string;
  61859. /**
  61860. * The scene the component belongs to.
  61861. */
  61862. scene: Scene;
  61863. /**
  61864. * Creates a new instance of the component for the given scene
  61865. * @param scene Defines the scene to register the component in
  61866. */
  61867. constructor(scene: Scene);
  61868. /**
  61869. * Registers the component in a given scene
  61870. */
  61871. register(): void;
  61872. /**
  61873. * Rebuilds the elements related to this component in case of
  61874. * context lost for instance.
  61875. */
  61876. rebuild(): void;
  61877. /**
  61878. * Disposes the component and the associated ressources
  61879. */
  61880. dispose(): void;
  61881. private _gatherRenderTargets;
  61882. }
  61883. }
  61884. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61885. /** @hidden */
  61886. export var motionBlurPixelShader: {
  61887. name: string;
  61888. shader: string;
  61889. };
  61890. }
  61891. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61892. import { Nullable } from "babylonjs/types";
  61893. import { Camera } from "babylonjs/Cameras/camera";
  61894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61895. import { Scene } from "babylonjs/scene";
  61896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61897. import "babylonjs/Animations/animatable";
  61898. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61899. import "babylonjs/Shaders/motionBlur.fragment";
  61900. import { Engine } from "babylonjs/Engines/engine";
  61901. /**
  61902. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61903. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61904. * As an example, all you have to do is to create the post-process:
  61905. * var mb = new BABYLON.MotionBlurPostProcess(
  61906. * 'mb', // The name of the effect.
  61907. * scene, // The scene containing the objects to blur according to their velocity.
  61908. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61909. * camera // The camera to apply the render pass to.
  61910. * );
  61911. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61912. */
  61913. export class MotionBlurPostProcess extends PostProcess {
  61914. /**
  61915. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61916. */
  61917. motionStrength: number;
  61918. /**
  61919. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61920. */
  61921. /**
  61922. * Sets the number of iterations to be used for motion blur quality
  61923. */
  61924. motionBlurSamples: number;
  61925. private _motionBlurSamples;
  61926. private _geometryBufferRenderer;
  61927. /**
  61928. * Creates a new instance MotionBlurPostProcess
  61929. * @param name The name of the effect.
  61930. * @param scene The scene containing the objects to blur according to their velocity.
  61931. * @param options The required width/height ratio to downsize to before computing the render pass.
  61932. * @param camera The camera to apply the render pass to.
  61933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61934. * @param engine The engine which the post process will be applied. (default: current engine)
  61935. * @param reusable If the post process can be reused on the same frame. (default: false)
  61936. * @param textureType Type of textures used when performing the post process. (default: 0)
  61937. * @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)
  61938. */
  61939. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61940. /**
  61941. * Excludes the given skinned mesh from computing bones velocities.
  61942. * 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.
  61943. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61944. */
  61945. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61946. /**
  61947. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61948. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61949. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61950. */
  61951. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61952. /**
  61953. * Disposes the post process.
  61954. * @param camera The camera to dispose the post process on.
  61955. */
  61956. dispose(camera?: Camera): void;
  61957. }
  61958. }
  61959. declare module "babylonjs/Shaders/refraction.fragment" {
  61960. /** @hidden */
  61961. export var refractionPixelShader: {
  61962. name: string;
  61963. shader: string;
  61964. };
  61965. }
  61966. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61967. import { Color3 } from "babylonjs/Maths/math.color";
  61968. import { Camera } from "babylonjs/Cameras/camera";
  61969. import { Texture } from "babylonjs/Materials/Textures/texture";
  61970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61971. import { Engine } from "babylonjs/Engines/engine";
  61972. import "babylonjs/Shaders/refraction.fragment";
  61973. /**
  61974. * Post process which applies a refractin texture
  61975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61976. */
  61977. export class RefractionPostProcess extends PostProcess {
  61978. /** the base color of the refraction (used to taint the rendering) */
  61979. color: Color3;
  61980. /** simulated refraction depth */
  61981. depth: number;
  61982. /** the coefficient of the base color (0 to remove base color tainting) */
  61983. colorLevel: number;
  61984. private _refTexture;
  61985. private _ownRefractionTexture;
  61986. /**
  61987. * Gets or sets the refraction texture
  61988. * Please note that you are responsible for disposing the texture if you set it manually
  61989. */
  61990. refractionTexture: Texture;
  61991. /**
  61992. * Initializes the RefractionPostProcess
  61993. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61994. * @param name The name of the effect.
  61995. * @param refractionTextureUrl Url of the refraction texture to use
  61996. * @param color the base color of the refraction (used to taint the rendering)
  61997. * @param depth simulated refraction depth
  61998. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61999. * @param camera The camera to apply the render pass to.
  62000. * @param options The required width/height ratio to downsize to before computing the render pass.
  62001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62002. * @param engine The engine which the post process will be applied. (default: current engine)
  62003. * @param reusable If the post process can be reused on the same frame. (default: false)
  62004. */
  62005. constructor(name: string, refractionTextureUrl: string,
  62006. /** the base color of the refraction (used to taint the rendering) */
  62007. color: Color3,
  62008. /** simulated refraction depth */
  62009. depth: number,
  62010. /** the coefficient of the base color (0 to remove base color tainting) */
  62011. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62012. /**
  62013. * Disposes of the post process
  62014. * @param camera Camera to dispose post process on
  62015. */
  62016. dispose(camera: Camera): void;
  62017. }
  62018. }
  62019. declare module "babylonjs/Shaders/sharpen.fragment" {
  62020. /** @hidden */
  62021. export var sharpenPixelShader: {
  62022. name: string;
  62023. shader: string;
  62024. };
  62025. }
  62026. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62027. import { Nullable } from "babylonjs/types";
  62028. import { Camera } from "babylonjs/Cameras/camera";
  62029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62030. import "babylonjs/Shaders/sharpen.fragment";
  62031. import { Engine } from "babylonjs/Engines/engine";
  62032. /**
  62033. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62034. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62035. */
  62036. export class SharpenPostProcess extends PostProcess {
  62037. /**
  62038. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62039. */
  62040. colorAmount: number;
  62041. /**
  62042. * How much sharpness should be applied (default: 0.3)
  62043. */
  62044. edgeAmount: number;
  62045. /**
  62046. * Creates a new instance ConvolutionPostProcess
  62047. * @param name The name of the effect.
  62048. * @param options The required width/height ratio to downsize to before computing the render pass.
  62049. * @param camera The camera to apply the render pass to.
  62050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62051. * @param engine The engine which the post process will be applied. (default: current engine)
  62052. * @param reusable If the post process can be reused on the same frame. (default: false)
  62053. * @param textureType Type of textures used when performing the post process. (default: 0)
  62054. * @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)
  62055. */
  62056. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62057. }
  62058. }
  62059. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62060. import { Nullable } from "babylonjs/types";
  62061. import { Camera } from "babylonjs/Cameras/camera";
  62062. import { Engine } from "babylonjs/Engines/engine";
  62063. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62064. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62065. /**
  62066. * PostProcessRenderPipeline
  62067. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62068. */
  62069. export class PostProcessRenderPipeline {
  62070. private engine;
  62071. private _renderEffects;
  62072. private _renderEffectsForIsolatedPass;
  62073. /**
  62074. * List of inspectable custom properties (used by the Inspector)
  62075. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62076. */
  62077. inspectableCustomProperties: IInspectable[];
  62078. /**
  62079. * @hidden
  62080. */
  62081. protected _cameras: Camera[];
  62082. /** @hidden */
  62083. _name: string;
  62084. /**
  62085. * Gets pipeline name
  62086. */
  62087. readonly name: string;
  62088. /**
  62089. * Initializes a PostProcessRenderPipeline
  62090. * @param engine engine to add the pipeline to
  62091. * @param name name of the pipeline
  62092. */
  62093. constructor(engine: Engine, name: string);
  62094. /**
  62095. * Gets the class name
  62096. * @returns "PostProcessRenderPipeline"
  62097. */
  62098. getClassName(): string;
  62099. /**
  62100. * If all the render effects in the pipeline are supported
  62101. */
  62102. readonly isSupported: boolean;
  62103. /**
  62104. * Adds an effect to the pipeline
  62105. * @param renderEffect the effect to add
  62106. */
  62107. addEffect(renderEffect: PostProcessRenderEffect): void;
  62108. /** @hidden */
  62109. _rebuild(): void;
  62110. /** @hidden */
  62111. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62112. /** @hidden */
  62113. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62114. /** @hidden */
  62115. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62116. /** @hidden */
  62117. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62118. /** @hidden */
  62119. _attachCameras(cameras: Camera, unique: boolean): void;
  62120. /** @hidden */
  62121. _attachCameras(cameras: Camera[], unique: boolean): void;
  62122. /** @hidden */
  62123. _detachCameras(cameras: Camera): void;
  62124. /** @hidden */
  62125. _detachCameras(cameras: Nullable<Camera[]>): void;
  62126. /** @hidden */
  62127. _update(): void;
  62128. /** @hidden */
  62129. _reset(): void;
  62130. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62131. /**
  62132. * Disposes of the pipeline
  62133. */
  62134. dispose(): void;
  62135. }
  62136. }
  62137. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62138. import { Camera } from "babylonjs/Cameras/camera";
  62139. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62140. /**
  62141. * PostProcessRenderPipelineManager class
  62142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62143. */
  62144. export class PostProcessRenderPipelineManager {
  62145. private _renderPipelines;
  62146. /**
  62147. * Initializes a PostProcessRenderPipelineManager
  62148. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62149. */
  62150. constructor();
  62151. /**
  62152. * Gets the list of supported render pipelines
  62153. */
  62154. readonly supportedPipelines: PostProcessRenderPipeline[];
  62155. /**
  62156. * Adds a pipeline to the manager
  62157. * @param renderPipeline The pipeline to add
  62158. */
  62159. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62160. /**
  62161. * Attaches a camera to the pipeline
  62162. * @param renderPipelineName The name of the pipeline to attach to
  62163. * @param cameras the camera to attach
  62164. * @param unique if the camera can be attached multiple times to the pipeline
  62165. */
  62166. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62167. /**
  62168. * Detaches a camera from the pipeline
  62169. * @param renderPipelineName The name of the pipeline to detach from
  62170. * @param cameras the camera to detach
  62171. */
  62172. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62173. /**
  62174. * Enables an effect by name on a pipeline
  62175. * @param renderPipelineName the name of the pipeline to enable the effect in
  62176. * @param renderEffectName the name of the effect to enable
  62177. * @param cameras the cameras that the effect should be enabled on
  62178. */
  62179. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62180. /**
  62181. * Disables an effect by name on a pipeline
  62182. * @param renderPipelineName the name of the pipeline to disable the effect in
  62183. * @param renderEffectName the name of the effect to disable
  62184. * @param cameras the cameras that the effect should be disabled on
  62185. */
  62186. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62187. /**
  62188. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62189. */
  62190. update(): void;
  62191. /** @hidden */
  62192. _rebuild(): void;
  62193. /**
  62194. * Disposes of the manager and pipelines
  62195. */
  62196. dispose(): void;
  62197. }
  62198. }
  62199. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62200. import { ISceneComponent } from "babylonjs/sceneComponent";
  62201. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62202. import { Scene } from "babylonjs/scene";
  62203. module "babylonjs/scene" {
  62204. interface Scene {
  62205. /** @hidden (Backing field) */
  62206. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62207. /**
  62208. * Gets the postprocess render pipeline manager
  62209. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62210. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62211. */
  62212. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62213. }
  62214. }
  62215. /**
  62216. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62217. */
  62218. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62219. /**
  62220. * The component name helpfull to identify the component in the list of scene components.
  62221. */
  62222. readonly name: string;
  62223. /**
  62224. * The scene the component belongs to.
  62225. */
  62226. scene: Scene;
  62227. /**
  62228. * Creates a new instance of the component for the given scene
  62229. * @param scene Defines the scene to register the component in
  62230. */
  62231. constructor(scene: Scene);
  62232. /**
  62233. * Registers the component in a given scene
  62234. */
  62235. register(): void;
  62236. /**
  62237. * Rebuilds the elements related to this component in case of
  62238. * context lost for instance.
  62239. */
  62240. rebuild(): void;
  62241. /**
  62242. * Disposes the component and the associated ressources
  62243. */
  62244. dispose(): void;
  62245. private _gatherRenderTargets;
  62246. }
  62247. }
  62248. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62249. import { Nullable } from "babylonjs/types";
  62250. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62251. import { Camera } from "babylonjs/Cameras/camera";
  62252. import { IDisposable } from "babylonjs/scene";
  62253. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62254. import { Scene } from "babylonjs/scene";
  62255. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62256. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62257. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62258. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62259. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62260. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62261. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62262. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62263. import { Animation } from "babylonjs/Animations/animation";
  62264. /**
  62265. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62266. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62267. */
  62268. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62269. private _scene;
  62270. private _camerasToBeAttached;
  62271. /**
  62272. * ID of the sharpen post process,
  62273. */
  62274. private readonly SharpenPostProcessId;
  62275. /**
  62276. * @ignore
  62277. * ID of the image processing post process;
  62278. */
  62279. readonly ImageProcessingPostProcessId: string;
  62280. /**
  62281. * @ignore
  62282. * ID of the Fast Approximate Anti-Aliasing post process;
  62283. */
  62284. readonly FxaaPostProcessId: string;
  62285. /**
  62286. * ID of the chromatic aberration post process,
  62287. */
  62288. private readonly ChromaticAberrationPostProcessId;
  62289. /**
  62290. * ID of the grain post process
  62291. */
  62292. private readonly GrainPostProcessId;
  62293. /**
  62294. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62295. */
  62296. sharpen: SharpenPostProcess;
  62297. private _sharpenEffect;
  62298. private bloom;
  62299. /**
  62300. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62301. */
  62302. depthOfField: DepthOfFieldEffect;
  62303. /**
  62304. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62305. */
  62306. fxaa: FxaaPostProcess;
  62307. /**
  62308. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62309. */
  62310. imageProcessing: ImageProcessingPostProcess;
  62311. /**
  62312. * Chromatic aberration post process which will shift rgb colors in the image
  62313. */
  62314. chromaticAberration: ChromaticAberrationPostProcess;
  62315. private _chromaticAberrationEffect;
  62316. /**
  62317. * Grain post process which add noise to the image
  62318. */
  62319. grain: GrainPostProcess;
  62320. private _grainEffect;
  62321. /**
  62322. * Glow post process which adds a glow to emissive areas of the image
  62323. */
  62324. private _glowLayer;
  62325. /**
  62326. * Animations which can be used to tweak settings over a period of time
  62327. */
  62328. animations: Animation[];
  62329. private _imageProcessingConfigurationObserver;
  62330. private _sharpenEnabled;
  62331. private _bloomEnabled;
  62332. private _depthOfFieldEnabled;
  62333. private _depthOfFieldBlurLevel;
  62334. private _fxaaEnabled;
  62335. private _imageProcessingEnabled;
  62336. private _defaultPipelineTextureType;
  62337. private _bloomScale;
  62338. private _chromaticAberrationEnabled;
  62339. private _grainEnabled;
  62340. private _buildAllowed;
  62341. /**
  62342. * Gets active scene
  62343. */
  62344. readonly scene: Scene;
  62345. /**
  62346. * Enable or disable the sharpen process from the pipeline
  62347. */
  62348. sharpenEnabled: boolean;
  62349. private _resizeObserver;
  62350. private _hardwareScaleLevel;
  62351. private _bloomKernel;
  62352. /**
  62353. * Specifies the size of the bloom blur kernel, relative to the final output size
  62354. */
  62355. bloomKernel: number;
  62356. /**
  62357. * Specifies the weight of the bloom in the final rendering
  62358. */
  62359. private _bloomWeight;
  62360. /**
  62361. * Specifies the luma threshold for the area that will be blurred by the bloom
  62362. */
  62363. private _bloomThreshold;
  62364. private _hdr;
  62365. /**
  62366. * The strength of the bloom.
  62367. */
  62368. bloomWeight: number;
  62369. /**
  62370. * The strength of the bloom.
  62371. */
  62372. bloomThreshold: number;
  62373. /**
  62374. * The scale of the bloom, lower value will provide better performance.
  62375. */
  62376. bloomScale: number;
  62377. /**
  62378. * Enable or disable the bloom from the pipeline
  62379. */
  62380. bloomEnabled: boolean;
  62381. private _rebuildBloom;
  62382. /**
  62383. * If the depth of field is enabled.
  62384. */
  62385. depthOfFieldEnabled: boolean;
  62386. /**
  62387. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62388. */
  62389. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62390. /**
  62391. * If the anti aliasing is enabled.
  62392. */
  62393. fxaaEnabled: boolean;
  62394. private _samples;
  62395. /**
  62396. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62397. */
  62398. samples: number;
  62399. /**
  62400. * If image processing is enabled.
  62401. */
  62402. imageProcessingEnabled: boolean;
  62403. /**
  62404. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62405. */
  62406. glowLayerEnabled: boolean;
  62407. /**
  62408. * Gets the glow layer (or null if not defined)
  62409. */
  62410. readonly glowLayer: Nullable<GlowLayer>;
  62411. /**
  62412. * Enable or disable the chromaticAberration process from the pipeline
  62413. */
  62414. chromaticAberrationEnabled: boolean;
  62415. /**
  62416. * Enable or disable the grain process from the pipeline
  62417. */
  62418. grainEnabled: boolean;
  62419. /**
  62420. * @constructor
  62421. * @param name - The rendering pipeline name (default: "")
  62422. * @param hdr - If high dynamic range textures should be used (default: true)
  62423. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62424. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62425. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62426. */
  62427. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62428. /**
  62429. * Get the class name
  62430. * @returns "DefaultRenderingPipeline"
  62431. */
  62432. getClassName(): string;
  62433. /**
  62434. * Force the compilation of the entire pipeline.
  62435. */
  62436. prepare(): void;
  62437. private _hasCleared;
  62438. private _prevPostProcess;
  62439. private _prevPrevPostProcess;
  62440. private _setAutoClearAndTextureSharing;
  62441. private _depthOfFieldSceneObserver;
  62442. private _buildPipeline;
  62443. private _disposePostProcesses;
  62444. /**
  62445. * Adds a camera to the pipeline
  62446. * @param camera the camera to be added
  62447. */
  62448. addCamera(camera: Camera): void;
  62449. /**
  62450. * Removes a camera from the pipeline
  62451. * @param camera the camera to remove
  62452. */
  62453. removeCamera(camera: Camera): void;
  62454. /**
  62455. * Dispose of the pipeline and stop all post processes
  62456. */
  62457. dispose(): void;
  62458. /**
  62459. * Serialize the rendering pipeline (Used when exporting)
  62460. * @returns the serialized object
  62461. */
  62462. serialize(): any;
  62463. /**
  62464. * Parse the serialized pipeline
  62465. * @param source Source pipeline.
  62466. * @param scene The scene to load the pipeline to.
  62467. * @param rootUrl The URL of the serialized pipeline.
  62468. * @returns An instantiated pipeline from the serialized object.
  62469. */
  62470. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62471. }
  62472. }
  62473. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62474. /** @hidden */
  62475. export var lensHighlightsPixelShader: {
  62476. name: string;
  62477. shader: string;
  62478. };
  62479. }
  62480. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62481. /** @hidden */
  62482. export var depthOfFieldPixelShader: {
  62483. name: string;
  62484. shader: string;
  62485. };
  62486. }
  62487. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62488. import { Camera } from "babylonjs/Cameras/camera";
  62489. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62490. import { Scene } from "babylonjs/scene";
  62491. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62492. import "babylonjs/Shaders/chromaticAberration.fragment";
  62493. import "babylonjs/Shaders/lensHighlights.fragment";
  62494. import "babylonjs/Shaders/depthOfField.fragment";
  62495. /**
  62496. * BABYLON.JS Chromatic Aberration GLSL Shader
  62497. * Author: Olivier Guyot
  62498. * Separates very slightly R, G and B colors on the edges of the screen
  62499. * Inspired by Francois Tarlier & Martins Upitis
  62500. */
  62501. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62502. /**
  62503. * @ignore
  62504. * The chromatic aberration PostProcess id in the pipeline
  62505. */
  62506. LensChromaticAberrationEffect: string;
  62507. /**
  62508. * @ignore
  62509. * The highlights enhancing PostProcess id in the pipeline
  62510. */
  62511. HighlightsEnhancingEffect: string;
  62512. /**
  62513. * @ignore
  62514. * The depth-of-field PostProcess id in the pipeline
  62515. */
  62516. LensDepthOfFieldEffect: string;
  62517. private _scene;
  62518. private _depthTexture;
  62519. private _grainTexture;
  62520. private _chromaticAberrationPostProcess;
  62521. private _highlightsPostProcess;
  62522. private _depthOfFieldPostProcess;
  62523. private _edgeBlur;
  62524. private _grainAmount;
  62525. private _chromaticAberration;
  62526. private _distortion;
  62527. private _highlightsGain;
  62528. private _highlightsThreshold;
  62529. private _dofDistance;
  62530. private _dofAperture;
  62531. private _dofDarken;
  62532. private _dofPentagon;
  62533. private _blurNoise;
  62534. /**
  62535. * @constructor
  62536. *
  62537. * Effect parameters are as follow:
  62538. * {
  62539. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62540. * edge_blur: number; // from 0 to x (1 for realism)
  62541. * distortion: number; // from 0 to x (1 for realism)
  62542. * grain_amount: number; // from 0 to 1
  62543. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62544. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62545. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62546. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62547. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62548. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62549. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62550. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62551. * }
  62552. * Note: if an effect parameter is unset, effect is disabled
  62553. *
  62554. * @param name The rendering pipeline name
  62555. * @param parameters - An object containing all parameters (see above)
  62556. * @param scene The scene linked to this pipeline
  62557. * @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)
  62558. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62559. */
  62560. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62561. /**
  62562. * Get the class name
  62563. * @returns "LensRenderingPipeline"
  62564. */
  62565. getClassName(): string;
  62566. /**
  62567. * Gets associated scene
  62568. */
  62569. readonly scene: Scene;
  62570. /**
  62571. * Gets or sets the edge blur
  62572. */
  62573. edgeBlur: number;
  62574. /**
  62575. * Gets or sets the grain amount
  62576. */
  62577. grainAmount: number;
  62578. /**
  62579. * Gets or sets the chromatic aberration amount
  62580. */
  62581. chromaticAberration: number;
  62582. /**
  62583. * Gets or sets the depth of field aperture
  62584. */
  62585. dofAperture: number;
  62586. /**
  62587. * Gets or sets the edge distortion
  62588. */
  62589. edgeDistortion: number;
  62590. /**
  62591. * Gets or sets the depth of field distortion
  62592. */
  62593. dofDistortion: number;
  62594. /**
  62595. * Gets or sets the darken out of focus amount
  62596. */
  62597. darkenOutOfFocus: number;
  62598. /**
  62599. * Gets or sets a boolean indicating if blur noise is enabled
  62600. */
  62601. blurNoise: boolean;
  62602. /**
  62603. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62604. */
  62605. pentagonBokeh: boolean;
  62606. /**
  62607. * Gets or sets the highlight grain amount
  62608. */
  62609. highlightsGain: number;
  62610. /**
  62611. * Gets or sets the highlight threshold
  62612. */
  62613. highlightsThreshold: number;
  62614. /**
  62615. * Sets the amount of blur at the edges
  62616. * @param amount blur amount
  62617. */
  62618. setEdgeBlur(amount: number): void;
  62619. /**
  62620. * Sets edge blur to 0
  62621. */
  62622. disableEdgeBlur(): void;
  62623. /**
  62624. * Sets the amout of grain
  62625. * @param amount Amount of grain
  62626. */
  62627. setGrainAmount(amount: number): void;
  62628. /**
  62629. * Set grain amount to 0
  62630. */
  62631. disableGrain(): void;
  62632. /**
  62633. * Sets the chromatic aberration amount
  62634. * @param amount amount of chromatic aberration
  62635. */
  62636. setChromaticAberration(amount: number): void;
  62637. /**
  62638. * Sets chromatic aberration amount to 0
  62639. */
  62640. disableChromaticAberration(): void;
  62641. /**
  62642. * Sets the EdgeDistortion amount
  62643. * @param amount amount of EdgeDistortion
  62644. */
  62645. setEdgeDistortion(amount: number): void;
  62646. /**
  62647. * Sets edge distortion to 0
  62648. */
  62649. disableEdgeDistortion(): void;
  62650. /**
  62651. * Sets the FocusDistance amount
  62652. * @param amount amount of FocusDistance
  62653. */
  62654. setFocusDistance(amount: number): void;
  62655. /**
  62656. * Disables depth of field
  62657. */
  62658. disableDepthOfField(): void;
  62659. /**
  62660. * Sets the Aperture amount
  62661. * @param amount amount of Aperture
  62662. */
  62663. setAperture(amount: number): void;
  62664. /**
  62665. * Sets the DarkenOutOfFocus amount
  62666. * @param amount amount of DarkenOutOfFocus
  62667. */
  62668. setDarkenOutOfFocus(amount: number): void;
  62669. private _pentagonBokehIsEnabled;
  62670. /**
  62671. * Creates a pentagon bokeh effect
  62672. */
  62673. enablePentagonBokeh(): void;
  62674. /**
  62675. * Disables the pentagon bokeh effect
  62676. */
  62677. disablePentagonBokeh(): void;
  62678. /**
  62679. * Enables noise blur
  62680. */
  62681. enableNoiseBlur(): void;
  62682. /**
  62683. * Disables noise blur
  62684. */
  62685. disableNoiseBlur(): void;
  62686. /**
  62687. * Sets the HighlightsGain amount
  62688. * @param amount amount of HighlightsGain
  62689. */
  62690. setHighlightsGain(amount: number): void;
  62691. /**
  62692. * Sets the HighlightsThreshold amount
  62693. * @param amount amount of HighlightsThreshold
  62694. */
  62695. setHighlightsThreshold(amount: number): void;
  62696. /**
  62697. * Disables highlights
  62698. */
  62699. disableHighlights(): void;
  62700. /**
  62701. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62702. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62703. */
  62704. dispose(disableDepthRender?: boolean): void;
  62705. private _createChromaticAberrationPostProcess;
  62706. private _createHighlightsPostProcess;
  62707. private _createDepthOfFieldPostProcess;
  62708. private _createGrainTexture;
  62709. }
  62710. }
  62711. declare module "babylonjs/Shaders/ssao2.fragment" {
  62712. /** @hidden */
  62713. export var ssao2PixelShader: {
  62714. name: string;
  62715. shader: string;
  62716. };
  62717. }
  62718. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62719. /** @hidden */
  62720. export var ssaoCombinePixelShader: {
  62721. name: string;
  62722. shader: string;
  62723. };
  62724. }
  62725. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62726. import { Camera } from "babylonjs/Cameras/camera";
  62727. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62728. import { Scene } from "babylonjs/scene";
  62729. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62730. import "babylonjs/Shaders/ssao2.fragment";
  62731. import "babylonjs/Shaders/ssaoCombine.fragment";
  62732. /**
  62733. * Render pipeline to produce ssao effect
  62734. */
  62735. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62736. /**
  62737. * @ignore
  62738. * The PassPostProcess id in the pipeline that contains the original scene color
  62739. */
  62740. SSAOOriginalSceneColorEffect: string;
  62741. /**
  62742. * @ignore
  62743. * The SSAO PostProcess id in the pipeline
  62744. */
  62745. SSAORenderEffect: string;
  62746. /**
  62747. * @ignore
  62748. * The horizontal blur PostProcess id in the pipeline
  62749. */
  62750. SSAOBlurHRenderEffect: string;
  62751. /**
  62752. * @ignore
  62753. * The vertical blur PostProcess id in the pipeline
  62754. */
  62755. SSAOBlurVRenderEffect: string;
  62756. /**
  62757. * @ignore
  62758. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62759. */
  62760. SSAOCombineRenderEffect: string;
  62761. /**
  62762. * The output strength of the SSAO post-process. Default value is 1.0.
  62763. */
  62764. totalStrength: number;
  62765. /**
  62766. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62767. */
  62768. maxZ: number;
  62769. /**
  62770. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62771. */
  62772. minZAspect: number;
  62773. private _samples;
  62774. /**
  62775. * Number of samples used for the SSAO calculations. Default value is 8
  62776. */
  62777. samples: number;
  62778. private _textureSamples;
  62779. /**
  62780. * Number of samples to use for antialiasing
  62781. */
  62782. textureSamples: number;
  62783. /**
  62784. * Ratio object used for SSAO ratio and blur ratio
  62785. */
  62786. private _ratio;
  62787. /**
  62788. * Dynamically generated sphere sampler.
  62789. */
  62790. private _sampleSphere;
  62791. /**
  62792. * Blur filter offsets
  62793. */
  62794. private _samplerOffsets;
  62795. private _expensiveBlur;
  62796. /**
  62797. * If bilateral blur should be used
  62798. */
  62799. expensiveBlur: boolean;
  62800. /**
  62801. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62802. */
  62803. radius: number;
  62804. /**
  62805. * The base color of the SSAO post-process
  62806. * The final result is "base + ssao" between [0, 1]
  62807. */
  62808. base: number;
  62809. /**
  62810. * Support test.
  62811. */
  62812. static readonly IsSupported: boolean;
  62813. private _scene;
  62814. private _depthTexture;
  62815. private _normalTexture;
  62816. private _randomTexture;
  62817. private _originalColorPostProcess;
  62818. private _ssaoPostProcess;
  62819. private _blurHPostProcess;
  62820. private _blurVPostProcess;
  62821. private _ssaoCombinePostProcess;
  62822. private _firstUpdate;
  62823. /**
  62824. * Gets active scene
  62825. */
  62826. readonly scene: Scene;
  62827. /**
  62828. * @constructor
  62829. * @param name The rendering pipeline name
  62830. * @param scene The scene linked to this pipeline
  62831. * @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 }
  62832. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62833. */
  62834. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62835. /**
  62836. * Get the class name
  62837. * @returns "SSAO2RenderingPipeline"
  62838. */
  62839. getClassName(): string;
  62840. /**
  62841. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62842. */
  62843. dispose(disableGeometryBufferRenderer?: boolean): void;
  62844. private _createBlurPostProcess;
  62845. /** @hidden */
  62846. _rebuild(): void;
  62847. private _bits;
  62848. private _radicalInverse_VdC;
  62849. private _hammersley;
  62850. private _hemisphereSample_uniform;
  62851. private _generateHemisphere;
  62852. private _createSSAOPostProcess;
  62853. private _createSSAOCombinePostProcess;
  62854. private _createRandomTexture;
  62855. /**
  62856. * Serialize the rendering pipeline (Used when exporting)
  62857. * @returns the serialized object
  62858. */
  62859. serialize(): any;
  62860. /**
  62861. * Parse the serialized pipeline
  62862. * @param source Source pipeline.
  62863. * @param scene The scene to load the pipeline to.
  62864. * @param rootUrl The URL of the serialized pipeline.
  62865. * @returns An instantiated pipeline from the serialized object.
  62866. */
  62867. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62868. }
  62869. }
  62870. declare module "babylonjs/Shaders/ssao.fragment" {
  62871. /** @hidden */
  62872. export var ssaoPixelShader: {
  62873. name: string;
  62874. shader: string;
  62875. };
  62876. }
  62877. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62878. import { Camera } from "babylonjs/Cameras/camera";
  62879. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62880. import { Scene } from "babylonjs/scene";
  62881. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62882. import "babylonjs/Shaders/ssao.fragment";
  62883. import "babylonjs/Shaders/ssaoCombine.fragment";
  62884. /**
  62885. * Render pipeline to produce ssao effect
  62886. */
  62887. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62888. /**
  62889. * @ignore
  62890. * The PassPostProcess id in the pipeline that contains the original scene color
  62891. */
  62892. SSAOOriginalSceneColorEffect: string;
  62893. /**
  62894. * @ignore
  62895. * The SSAO PostProcess id in the pipeline
  62896. */
  62897. SSAORenderEffect: string;
  62898. /**
  62899. * @ignore
  62900. * The horizontal blur PostProcess id in the pipeline
  62901. */
  62902. SSAOBlurHRenderEffect: string;
  62903. /**
  62904. * @ignore
  62905. * The vertical blur PostProcess id in the pipeline
  62906. */
  62907. SSAOBlurVRenderEffect: string;
  62908. /**
  62909. * @ignore
  62910. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62911. */
  62912. SSAOCombineRenderEffect: string;
  62913. /**
  62914. * The output strength of the SSAO post-process. Default value is 1.0.
  62915. */
  62916. totalStrength: number;
  62917. /**
  62918. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62919. */
  62920. radius: number;
  62921. /**
  62922. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62923. * Must not be equal to fallOff and superior to fallOff.
  62924. * Default value is 0.0075
  62925. */
  62926. area: number;
  62927. /**
  62928. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62929. * Must not be equal to area and inferior to area.
  62930. * Default value is 0.000001
  62931. */
  62932. fallOff: number;
  62933. /**
  62934. * The base color of the SSAO post-process
  62935. * The final result is "base + ssao" between [0, 1]
  62936. */
  62937. base: number;
  62938. private _scene;
  62939. private _depthTexture;
  62940. private _randomTexture;
  62941. private _originalColorPostProcess;
  62942. private _ssaoPostProcess;
  62943. private _blurHPostProcess;
  62944. private _blurVPostProcess;
  62945. private _ssaoCombinePostProcess;
  62946. private _firstUpdate;
  62947. /**
  62948. * Gets active scene
  62949. */
  62950. readonly scene: Scene;
  62951. /**
  62952. * @constructor
  62953. * @param name - The rendering pipeline name
  62954. * @param scene - The scene linked to this pipeline
  62955. * @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 }
  62956. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62957. */
  62958. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62959. /**
  62960. * Get the class name
  62961. * @returns "SSAORenderingPipeline"
  62962. */
  62963. getClassName(): string;
  62964. /**
  62965. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62966. */
  62967. dispose(disableDepthRender?: boolean): void;
  62968. private _createBlurPostProcess;
  62969. /** @hidden */
  62970. _rebuild(): void;
  62971. private _createSSAOPostProcess;
  62972. private _createSSAOCombinePostProcess;
  62973. private _createRandomTexture;
  62974. }
  62975. }
  62976. declare module "babylonjs/Shaders/standard.fragment" {
  62977. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62978. /** @hidden */
  62979. export var standardPixelShader: {
  62980. name: string;
  62981. shader: string;
  62982. };
  62983. }
  62984. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62985. import { Nullable } from "babylonjs/types";
  62986. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62987. import { Camera } from "babylonjs/Cameras/camera";
  62988. import { Texture } from "babylonjs/Materials/Textures/texture";
  62989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62990. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62991. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62992. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62993. import { IDisposable } from "babylonjs/scene";
  62994. import { SpotLight } from "babylonjs/Lights/spotLight";
  62995. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62996. import { Scene } from "babylonjs/scene";
  62997. import { Animation } from "babylonjs/Animations/animation";
  62998. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62999. import "babylonjs/Shaders/standard.fragment";
  63000. /**
  63001. * Standard rendering pipeline
  63002. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63003. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63004. */
  63005. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63006. /**
  63007. * Public members
  63008. */
  63009. /**
  63010. * Post-process which contains the original scene color before the pipeline applies all the effects
  63011. */
  63012. originalPostProcess: Nullable<PostProcess>;
  63013. /**
  63014. * Post-process used to down scale an image x4
  63015. */
  63016. downSampleX4PostProcess: Nullable<PostProcess>;
  63017. /**
  63018. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63019. */
  63020. brightPassPostProcess: Nullable<PostProcess>;
  63021. /**
  63022. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63023. */
  63024. blurHPostProcesses: PostProcess[];
  63025. /**
  63026. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63027. */
  63028. blurVPostProcesses: PostProcess[];
  63029. /**
  63030. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63031. */
  63032. textureAdderPostProcess: Nullable<PostProcess>;
  63033. /**
  63034. * Post-process used to create volumetric lighting effect
  63035. */
  63036. volumetricLightPostProcess: Nullable<PostProcess>;
  63037. /**
  63038. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63039. */
  63040. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63041. /**
  63042. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63043. */
  63044. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63045. /**
  63046. * Post-process used to merge the volumetric light effect and the real scene color
  63047. */
  63048. volumetricLightMergePostProces: Nullable<PostProcess>;
  63049. /**
  63050. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63051. */
  63052. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63053. /**
  63054. * Base post-process used to calculate the average luminance of the final image for HDR
  63055. */
  63056. luminancePostProcess: Nullable<PostProcess>;
  63057. /**
  63058. * Post-processes used to create down sample post-processes in order to get
  63059. * the average luminance of the final image for HDR
  63060. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63061. */
  63062. luminanceDownSamplePostProcesses: PostProcess[];
  63063. /**
  63064. * Post-process used to create a HDR effect (light adaptation)
  63065. */
  63066. hdrPostProcess: Nullable<PostProcess>;
  63067. /**
  63068. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63069. */
  63070. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63071. /**
  63072. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63073. */
  63074. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63075. /**
  63076. * Post-process used to merge the final HDR post-process and the real scene color
  63077. */
  63078. hdrFinalPostProcess: Nullable<PostProcess>;
  63079. /**
  63080. * Post-process used to create a lens flare effect
  63081. */
  63082. lensFlarePostProcess: Nullable<PostProcess>;
  63083. /**
  63084. * Post-process that merges the result of the lens flare post-process and the real scene color
  63085. */
  63086. lensFlareComposePostProcess: Nullable<PostProcess>;
  63087. /**
  63088. * Post-process used to create a motion blur effect
  63089. */
  63090. motionBlurPostProcess: Nullable<PostProcess>;
  63091. /**
  63092. * Post-process used to create a depth of field effect
  63093. */
  63094. depthOfFieldPostProcess: Nullable<PostProcess>;
  63095. /**
  63096. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63097. */
  63098. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63099. /**
  63100. * Represents the brightness threshold in order to configure the illuminated surfaces
  63101. */
  63102. brightThreshold: number;
  63103. /**
  63104. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63105. */
  63106. blurWidth: number;
  63107. /**
  63108. * Sets if the blur for highlighted surfaces must be only horizontal
  63109. */
  63110. horizontalBlur: boolean;
  63111. /**
  63112. * Gets the overall exposure used by the pipeline
  63113. */
  63114. /**
  63115. * Sets the overall exposure used by the pipeline
  63116. */
  63117. exposure: number;
  63118. /**
  63119. * Texture used typically to simulate "dirty" on camera lens
  63120. */
  63121. lensTexture: Nullable<Texture>;
  63122. /**
  63123. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63124. */
  63125. volumetricLightCoefficient: number;
  63126. /**
  63127. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63128. */
  63129. volumetricLightPower: number;
  63130. /**
  63131. * Used the set the blur intensity to smooth the volumetric lights
  63132. */
  63133. volumetricLightBlurScale: number;
  63134. /**
  63135. * Light (spot or directional) used to generate the volumetric lights rays
  63136. * The source light must have a shadow generate so the pipeline can get its
  63137. * depth map
  63138. */
  63139. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63140. /**
  63141. * For eye adaptation, represents the minimum luminance the eye can see
  63142. */
  63143. hdrMinimumLuminance: number;
  63144. /**
  63145. * For eye adaptation, represents the decrease luminance speed
  63146. */
  63147. hdrDecreaseRate: number;
  63148. /**
  63149. * For eye adaptation, represents the increase luminance speed
  63150. */
  63151. hdrIncreaseRate: number;
  63152. /**
  63153. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63154. */
  63155. /**
  63156. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63157. */
  63158. hdrAutoExposure: boolean;
  63159. /**
  63160. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63161. */
  63162. lensColorTexture: Nullable<Texture>;
  63163. /**
  63164. * The overall strengh for the lens flare effect
  63165. */
  63166. lensFlareStrength: number;
  63167. /**
  63168. * Dispersion coefficient for lens flare ghosts
  63169. */
  63170. lensFlareGhostDispersal: number;
  63171. /**
  63172. * Main lens flare halo width
  63173. */
  63174. lensFlareHaloWidth: number;
  63175. /**
  63176. * Based on the lens distortion effect, defines how much the lens flare result
  63177. * is distorted
  63178. */
  63179. lensFlareDistortionStrength: number;
  63180. /**
  63181. * Configures the blur intensity used for for lens flare (halo)
  63182. */
  63183. lensFlareBlurWidth: number;
  63184. /**
  63185. * Lens star texture must be used to simulate rays on the flares and is available
  63186. * in the documentation
  63187. */
  63188. lensStarTexture: Nullable<Texture>;
  63189. /**
  63190. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63191. * flare effect by taking account of the dirt texture
  63192. */
  63193. lensFlareDirtTexture: Nullable<Texture>;
  63194. /**
  63195. * Represents the focal length for the depth of field effect
  63196. */
  63197. depthOfFieldDistance: number;
  63198. /**
  63199. * Represents the blur intensity for the blurred part of the depth of field effect
  63200. */
  63201. depthOfFieldBlurWidth: number;
  63202. /**
  63203. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63204. */
  63205. /**
  63206. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63207. */
  63208. motionStrength: number;
  63209. /**
  63210. * Gets wether or not the motion blur post-process is object based or screen based.
  63211. */
  63212. /**
  63213. * Sets wether or not the motion blur post-process should be object based or screen based
  63214. */
  63215. objectBasedMotionBlur: boolean;
  63216. /**
  63217. * List of animations for the pipeline (IAnimatable implementation)
  63218. */
  63219. animations: Animation[];
  63220. /**
  63221. * Private members
  63222. */
  63223. private _scene;
  63224. private _currentDepthOfFieldSource;
  63225. private _basePostProcess;
  63226. private _fixedExposure;
  63227. private _currentExposure;
  63228. private _hdrAutoExposure;
  63229. private _hdrCurrentLuminance;
  63230. private _motionStrength;
  63231. private _isObjectBasedMotionBlur;
  63232. private _floatTextureType;
  63233. private _camerasToBeAttached;
  63234. private _ratio;
  63235. private _bloomEnabled;
  63236. private _depthOfFieldEnabled;
  63237. private _vlsEnabled;
  63238. private _lensFlareEnabled;
  63239. private _hdrEnabled;
  63240. private _motionBlurEnabled;
  63241. private _fxaaEnabled;
  63242. private _motionBlurSamples;
  63243. private _volumetricLightStepsCount;
  63244. private _samples;
  63245. /**
  63246. * @ignore
  63247. * Specifies if the bloom pipeline is enabled
  63248. */
  63249. BloomEnabled: boolean;
  63250. /**
  63251. * @ignore
  63252. * Specifies if the depth of field pipeline is enabed
  63253. */
  63254. DepthOfFieldEnabled: boolean;
  63255. /**
  63256. * @ignore
  63257. * Specifies if the lens flare pipeline is enabed
  63258. */
  63259. LensFlareEnabled: boolean;
  63260. /**
  63261. * @ignore
  63262. * Specifies if the HDR pipeline is enabled
  63263. */
  63264. HDREnabled: boolean;
  63265. /**
  63266. * @ignore
  63267. * Specifies if the volumetric lights scattering effect is enabled
  63268. */
  63269. VLSEnabled: boolean;
  63270. /**
  63271. * @ignore
  63272. * Specifies if the motion blur effect is enabled
  63273. */
  63274. MotionBlurEnabled: boolean;
  63275. /**
  63276. * Specifies if anti-aliasing is enabled
  63277. */
  63278. fxaaEnabled: boolean;
  63279. /**
  63280. * Specifies the number of steps used to calculate the volumetric lights
  63281. * Typically in interval [50, 200]
  63282. */
  63283. volumetricLightStepsCount: number;
  63284. /**
  63285. * Specifies the number of samples used for the motion blur effect
  63286. * Typically in interval [16, 64]
  63287. */
  63288. motionBlurSamples: number;
  63289. /**
  63290. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63291. */
  63292. samples: number;
  63293. /**
  63294. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63295. * @constructor
  63296. * @param name The rendering pipeline name
  63297. * @param scene The scene linked to this pipeline
  63298. * @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)
  63299. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63300. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63301. */
  63302. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63303. private _buildPipeline;
  63304. private _createDownSampleX4PostProcess;
  63305. private _createBrightPassPostProcess;
  63306. private _createBlurPostProcesses;
  63307. private _createTextureAdderPostProcess;
  63308. private _createVolumetricLightPostProcess;
  63309. private _createLuminancePostProcesses;
  63310. private _createHdrPostProcess;
  63311. private _createLensFlarePostProcess;
  63312. private _createDepthOfFieldPostProcess;
  63313. private _createMotionBlurPostProcess;
  63314. private _getDepthTexture;
  63315. private _disposePostProcesses;
  63316. /**
  63317. * Dispose of the pipeline and stop all post processes
  63318. */
  63319. dispose(): void;
  63320. /**
  63321. * Serialize the rendering pipeline (Used when exporting)
  63322. * @returns the serialized object
  63323. */
  63324. serialize(): any;
  63325. /**
  63326. * Parse the serialized pipeline
  63327. * @param source Source pipeline.
  63328. * @param scene The scene to load the pipeline to.
  63329. * @param rootUrl The URL of the serialized pipeline.
  63330. * @returns An instantiated pipeline from the serialized object.
  63331. */
  63332. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63333. /**
  63334. * Luminance steps
  63335. */
  63336. static LuminanceSteps: number;
  63337. }
  63338. }
  63339. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63340. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63341. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63342. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63343. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63344. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63345. }
  63346. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63347. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63348. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63349. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63350. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63351. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63352. }
  63353. declare module "babylonjs/Shaders/tonemap.fragment" {
  63354. /** @hidden */
  63355. export var tonemapPixelShader: {
  63356. name: string;
  63357. shader: string;
  63358. };
  63359. }
  63360. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63361. import { Camera } from "babylonjs/Cameras/camera";
  63362. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63363. import "babylonjs/Shaders/tonemap.fragment";
  63364. import { Engine } from "babylonjs/Engines/engine";
  63365. /** Defines operator used for tonemapping */
  63366. export enum TonemappingOperator {
  63367. /** Hable */
  63368. Hable = 0,
  63369. /** Reinhard */
  63370. Reinhard = 1,
  63371. /** HejiDawson */
  63372. HejiDawson = 2,
  63373. /** Photographic */
  63374. Photographic = 3
  63375. }
  63376. /**
  63377. * Defines a post process to apply tone mapping
  63378. */
  63379. export class TonemapPostProcess extends PostProcess {
  63380. private _operator;
  63381. /** Defines the required exposure adjustement */
  63382. exposureAdjustment: number;
  63383. /**
  63384. * Creates a new TonemapPostProcess
  63385. * @param name defines the name of the postprocess
  63386. * @param _operator defines the operator to use
  63387. * @param exposureAdjustment defines the required exposure adjustement
  63388. * @param camera defines the camera to use (can be null)
  63389. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63390. * @param engine defines the hosting engine (can be ignore if camera is set)
  63391. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63392. */
  63393. constructor(name: string, _operator: TonemappingOperator,
  63394. /** Defines the required exposure adjustement */
  63395. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63396. }
  63397. }
  63398. declare module "babylonjs/Shaders/depth.vertex" {
  63399. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63402. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63403. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63404. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63405. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63406. /** @hidden */
  63407. export var depthVertexShader: {
  63408. name: string;
  63409. shader: string;
  63410. };
  63411. }
  63412. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63413. /** @hidden */
  63414. export var volumetricLightScatteringPixelShader: {
  63415. name: string;
  63416. shader: string;
  63417. };
  63418. }
  63419. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63420. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63423. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63424. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63425. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63426. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63427. /** @hidden */
  63428. export var volumetricLightScatteringPassVertexShader: {
  63429. name: string;
  63430. shader: string;
  63431. };
  63432. }
  63433. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63434. /** @hidden */
  63435. export var volumetricLightScatteringPassPixelShader: {
  63436. name: string;
  63437. shader: string;
  63438. };
  63439. }
  63440. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63441. import { Vector3 } from "babylonjs/Maths/math.vector";
  63442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63443. import { Mesh } from "babylonjs/Meshes/mesh";
  63444. import { Camera } from "babylonjs/Cameras/camera";
  63445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63446. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63447. import { Scene } from "babylonjs/scene";
  63448. import "babylonjs/Meshes/Builders/planeBuilder";
  63449. import "babylonjs/Shaders/depth.vertex";
  63450. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63451. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63452. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63453. import { Engine } from "babylonjs/Engines/engine";
  63454. /**
  63455. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63456. */
  63457. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63458. private _volumetricLightScatteringPass;
  63459. private _volumetricLightScatteringRTT;
  63460. private _viewPort;
  63461. private _screenCoordinates;
  63462. private _cachedDefines;
  63463. /**
  63464. * If not undefined, the mesh position is computed from the attached node position
  63465. */
  63466. attachedNode: {
  63467. position: Vector3;
  63468. };
  63469. /**
  63470. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63471. */
  63472. customMeshPosition: Vector3;
  63473. /**
  63474. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63475. */
  63476. useCustomMeshPosition: boolean;
  63477. /**
  63478. * If the post-process should inverse the light scattering direction
  63479. */
  63480. invert: boolean;
  63481. /**
  63482. * The internal mesh used by the post-process
  63483. */
  63484. mesh: Mesh;
  63485. /**
  63486. * @hidden
  63487. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63488. */
  63489. useDiffuseColor: boolean;
  63490. /**
  63491. * Array containing the excluded meshes not rendered in the internal pass
  63492. */
  63493. excludedMeshes: AbstractMesh[];
  63494. /**
  63495. * Controls the overall intensity of the post-process
  63496. */
  63497. exposure: number;
  63498. /**
  63499. * Dissipates each sample's contribution in range [0, 1]
  63500. */
  63501. decay: number;
  63502. /**
  63503. * Controls the overall intensity of each sample
  63504. */
  63505. weight: number;
  63506. /**
  63507. * Controls the density of each sample
  63508. */
  63509. density: number;
  63510. /**
  63511. * @constructor
  63512. * @param name The post-process name
  63513. * @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)
  63514. * @param camera The camera that the post-process will be attached to
  63515. * @param mesh The mesh used to create the light scattering
  63516. * @param samples The post-process quality, default 100
  63517. * @param samplingModeThe post-process filtering mode
  63518. * @param engine The babylon engine
  63519. * @param reusable If the post-process is reusable
  63520. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63521. */
  63522. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63523. /**
  63524. * Returns the string "VolumetricLightScatteringPostProcess"
  63525. * @returns "VolumetricLightScatteringPostProcess"
  63526. */
  63527. getClassName(): string;
  63528. private _isReady;
  63529. /**
  63530. * Sets the new light position for light scattering effect
  63531. * @param position The new custom light position
  63532. */
  63533. setCustomMeshPosition(position: Vector3): void;
  63534. /**
  63535. * Returns the light position for light scattering effect
  63536. * @return Vector3 The custom light position
  63537. */
  63538. getCustomMeshPosition(): Vector3;
  63539. /**
  63540. * Disposes the internal assets and detaches the post-process from the camera
  63541. */
  63542. dispose(camera: Camera): void;
  63543. /**
  63544. * Returns the render target texture used by the post-process
  63545. * @return the render target texture used by the post-process
  63546. */
  63547. getPass(): RenderTargetTexture;
  63548. private _meshExcluded;
  63549. private _createPass;
  63550. private _updateMeshScreenCoordinates;
  63551. /**
  63552. * Creates a default mesh for the Volumeric Light Scattering post-process
  63553. * @param name The mesh name
  63554. * @param scene The scene where to create the mesh
  63555. * @return the default mesh
  63556. */
  63557. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63558. }
  63559. }
  63560. declare module "babylonjs/PostProcesses/index" {
  63561. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63562. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63563. export * from "babylonjs/PostProcesses/bloomEffect";
  63564. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63565. export * from "babylonjs/PostProcesses/blurPostProcess";
  63566. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63567. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63568. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63569. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63570. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63571. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63572. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63573. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63574. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63575. export * from "babylonjs/PostProcesses/filterPostProcess";
  63576. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63577. export * from "babylonjs/PostProcesses/grainPostProcess";
  63578. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63579. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63580. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63581. export * from "babylonjs/PostProcesses/passPostProcess";
  63582. export * from "babylonjs/PostProcesses/postProcess";
  63583. export * from "babylonjs/PostProcesses/postProcessManager";
  63584. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63585. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63586. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63587. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63588. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63589. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63590. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63591. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63592. }
  63593. declare module "babylonjs/Probes/index" {
  63594. export * from "babylonjs/Probes/reflectionProbe";
  63595. }
  63596. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63597. import { Scene } from "babylonjs/scene";
  63598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63599. import { SmartArray } from "babylonjs/Misc/smartArray";
  63600. import { ISceneComponent } from "babylonjs/sceneComponent";
  63601. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63602. import "babylonjs/Meshes/Builders/boxBuilder";
  63603. import "babylonjs/Shaders/color.fragment";
  63604. import "babylonjs/Shaders/color.vertex";
  63605. import { Color3 } from "babylonjs/Maths/math.color";
  63606. module "babylonjs/scene" {
  63607. interface Scene {
  63608. /** @hidden (Backing field) */
  63609. _boundingBoxRenderer: BoundingBoxRenderer;
  63610. /** @hidden (Backing field) */
  63611. _forceShowBoundingBoxes: boolean;
  63612. /**
  63613. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63614. */
  63615. forceShowBoundingBoxes: boolean;
  63616. /**
  63617. * Gets the bounding box renderer associated with the scene
  63618. * @returns a BoundingBoxRenderer
  63619. */
  63620. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63621. }
  63622. }
  63623. module "babylonjs/Meshes/abstractMesh" {
  63624. interface AbstractMesh {
  63625. /** @hidden (Backing field) */
  63626. _showBoundingBox: boolean;
  63627. /**
  63628. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63629. */
  63630. showBoundingBox: boolean;
  63631. }
  63632. }
  63633. /**
  63634. * Component responsible of rendering the bounding box of the meshes in a scene.
  63635. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63636. */
  63637. export class BoundingBoxRenderer implements ISceneComponent {
  63638. /**
  63639. * The component name helpfull to identify the component in the list of scene components.
  63640. */
  63641. readonly name: string;
  63642. /**
  63643. * The scene the component belongs to.
  63644. */
  63645. scene: Scene;
  63646. /**
  63647. * Color of the bounding box lines placed in front of an object
  63648. */
  63649. frontColor: Color3;
  63650. /**
  63651. * Color of the bounding box lines placed behind an object
  63652. */
  63653. backColor: Color3;
  63654. /**
  63655. * Defines if the renderer should show the back lines or not
  63656. */
  63657. showBackLines: boolean;
  63658. /**
  63659. * @hidden
  63660. */
  63661. renderList: SmartArray<BoundingBox>;
  63662. private _colorShader;
  63663. private _vertexBuffers;
  63664. private _indexBuffer;
  63665. private _fillIndexBuffer;
  63666. private _fillIndexData;
  63667. /**
  63668. * Instantiates a new bounding box renderer in a scene.
  63669. * @param scene the scene the renderer renders in
  63670. */
  63671. constructor(scene: Scene);
  63672. /**
  63673. * Registers the component in a given scene
  63674. */
  63675. register(): void;
  63676. private _evaluateSubMesh;
  63677. private _activeMesh;
  63678. private _prepareRessources;
  63679. private _createIndexBuffer;
  63680. /**
  63681. * Rebuilds the elements related to this component in case of
  63682. * context lost for instance.
  63683. */
  63684. rebuild(): void;
  63685. /**
  63686. * @hidden
  63687. */
  63688. reset(): void;
  63689. /**
  63690. * Render the bounding boxes of a specific rendering group
  63691. * @param renderingGroupId defines the rendering group to render
  63692. */
  63693. render(renderingGroupId: number): void;
  63694. /**
  63695. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63696. * @param mesh Define the mesh to render the occlusion bounding box for
  63697. */
  63698. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63699. /**
  63700. * Dispose and release the resources attached to this renderer.
  63701. */
  63702. dispose(): void;
  63703. }
  63704. }
  63705. declare module "babylonjs/Shaders/depth.fragment" {
  63706. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63707. /** @hidden */
  63708. export var depthPixelShader: {
  63709. name: string;
  63710. shader: string;
  63711. };
  63712. }
  63713. declare module "babylonjs/Rendering/depthRenderer" {
  63714. import { Nullable } from "babylonjs/types";
  63715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63716. import { Scene } from "babylonjs/scene";
  63717. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63718. import { Camera } from "babylonjs/Cameras/camera";
  63719. import "babylonjs/Shaders/depth.fragment";
  63720. import "babylonjs/Shaders/depth.vertex";
  63721. /**
  63722. * This represents a depth renderer in Babylon.
  63723. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63724. */
  63725. export class DepthRenderer {
  63726. private _scene;
  63727. private _depthMap;
  63728. private _effect;
  63729. private readonly _storeNonLinearDepth;
  63730. private readonly _clearColor;
  63731. /** Get if the depth renderer is using packed depth or not */
  63732. readonly isPacked: boolean;
  63733. private _cachedDefines;
  63734. private _camera;
  63735. /**
  63736. * Specifiess that the depth renderer will only be used within
  63737. * the camera it is created for.
  63738. * This can help forcing its rendering during the camera processing.
  63739. */
  63740. useOnlyInActiveCamera: boolean;
  63741. /** @hidden */
  63742. static _SceneComponentInitialization: (scene: Scene) => void;
  63743. /**
  63744. * Instantiates a depth renderer
  63745. * @param scene The scene the renderer belongs to
  63746. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63747. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63748. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63749. */
  63750. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63751. /**
  63752. * Creates the depth rendering effect and checks if the effect is ready.
  63753. * @param subMesh The submesh to be used to render the depth map of
  63754. * @param useInstances If multiple world instances should be used
  63755. * @returns if the depth renderer is ready to render the depth map
  63756. */
  63757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63758. /**
  63759. * Gets the texture which the depth map will be written to.
  63760. * @returns The depth map texture
  63761. */
  63762. getDepthMap(): RenderTargetTexture;
  63763. /**
  63764. * Disposes of the depth renderer.
  63765. */
  63766. dispose(): void;
  63767. }
  63768. }
  63769. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63770. import { Nullable } from "babylonjs/types";
  63771. import { Scene } from "babylonjs/scene";
  63772. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63773. import { Camera } from "babylonjs/Cameras/camera";
  63774. import { ISceneComponent } from "babylonjs/sceneComponent";
  63775. module "babylonjs/scene" {
  63776. interface Scene {
  63777. /** @hidden (Backing field) */
  63778. _depthRenderer: {
  63779. [id: string]: DepthRenderer;
  63780. };
  63781. /**
  63782. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63783. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63784. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63785. * @returns the created depth renderer
  63786. */
  63787. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63788. /**
  63789. * Disables a depth renderer for a given camera
  63790. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63791. */
  63792. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63793. }
  63794. }
  63795. /**
  63796. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63797. * in several rendering techniques.
  63798. */
  63799. export class DepthRendererSceneComponent implements ISceneComponent {
  63800. /**
  63801. * The component name helpfull to identify the component in the list of scene components.
  63802. */
  63803. readonly name: string;
  63804. /**
  63805. * The scene the component belongs to.
  63806. */
  63807. scene: Scene;
  63808. /**
  63809. * Creates a new instance of the component for the given scene
  63810. * @param scene Defines the scene to register the component in
  63811. */
  63812. constructor(scene: Scene);
  63813. /**
  63814. * Registers the component in a given scene
  63815. */
  63816. register(): void;
  63817. /**
  63818. * Rebuilds the elements related to this component in case of
  63819. * context lost for instance.
  63820. */
  63821. rebuild(): void;
  63822. /**
  63823. * Disposes the component and the associated ressources
  63824. */
  63825. dispose(): void;
  63826. private _gatherRenderTargets;
  63827. private _gatherActiveCameraRenderTargets;
  63828. }
  63829. }
  63830. declare module "babylonjs/Shaders/outline.fragment" {
  63831. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63832. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63833. /** @hidden */
  63834. export var outlinePixelShader: {
  63835. name: string;
  63836. shader: string;
  63837. };
  63838. }
  63839. declare module "babylonjs/Shaders/outline.vertex" {
  63840. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63843. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63844. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63848. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63849. /** @hidden */
  63850. export var outlineVertexShader: {
  63851. name: string;
  63852. shader: string;
  63853. };
  63854. }
  63855. declare module "babylonjs/Rendering/outlineRenderer" {
  63856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63857. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63858. import { Scene } from "babylonjs/scene";
  63859. import { ISceneComponent } from "babylonjs/sceneComponent";
  63860. import "babylonjs/Shaders/outline.fragment";
  63861. import "babylonjs/Shaders/outline.vertex";
  63862. module "babylonjs/scene" {
  63863. interface Scene {
  63864. /** @hidden */
  63865. _outlineRenderer: OutlineRenderer;
  63866. /**
  63867. * Gets the outline renderer associated with the scene
  63868. * @returns a OutlineRenderer
  63869. */
  63870. getOutlineRenderer(): OutlineRenderer;
  63871. }
  63872. }
  63873. module "babylonjs/Meshes/abstractMesh" {
  63874. interface AbstractMesh {
  63875. /** @hidden (Backing field) */
  63876. _renderOutline: boolean;
  63877. /**
  63878. * Gets or sets a boolean indicating if the outline must be rendered as well
  63879. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63880. */
  63881. renderOutline: boolean;
  63882. /** @hidden (Backing field) */
  63883. _renderOverlay: boolean;
  63884. /**
  63885. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63886. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63887. */
  63888. renderOverlay: boolean;
  63889. }
  63890. }
  63891. /**
  63892. * This class is responsible to draw bothe outline/overlay of meshes.
  63893. * It should not be used directly but through the available method on mesh.
  63894. */
  63895. export class OutlineRenderer implements ISceneComponent {
  63896. /**
  63897. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63898. */
  63899. private static _StencilReference;
  63900. /**
  63901. * The name of the component. Each component must have a unique name.
  63902. */
  63903. name: string;
  63904. /**
  63905. * The scene the component belongs to.
  63906. */
  63907. scene: Scene;
  63908. /**
  63909. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63910. */
  63911. zOffset: number;
  63912. private _engine;
  63913. private _effect;
  63914. private _cachedDefines;
  63915. private _savedDepthWrite;
  63916. /**
  63917. * Instantiates a new outline renderer. (There could be only one per scene).
  63918. * @param scene Defines the scene it belongs to
  63919. */
  63920. constructor(scene: Scene);
  63921. /**
  63922. * Register the component to one instance of a scene.
  63923. */
  63924. register(): void;
  63925. /**
  63926. * Rebuilds the elements related to this component in case of
  63927. * context lost for instance.
  63928. */
  63929. rebuild(): void;
  63930. /**
  63931. * Disposes the component and the associated ressources.
  63932. */
  63933. dispose(): void;
  63934. /**
  63935. * Renders the outline in the canvas.
  63936. * @param subMesh Defines the sumesh to render
  63937. * @param batch Defines the batch of meshes in case of instances
  63938. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63939. */
  63940. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63941. /**
  63942. * Returns whether or not the outline renderer is ready for a given submesh.
  63943. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63944. * @param subMesh Defines the submesh to check readyness for
  63945. * @param useInstances Defines wheter wee are trying to render instances or not
  63946. * @returns true if ready otherwise false
  63947. */
  63948. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63949. private _beforeRenderingMesh;
  63950. private _afterRenderingMesh;
  63951. }
  63952. }
  63953. declare module "babylonjs/Rendering/index" {
  63954. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63955. export * from "babylonjs/Rendering/depthRenderer";
  63956. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63957. export * from "babylonjs/Rendering/edgesRenderer";
  63958. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63959. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63960. export * from "babylonjs/Rendering/outlineRenderer";
  63961. export * from "babylonjs/Rendering/renderingGroup";
  63962. export * from "babylonjs/Rendering/renderingManager";
  63963. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63964. }
  63965. declare module "babylonjs/Sprites/spritePackedManager" {
  63966. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63967. import { Scene } from "babylonjs/scene";
  63968. /**
  63969. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63970. * @see http://doc.babylonjs.com/babylon101/sprites
  63971. */
  63972. export class SpritePackedManager extends SpriteManager {
  63973. /** defines the packed manager's name */
  63974. name: string;
  63975. /**
  63976. * Creates a new sprite manager from a packed sprite sheet
  63977. * @param name defines the manager's name
  63978. * @param imgUrl defines the sprite sheet url
  63979. * @param capacity defines the maximum allowed number of sprites
  63980. * @param scene defines the hosting scene
  63981. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63982. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63983. * @param samplingMode defines the smapling mode to use with spritesheet
  63984. * @param fromPacked set to true; do not alter
  63985. */
  63986. constructor(
  63987. /** defines the packed manager's name */
  63988. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63989. }
  63990. }
  63991. declare module "babylonjs/Sprites/index" {
  63992. export * from "babylonjs/Sprites/sprite";
  63993. export * from "babylonjs/Sprites/spriteManager";
  63994. export * from "babylonjs/Sprites/spritePackedManager";
  63995. export * from "babylonjs/Sprites/spriteSceneComponent";
  63996. }
  63997. declare module "babylonjs/Misc/assetsManager" {
  63998. import { Scene } from "babylonjs/scene";
  63999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64000. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64001. import { Skeleton } from "babylonjs/Bones/skeleton";
  64002. import { Observable } from "babylonjs/Misc/observable";
  64003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64004. import { Texture } from "babylonjs/Materials/Textures/texture";
  64005. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64006. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64007. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64008. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64009. /**
  64010. * Defines the list of states available for a task inside a AssetsManager
  64011. */
  64012. export enum AssetTaskState {
  64013. /**
  64014. * Initialization
  64015. */
  64016. INIT = 0,
  64017. /**
  64018. * Running
  64019. */
  64020. RUNNING = 1,
  64021. /**
  64022. * Done
  64023. */
  64024. DONE = 2,
  64025. /**
  64026. * Error
  64027. */
  64028. ERROR = 3
  64029. }
  64030. /**
  64031. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64032. */
  64033. export abstract class AbstractAssetTask {
  64034. /**
  64035. * Task name
  64036. */ name: string;
  64037. /**
  64038. * Callback called when the task is successful
  64039. */
  64040. onSuccess: (task: any) => void;
  64041. /**
  64042. * Callback called when the task is not successful
  64043. */
  64044. onError: (task: any, message?: string, exception?: any) => void;
  64045. /**
  64046. * Creates a new AssetsManager
  64047. * @param name defines the name of the task
  64048. */
  64049. constructor(
  64050. /**
  64051. * Task name
  64052. */ name: string);
  64053. private _isCompleted;
  64054. private _taskState;
  64055. private _errorObject;
  64056. /**
  64057. * Get if the task is completed
  64058. */
  64059. readonly isCompleted: boolean;
  64060. /**
  64061. * Gets the current state of the task
  64062. */
  64063. readonly taskState: AssetTaskState;
  64064. /**
  64065. * Gets the current error object (if task is in error)
  64066. */
  64067. readonly errorObject: {
  64068. message?: string;
  64069. exception?: any;
  64070. };
  64071. /**
  64072. * Internal only
  64073. * @hidden
  64074. */
  64075. _setErrorObject(message?: string, exception?: any): void;
  64076. /**
  64077. * Execute the current task
  64078. * @param scene defines the scene where you want your assets to be loaded
  64079. * @param onSuccess is a callback called when the task is successfully executed
  64080. * @param onError is a callback called if an error occurs
  64081. */
  64082. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64083. /**
  64084. * Execute the current task
  64085. * @param scene defines the scene where you want your assets to be loaded
  64086. * @param onSuccess is a callback called when the task is successfully executed
  64087. * @param onError is a callback called if an error occurs
  64088. */
  64089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64090. /**
  64091. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64092. * This can be used with failed tasks that have the reason for failure fixed.
  64093. */
  64094. reset(): void;
  64095. private onErrorCallback;
  64096. private onDoneCallback;
  64097. }
  64098. /**
  64099. * Define the interface used by progress events raised during assets loading
  64100. */
  64101. export interface IAssetsProgressEvent {
  64102. /**
  64103. * Defines the number of remaining tasks to process
  64104. */
  64105. remainingCount: number;
  64106. /**
  64107. * Defines the total number of tasks
  64108. */
  64109. totalCount: number;
  64110. /**
  64111. * Defines the task that was just processed
  64112. */
  64113. task: AbstractAssetTask;
  64114. }
  64115. /**
  64116. * Class used to share progress information about assets loading
  64117. */
  64118. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64119. /**
  64120. * Defines the number of remaining tasks to process
  64121. */
  64122. remainingCount: number;
  64123. /**
  64124. * Defines the total number of tasks
  64125. */
  64126. totalCount: number;
  64127. /**
  64128. * Defines the task that was just processed
  64129. */
  64130. task: AbstractAssetTask;
  64131. /**
  64132. * Creates a AssetsProgressEvent
  64133. * @param remainingCount defines the number of remaining tasks to process
  64134. * @param totalCount defines the total number of tasks
  64135. * @param task defines the task that was just processed
  64136. */
  64137. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64138. }
  64139. /**
  64140. * Define a task used by AssetsManager to load meshes
  64141. */
  64142. export class MeshAssetTask extends AbstractAssetTask {
  64143. /**
  64144. * Defines the name of the task
  64145. */
  64146. name: string;
  64147. /**
  64148. * Defines the list of mesh's names you want to load
  64149. */
  64150. meshesNames: any;
  64151. /**
  64152. * Defines the root url to use as a base to load your meshes and associated resources
  64153. */
  64154. rootUrl: string;
  64155. /**
  64156. * Defines the filename of the scene to load from
  64157. */
  64158. sceneFilename: string;
  64159. /**
  64160. * Gets the list of loaded meshes
  64161. */
  64162. loadedMeshes: Array<AbstractMesh>;
  64163. /**
  64164. * Gets the list of loaded particle systems
  64165. */
  64166. loadedParticleSystems: Array<IParticleSystem>;
  64167. /**
  64168. * Gets the list of loaded skeletons
  64169. */
  64170. loadedSkeletons: Array<Skeleton>;
  64171. /**
  64172. * Gets the list of loaded animation groups
  64173. */
  64174. loadedAnimationGroups: Array<AnimationGroup>;
  64175. /**
  64176. * Callback called when the task is successful
  64177. */
  64178. onSuccess: (task: MeshAssetTask) => void;
  64179. /**
  64180. * Callback called when the task is successful
  64181. */
  64182. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64183. /**
  64184. * Creates a new MeshAssetTask
  64185. * @param name defines the name of the task
  64186. * @param meshesNames defines the list of mesh's names you want to load
  64187. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64188. * @param sceneFilename defines the filename of the scene to load from
  64189. */
  64190. constructor(
  64191. /**
  64192. * Defines the name of the task
  64193. */
  64194. name: string,
  64195. /**
  64196. * Defines the list of mesh's names you want to load
  64197. */
  64198. meshesNames: any,
  64199. /**
  64200. * Defines the root url to use as a base to load your meshes and associated resources
  64201. */
  64202. rootUrl: string,
  64203. /**
  64204. * Defines the filename of the scene to load from
  64205. */
  64206. sceneFilename: string);
  64207. /**
  64208. * Execute the current task
  64209. * @param scene defines the scene where you want your assets to be loaded
  64210. * @param onSuccess is a callback called when the task is successfully executed
  64211. * @param onError is a callback called if an error occurs
  64212. */
  64213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64214. }
  64215. /**
  64216. * Define a task used by AssetsManager to load text content
  64217. */
  64218. export class TextFileAssetTask extends AbstractAssetTask {
  64219. /**
  64220. * Defines the name of the task
  64221. */
  64222. name: string;
  64223. /**
  64224. * Defines the location of the file to load
  64225. */
  64226. url: string;
  64227. /**
  64228. * Gets the loaded text string
  64229. */
  64230. text: string;
  64231. /**
  64232. * Callback called when the task is successful
  64233. */
  64234. onSuccess: (task: TextFileAssetTask) => void;
  64235. /**
  64236. * Callback called when the task is successful
  64237. */
  64238. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64239. /**
  64240. * Creates a new TextFileAssetTask object
  64241. * @param name defines the name of the task
  64242. * @param url defines the location of the file to load
  64243. */
  64244. constructor(
  64245. /**
  64246. * Defines the name of the task
  64247. */
  64248. name: string,
  64249. /**
  64250. * Defines the location of the file to load
  64251. */
  64252. url: string);
  64253. /**
  64254. * Execute the current task
  64255. * @param scene defines the scene where you want your assets to be loaded
  64256. * @param onSuccess is a callback called when the task is successfully executed
  64257. * @param onError is a callback called if an error occurs
  64258. */
  64259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64260. }
  64261. /**
  64262. * Define a task used by AssetsManager to load binary data
  64263. */
  64264. export class BinaryFileAssetTask extends AbstractAssetTask {
  64265. /**
  64266. * Defines the name of the task
  64267. */
  64268. name: string;
  64269. /**
  64270. * Defines the location of the file to load
  64271. */
  64272. url: string;
  64273. /**
  64274. * Gets the lodaded data (as an array buffer)
  64275. */
  64276. data: ArrayBuffer;
  64277. /**
  64278. * Callback called when the task is successful
  64279. */
  64280. onSuccess: (task: BinaryFileAssetTask) => void;
  64281. /**
  64282. * Callback called when the task is successful
  64283. */
  64284. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64285. /**
  64286. * Creates a new BinaryFileAssetTask object
  64287. * @param name defines the name of the new task
  64288. * @param url defines the location of the file to load
  64289. */
  64290. constructor(
  64291. /**
  64292. * Defines the name of the task
  64293. */
  64294. name: string,
  64295. /**
  64296. * Defines the location of the file to load
  64297. */
  64298. url: string);
  64299. /**
  64300. * Execute the current task
  64301. * @param scene defines the scene where you want your assets to be loaded
  64302. * @param onSuccess is a callback called when the task is successfully executed
  64303. * @param onError is a callback called if an error occurs
  64304. */
  64305. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64306. }
  64307. /**
  64308. * Define a task used by AssetsManager to load images
  64309. */
  64310. export class ImageAssetTask extends AbstractAssetTask {
  64311. /**
  64312. * Defines the name of the task
  64313. */
  64314. name: string;
  64315. /**
  64316. * Defines the location of the image to load
  64317. */
  64318. url: string;
  64319. /**
  64320. * Gets the loaded images
  64321. */
  64322. image: HTMLImageElement;
  64323. /**
  64324. * Callback called when the task is successful
  64325. */
  64326. onSuccess: (task: ImageAssetTask) => void;
  64327. /**
  64328. * Callback called when the task is successful
  64329. */
  64330. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64331. /**
  64332. * Creates a new ImageAssetTask
  64333. * @param name defines the name of the task
  64334. * @param url defines the location of the image to load
  64335. */
  64336. constructor(
  64337. /**
  64338. * Defines the name of the task
  64339. */
  64340. name: string,
  64341. /**
  64342. * Defines the location of the image to load
  64343. */
  64344. url: string);
  64345. /**
  64346. * Execute the current task
  64347. * @param scene defines the scene where you want your assets to be loaded
  64348. * @param onSuccess is a callback called when the task is successfully executed
  64349. * @param onError is a callback called if an error occurs
  64350. */
  64351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64352. }
  64353. /**
  64354. * Defines the interface used by texture loading tasks
  64355. */
  64356. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64357. /**
  64358. * Gets the loaded texture
  64359. */
  64360. texture: TEX;
  64361. }
  64362. /**
  64363. * Define a task used by AssetsManager to load 2D textures
  64364. */
  64365. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64366. /**
  64367. * Defines the name of the task
  64368. */
  64369. name: string;
  64370. /**
  64371. * Defines the location of the file to load
  64372. */
  64373. url: string;
  64374. /**
  64375. * Defines if mipmap should not be generated (default is false)
  64376. */
  64377. noMipmap?: boolean | undefined;
  64378. /**
  64379. * Defines if texture must be inverted on Y axis (default is false)
  64380. */
  64381. invertY?: boolean | undefined;
  64382. /**
  64383. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64384. */
  64385. samplingMode: number;
  64386. /**
  64387. * Gets the loaded texture
  64388. */
  64389. texture: Texture;
  64390. /**
  64391. * Callback called when the task is successful
  64392. */
  64393. onSuccess: (task: TextureAssetTask) => void;
  64394. /**
  64395. * Callback called when the task is successful
  64396. */
  64397. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64398. /**
  64399. * Creates a new TextureAssetTask object
  64400. * @param name defines the name of the task
  64401. * @param url defines the location of the file to load
  64402. * @param noMipmap defines if mipmap should not be generated (default is false)
  64403. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64404. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64405. */
  64406. constructor(
  64407. /**
  64408. * Defines the name of the task
  64409. */
  64410. name: string,
  64411. /**
  64412. * Defines the location of the file to load
  64413. */
  64414. url: string,
  64415. /**
  64416. * Defines if mipmap should not be generated (default is false)
  64417. */
  64418. noMipmap?: boolean | undefined,
  64419. /**
  64420. * Defines if texture must be inverted on Y axis (default is false)
  64421. */
  64422. invertY?: boolean | undefined,
  64423. /**
  64424. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64425. */
  64426. samplingMode?: number);
  64427. /**
  64428. * Execute the current task
  64429. * @param scene defines the scene where you want your assets to be loaded
  64430. * @param onSuccess is a callback called when the task is successfully executed
  64431. * @param onError is a callback called if an error occurs
  64432. */
  64433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64434. }
  64435. /**
  64436. * Define a task used by AssetsManager to load cube textures
  64437. */
  64438. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64439. /**
  64440. * Defines the name of the task
  64441. */
  64442. name: string;
  64443. /**
  64444. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64445. */
  64446. url: string;
  64447. /**
  64448. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64449. */
  64450. extensions?: string[] | undefined;
  64451. /**
  64452. * Defines if mipmaps should not be generated (default is false)
  64453. */
  64454. noMipmap?: boolean | undefined;
  64455. /**
  64456. * Defines the explicit list of files (undefined by default)
  64457. */
  64458. files?: string[] | undefined;
  64459. /**
  64460. * Gets the loaded texture
  64461. */
  64462. texture: CubeTexture;
  64463. /**
  64464. * Callback called when the task is successful
  64465. */
  64466. onSuccess: (task: CubeTextureAssetTask) => void;
  64467. /**
  64468. * Callback called when the task is successful
  64469. */
  64470. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64471. /**
  64472. * Creates a new CubeTextureAssetTask
  64473. * @param name defines the name of the task
  64474. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64475. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64476. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64477. * @param files defines the explicit list of files (undefined by default)
  64478. */
  64479. constructor(
  64480. /**
  64481. * Defines the name of the task
  64482. */
  64483. name: string,
  64484. /**
  64485. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64486. */
  64487. url: string,
  64488. /**
  64489. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64490. */
  64491. extensions?: string[] | undefined,
  64492. /**
  64493. * Defines if mipmaps should not be generated (default is false)
  64494. */
  64495. noMipmap?: boolean | undefined,
  64496. /**
  64497. * Defines the explicit list of files (undefined by default)
  64498. */
  64499. files?: string[] | undefined);
  64500. /**
  64501. * Execute the current task
  64502. * @param scene defines the scene where you want your assets to be loaded
  64503. * @param onSuccess is a callback called when the task is successfully executed
  64504. * @param onError is a callback called if an error occurs
  64505. */
  64506. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64507. }
  64508. /**
  64509. * Define a task used by AssetsManager to load HDR cube textures
  64510. */
  64511. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64512. /**
  64513. * Defines the name of the task
  64514. */
  64515. name: string;
  64516. /**
  64517. * Defines the location of the file to load
  64518. */
  64519. url: string;
  64520. /**
  64521. * Defines the desired size (the more it increases the longer the generation will be)
  64522. */
  64523. size: number;
  64524. /**
  64525. * Defines if mipmaps should not be generated (default is false)
  64526. */
  64527. noMipmap: boolean;
  64528. /**
  64529. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64530. */
  64531. generateHarmonics: boolean;
  64532. /**
  64533. * 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)
  64534. */
  64535. gammaSpace: boolean;
  64536. /**
  64537. * Internal Use Only
  64538. */
  64539. reserved: boolean;
  64540. /**
  64541. * Gets the loaded texture
  64542. */
  64543. texture: HDRCubeTexture;
  64544. /**
  64545. * Callback called when the task is successful
  64546. */
  64547. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64548. /**
  64549. * Callback called when the task is successful
  64550. */
  64551. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64552. /**
  64553. * Creates a new HDRCubeTextureAssetTask object
  64554. * @param name defines the name of the task
  64555. * @param url defines the location of the file to load
  64556. * @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.
  64557. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64558. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64559. * @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)
  64560. * @param reserved Internal use only
  64561. */
  64562. constructor(
  64563. /**
  64564. * Defines the name of the task
  64565. */
  64566. name: string,
  64567. /**
  64568. * Defines the location of the file to load
  64569. */
  64570. url: string,
  64571. /**
  64572. * Defines the desired size (the more it increases the longer the generation will be)
  64573. */
  64574. size: number,
  64575. /**
  64576. * Defines if mipmaps should not be generated (default is false)
  64577. */
  64578. noMipmap?: boolean,
  64579. /**
  64580. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64581. */
  64582. generateHarmonics?: boolean,
  64583. /**
  64584. * 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)
  64585. */
  64586. gammaSpace?: boolean,
  64587. /**
  64588. * Internal Use Only
  64589. */
  64590. reserved?: boolean);
  64591. /**
  64592. * Execute the current task
  64593. * @param scene defines the scene where you want your assets to be loaded
  64594. * @param onSuccess is a callback called when the task is successfully executed
  64595. * @param onError is a callback called if an error occurs
  64596. */
  64597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64598. }
  64599. /**
  64600. * Define a task used by AssetsManager to load Equirectangular cube textures
  64601. */
  64602. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64603. /**
  64604. * Defines the name of the task
  64605. */
  64606. name: string;
  64607. /**
  64608. * Defines the location of the file to load
  64609. */
  64610. url: string;
  64611. /**
  64612. * Defines the desired size (the more it increases the longer the generation will be)
  64613. */
  64614. size: number;
  64615. /**
  64616. * Defines if mipmaps should not be generated (default is false)
  64617. */
  64618. noMipmap: boolean;
  64619. /**
  64620. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64621. * but the standard material would require them in Gamma space) (default is true)
  64622. */
  64623. gammaSpace: boolean;
  64624. /**
  64625. * Gets the loaded texture
  64626. */
  64627. texture: EquiRectangularCubeTexture;
  64628. /**
  64629. * Callback called when the task is successful
  64630. */
  64631. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64632. /**
  64633. * Callback called when the task is successful
  64634. */
  64635. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64636. /**
  64637. * Creates a new EquiRectangularCubeTextureAssetTask object
  64638. * @param name defines the name of the task
  64639. * @param url defines the location of the file to load
  64640. * @param size defines the desired size (the more it increases the longer the generation will be)
  64641. * If the size is omitted this implies you are using a preprocessed cubemap.
  64642. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64643. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64644. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64645. * (default is true)
  64646. */
  64647. constructor(
  64648. /**
  64649. * Defines the name of the task
  64650. */
  64651. name: string,
  64652. /**
  64653. * Defines the location of the file to load
  64654. */
  64655. url: string,
  64656. /**
  64657. * Defines the desired size (the more it increases the longer the generation will be)
  64658. */
  64659. size: number,
  64660. /**
  64661. * Defines if mipmaps should not be generated (default is false)
  64662. */
  64663. noMipmap?: boolean,
  64664. /**
  64665. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64666. * but the standard material would require them in Gamma space) (default is true)
  64667. */
  64668. gammaSpace?: boolean);
  64669. /**
  64670. * Execute the current task
  64671. * @param scene defines the scene where you want your assets to be loaded
  64672. * @param onSuccess is a callback called when the task is successfully executed
  64673. * @param onError is a callback called if an error occurs
  64674. */
  64675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64676. }
  64677. /**
  64678. * This class can be used to easily import assets into a scene
  64679. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64680. */
  64681. export class AssetsManager {
  64682. private _scene;
  64683. private _isLoading;
  64684. protected _tasks: AbstractAssetTask[];
  64685. protected _waitingTasksCount: number;
  64686. protected _totalTasksCount: number;
  64687. /**
  64688. * Callback called when all tasks are processed
  64689. */
  64690. onFinish: (tasks: AbstractAssetTask[]) => void;
  64691. /**
  64692. * Callback called when a task is successful
  64693. */
  64694. onTaskSuccess: (task: AbstractAssetTask) => void;
  64695. /**
  64696. * Callback called when a task had an error
  64697. */
  64698. onTaskError: (task: AbstractAssetTask) => void;
  64699. /**
  64700. * Callback called when a task is done (whatever the result is)
  64701. */
  64702. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64703. /**
  64704. * Observable called when all tasks are processed
  64705. */
  64706. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64707. /**
  64708. * Observable called when a task had an error
  64709. */
  64710. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64711. /**
  64712. * Observable called when all tasks were executed
  64713. */
  64714. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64715. /**
  64716. * Observable called when a task is done (whatever the result is)
  64717. */
  64718. onProgressObservable: Observable<IAssetsProgressEvent>;
  64719. /**
  64720. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64721. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64722. */
  64723. useDefaultLoadingScreen: boolean;
  64724. /**
  64725. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64726. * when all assets have been downloaded.
  64727. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64728. */
  64729. autoHideLoadingUI: boolean;
  64730. /**
  64731. * Creates a new AssetsManager
  64732. * @param scene defines the scene to work on
  64733. */
  64734. constructor(scene: Scene);
  64735. /**
  64736. * Add a MeshAssetTask to the list of active tasks
  64737. * @param taskName defines the name of the new task
  64738. * @param meshesNames defines the name of meshes to load
  64739. * @param rootUrl defines the root url to use to locate files
  64740. * @param sceneFilename defines the filename of the scene file
  64741. * @returns a new MeshAssetTask object
  64742. */
  64743. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64744. /**
  64745. * Add a TextFileAssetTask to the list of active tasks
  64746. * @param taskName defines the name of the new task
  64747. * @param url defines the url of the file to load
  64748. * @returns a new TextFileAssetTask object
  64749. */
  64750. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64751. /**
  64752. * Add a BinaryFileAssetTask to the list of active tasks
  64753. * @param taskName defines the name of the new task
  64754. * @param url defines the url of the file to load
  64755. * @returns a new BinaryFileAssetTask object
  64756. */
  64757. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64758. /**
  64759. * Add a ImageAssetTask to the list of active tasks
  64760. * @param taskName defines the name of the new task
  64761. * @param url defines the url of the file to load
  64762. * @returns a new ImageAssetTask object
  64763. */
  64764. addImageTask(taskName: string, url: string): ImageAssetTask;
  64765. /**
  64766. * Add a TextureAssetTask to the list of active tasks
  64767. * @param taskName defines the name of the new task
  64768. * @param url defines the url of the file to load
  64769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64770. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64771. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64772. * @returns a new TextureAssetTask object
  64773. */
  64774. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64775. /**
  64776. * Add a CubeTextureAssetTask to the list of active tasks
  64777. * @param taskName defines the name of the new task
  64778. * @param url defines the url of the file to load
  64779. * @param extensions defines the extension to use to load the cube map (can be null)
  64780. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64781. * @param files defines the list of files to load (can be null)
  64782. * @returns a new CubeTextureAssetTask object
  64783. */
  64784. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64785. /**
  64786. *
  64787. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64788. * @param taskName defines the name of the new task
  64789. * @param url defines the url of the file to load
  64790. * @param size defines the size you want for the cubemap (can be null)
  64791. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64792. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64793. * @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)
  64794. * @param reserved Internal use only
  64795. * @returns a new HDRCubeTextureAssetTask object
  64796. */
  64797. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64798. /**
  64799. *
  64800. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64801. * @param taskName defines the name of the new task
  64802. * @param url defines the url of the file to load
  64803. * @param size defines the size you want for the cubemap (can be null)
  64804. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64805. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64806. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64807. * @returns a new EquiRectangularCubeTextureAssetTask object
  64808. */
  64809. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64810. /**
  64811. * Remove a task from the assets manager.
  64812. * @param task the task to remove
  64813. */
  64814. removeTask(task: AbstractAssetTask): void;
  64815. private _decreaseWaitingTasksCount;
  64816. private _runTask;
  64817. /**
  64818. * Reset the AssetsManager and remove all tasks
  64819. * @return the current instance of the AssetsManager
  64820. */
  64821. reset(): AssetsManager;
  64822. /**
  64823. * Start the loading process
  64824. * @return the current instance of the AssetsManager
  64825. */
  64826. load(): AssetsManager;
  64827. /**
  64828. * Start the loading process as an async operation
  64829. * @return a promise returning the list of failed tasks
  64830. */
  64831. loadAsync(): Promise<void>;
  64832. }
  64833. }
  64834. declare module "babylonjs/Misc/deferred" {
  64835. /**
  64836. * Wrapper class for promise with external resolve and reject.
  64837. */
  64838. export class Deferred<T> {
  64839. /**
  64840. * The promise associated with this deferred object.
  64841. */
  64842. readonly promise: Promise<T>;
  64843. private _resolve;
  64844. private _reject;
  64845. /**
  64846. * The resolve method of the promise associated with this deferred object.
  64847. */
  64848. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64849. /**
  64850. * The reject method of the promise associated with this deferred object.
  64851. */
  64852. readonly reject: (reason?: any) => void;
  64853. /**
  64854. * Constructor for this deferred object.
  64855. */
  64856. constructor();
  64857. }
  64858. }
  64859. declare module "babylonjs/Misc/meshExploder" {
  64860. import { Mesh } from "babylonjs/Meshes/mesh";
  64861. /**
  64862. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64863. */
  64864. export class MeshExploder {
  64865. private _centerMesh;
  64866. private _meshes;
  64867. private _meshesOrigins;
  64868. private _toCenterVectors;
  64869. private _scaledDirection;
  64870. private _newPosition;
  64871. private _centerPosition;
  64872. /**
  64873. * Explodes meshes from a center mesh.
  64874. * @param meshes The meshes to explode.
  64875. * @param centerMesh The mesh to be center of explosion.
  64876. */
  64877. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64878. private _setCenterMesh;
  64879. /**
  64880. * Get class name
  64881. * @returns "MeshExploder"
  64882. */
  64883. getClassName(): string;
  64884. /**
  64885. * "Exploded meshes"
  64886. * @returns Array of meshes with the centerMesh at index 0.
  64887. */
  64888. getMeshes(): Array<Mesh>;
  64889. /**
  64890. * Explodes meshes giving a specific direction
  64891. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64892. */
  64893. explode(direction?: number): void;
  64894. }
  64895. }
  64896. declare module "babylonjs/Misc/filesInput" {
  64897. import { Engine } from "babylonjs/Engines/engine";
  64898. import { Scene } from "babylonjs/scene";
  64899. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64900. /**
  64901. * Class used to help managing file picking and drag'n'drop
  64902. */
  64903. export class FilesInput {
  64904. /**
  64905. * List of files ready to be loaded
  64906. */
  64907. static readonly FilesToLoad: {
  64908. [key: string]: File;
  64909. };
  64910. /**
  64911. * Callback called when a file is processed
  64912. */
  64913. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64914. private _engine;
  64915. private _currentScene;
  64916. private _sceneLoadedCallback;
  64917. private _progressCallback;
  64918. private _additionalRenderLoopLogicCallback;
  64919. private _textureLoadingCallback;
  64920. private _startingProcessingFilesCallback;
  64921. private _onReloadCallback;
  64922. private _errorCallback;
  64923. private _elementToMonitor;
  64924. private _sceneFileToLoad;
  64925. private _filesToLoad;
  64926. /**
  64927. * Creates a new FilesInput
  64928. * @param engine defines the rendering engine
  64929. * @param scene defines the hosting scene
  64930. * @param sceneLoadedCallback callback called when scene is loaded
  64931. * @param progressCallback callback called to track progress
  64932. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64933. * @param textureLoadingCallback callback called when a texture is loading
  64934. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64935. * @param onReloadCallback callback called when a reload is requested
  64936. * @param errorCallback callback call if an error occurs
  64937. */
  64938. 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);
  64939. private _dragEnterHandler;
  64940. private _dragOverHandler;
  64941. private _dropHandler;
  64942. /**
  64943. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64944. * @param elementToMonitor defines the DOM element to track
  64945. */
  64946. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64947. /**
  64948. * Release all associated resources
  64949. */
  64950. dispose(): void;
  64951. private renderFunction;
  64952. private drag;
  64953. private drop;
  64954. private _traverseFolder;
  64955. private _processFiles;
  64956. /**
  64957. * Load files from a drop event
  64958. * @param event defines the drop event to use as source
  64959. */
  64960. loadFiles(event: any): void;
  64961. private _processReload;
  64962. /**
  64963. * Reload the current scene from the loaded files
  64964. */
  64965. reload(): void;
  64966. }
  64967. }
  64968. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64969. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64970. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64971. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64972. }
  64973. declare module "babylonjs/Misc/sceneOptimizer" {
  64974. import { Scene, IDisposable } from "babylonjs/scene";
  64975. import { Observable } from "babylonjs/Misc/observable";
  64976. /**
  64977. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64978. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64979. */
  64980. export class SceneOptimization {
  64981. /**
  64982. * Defines the priority of this optimization (0 by default which means first in the list)
  64983. */
  64984. priority: number;
  64985. /**
  64986. * Gets a string describing the action executed by the current optimization
  64987. * @returns description string
  64988. */
  64989. getDescription(): string;
  64990. /**
  64991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64992. * @param scene defines the current scene where to apply this optimization
  64993. * @param optimizer defines the current optimizer
  64994. * @returns true if everything that can be done was applied
  64995. */
  64996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64997. /**
  64998. * Creates the SceneOptimization object
  64999. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65000. * @param desc defines the description associated with the optimization
  65001. */
  65002. constructor(
  65003. /**
  65004. * Defines the priority of this optimization (0 by default which means first in the list)
  65005. */
  65006. priority?: number);
  65007. }
  65008. /**
  65009. * Defines an optimization used to reduce the size of render target textures
  65010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65011. */
  65012. export class TextureOptimization extends SceneOptimization {
  65013. /**
  65014. * Defines the priority of this optimization (0 by default which means first in the list)
  65015. */
  65016. priority: number;
  65017. /**
  65018. * 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
  65019. */
  65020. maximumSize: number;
  65021. /**
  65022. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65023. */
  65024. step: number;
  65025. /**
  65026. * Gets a string describing the action executed by the current optimization
  65027. * @returns description string
  65028. */
  65029. getDescription(): string;
  65030. /**
  65031. * Creates the TextureOptimization object
  65032. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65033. * @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
  65034. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65035. */
  65036. constructor(
  65037. /**
  65038. * Defines the priority of this optimization (0 by default which means first in the list)
  65039. */
  65040. priority?: number,
  65041. /**
  65042. * 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
  65043. */
  65044. maximumSize?: number,
  65045. /**
  65046. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65047. */
  65048. step?: number);
  65049. /**
  65050. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65051. * @param scene defines the current scene where to apply this optimization
  65052. * @param optimizer defines the current optimizer
  65053. * @returns true if everything that can be done was applied
  65054. */
  65055. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65056. }
  65057. /**
  65058. * Defines an optimization used to increase or decrease the rendering resolution
  65059. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65060. */
  65061. export class HardwareScalingOptimization extends SceneOptimization {
  65062. /**
  65063. * Defines the priority of this optimization (0 by default which means first in the list)
  65064. */
  65065. priority: number;
  65066. /**
  65067. * Defines the maximum scale to use (2 by default)
  65068. */
  65069. maximumScale: number;
  65070. /**
  65071. * Defines the step to use between two passes (0.5 by default)
  65072. */
  65073. step: number;
  65074. private _currentScale;
  65075. private _directionOffset;
  65076. /**
  65077. * Gets a string describing the action executed by the current optimization
  65078. * @return description string
  65079. */
  65080. getDescription(): string;
  65081. /**
  65082. * Creates the HardwareScalingOptimization object
  65083. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65084. * @param maximumScale defines the maximum scale to use (2 by default)
  65085. * @param step defines the step to use between two passes (0.5 by default)
  65086. */
  65087. constructor(
  65088. /**
  65089. * Defines the priority of this optimization (0 by default which means first in the list)
  65090. */
  65091. priority?: number,
  65092. /**
  65093. * Defines the maximum scale to use (2 by default)
  65094. */
  65095. maximumScale?: number,
  65096. /**
  65097. * Defines the step to use between two passes (0.5 by default)
  65098. */
  65099. step?: number);
  65100. /**
  65101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65102. * @param scene defines the current scene where to apply this optimization
  65103. * @param optimizer defines the current optimizer
  65104. * @returns true if everything that can be done was applied
  65105. */
  65106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65107. }
  65108. /**
  65109. * Defines an optimization used to remove shadows
  65110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65111. */
  65112. export class ShadowsOptimization extends SceneOptimization {
  65113. /**
  65114. * Gets a string describing the action executed by the current optimization
  65115. * @return description string
  65116. */
  65117. getDescription(): string;
  65118. /**
  65119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65120. * @param scene defines the current scene where to apply this optimization
  65121. * @param optimizer defines the current optimizer
  65122. * @returns true if everything that can be done was applied
  65123. */
  65124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65125. }
  65126. /**
  65127. * Defines an optimization used to turn post-processes off
  65128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65129. */
  65130. export class PostProcessesOptimization extends SceneOptimization {
  65131. /**
  65132. * Gets a string describing the action executed by the current optimization
  65133. * @return description string
  65134. */
  65135. getDescription(): string;
  65136. /**
  65137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65138. * @param scene defines the current scene where to apply this optimization
  65139. * @param optimizer defines the current optimizer
  65140. * @returns true if everything that can be done was applied
  65141. */
  65142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65143. }
  65144. /**
  65145. * Defines an optimization used to turn lens flares off
  65146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65147. */
  65148. export class LensFlaresOptimization extends SceneOptimization {
  65149. /**
  65150. * Gets a string describing the action executed by the current optimization
  65151. * @return description string
  65152. */
  65153. getDescription(): string;
  65154. /**
  65155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65156. * @param scene defines the current scene where to apply this optimization
  65157. * @param optimizer defines the current optimizer
  65158. * @returns true if everything that can be done was applied
  65159. */
  65160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65161. }
  65162. /**
  65163. * Defines an optimization based on user defined callback.
  65164. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65165. */
  65166. export class CustomOptimization extends SceneOptimization {
  65167. /**
  65168. * Callback called to apply the custom optimization.
  65169. */
  65170. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65171. /**
  65172. * Callback called to get custom description
  65173. */
  65174. onGetDescription: () => string;
  65175. /**
  65176. * Gets a string describing the action executed by the current optimization
  65177. * @returns description string
  65178. */
  65179. getDescription(): string;
  65180. /**
  65181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65182. * @param scene defines the current scene where to apply this optimization
  65183. * @param optimizer defines the current optimizer
  65184. * @returns true if everything that can be done was applied
  65185. */
  65186. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65187. }
  65188. /**
  65189. * Defines an optimization used to turn particles off
  65190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65191. */
  65192. export class ParticlesOptimization extends SceneOptimization {
  65193. /**
  65194. * Gets a string describing the action executed by the current optimization
  65195. * @return description string
  65196. */
  65197. getDescription(): string;
  65198. /**
  65199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65200. * @param scene defines the current scene where to apply this optimization
  65201. * @param optimizer defines the current optimizer
  65202. * @returns true if everything that can be done was applied
  65203. */
  65204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65205. }
  65206. /**
  65207. * Defines an optimization used to turn render targets off
  65208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65209. */
  65210. export class RenderTargetsOptimization extends SceneOptimization {
  65211. /**
  65212. * Gets a string describing the action executed by the current optimization
  65213. * @return description string
  65214. */
  65215. getDescription(): string;
  65216. /**
  65217. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65218. * @param scene defines the current scene where to apply this optimization
  65219. * @param optimizer defines the current optimizer
  65220. * @returns true if everything that can be done was applied
  65221. */
  65222. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65223. }
  65224. /**
  65225. * Defines an optimization used to merge meshes with compatible materials
  65226. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65227. */
  65228. export class MergeMeshesOptimization extends SceneOptimization {
  65229. private static _UpdateSelectionTree;
  65230. /**
  65231. * Gets or sets a boolean which defines if optimization octree has to be updated
  65232. */
  65233. /**
  65234. * Gets or sets a boolean which defines if optimization octree has to be updated
  65235. */
  65236. static UpdateSelectionTree: boolean;
  65237. /**
  65238. * Gets a string describing the action executed by the current optimization
  65239. * @return description string
  65240. */
  65241. getDescription(): string;
  65242. private _canBeMerged;
  65243. /**
  65244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65245. * @param scene defines the current scene where to apply this optimization
  65246. * @param optimizer defines the current optimizer
  65247. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65248. * @returns true if everything that can be done was applied
  65249. */
  65250. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65251. }
  65252. /**
  65253. * Defines a list of options used by SceneOptimizer
  65254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65255. */
  65256. export class SceneOptimizerOptions {
  65257. /**
  65258. * Defines the target frame rate to reach (60 by default)
  65259. */
  65260. targetFrameRate: number;
  65261. /**
  65262. * Defines the interval between two checkes (2000ms by default)
  65263. */
  65264. trackerDuration: number;
  65265. /**
  65266. * Gets the list of optimizations to apply
  65267. */
  65268. optimizations: SceneOptimization[];
  65269. /**
  65270. * Creates a new list of options used by SceneOptimizer
  65271. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65272. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65273. */
  65274. constructor(
  65275. /**
  65276. * Defines the target frame rate to reach (60 by default)
  65277. */
  65278. targetFrameRate?: number,
  65279. /**
  65280. * Defines the interval between two checkes (2000ms by default)
  65281. */
  65282. trackerDuration?: number);
  65283. /**
  65284. * Add a new optimization
  65285. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65286. * @returns the current SceneOptimizerOptions
  65287. */
  65288. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65289. /**
  65290. * Add a new custom optimization
  65291. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65292. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65293. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65294. * @returns the current SceneOptimizerOptions
  65295. */
  65296. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65297. /**
  65298. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65299. * @param targetFrameRate defines the target frame rate (60 by default)
  65300. * @returns a SceneOptimizerOptions object
  65301. */
  65302. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65303. /**
  65304. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65305. * @param targetFrameRate defines the target frame rate (60 by default)
  65306. * @returns a SceneOptimizerOptions object
  65307. */
  65308. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65309. /**
  65310. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65311. * @param targetFrameRate defines the target frame rate (60 by default)
  65312. * @returns a SceneOptimizerOptions object
  65313. */
  65314. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65315. }
  65316. /**
  65317. * Class used to run optimizations in order to reach a target frame rate
  65318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65319. */
  65320. export class SceneOptimizer implements IDisposable {
  65321. private _isRunning;
  65322. private _options;
  65323. private _scene;
  65324. private _currentPriorityLevel;
  65325. private _targetFrameRate;
  65326. private _trackerDuration;
  65327. private _currentFrameRate;
  65328. private _sceneDisposeObserver;
  65329. private _improvementMode;
  65330. /**
  65331. * Defines an observable called when the optimizer reaches the target frame rate
  65332. */
  65333. onSuccessObservable: Observable<SceneOptimizer>;
  65334. /**
  65335. * Defines an observable called when the optimizer enables an optimization
  65336. */
  65337. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65338. /**
  65339. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65340. */
  65341. onFailureObservable: Observable<SceneOptimizer>;
  65342. /**
  65343. * Gets a boolean indicating if the optimizer is in improvement mode
  65344. */
  65345. readonly isInImprovementMode: boolean;
  65346. /**
  65347. * Gets the current priority level (0 at start)
  65348. */
  65349. readonly currentPriorityLevel: number;
  65350. /**
  65351. * Gets the current frame rate checked by the SceneOptimizer
  65352. */
  65353. readonly currentFrameRate: number;
  65354. /**
  65355. * Gets or sets the current target frame rate (60 by default)
  65356. */
  65357. /**
  65358. * Gets or sets the current target frame rate (60 by default)
  65359. */
  65360. targetFrameRate: number;
  65361. /**
  65362. * Gets or sets the current interval between two checks (every 2000ms by default)
  65363. */
  65364. /**
  65365. * Gets or sets the current interval between two checks (every 2000ms by default)
  65366. */
  65367. trackerDuration: number;
  65368. /**
  65369. * Gets the list of active optimizations
  65370. */
  65371. readonly optimizations: SceneOptimization[];
  65372. /**
  65373. * Creates a new SceneOptimizer
  65374. * @param scene defines the scene to work on
  65375. * @param options defines the options to use with the SceneOptimizer
  65376. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65377. * @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)
  65378. */
  65379. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65380. /**
  65381. * Stops the current optimizer
  65382. */
  65383. stop(): void;
  65384. /**
  65385. * Reset the optimizer to initial step (current priority level = 0)
  65386. */
  65387. reset(): void;
  65388. /**
  65389. * Start the optimizer. By default it will try to reach a specific framerate
  65390. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65391. */
  65392. start(): void;
  65393. private _checkCurrentState;
  65394. /**
  65395. * Release all resources
  65396. */
  65397. dispose(): void;
  65398. /**
  65399. * Helper function to create a SceneOptimizer with one single line of code
  65400. * @param scene defines the scene to work on
  65401. * @param options defines the options to use with the SceneOptimizer
  65402. * @param onSuccess defines a callback to call on success
  65403. * @param onFailure defines a callback to call on failure
  65404. * @returns the new SceneOptimizer object
  65405. */
  65406. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65407. }
  65408. }
  65409. declare module "babylonjs/Misc/sceneSerializer" {
  65410. import { Scene } from "babylonjs/scene";
  65411. /**
  65412. * Class used to serialize a scene into a string
  65413. */
  65414. export class SceneSerializer {
  65415. /**
  65416. * Clear cache used by a previous serialization
  65417. */
  65418. static ClearCache(): void;
  65419. /**
  65420. * Serialize a scene into a JSON compatible object
  65421. * @param scene defines the scene to serialize
  65422. * @returns a JSON compatible object
  65423. */
  65424. static Serialize(scene: Scene): any;
  65425. /**
  65426. * Serialize a mesh into a JSON compatible object
  65427. * @param toSerialize defines the mesh to serialize
  65428. * @param withParents defines if parents must be serialized as well
  65429. * @param withChildren defines if children must be serialized as well
  65430. * @returns a JSON compatible object
  65431. */
  65432. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65433. }
  65434. }
  65435. declare module "babylonjs/Misc/textureTools" {
  65436. import { Texture } from "babylonjs/Materials/Textures/texture";
  65437. /**
  65438. * Class used to host texture specific utilities
  65439. */
  65440. export class TextureTools {
  65441. /**
  65442. * Uses the GPU to create a copy texture rescaled at a given size
  65443. * @param texture Texture to copy from
  65444. * @param width defines the desired width
  65445. * @param height defines the desired height
  65446. * @param useBilinearMode defines if bilinear mode has to be used
  65447. * @return the generated texture
  65448. */
  65449. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65450. }
  65451. }
  65452. declare module "babylonjs/Misc/videoRecorder" {
  65453. import { Nullable } from "babylonjs/types";
  65454. import { Engine } from "babylonjs/Engines/engine";
  65455. /**
  65456. * This represents the different options available for the video capture.
  65457. */
  65458. export interface VideoRecorderOptions {
  65459. /** Defines the mime type of the video. */
  65460. mimeType: string;
  65461. /** Defines the FPS the video should be recorded at. */
  65462. fps: number;
  65463. /** Defines the chunk size for the recording data. */
  65464. recordChunckSize: number;
  65465. /** The audio tracks to attach to the recording. */
  65466. audioTracks?: MediaStreamTrack[];
  65467. }
  65468. /**
  65469. * This can help with recording videos from BabylonJS.
  65470. * This is based on the available WebRTC functionalities of the browser.
  65471. *
  65472. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65473. */
  65474. export class VideoRecorder {
  65475. private static readonly _defaultOptions;
  65476. /**
  65477. * Returns whether or not the VideoRecorder is available in your browser.
  65478. * @param engine Defines the Babylon Engine.
  65479. * @returns true if supported otherwise false.
  65480. */
  65481. static IsSupported(engine: Engine): boolean;
  65482. private readonly _options;
  65483. private _canvas;
  65484. private _mediaRecorder;
  65485. private _recordedChunks;
  65486. private _fileName;
  65487. private _resolve;
  65488. private _reject;
  65489. /**
  65490. * True when a recording is already in progress.
  65491. */
  65492. readonly isRecording: boolean;
  65493. /**
  65494. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65495. * @param engine Defines the BabylonJS Engine you wish to record.
  65496. * @param options Defines options that can be used to customize the capture.
  65497. */
  65498. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65499. /**
  65500. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65501. */
  65502. stopRecording(): void;
  65503. /**
  65504. * Starts recording the canvas for a max duration specified in parameters.
  65505. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65506. * If null no automatic download will start and you can rely on the promise to get the data back.
  65507. * @param maxDuration Defines the maximum recording time in seconds.
  65508. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65509. * @return A promise callback at the end of the recording with the video data in Blob.
  65510. */
  65511. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65512. /**
  65513. * Releases internal resources used during the recording.
  65514. */
  65515. dispose(): void;
  65516. private _handleDataAvailable;
  65517. private _handleError;
  65518. private _handleStop;
  65519. }
  65520. }
  65521. declare module "babylonjs/Misc/screenshotTools" {
  65522. import { Camera } from "babylonjs/Cameras/camera";
  65523. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65524. import { Engine } from "babylonjs/Engines/engine";
  65525. /**
  65526. * Class containing a set of static utilities functions for screenshots
  65527. */
  65528. export class ScreenshotTools {
  65529. /**
  65530. * Captures a screenshot of the current rendering
  65531. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65532. * @param engine defines the rendering engine
  65533. * @param camera defines the source camera
  65534. * @param size This parameter can be set to a single number or to an object with the
  65535. * following (optional) properties: precision, width, height. If a single number is passed,
  65536. * it will be used for both width and height. If an object is passed, the screenshot size
  65537. * will be derived from the parameters. The precision property is a multiplier allowing
  65538. * rendering at a higher or lower resolution
  65539. * @param successCallback defines the callback receives a single parameter which contains the
  65540. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65541. * src parameter of an <img> to display it
  65542. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65543. * Check your browser for supported MIME types
  65544. */
  65545. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65546. /**
  65547. * Captures a screenshot of the current rendering
  65548. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65549. * @param engine defines the rendering engine
  65550. * @param camera defines the source camera
  65551. * @param size This parameter can be set to a single number or to an object with the
  65552. * following (optional) properties: precision, width, height. If a single number is passed,
  65553. * it will be used for both width and height. If an object is passed, the screenshot size
  65554. * will be derived from the parameters. The precision property is a multiplier allowing
  65555. * rendering at a higher or lower resolution
  65556. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65557. * Check your browser for supported MIME types
  65558. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65559. * to the src parameter of an <img> to display it
  65560. */
  65561. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65562. /**
  65563. * Generates an image screenshot from the specified camera.
  65564. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65565. * @param engine The engine to use for rendering
  65566. * @param camera The camera to use for rendering
  65567. * @param size This parameter can be set to a single number or to an object with the
  65568. * following (optional) properties: precision, width, height. If a single number is passed,
  65569. * it will be used for both width and height. If an object is passed, the screenshot size
  65570. * will be derived from the parameters. The precision property is a multiplier allowing
  65571. * rendering at a higher or lower resolution
  65572. * @param successCallback The callback receives a single parameter which contains the
  65573. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65574. * src parameter of an <img> to display it
  65575. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65576. * Check your browser for supported MIME types
  65577. * @param samples Texture samples (default: 1)
  65578. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65579. * @param fileName A name for for the downloaded file.
  65580. */
  65581. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65582. /**
  65583. * Generates an image screenshot from the specified camera.
  65584. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65585. * @param engine The engine to use for rendering
  65586. * @param camera The camera to use for rendering
  65587. * @param size This parameter can be set to a single number or to an object with the
  65588. * following (optional) properties: precision, width, height. If a single number is passed,
  65589. * it will be used for both width and height. If an object is passed, the screenshot size
  65590. * will be derived from the parameters. The precision property is a multiplier allowing
  65591. * rendering at a higher or lower resolution
  65592. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65593. * Check your browser for supported MIME types
  65594. * @param samples Texture samples (default: 1)
  65595. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65596. * @param fileName A name for for the downloaded file.
  65597. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65598. * to the src parameter of an <img> to display it
  65599. */
  65600. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65601. /**
  65602. * Gets height and width for screenshot size
  65603. * @private
  65604. */
  65605. private static _getScreenshotSize;
  65606. }
  65607. }
  65608. declare module "babylonjs/Misc/index" {
  65609. export * from "babylonjs/Misc/andOrNotEvaluator";
  65610. export * from "babylonjs/Misc/assetsManager";
  65611. export * from "babylonjs/Misc/dds";
  65612. export * from "babylonjs/Misc/decorators";
  65613. export * from "babylonjs/Misc/deferred";
  65614. export * from "babylonjs/Misc/environmentTextureTools";
  65615. export * from "babylonjs/Misc/meshExploder";
  65616. export * from "babylonjs/Misc/filesInput";
  65617. export * from "babylonjs/Misc/HighDynamicRange/index";
  65618. export * from "babylonjs/Misc/khronosTextureContainer";
  65619. export * from "babylonjs/Misc/observable";
  65620. export * from "babylonjs/Misc/performanceMonitor";
  65621. export * from "babylonjs/Misc/promise";
  65622. export * from "babylonjs/Misc/sceneOptimizer";
  65623. export * from "babylonjs/Misc/sceneSerializer";
  65624. export * from "babylonjs/Misc/smartArray";
  65625. export * from "babylonjs/Misc/stringDictionary";
  65626. export * from "babylonjs/Misc/tags";
  65627. export * from "babylonjs/Misc/textureTools";
  65628. export * from "babylonjs/Misc/tga";
  65629. export * from "babylonjs/Misc/tools";
  65630. export * from "babylonjs/Misc/videoRecorder";
  65631. export * from "babylonjs/Misc/virtualJoystick";
  65632. export * from "babylonjs/Misc/workerPool";
  65633. export * from "babylonjs/Misc/logger";
  65634. export * from "babylonjs/Misc/typeStore";
  65635. export * from "babylonjs/Misc/filesInputStore";
  65636. export * from "babylonjs/Misc/deepCopier";
  65637. export * from "babylonjs/Misc/pivotTools";
  65638. export * from "babylonjs/Misc/precisionDate";
  65639. export * from "babylonjs/Misc/screenshotTools";
  65640. export * from "babylonjs/Misc/typeStore";
  65641. export * from "babylonjs/Misc/webRequest";
  65642. export * from "babylonjs/Misc/iInspectable";
  65643. export * from "babylonjs/Misc/brdfTextureTools";
  65644. export * from "babylonjs/Misc/rgbdTextureTools";
  65645. export * from "babylonjs/Misc/gradients";
  65646. export * from "babylonjs/Misc/perfCounter";
  65647. export * from "babylonjs/Misc/fileRequest";
  65648. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65649. export * from "babylonjs/Misc/retryStrategy";
  65650. export * from "babylonjs/Misc/loadFileError";
  65651. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65652. }
  65653. declare module "babylonjs/index" {
  65654. export * from "babylonjs/abstractScene";
  65655. export * from "babylonjs/Actions/index";
  65656. export * from "babylonjs/Animations/index";
  65657. export * from "babylonjs/assetContainer";
  65658. export * from "babylonjs/Audio/index";
  65659. export * from "babylonjs/Behaviors/index";
  65660. export * from "babylonjs/Bones/index";
  65661. export * from "babylonjs/Cameras/index";
  65662. export * from "babylonjs/Collisions/index";
  65663. export * from "babylonjs/Culling/index";
  65664. export * from "babylonjs/Debug/index";
  65665. export * from "babylonjs/Engines/index";
  65666. export * from "babylonjs/Events/index";
  65667. export * from "babylonjs/Gamepads/index";
  65668. export * from "babylonjs/Gizmos/index";
  65669. export * from "babylonjs/Helpers/index";
  65670. export * from "babylonjs/Instrumentation/index";
  65671. export * from "babylonjs/Layers/index";
  65672. export * from "babylonjs/LensFlares/index";
  65673. export * from "babylonjs/Lights/index";
  65674. export * from "babylonjs/Loading/index";
  65675. export * from "babylonjs/Materials/index";
  65676. export * from "babylonjs/Maths/index";
  65677. export * from "babylonjs/Meshes/index";
  65678. export * from "babylonjs/Morph/index";
  65679. export * from "babylonjs/Navigation/index";
  65680. export * from "babylonjs/node";
  65681. export * from "babylonjs/Offline/index";
  65682. export * from "babylonjs/Particles/index";
  65683. export * from "babylonjs/Physics/index";
  65684. export * from "babylonjs/PostProcesses/index";
  65685. export * from "babylonjs/Probes/index";
  65686. export * from "babylonjs/Rendering/index";
  65687. export * from "babylonjs/scene";
  65688. export * from "babylonjs/sceneComponent";
  65689. export * from "babylonjs/Sprites/index";
  65690. export * from "babylonjs/States/index";
  65691. export * from "babylonjs/Misc/index";
  65692. export * from "babylonjs/types";
  65693. }
  65694. declare module "babylonjs/Animations/pathCursor" {
  65695. import { Vector3 } from "babylonjs/Maths/math.vector";
  65696. import { Path2 } from "babylonjs/Maths/math.path";
  65697. /**
  65698. * A cursor which tracks a point on a path
  65699. */
  65700. export class PathCursor {
  65701. private path;
  65702. /**
  65703. * Stores path cursor callbacks for when an onchange event is triggered
  65704. */
  65705. private _onchange;
  65706. /**
  65707. * The value of the path cursor
  65708. */
  65709. value: number;
  65710. /**
  65711. * The animation array of the path cursor
  65712. */
  65713. animations: Animation[];
  65714. /**
  65715. * Initializes the path cursor
  65716. * @param path The path to track
  65717. */
  65718. constructor(path: Path2);
  65719. /**
  65720. * Gets the cursor point on the path
  65721. * @returns A point on the path cursor at the cursor location
  65722. */
  65723. getPoint(): Vector3;
  65724. /**
  65725. * Moves the cursor ahead by the step amount
  65726. * @param step The amount to move the cursor forward
  65727. * @returns This path cursor
  65728. */
  65729. moveAhead(step?: number): PathCursor;
  65730. /**
  65731. * Moves the cursor behind by the step amount
  65732. * @param step The amount to move the cursor back
  65733. * @returns This path cursor
  65734. */
  65735. moveBack(step?: number): PathCursor;
  65736. /**
  65737. * Moves the cursor by the step amount
  65738. * If the step amount is greater than one, an exception is thrown
  65739. * @param step The amount to move the cursor
  65740. * @returns This path cursor
  65741. */
  65742. move(step: number): PathCursor;
  65743. /**
  65744. * Ensures that the value is limited between zero and one
  65745. * @returns This path cursor
  65746. */
  65747. private ensureLimits;
  65748. /**
  65749. * Runs onchange callbacks on change (used by the animation engine)
  65750. * @returns This path cursor
  65751. */
  65752. private raiseOnChange;
  65753. /**
  65754. * Executes a function on change
  65755. * @param f A path cursor onchange callback
  65756. * @returns This path cursor
  65757. */
  65758. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65759. }
  65760. }
  65761. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65762. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65763. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65764. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65765. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65766. }
  65767. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65768. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65769. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65770. }
  65771. declare module "babylonjs/Engines/Processors/index" {
  65772. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65773. export * from "babylonjs/Engines/Processors/Expressions/index";
  65774. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65775. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65776. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65777. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65778. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65779. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65780. }
  65781. declare module "babylonjs/Legacy/legacy" {
  65782. import * as Babylon from "babylonjs/index";
  65783. export * from "babylonjs/index";
  65784. }
  65785. declare module "babylonjs/Shaders/blur.fragment" {
  65786. /** @hidden */
  65787. export var blurPixelShader: {
  65788. name: string;
  65789. shader: string;
  65790. };
  65791. }
  65792. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65793. /** @hidden */
  65794. export var pointCloudVertexDeclaration: {
  65795. name: string;
  65796. shader: string;
  65797. };
  65798. }
  65799. declare module "babylonjs" {
  65800. export * from "babylonjs/Legacy/legacy";
  65801. }
  65802. declare module BABYLON {
  65803. /** Alias type for value that can be null */
  65804. export type Nullable<T> = T | null;
  65805. /**
  65806. * Alias type for number that are floats
  65807. * @ignorenaming
  65808. */
  65809. export type float = number;
  65810. /**
  65811. * Alias type for number that are doubles.
  65812. * @ignorenaming
  65813. */
  65814. export type double = number;
  65815. /**
  65816. * Alias type for number that are integer
  65817. * @ignorenaming
  65818. */
  65819. export type int = number;
  65820. /** Alias type for number array or Float32Array */
  65821. export type FloatArray = number[] | Float32Array;
  65822. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65823. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65824. /**
  65825. * Alias for types that can be used by a Buffer or VertexBuffer.
  65826. */
  65827. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65828. /**
  65829. * Alias type for primitive types
  65830. * @ignorenaming
  65831. */
  65832. type Primitive = undefined | null | boolean | string | number | Function;
  65833. /**
  65834. * Type modifier to make all the properties of an object Readonly
  65835. */
  65836. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65837. /**
  65838. * Type modifier to make all the properties of an object Readonly recursively
  65839. */
  65840. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65841. /** @hidden */
  65842. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65843. }
  65844. /** @hidden */
  65845. /** @hidden */
  65846. type DeepImmutableObject<T> = {
  65847. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65848. };
  65849. }
  65850. declare module BABYLON {
  65851. /**
  65852. * A class serves as a medium between the observable and its observers
  65853. */
  65854. export class EventState {
  65855. /**
  65856. * Create a new EventState
  65857. * @param mask defines the mask associated with this state
  65858. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65859. * @param target defines the original target of the state
  65860. * @param currentTarget defines the current target of the state
  65861. */
  65862. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65863. /**
  65864. * Initialize the current event state
  65865. * @param mask defines the mask associated with this state
  65866. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65867. * @param target defines the original target of the state
  65868. * @param currentTarget defines the current target of the state
  65869. * @returns the current event state
  65870. */
  65871. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65872. /**
  65873. * An Observer can set this property to true to prevent subsequent observers of being notified
  65874. */
  65875. skipNextObservers: boolean;
  65876. /**
  65877. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65878. */
  65879. mask: number;
  65880. /**
  65881. * The object that originally notified the event
  65882. */
  65883. target?: any;
  65884. /**
  65885. * The current object in the bubbling phase
  65886. */
  65887. currentTarget?: any;
  65888. /**
  65889. * This will be populated with the return value of the last function that was executed.
  65890. * If it is the first function in the callback chain it will be the event data.
  65891. */
  65892. lastReturnValue?: any;
  65893. }
  65894. /**
  65895. * Represent an Observer registered to a given Observable object.
  65896. */
  65897. export class Observer<T> {
  65898. /**
  65899. * Defines the callback to call when the observer is notified
  65900. */
  65901. callback: (eventData: T, eventState: EventState) => void;
  65902. /**
  65903. * Defines the mask of the observer (used to filter notifications)
  65904. */
  65905. mask: number;
  65906. /**
  65907. * Defines the current scope used to restore the JS context
  65908. */
  65909. scope: any;
  65910. /** @hidden */
  65911. _willBeUnregistered: boolean;
  65912. /**
  65913. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65914. */
  65915. unregisterOnNextCall: boolean;
  65916. /**
  65917. * Creates a new observer
  65918. * @param callback defines the callback to call when the observer is notified
  65919. * @param mask defines the mask of the observer (used to filter notifications)
  65920. * @param scope defines the current scope used to restore the JS context
  65921. */
  65922. constructor(
  65923. /**
  65924. * Defines the callback to call when the observer is notified
  65925. */
  65926. callback: (eventData: T, eventState: EventState) => void,
  65927. /**
  65928. * Defines the mask of the observer (used to filter notifications)
  65929. */
  65930. mask: number,
  65931. /**
  65932. * Defines the current scope used to restore the JS context
  65933. */
  65934. scope?: any);
  65935. }
  65936. /**
  65937. * Represent a list of observers registered to multiple Observables object.
  65938. */
  65939. export class MultiObserver<T> {
  65940. private _observers;
  65941. private _observables;
  65942. /**
  65943. * Release associated resources
  65944. */
  65945. dispose(): void;
  65946. /**
  65947. * Raise a callback when one of the observable will notify
  65948. * @param observables defines a list of observables to watch
  65949. * @param callback defines the callback to call on notification
  65950. * @param mask defines the mask used to filter notifications
  65951. * @param scope defines the current scope used to restore the JS context
  65952. * @returns the new MultiObserver
  65953. */
  65954. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65955. }
  65956. /**
  65957. * The Observable class is a simple implementation of the Observable pattern.
  65958. *
  65959. * 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.
  65960. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65961. * 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).
  65962. * 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.
  65963. */
  65964. export class Observable<T> {
  65965. private _observers;
  65966. private _eventState;
  65967. private _onObserverAdded;
  65968. /**
  65969. * Gets the list of observers
  65970. */
  65971. readonly observers: Array<Observer<T>>;
  65972. /**
  65973. * Creates a new observable
  65974. * @param onObserverAdded defines a callback to call when a new observer is added
  65975. */
  65976. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65977. /**
  65978. * Create a new Observer with the specified callback
  65979. * @param callback the callback that will be executed for that Observer
  65980. * @param mask the mask used to filter observers
  65981. * @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.
  65982. * @param scope optional scope for the callback to be called from
  65983. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65984. * @returns the new observer created for the callback
  65985. */
  65986. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65987. /**
  65988. * Create a new Observer with the specified callback and unregisters after the next notification
  65989. * @param callback the callback that will be executed for that Observer
  65990. * @returns the new observer created for the callback
  65991. */
  65992. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65993. /**
  65994. * Remove an Observer from the Observable object
  65995. * @param observer the instance of the Observer to remove
  65996. * @returns false if it doesn't belong to this Observable
  65997. */
  65998. remove(observer: Nullable<Observer<T>>): boolean;
  65999. /**
  66000. * Remove a callback from the Observable object
  66001. * @param callback the callback to remove
  66002. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66003. * @returns false if it doesn't belong to this Observable
  66004. */
  66005. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66006. private _deferUnregister;
  66007. private _remove;
  66008. /**
  66009. * Moves the observable to the top of the observer list making it get called first when notified
  66010. * @param observer the observer to move
  66011. */
  66012. makeObserverTopPriority(observer: Observer<T>): void;
  66013. /**
  66014. * Moves the observable to the bottom of the observer list making it get called last when notified
  66015. * @param observer the observer to move
  66016. */
  66017. makeObserverBottomPriority(observer: Observer<T>): void;
  66018. /**
  66019. * Notify all Observers by calling their respective callback with the given data
  66020. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66021. * @param eventData defines the data to send to all observers
  66022. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66023. * @param target defines the original target of the state
  66024. * @param currentTarget defines the current target of the state
  66025. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66026. */
  66027. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66028. /**
  66029. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66030. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66031. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66032. * and it is crucial that all callbacks will be executed.
  66033. * The order of the callbacks is kept, callbacks are not executed parallel.
  66034. *
  66035. * @param eventData The data to be sent to each callback
  66036. * @param mask is used to filter observers defaults to -1
  66037. * @param target defines the callback target (see EventState)
  66038. * @param currentTarget defines he current object in the bubbling phase
  66039. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66040. */
  66041. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66042. /**
  66043. * Notify a specific observer
  66044. * @param observer defines the observer to notify
  66045. * @param eventData defines the data to be sent to each callback
  66046. * @param mask is used to filter observers defaults to -1
  66047. */
  66048. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66049. /**
  66050. * Gets a boolean indicating if the observable has at least one observer
  66051. * @returns true is the Observable has at least one Observer registered
  66052. */
  66053. hasObservers(): boolean;
  66054. /**
  66055. * Clear the list of observers
  66056. */
  66057. clear(): void;
  66058. /**
  66059. * Clone the current observable
  66060. * @returns a new observable
  66061. */
  66062. clone(): Observable<T>;
  66063. /**
  66064. * Does this observable handles observer registered with a given mask
  66065. * @param mask defines the mask to be tested
  66066. * @return whether or not one observer registered with the given mask is handeled
  66067. **/
  66068. hasSpecificMask(mask?: number): boolean;
  66069. }
  66070. }
  66071. declare module BABYLON {
  66072. /**
  66073. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66074. * Babylon.js
  66075. */
  66076. export class DomManagement {
  66077. /**
  66078. * Checks if the window object exists
  66079. * @returns true if the window object exists
  66080. */
  66081. static IsWindowObjectExist(): boolean;
  66082. /**
  66083. * Checks if the navigator object exists
  66084. * @returns true if the navigator object exists
  66085. */
  66086. static IsNavigatorAvailable(): boolean;
  66087. /**
  66088. * Extracts text content from a DOM element hierarchy
  66089. * @param element defines the root element
  66090. * @returns a string
  66091. */
  66092. static GetDOMTextContent(element: HTMLElement): string;
  66093. }
  66094. }
  66095. declare module BABYLON {
  66096. /**
  66097. * Logger used througouht the application to allow configuration of
  66098. * the log level required for the messages.
  66099. */
  66100. export class Logger {
  66101. /**
  66102. * No log
  66103. */
  66104. static readonly NoneLogLevel: number;
  66105. /**
  66106. * Only message logs
  66107. */
  66108. static readonly MessageLogLevel: number;
  66109. /**
  66110. * Only warning logs
  66111. */
  66112. static readonly WarningLogLevel: number;
  66113. /**
  66114. * Only error logs
  66115. */
  66116. static readonly ErrorLogLevel: number;
  66117. /**
  66118. * All logs
  66119. */
  66120. static readonly AllLogLevel: number;
  66121. private static _LogCache;
  66122. /**
  66123. * Gets a value indicating the number of loading errors
  66124. * @ignorenaming
  66125. */
  66126. static errorsCount: number;
  66127. /**
  66128. * Callback called when a new log is added
  66129. */
  66130. static OnNewCacheEntry: (entry: string) => void;
  66131. private static _AddLogEntry;
  66132. private static _FormatMessage;
  66133. private static _LogDisabled;
  66134. private static _LogEnabled;
  66135. private static _WarnDisabled;
  66136. private static _WarnEnabled;
  66137. private static _ErrorDisabled;
  66138. private static _ErrorEnabled;
  66139. /**
  66140. * Log a message to the console
  66141. */
  66142. static Log: (message: string) => void;
  66143. /**
  66144. * Write a warning message to the console
  66145. */
  66146. static Warn: (message: string) => void;
  66147. /**
  66148. * Write an error message to the console
  66149. */
  66150. static Error: (message: string) => void;
  66151. /**
  66152. * Gets current log cache (list of logs)
  66153. */
  66154. static readonly LogCache: string;
  66155. /**
  66156. * Clears the log cache
  66157. */
  66158. static ClearLogCache(): void;
  66159. /**
  66160. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66161. */
  66162. static LogLevels: number;
  66163. }
  66164. }
  66165. declare module BABYLON {
  66166. /** @hidden */
  66167. export class _TypeStore {
  66168. /** @hidden */
  66169. static RegisteredTypes: {
  66170. [key: string]: Object;
  66171. };
  66172. /** @hidden */
  66173. static GetClass(fqdn: string): any;
  66174. }
  66175. }
  66176. declare module BABYLON {
  66177. /**
  66178. * Class containing a set of static utilities functions for deep copy.
  66179. */
  66180. export class DeepCopier {
  66181. /**
  66182. * Tries to copy an object by duplicating every property
  66183. * @param source defines the source object
  66184. * @param destination defines the target object
  66185. * @param doNotCopyList defines a list of properties to avoid
  66186. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66187. */
  66188. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66189. }
  66190. }
  66191. declare module BABYLON {
  66192. /**
  66193. * Class containing a set of static utilities functions for precision date
  66194. */
  66195. export class PrecisionDate {
  66196. /**
  66197. * Gets either window.performance.now() if supported or Date.now() else
  66198. */
  66199. static readonly Now: number;
  66200. }
  66201. }
  66202. declare module BABYLON {
  66203. /** @hidden */
  66204. export class _DevTools {
  66205. static WarnImport(name: string): string;
  66206. }
  66207. }
  66208. declare module BABYLON {
  66209. /**
  66210. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66211. */
  66212. export class WebRequest {
  66213. private _xhr;
  66214. /**
  66215. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66216. * i.e. when loading files, where the server/service expects an Authorization header
  66217. */
  66218. static CustomRequestHeaders: {
  66219. [key: string]: string;
  66220. };
  66221. /**
  66222. * Add callback functions in this array to update all the requests before they get sent to the network
  66223. */
  66224. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66225. private _injectCustomRequestHeaders;
  66226. /**
  66227. * Gets or sets a function to be called when loading progress changes
  66228. */
  66229. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66230. /**
  66231. * Returns client's state
  66232. */
  66233. readonly readyState: number;
  66234. /**
  66235. * Returns client's status
  66236. */
  66237. readonly status: number;
  66238. /**
  66239. * Returns client's status as a text
  66240. */
  66241. readonly statusText: string;
  66242. /**
  66243. * Returns client's response
  66244. */
  66245. readonly response: any;
  66246. /**
  66247. * Returns client's response url
  66248. */
  66249. readonly responseURL: string;
  66250. /**
  66251. * Returns client's response as text
  66252. */
  66253. readonly responseText: string;
  66254. /**
  66255. * Gets or sets the expected response type
  66256. */
  66257. responseType: XMLHttpRequestResponseType;
  66258. /** @hidden */
  66259. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66260. /** @hidden */
  66261. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66262. /**
  66263. * Cancels any network activity
  66264. */
  66265. abort(): void;
  66266. /**
  66267. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66268. * @param body defines an optional request body
  66269. */
  66270. send(body?: Document | BodyInit | null): void;
  66271. /**
  66272. * Sets the request method, request URL
  66273. * @param method defines the method to use (GET, POST, etc..)
  66274. * @param url defines the url to connect with
  66275. */
  66276. open(method: string, url: string): void;
  66277. }
  66278. }
  66279. declare module BABYLON {
  66280. /**
  66281. * File request interface
  66282. */
  66283. export interface IFileRequest {
  66284. /**
  66285. * Raised when the request is complete (success or error).
  66286. */
  66287. onCompleteObservable: Observable<IFileRequest>;
  66288. /**
  66289. * Aborts the request for a file.
  66290. */
  66291. abort: () => void;
  66292. }
  66293. }
  66294. declare module BABYLON {
  66295. /**
  66296. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66297. */
  66298. export class PerformanceMonitor {
  66299. private _enabled;
  66300. private _rollingFrameTime;
  66301. private _lastFrameTimeMs;
  66302. /**
  66303. * constructor
  66304. * @param frameSampleSize The number of samples required to saturate the sliding window
  66305. */
  66306. constructor(frameSampleSize?: number);
  66307. /**
  66308. * Samples current frame
  66309. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66310. */
  66311. sampleFrame(timeMs?: number): void;
  66312. /**
  66313. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66314. */
  66315. readonly averageFrameTime: number;
  66316. /**
  66317. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66318. */
  66319. readonly averageFrameTimeVariance: number;
  66320. /**
  66321. * Returns the frame time of the most recent frame
  66322. */
  66323. readonly instantaneousFrameTime: number;
  66324. /**
  66325. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66326. */
  66327. readonly averageFPS: number;
  66328. /**
  66329. * Returns the average framerate in frames per second using the most recent frame time
  66330. */
  66331. readonly instantaneousFPS: number;
  66332. /**
  66333. * Returns true if enough samples have been taken to completely fill the sliding window
  66334. */
  66335. readonly isSaturated: boolean;
  66336. /**
  66337. * Enables contributions to the sliding window sample set
  66338. */
  66339. enable(): void;
  66340. /**
  66341. * Disables contributions to the sliding window sample set
  66342. * Samples will not be interpolated over the disabled period
  66343. */
  66344. disable(): void;
  66345. /**
  66346. * Returns true if sampling is enabled
  66347. */
  66348. readonly isEnabled: boolean;
  66349. /**
  66350. * Resets performance monitor
  66351. */
  66352. reset(): void;
  66353. }
  66354. /**
  66355. * RollingAverage
  66356. *
  66357. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66358. */
  66359. export class RollingAverage {
  66360. /**
  66361. * Current average
  66362. */
  66363. average: number;
  66364. /**
  66365. * Current variance
  66366. */
  66367. variance: number;
  66368. protected _samples: Array<number>;
  66369. protected _sampleCount: number;
  66370. protected _pos: number;
  66371. protected _m2: number;
  66372. /**
  66373. * constructor
  66374. * @param length The number of samples required to saturate the sliding window
  66375. */
  66376. constructor(length: number);
  66377. /**
  66378. * Adds a sample to the sample set
  66379. * @param v The sample value
  66380. */
  66381. add(v: number): void;
  66382. /**
  66383. * Returns previously added values or null if outside of history or outside the sliding window domain
  66384. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66385. * @return Value previously recorded with add() or null if outside of range
  66386. */
  66387. history(i: number): number;
  66388. /**
  66389. * Returns true if enough samples have been taken to completely fill the sliding window
  66390. * @return true if sample-set saturated
  66391. */
  66392. isSaturated(): boolean;
  66393. /**
  66394. * Resets the rolling average (equivalent to 0 samples taken so far)
  66395. */
  66396. reset(): void;
  66397. /**
  66398. * Wraps a value around the sample range boundaries
  66399. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66400. * @return Wrapped position in sample range
  66401. */
  66402. protected _wrapPosition(i: number): number;
  66403. }
  66404. }
  66405. declare module BABYLON {
  66406. /**
  66407. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66408. * The underlying implementation relies on an associative array to ensure the best performances.
  66409. * The value can be anything including 'null' but except 'undefined'
  66410. */
  66411. export class StringDictionary<T> {
  66412. /**
  66413. * This will clear this dictionary and copy the content from the 'source' one.
  66414. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66415. * @param source the dictionary to take the content from and copy to this dictionary
  66416. */
  66417. copyFrom(source: StringDictionary<T>): void;
  66418. /**
  66419. * Get a value based from its key
  66420. * @param key the given key to get the matching value from
  66421. * @return the value if found, otherwise undefined is returned
  66422. */
  66423. get(key: string): T | undefined;
  66424. /**
  66425. * Get a value from its key or add it if it doesn't exist.
  66426. * This method will ensure you that a given key/data will be present in the dictionary.
  66427. * @param key the given key to get the matching value from
  66428. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66429. * The factory will only be invoked if there's no data for the given key.
  66430. * @return the value corresponding to the key.
  66431. */
  66432. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66433. /**
  66434. * Get a value from its key if present in the dictionary otherwise add it
  66435. * @param key the key to get the value from
  66436. * @param val if there's no such key/value pair in the dictionary add it with this value
  66437. * @return the value corresponding to the key
  66438. */
  66439. getOrAdd(key: string, val: T): T;
  66440. /**
  66441. * Check if there's a given key in the dictionary
  66442. * @param key the key to check for
  66443. * @return true if the key is present, false otherwise
  66444. */
  66445. contains(key: string): boolean;
  66446. /**
  66447. * Add a new key and its corresponding value
  66448. * @param key the key to add
  66449. * @param value the value corresponding to the key
  66450. * @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
  66451. */
  66452. add(key: string, value: T): boolean;
  66453. /**
  66454. * Update a specific value associated to a key
  66455. * @param key defines the key to use
  66456. * @param value defines the value to store
  66457. * @returns true if the value was updated (or false if the key was not found)
  66458. */
  66459. set(key: string, value: T): boolean;
  66460. /**
  66461. * Get the element of the given key and remove it from the dictionary
  66462. * @param key defines the key to search
  66463. * @returns the value associated with the key or null if not found
  66464. */
  66465. getAndRemove(key: string): Nullable<T>;
  66466. /**
  66467. * Remove a key/value from the dictionary.
  66468. * @param key the key to remove
  66469. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66470. */
  66471. remove(key: string): boolean;
  66472. /**
  66473. * Clear the whole content of the dictionary
  66474. */
  66475. clear(): void;
  66476. /**
  66477. * Gets the current count
  66478. */
  66479. readonly count: number;
  66480. /**
  66481. * Execute a callback on each key/val of the dictionary.
  66482. * Note that you can remove any element in this dictionary in the callback implementation
  66483. * @param callback the callback to execute on a given key/value pair
  66484. */
  66485. forEach(callback: (key: string, val: T) => void): void;
  66486. /**
  66487. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66488. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66489. * Note that you can remove any element in this dictionary in the callback implementation
  66490. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66491. * @returns the first item
  66492. */
  66493. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66494. private _count;
  66495. private _data;
  66496. }
  66497. }
  66498. declare module BABYLON {
  66499. /**
  66500. * Class used to store gfx data (like WebGLBuffer)
  66501. */
  66502. export class DataBuffer {
  66503. /**
  66504. * Gets or sets the number of objects referencing this buffer
  66505. */
  66506. references: number;
  66507. /** Gets or sets the size of the underlying buffer */
  66508. capacity: number;
  66509. /**
  66510. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66511. */
  66512. is32Bits: boolean;
  66513. /**
  66514. * Gets the underlying buffer
  66515. */
  66516. readonly underlyingResource: any;
  66517. }
  66518. }
  66519. declare module BABYLON {
  66520. /**
  66521. * Class used to store data that will be store in GPU memory
  66522. */
  66523. export class Buffer {
  66524. private _engine;
  66525. private _buffer;
  66526. /** @hidden */
  66527. _data: Nullable<DataArray>;
  66528. private _updatable;
  66529. private _instanced;
  66530. /**
  66531. * Gets the byte stride.
  66532. */
  66533. readonly byteStride: number;
  66534. /**
  66535. * Constructor
  66536. * @param engine the engine
  66537. * @param data the data to use for this buffer
  66538. * @param updatable whether the data is updatable
  66539. * @param stride the stride (optional)
  66540. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66541. * @param instanced whether the buffer is instanced (optional)
  66542. * @param useBytes set to true if the stride in in bytes (optional)
  66543. */
  66544. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66545. /**
  66546. * Create a new VertexBuffer based on the current buffer
  66547. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66548. * @param offset defines offset in the buffer (0 by default)
  66549. * @param size defines the size in floats of attributes (position is 3 for instance)
  66550. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66551. * @param instanced defines if the vertex buffer contains indexed data
  66552. * @param useBytes defines if the offset and stride are in bytes
  66553. * @returns the new vertex buffer
  66554. */
  66555. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66556. /**
  66557. * Gets a boolean indicating if the Buffer is updatable?
  66558. * @returns true if the buffer is updatable
  66559. */
  66560. isUpdatable(): boolean;
  66561. /**
  66562. * Gets current buffer's data
  66563. * @returns a DataArray or null
  66564. */
  66565. getData(): Nullable<DataArray>;
  66566. /**
  66567. * Gets underlying native buffer
  66568. * @returns underlying native buffer
  66569. */
  66570. getBuffer(): Nullable<DataBuffer>;
  66571. /**
  66572. * Gets the stride in float32 units (i.e. byte stride / 4).
  66573. * May not be an integer if the byte stride is not divisible by 4.
  66574. * DEPRECATED. Use byteStride instead.
  66575. * @returns the stride in float32 units
  66576. */
  66577. getStrideSize(): number;
  66578. /**
  66579. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66580. * @param data defines the data to store
  66581. */
  66582. create(data?: Nullable<DataArray>): void;
  66583. /** @hidden */
  66584. _rebuild(): void;
  66585. /**
  66586. * Update current buffer data
  66587. * @param data defines the data to store
  66588. */
  66589. update(data: DataArray): void;
  66590. /**
  66591. * Updates the data directly.
  66592. * @param data the new data
  66593. * @param offset the new offset
  66594. * @param vertexCount the vertex count (optional)
  66595. * @param useBytes set to true if the offset is in bytes
  66596. */
  66597. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66598. /**
  66599. * Release all resources
  66600. */
  66601. dispose(): void;
  66602. }
  66603. /**
  66604. * Specialized buffer used to store vertex data
  66605. */
  66606. export class VertexBuffer {
  66607. /** @hidden */
  66608. _buffer: Buffer;
  66609. private _kind;
  66610. private _size;
  66611. private _ownsBuffer;
  66612. private _instanced;
  66613. private _instanceDivisor;
  66614. /**
  66615. * The byte type.
  66616. */
  66617. static readonly BYTE: number;
  66618. /**
  66619. * The unsigned byte type.
  66620. */
  66621. static readonly UNSIGNED_BYTE: number;
  66622. /**
  66623. * The short type.
  66624. */
  66625. static readonly SHORT: number;
  66626. /**
  66627. * The unsigned short type.
  66628. */
  66629. static readonly UNSIGNED_SHORT: number;
  66630. /**
  66631. * The integer type.
  66632. */
  66633. static readonly INT: number;
  66634. /**
  66635. * The unsigned integer type.
  66636. */
  66637. static readonly UNSIGNED_INT: number;
  66638. /**
  66639. * The float type.
  66640. */
  66641. static readonly FLOAT: number;
  66642. /**
  66643. * Gets or sets the instance divisor when in instanced mode
  66644. */
  66645. instanceDivisor: number;
  66646. /**
  66647. * Gets the byte stride.
  66648. */
  66649. readonly byteStride: number;
  66650. /**
  66651. * Gets the byte offset.
  66652. */
  66653. readonly byteOffset: number;
  66654. /**
  66655. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66656. */
  66657. readonly normalized: boolean;
  66658. /**
  66659. * Gets the data type of each component in the array.
  66660. */
  66661. readonly type: number;
  66662. /**
  66663. * Constructor
  66664. * @param engine the engine
  66665. * @param data the data to use for this vertex buffer
  66666. * @param kind the vertex buffer kind
  66667. * @param updatable whether the data is updatable
  66668. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66669. * @param stride the stride (optional)
  66670. * @param instanced whether the buffer is instanced (optional)
  66671. * @param offset the offset of the data (optional)
  66672. * @param size the number of components (optional)
  66673. * @param type the type of the component (optional)
  66674. * @param normalized whether the data contains normalized data (optional)
  66675. * @param useBytes set to true if stride and offset are in bytes (optional)
  66676. */
  66677. 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);
  66678. /** @hidden */
  66679. _rebuild(): void;
  66680. /**
  66681. * Returns the kind of the VertexBuffer (string)
  66682. * @returns a string
  66683. */
  66684. getKind(): string;
  66685. /**
  66686. * Gets a boolean indicating if the VertexBuffer is updatable?
  66687. * @returns true if the buffer is updatable
  66688. */
  66689. isUpdatable(): boolean;
  66690. /**
  66691. * Gets current buffer's data
  66692. * @returns a DataArray or null
  66693. */
  66694. getData(): Nullable<DataArray>;
  66695. /**
  66696. * Gets underlying native buffer
  66697. * @returns underlying native buffer
  66698. */
  66699. getBuffer(): Nullable<DataBuffer>;
  66700. /**
  66701. * Gets the stride in float32 units (i.e. byte stride / 4).
  66702. * May not be an integer if the byte stride is not divisible by 4.
  66703. * DEPRECATED. Use byteStride instead.
  66704. * @returns the stride in float32 units
  66705. */
  66706. getStrideSize(): number;
  66707. /**
  66708. * Returns the offset as a multiple of the type byte length.
  66709. * DEPRECATED. Use byteOffset instead.
  66710. * @returns the offset in bytes
  66711. */
  66712. getOffset(): number;
  66713. /**
  66714. * Returns the number of components per vertex attribute (integer)
  66715. * @returns the size in float
  66716. */
  66717. getSize(): number;
  66718. /**
  66719. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66720. * @returns true if this buffer is instanced
  66721. */
  66722. getIsInstanced(): boolean;
  66723. /**
  66724. * Returns the instancing divisor, zero for non-instanced (integer).
  66725. * @returns a number
  66726. */
  66727. getInstanceDivisor(): number;
  66728. /**
  66729. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66730. * @param data defines the data to store
  66731. */
  66732. create(data?: DataArray): void;
  66733. /**
  66734. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66735. * This function will create a new buffer if the current one is not updatable
  66736. * @param data defines the data to store
  66737. */
  66738. update(data: DataArray): void;
  66739. /**
  66740. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66741. * Returns the directly updated WebGLBuffer.
  66742. * @param data the new data
  66743. * @param offset the new offset
  66744. * @param useBytes set to true if the offset is in bytes
  66745. */
  66746. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66747. /**
  66748. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66749. */
  66750. dispose(): void;
  66751. /**
  66752. * Enumerates each value of this vertex buffer as numbers.
  66753. * @param count the number of values to enumerate
  66754. * @param callback the callback function called for each value
  66755. */
  66756. forEach(count: number, callback: (value: number, index: number) => void): void;
  66757. /**
  66758. * Positions
  66759. */
  66760. static readonly PositionKind: string;
  66761. /**
  66762. * Normals
  66763. */
  66764. static readonly NormalKind: string;
  66765. /**
  66766. * Tangents
  66767. */
  66768. static readonly TangentKind: string;
  66769. /**
  66770. * Texture coordinates
  66771. */
  66772. static readonly UVKind: string;
  66773. /**
  66774. * Texture coordinates 2
  66775. */
  66776. static readonly UV2Kind: string;
  66777. /**
  66778. * Texture coordinates 3
  66779. */
  66780. static readonly UV3Kind: string;
  66781. /**
  66782. * Texture coordinates 4
  66783. */
  66784. static readonly UV4Kind: string;
  66785. /**
  66786. * Texture coordinates 5
  66787. */
  66788. static readonly UV5Kind: string;
  66789. /**
  66790. * Texture coordinates 6
  66791. */
  66792. static readonly UV6Kind: string;
  66793. /**
  66794. * Colors
  66795. */
  66796. static readonly ColorKind: string;
  66797. /**
  66798. * Matrix indices (for bones)
  66799. */
  66800. static readonly MatricesIndicesKind: string;
  66801. /**
  66802. * Matrix weights (for bones)
  66803. */
  66804. static readonly MatricesWeightsKind: string;
  66805. /**
  66806. * Additional matrix indices (for bones)
  66807. */
  66808. static readonly MatricesIndicesExtraKind: string;
  66809. /**
  66810. * Additional matrix weights (for bones)
  66811. */
  66812. static readonly MatricesWeightsExtraKind: string;
  66813. /**
  66814. * Deduces the stride given a kind.
  66815. * @param kind The kind string to deduce
  66816. * @returns The deduced stride
  66817. */
  66818. static DeduceStride(kind: string): number;
  66819. /**
  66820. * Gets the byte length of the given type.
  66821. * @param type the type
  66822. * @returns the number of bytes
  66823. */
  66824. static GetTypeByteLength(type: number): number;
  66825. /**
  66826. * Enumerates each value of the given parameters as numbers.
  66827. * @param data the data to enumerate
  66828. * @param byteOffset the byte offset of the data
  66829. * @param byteStride the byte stride of the data
  66830. * @param componentCount the number of components per element
  66831. * @param componentType the type of the component
  66832. * @param count the number of values to enumerate
  66833. * @param normalized whether the data is normalized
  66834. * @param callback the callback function called for each value
  66835. */
  66836. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66837. private static _GetFloatValue;
  66838. }
  66839. }
  66840. declare module BABYLON {
  66841. /**
  66842. * Scalar computation library
  66843. */
  66844. export class Scalar {
  66845. /**
  66846. * Two pi constants convenient for computation.
  66847. */
  66848. static TwoPi: number;
  66849. /**
  66850. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66851. * @param a number
  66852. * @param b number
  66853. * @param epsilon (default = 1.401298E-45)
  66854. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66855. */
  66856. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66857. /**
  66858. * Returns a string : the upper case translation of the number i to hexadecimal.
  66859. * @param i number
  66860. * @returns the upper case translation of the number i to hexadecimal.
  66861. */
  66862. static ToHex(i: number): string;
  66863. /**
  66864. * Returns -1 if value is negative and +1 is value is positive.
  66865. * @param value the value
  66866. * @returns the value itself if it's equal to zero.
  66867. */
  66868. static Sign(value: number): number;
  66869. /**
  66870. * Returns the value itself if it's between min and max.
  66871. * Returns min if the value is lower than min.
  66872. * Returns max if the value is greater than max.
  66873. * @param value the value to clmap
  66874. * @param min the min value to clamp to (default: 0)
  66875. * @param max the max value to clamp to (default: 1)
  66876. * @returns the clamped value
  66877. */
  66878. static Clamp(value: number, min?: number, max?: number): number;
  66879. /**
  66880. * the log2 of value.
  66881. * @param value the value to compute log2 of
  66882. * @returns the log2 of value.
  66883. */
  66884. static Log2(value: number): number;
  66885. /**
  66886. * Loops the value, so that it is never larger than length and never smaller than 0.
  66887. *
  66888. * This is similar to the modulo operator but it works with floating point numbers.
  66889. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66890. * With t = 5 and length = 2.5, the result would be 0.0.
  66891. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66892. * @param value the value
  66893. * @param length the length
  66894. * @returns the looped value
  66895. */
  66896. static Repeat(value: number, length: number): number;
  66897. /**
  66898. * Normalize the value between 0.0 and 1.0 using min and max values
  66899. * @param value value to normalize
  66900. * @param min max to normalize between
  66901. * @param max min to normalize between
  66902. * @returns the normalized value
  66903. */
  66904. static Normalize(value: number, min: number, max: number): number;
  66905. /**
  66906. * Denormalize the value from 0.0 and 1.0 using min and max values
  66907. * @param normalized value to denormalize
  66908. * @param min max to denormalize between
  66909. * @param max min to denormalize between
  66910. * @returns the denormalized value
  66911. */
  66912. static Denormalize(normalized: number, min: number, max: number): number;
  66913. /**
  66914. * Calculates the shortest difference between two given angles given in degrees.
  66915. * @param current current angle in degrees
  66916. * @param target target angle in degrees
  66917. * @returns the delta
  66918. */
  66919. static DeltaAngle(current: number, target: number): number;
  66920. /**
  66921. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66922. * @param tx value
  66923. * @param length length
  66924. * @returns The returned value will move back and forth between 0 and length
  66925. */
  66926. static PingPong(tx: number, length: number): number;
  66927. /**
  66928. * Interpolates between min and max with smoothing at the limits.
  66929. *
  66930. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66931. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66932. * @param from from
  66933. * @param to to
  66934. * @param tx value
  66935. * @returns the smooth stepped value
  66936. */
  66937. static SmoothStep(from: number, to: number, tx: number): number;
  66938. /**
  66939. * Moves a value current towards target.
  66940. *
  66941. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66942. * Negative values of maxDelta pushes the value away from target.
  66943. * @param current current value
  66944. * @param target target value
  66945. * @param maxDelta max distance to move
  66946. * @returns resulting value
  66947. */
  66948. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66949. /**
  66950. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66951. *
  66952. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66953. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66954. * @param current current value
  66955. * @param target target value
  66956. * @param maxDelta max distance to move
  66957. * @returns resulting angle
  66958. */
  66959. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66960. /**
  66961. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66962. * @param start start value
  66963. * @param end target value
  66964. * @param amount amount to lerp between
  66965. * @returns the lerped value
  66966. */
  66967. static Lerp(start: number, end: number, amount: number): number;
  66968. /**
  66969. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66970. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66971. * @param start start value
  66972. * @param end target value
  66973. * @param amount amount to lerp between
  66974. * @returns the lerped value
  66975. */
  66976. static LerpAngle(start: number, end: number, amount: number): number;
  66977. /**
  66978. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66979. * @param a start value
  66980. * @param b target value
  66981. * @param value value between a and b
  66982. * @returns the inverseLerp value
  66983. */
  66984. static InverseLerp(a: number, b: number, value: number): number;
  66985. /**
  66986. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66987. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66988. * @param value1 spline value
  66989. * @param tangent1 spline value
  66990. * @param value2 spline value
  66991. * @param tangent2 spline value
  66992. * @param amount input value
  66993. * @returns hermite result
  66994. */
  66995. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66996. /**
  66997. * Returns a random float number between and min and max values
  66998. * @param min min value of random
  66999. * @param max max value of random
  67000. * @returns random value
  67001. */
  67002. static RandomRange(min: number, max: number): number;
  67003. /**
  67004. * This function returns percentage of a number in a given range.
  67005. *
  67006. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67007. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67008. * @param number to convert to percentage
  67009. * @param min min range
  67010. * @param max max range
  67011. * @returns the percentage
  67012. */
  67013. static RangeToPercent(number: number, min: number, max: number): number;
  67014. /**
  67015. * This function returns number that corresponds to the percentage in a given range.
  67016. *
  67017. * PercentToRange(0.34,0,100) will return 34.
  67018. * @param percent to convert to number
  67019. * @param min min range
  67020. * @param max max range
  67021. * @returns the number
  67022. */
  67023. static PercentToRange(percent: number, min: number, max: number): number;
  67024. /**
  67025. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67026. * @param angle The angle to normalize in radian.
  67027. * @return The converted angle.
  67028. */
  67029. static NormalizeRadians(angle: number): number;
  67030. }
  67031. }
  67032. declare module BABYLON {
  67033. /**
  67034. * Constant used to convert a value to gamma space
  67035. * @ignorenaming
  67036. */
  67037. export const ToGammaSpace: number;
  67038. /**
  67039. * Constant used to convert a value to linear space
  67040. * @ignorenaming
  67041. */
  67042. export const ToLinearSpace = 2.2;
  67043. /**
  67044. * Constant used to define the minimal number value in Babylon.js
  67045. * @ignorenaming
  67046. */
  67047. let Epsilon: number;
  67048. }
  67049. declare module BABYLON {
  67050. /**
  67051. * Class used to represent a viewport on screen
  67052. */
  67053. export class Viewport {
  67054. /** viewport left coordinate */
  67055. x: number;
  67056. /** viewport top coordinate */
  67057. y: number;
  67058. /**viewport width */
  67059. width: number;
  67060. /** viewport height */
  67061. height: number;
  67062. /**
  67063. * Creates a Viewport object located at (x, y) and sized (width, height)
  67064. * @param x defines viewport left coordinate
  67065. * @param y defines viewport top coordinate
  67066. * @param width defines the viewport width
  67067. * @param height defines the viewport height
  67068. */
  67069. constructor(
  67070. /** viewport left coordinate */
  67071. x: number,
  67072. /** viewport top coordinate */
  67073. y: number,
  67074. /**viewport width */
  67075. width: number,
  67076. /** viewport height */
  67077. height: number);
  67078. /**
  67079. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67080. * @param renderWidth defines the rendering width
  67081. * @param renderHeight defines the rendering height
  67082. * @returns a new Viewport
  67083. */
  67084. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67085. /**
  67086. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67087. * @param renderWidth defines the rendering width
  67088. * @param renderHeight defines the rendering height
  67089. * @param ref defines the target viewport
  67090. * @returns the current viewport
  67091. */
  67092. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67093. /**
  67094. * Returns a new Viewport copied from the current one
  67095. * @returns a new Viewport
  67096. */
  67097. clone(): Viewport;
  67098. }
  67099. }
  67100. declare module BABYLON {
  67101. /**
  67102. * Class containing a set of static utilities functions for arrays.
  67103. */
  67104. export class ArrayTools {
  67105. /**
  67106. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67107. * @param size the number of element to construct and put in the array
  67108. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67109. * @returns a new array filled with new objects
  67110. */
  67111. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67112. }
  67113. }
  67114. declare module BABYLON {
  67115. /**
  67116. * @hidden
  67117. */
  67118. export interface IColor4Like {
  67119. r: float;
  67120. g: float;
  67121. b: float;
  67122. a: float;
  67123. }
  67124. /**
  67125. * @hidden
  67126. */
  67127. export interface IColor3Like {
  67128. r: float;
  67129. g: float;
  67130. b: float;
  67131. }
  67132. /**
  67133. * @hidden
  67134. */
  67135. export interface IVector4Like {
  67136. x: float;
  67137. y: float;
  67138. z: float;
  67139. w: float;
  67140. }
  67141. /**
  67142. * @hidden
  67143. */
  67144. export interface IVector3Like {
  67145. x: float;
  67146. y: float;
  67147. z: float;
  67148. }
  67149. /**
  67150. * @hidden
  67151. */
  67152. export interface IVector2Like {
  67153. x: float;
  67154. y: float;
  67155. }
  67156. /**
  67157. * @hidden
  67158. */
  67159. export interface IMatrixLike {
  67160. toArray(): DeepImmutable<Float32Array>;
  67161. updateFlag: int;
  67162. }
  67163. /**
  67164. * @hidden
  67165. */
  67166. export interface IViewportLike {
  67167. x: float;
  67168. y: float;
  67169. width: float;
  67170. height: float;
  67171. }
  67172. /**
  67173. * @hidden
  67174. */
  67175. export interface IPlaneLike {
  67176. normal: IVector3Like;
  67177. d: float;
  67178. normalize(): void;
  67179. }
  67180. }
  67181. declare module BABYLON {
  67182. /**
  67183. * Class representing a vector containing 2 coordinates
  67184. */
  67185. export class Vector2 {
  67186. /** defines the first coordinate */
  67187. x: number;
  67188. /** defines the second coordinate */
  67189. y: number;
  67190. /**
  67191. * Creates a new Vector2 from the given x and y coordinates
  67192. * @param x defines the first coordinate
  67193. * @param y defines the second coordinate
  67194. */
  67195. constructor(
  67196. /** defines the first coordinate */
  67197. x?: number,
  67198. /** defines the second coordinate */
  67199. y?: number);
  67200. /**
  67201. * Gets a string with the Vector2 coordinates
  67202. * @returns a string with the Vector2 coordinates
  67203. */
  67204. toString(): string;
  67205. /**
  67206. * Gets class name
  67207. * @returns the string "Vector2"
  67208. */
  67209. getClassName(): string;
  67210. /**
  67211. * Gets current vector hash code
  67212. * @returns the Vector2 hash code as a number
  67213. */
  67214. getHashCode(): number;
  67215. /**
  67216. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67217. * @param array defines the source array
  67218. * @param index defines the offset in source array
  67219. * @returns the current Vector2
  67220. */
  67221. toArray(array: FloatArray, index?: number): Vector2;
  67222. /**
  67223. * Copy the current vector to an array
  67224. * @returns a new array with 2 elements: the Vector2 coordinates.
  67225. */
  67226. asArray(): number[];
  67227. /**
  67228. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67229. * @param source defines the source Vector2
  67230. * @returns the current updated Vector2
  67231. */
  67232. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67233. /**
  67234. * Sets the Vector2 coordinates with the given floats
  67235. * @param x defines the first coordinate
  67236. * @param y defines the second coordinate
  67237. * @returns the current updated Vector2
  67238. */
  67239. copyFromFloats(x: number, y: number): Vector2;
  67240. /**
  67241. * Sets the Vector2 coordinates with the given floats
  67242. * @param x defines the first coordinate
  67243. * @param y defines the second coordinate
  67244. * @returns the current updated Vector2
  67245. */
  67246. set(x: number, y: number): Vector2;
  67247. /**
  67248. * Add another vector with the current one
  67249. * @param otherVector defines the other vector
  67250. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67251. */
  67252. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67253. /**
  67254. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67255. * @param otherVector defines the other vector
  67256. * @param result defines the target vector
  67257. * @returns the unmodified current Vector2
  67258. */
  67259. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67260. /**
  67261. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67262. * @param otherVector defines the other vector
  67263. * @returns the current updated Vector2
  67264. */
  67265. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67266. /**
  67267. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67268. * @param otherVector defines the other vector
  67269. * @returns a new Vector2
  67270. */
  67271. addVector3(otherVector: Vector3): Vector2;
  67272. /**
  67273. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67274. * @param otherVector defines the other vector
  67275. * @returns a new Vector2
  67276. */
  67277. subtract(otherVector: Vector2): Vector2;
  67278. /**
  67279. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67280. * @param otherVector defines the other vector
  67281. * @param result defines the target vector
  67282. * @returns the unmodified current Vector2
  67283. */
  67284. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67285. /**
  67286. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67287. * @param otherVector defines the other vector
  67288. * @returns the current updated Vector2
  67289. */
  67290. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67291. /**
  67292. * Multiplies in place the current Vector2 coordinates by the given ones
  67293. * @param otherVector defines the other vector
  67294. * @returns the current updated Vector2
  67295. */
  67296. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67297. /**
  67298. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67299. * @param otherVector defines the other vector
  67300. * @returns a new Vector2
  67301. */
  67302. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67303. /**
  67304. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67305. * @param otherVector defines the other vector
  67306. * @param result defines the target vector
  67307. * @returns the unmodified current Vector2
  67308. */
  67309. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67310. /**
  67311. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67312. * @param x defines the first coordinate
  67313. * @param y defines the second coordinate
  67314. * @returns a new Vector2
  67315. */
  67316. multiplyByFloats(x: number, y: number): Vector2;
  67317. /**
  67318. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67319. * @param otherVector defines the other vector
  67320. * @returns a new Vector2
  67321. */
  67322. divide(otherVector: Vector2): Vector2;
  67323. /**
  67324. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67325. * @param otherVector defines the other vector
  67326. * @param result defines the target vector
  67327. * @returns the unmodified current Vector2
  67328. */
  67329. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67330. /**
  67331. * Divides the current Vector2 coordinates by the given ones
  67332. * @param otherVector defines the other vector
  67333. * @returns the current updated Vector2
  67334. */
  67335. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67336. /**
  67337. * Gets a new Vector2 with current Vector2 negated coordinates
  67338. * @returns a new Vector2
  67339. */
  67340. negate(): Vector2;
  67341. /**
  67342. * Multiply the Vector2 coordinates by scale
  67343. * @param scale defines the scaling factor
  67344. * @returns the current updated Vector2
  67345. */
  67346. scaleInPlace(scale: number): Vector2;
  67347. /**
  67348. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67349. * @param scale defines the scaling factor
  67350. * @returns a new Vector2
  67351. */
  67352. scale(scale: number): Vector2;
  67353. /**
  67354. * Scale the current Vector2 values by a factor to a given Vector2
  67355. * @param scale defines the scale factor
  67356. * @param result defines the Vector2 object where to store the result
  67357. * @returns the unmodified current Vector2
  67358. */
  67359. scaleToRef(scale: number, result: Vector2): Vector2;
  67360. /**
  67361. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67362. * @param scale defines the scale factor
  67363. * @param result defines the Vector2 object where to store the result
  67364. * @returns the unmodified current Vector2
  67365. */
  67366. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67367. /**
  67368. * Gets a boolean if two vectors are equals
  67369. * @param otherVector defines the other vector
  67370. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67371. */
  67372. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67373. /**
  67374. * Gets a boolean if two vectors are equals (using an epsilon value)
  67375. * @param otherVector defines the other vector
  67376. * @param epsilon defines the minimal distance to consider equality
  67377. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67378. */
  67379. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67380. /**
  67381. * Gets a new Vector2 from current Vector2 floored values
  67382. * @returns a new Vector2
  67383. */
  67384. floor(): Vector2;
  67385. /**
  67386. * Gets a new Vector2 from current Vector2 floored values
  67387. * @returns a new Vector2
  67388. */
  67389. fract(): Vector2;
  67390. /**
  67391. * Gets the length of the vector
  67392. * @returns the vector length (float)
  67393. */
  67394. length(): number;
  67395. /**
  67396. * Gets the vector squared length
  67397. * @returns the vector squared length (float)
  67398. */
  67399. lengthSquared(): number;
  67400. /**
  67401. * Normalize the vector
  67402. * @returns the current updated Vector2
  67403. */
  67404. normalize(): Vector2;
  67405. /**
  67406. * Gets a new Vector2 copied from the Vector2
  67407. * @returns a new Vector2
  67408. */
  67409. clone(): Vector2;
  67410. /**
  67411. * Gets a new Vector2(0, 0)
  67412. * @returns a new Vector2
  67413. */
  67414. static Zero(): Vector2;
  67415. /**
  67416. * Gets a new Vector2(1, 1)
  67417. * @returns a new Vector2
  67418. */
  67419. static One(): Vector2;
  67420. /**
  67421. * Gets a new Vector2 set from the given index element of the given array
  67422. * @param array defines the data source
  67423. * @param offset defines the offset in the data source
  67424. * @returns a new Vector2
  67425. */
  67426. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67427. /**
  67428. * Sets "result" from the given index element of the given array
  67429. * @param array defines the data source
  67430. * @param offset defines the offset in the data source
  67431. * @param result defines the target vector
  67432. */
  67433. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67434. /**
  67435. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67436. * @param value1 defines 1st point of control
  67437. * @param value2 defines 2nd point of control
  67438. * @param value3 defines 3rd point of control
  67439. * @param value4 defines 4th point of control
  67440. * @param amount defines the interpolation factor
  67441. * @returns a new Vector2
  67442. */
  67443. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67444. /**
  67445. * 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".
  67446. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67447. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67448. * @param value defines the value to clamp
  67449. * @param min defines the lower limit
  67450. * @param max defines the upper limit
  67451. * @returns a new Vector2
  67452. */
  67453. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67454. /**
  67455. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67456. * @param value1 defines the 1st control point
  67457. * @param tangent1 defines the outgoing tangent
  67458. * @param value2 defines the 2nd control point
  67459. * @param tangent2 defines the incoming tangent
  67460. * @param amount defines the interpolation factor
  67461. * @returns a new Vector2
  67462. */
  67463. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67464. /**
  67465. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67466. * @param start defines the start vector
  67467. * @param end defines the end vector
  67468. * @param amount defines the interpolation factor
  67469. * @returns a new Vector2
  67470. */
  67471. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67472. /**
  67473. * Gets the dot product of the vector "left" and the vector "right"
  67474. * @param left defines first vector
  67475. * @param right defines second vector
  67476. * @returns the dot product (float)
  67477. */
  67478. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67479. /**
  67480. * Returns a new Vector2 equal to the normalized given vector
  67481. * @param vector defines the vector to normalize
  67482. * @returns a new Vector2
  67483. */
  67484. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67485. /**
  67486. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67487. * @param left defines 1st vector
  67488. * @param right defines 2nd vector
  67489. * @returns a new Vector2
  67490. */
  67491. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67492. /**
  67493. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67494. * @param left defines 1st vector
  67495. * @param right defines 2nd vector
  67496. * @returns a new Vector2
  67497. */
  67498. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67499. /**
  67500. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67501. * @param vector defines the vector to transform
  67502. * @param transformation defines the matrix to apply
  67503. * @returns a new Vector2
  67504. */
  67505. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67506. /**
  67507. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67508. * @param vector defines the vector to transform
  67509. * @param transformation defines the matrix to apply
  67510. * @param result defines the target vector
  67511. */
  67512. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67513. /**
  67514. * Determines if a given vector is included in a triangle
  67515. * @param p defines the vector to test
  67516. * @param p0 defines 1st triangle point
  67517. * @param p1 defines 2nd triangle point
  67518. * @param p2 defines 3rd triangle point
  67519. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67520. */
  67521. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67522. /**
  67523. * Gets the distance between the vectors "value1" and "value2"
  67524. * @param value1 defines first vector
  67525. * @param value2 defines second vector
  67526. * @returns the distance between vectors
  67527. */
  67528. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67529. /**
  67530. * Returns the squared distance between the vectors "value1" and "value2"
  67531. * @param value1 defines first vector
  67532. * @param value2 defines second vector
  67533. * @returns the squared distance between vectors
  67534. */
  67535. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67536. /**
  67537. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67538. * @param value1 defines first vector
  67539. * @param value2 defines second vector
  67540. * @returns a new Vector2
  67541. */
  67542. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67543. /**
  67544. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67545. * @param p defines the middle point
  67546. * @param segA defines one point of the segment
  67547. * @param segB defines the other point of the segment
  67548. * @returns the shortest distance
  67549. */
  67550. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67551. }
  67552. /**
  67553. * Classed used to store (x,y,z) vector representation
  67554. * A Vector3 is the main object used in 3D geometry
  67555. * It can represent etiher the coordinates of a point the space, either a direction
  67556. * Reminder: js uses a left handed forward facing system
  67557. */
  67558. export class Vector3 {
  67559. /**
  67560. * Defines the first coordinates (on X axis)
  67561. */
  67562. x: number;
  67563. /**
  67564. * Defines the second coordinates (on Y axis)
  67565. */
  67566. y: number;
  67567. /**
  67568. * Defines the third coordinates (on Z axis)
  67569. */
  67570. z: number;
  67571. private static _UpReadOnly;
  67572. private static _ZeroReadOnly;
  67573. /**
  67574. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67575. * @param x defines the first coordinates (on X axis)
  67576. * @param y defines the second coordinates (on Y axis)
  67577. * @param z defines the third coordinates (on Z axis)
  67578. */
  67579. constructor(
  67580. /**
  67581. * Defines the first coordinates (on X axis)
  67582. */
  67583. x?: number,
  67584. /**
  67585. * Defines the second coordinates (on Y axis)
  67586. */
  67587. y?: number,
  67588. /**
  67589. * Defines the third coordinates (on Z axis)
  67590. */
  67591. z?: number);
  67592. /**
  67593. * Creates a string representation of the Vector3
  67594. * @returns a string with the Vector3 coordinates.
  67595. */
  67596. toString(): string;
  67597. /**
  67598. * Gets the class name
  67599. * @returns the string "Vector3"
  67600. */
  67601. getClassName(): string;
  67602. /**
  67603. * Creates the Vector3 hash code
  67604. * @returns a number which tends to be unique between Vector3 instances
  67605. */
  67606. getHashCode(): number;
  67607. /**
  67608. * Creates an array containing three elements : the coordinates of the Vector3
  67609. * @returns a new array of numbers
  67610. */
  67611. asArray(): number[];
  67612. /**
  67613. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67614. * @param array defines the destination array
  67615. * @param index defines the offset in the destination array
  67616. * @returns the current Vector3
  67617. */
  67618. toArray(array: FloatArray, index?: number): Vector3;
  67619. /**
  67620. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67621. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67622. */
  67623. toQuaternion(): Quaternion;
  67624. /**
  67625. * Adds the given vector to the current Vector3
  67626. * @param otherVector defines the second operand
  67627. * @returns the current updated Vector3
  67628. */
  67629. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67630. /**
  67631. * Adds the given coordinates to the current Vector3
  67632. * @param x defines the x coordinate of the operand
  67633. * @param y defines the y coordinate of the operand
  67634. * @param z defines the z coordinate of the operand
  67635. * @returns the current updated Vector3
  67636. */
  67637. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67638. /**
  67639. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67640. * @param otherVector defines the second operand
  67641. * @returns the resulting Vector3
  67642. */
  67643. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67644. /**
  67645. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67646. * @param otherVector defines the second operand
  67647. * @param result defines the Vector3 object where to store the result
  67648. * @returns the current Vector3
  67649. */
  67650. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67651. /**
  67652. * Subtract the given vector from the current Vector3
  67653. * @param otherVector defines the second operand
  67654. * @returns the current updated Vector3
  67655. */
  67656. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67657. /**
  67658. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67659. * @param otherVector defines the second operand
  67660. * @returns the resulting Vector3
  67661. */
  67662. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67663. /**
  67664. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67665. * @param otherVector defines the second operand
  67666. * @param result defines the Vector3 object where to store the result
  67667. * @returns the current Vector3
  67668. */
  67669. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67670. /**
  67671. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67672. * @param x defines the x coordinate of the operand
  67673. * @param y defines the y coordinate of the operand
  67674. * @param z defines the z coordinate of the operand
  67675. * @returns the resulting Vector3
  67676. */
  67677. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67678. /**
  67679. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67680. * @param x defines the x coordinate of the operand
  67681. * @param y defines the y coordinate of the operand
  67682. * @param z defines the z coordinate of the operand
  67683. * @param result defines the Vector3 object where to store the result
  67684. * @returns the current Vector3
  67685. */
  67686. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67687. /**
  67688. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67689. * @returns a new Vector3
  67690. */
  67691. negate(): Vector3;
  67692. /**
  67693. * Multiplies the Vector3 coordinates by the float "scale"
  67694. * @param scale defines the multiplier factor
  67695. * @returns the current updated Vector3
  67696. */
  67697. scaleInPlace(scale: number): Vector3;
  67698. /**
  67699. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67700. * @param scale defines the multiplier factor
  67701. * @returns a new Vector3
  67702. */
  67703. scale(scale: number): Vector3;
  67704. /**
  67705. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67706. * @param scale defines the multiplier factor
  67707. * @param result defines the Vector3 object where to store the result
  67708. * @returns the current Vector3
  67709. */
  67710. scaleToRef(scale: number, result: Vector3): Vector3;
  67711. /**
  67712. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67713. * @param scale defines the scale factor
  67714. * @param result defines the Vector3 object where to store the result
  67715. * @returns the unmodified current Vector3
  67716. */
  67717. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67718. /**
  67719. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67720. * @param otherVector defines the second operand
  67721. * @returns true if both vectors are equals
  67722. */
  67723. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67724. /**
  67725. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67726. * @param otherVector defines the second operand
  67727. * @param epsilon defines the minimal distance to define values as equals
  67728. * @returns true if both vectors are distant less than epsilon
  67729. */
  67730. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67731. /**
  67732. * Returns true if the current Vector3 coordinates equals the given floats
  67733. * @param x defines the x coordinate of the operand
  67734. * @param y defines the y coordinate of the operand
  67735. * @param z defines the z coordinate of the operand
  67736. * @returns true if both vectors are equals
  67737. */
  67738. equalsToFloats(x: number, y: number, z: number): boolean;
  67739. /**
  67740. * Multiplies the current Vector3 coordinates by the given ones
  67741. * @param otherVector defines the second operand
  67742. * @returns the current updated Vector3
  67743. */
  67744. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67745. /**
  67746. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67747. * @param otherVector defines the second operand
  67748. * @returns the new Vector3
  67749. */
  67750. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67751. /**
  67752. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67753. * @param otherVector defines the second operand
  67754. * @param result defines the Vector3 object where to store the result
  67755. * @returns the current Vector3
  67756. */
  67757. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67758. /**
  67759. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67760. * @param x defines the x coordinate of the operand
  67761. * @param y defines the y coordinate of the operand
  67762. * @param z defines the z coordinate of the operand
  67763. * @returns the new Vector3
  67764. */
  67765. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67766. /**
  67767. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67768. * @param otherVector defines the second operand
  67769. * @returns the new Vector3
  67770. */
  67771. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67772. /**
  67773. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67774. * @param otherVector defines the second operand
  67775. * @param result defines the Vector3 object where to store the result
  67776. * @returns the current Vector3
  67777. */
  67778. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67779. /**
  67780. * Divides the current Vector3 coordinates by the given ones.
  67781. * @param otherVector defines the second operand
  67782. * @returns the current updated Vector3
  67783. */
  67784. divideInPlace(otherVector: Vector3): Vector3;
  67785. /**
  67786. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67787. * @param other defines the second operand
  67788. * @returns the current updated Vector3
  67789. */
  67790. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67791. /**
  67792. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67793. * @param other defines the second operand
  67794. * @returns the current updated Vector3
  67795. */
  67796. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67797. /**
  67798. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67799. * @param x defines the x coordinate of the operand
  67800. * @param y defines the y coordinate of the operand
  67801. * @param z defines the z coordinate of the operand
  67802. * @returns the current updated Vector3
  67803. */
  67804. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67805. /**
  67806. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67807. * @param x defines the x coordinate of the operand
  67808. * @param y defines the y coordinate of the operand
  67809. * @param z defines the z coordinate of the operand
  67810. * @returns the current updated Vector3
  67811. */
  67812. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67813. /**
  67814. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67815. * Check if is non uniform within a certain amount of decimal places to account for this
  67816. * @param epsilon the amount the values can differ
  67817. * @returns if the the vector is non uniform to a certain number of decimal places
  67818. */
  67819. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67820. /**
  67821. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67822. */
  67823. readonly isNonUniform: boolean;
  67824. /**
  67825. * Gets a new Vector3 from current Vector3 floored values
  67826. * @returns a new Vector3
  67827. */
  67828. floor(): Vector3;
  67829. /**
  67830. * Gets a new Vector3 from current Vector3 floored values
  67831. * @returns a new Vector3
  67832. */
  67833. fract(): Vector3;
  67834. /**
  67835. * Gets the length of the Vector3
  67836. * @returns the length of the Vector3
  67837. */
  67838. length(): number;
  67839. /**
  67840. * Gets the squared length of the Vector3
  67841. * @returns squared length of the Vector3
  67842. */
  67843. lengthSquared(): number;
  67844. /**
  67845. * Normalize the current Vector3.
  67846. * Please note that this is an in place operation.
  67847. * @returns the current updated Vector3
  67848. */
  67849. normalize(): Vector3;
  67850. /**
  67851. * Reorders the x y z properties of the vector in place
  67852. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67853. * @returns the current updated vector
  67854. */
  67855. reorderInPlace(order: string): this;
  67856. /**
  67857. * Rotates the vector around 0,0,0 by a quaternion
  67858. * @param quaternion the rotation quaternion
  67859. * @param result vector to store the result
  67860. * @returns the resulting vector
  67861. */
  67862. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67863. /**
  67864. * Rotates a vector around a given point
  67865. * @param quaternion the rotation quaternion
  67866. * @param point the point to rotate around
  67867. * @param result vector to store the result
  67868. * @returns the resulting vector
  67869. */
  67870. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67871. /**
  67872. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67873. * The cross product is then orthogonal to both current and "other"
  67874. * @param other defines the right operand
  67875. * @returns the cross product
  67876. */
  67877. cross(other: Vector3): Vector3;
  67878. /**
  67879. * Normalize the current Vector3 with the given input length.
  67880. * Please note that this is an in place operation.
  67881. * @param len the length of the vector
  67882. * @returns the current updated Vector3
  67883. */
  67884. normalizeFromLength(len: number): Vector3;
  67885. /**
  67886. * Normalize the current Vector3 to a new vector
  67887. * @returns the new Vector3
  67888. */
  67889. normalizeToNew(): Vector3;
  67890. /**
  67891. * Normalize the current Vector3 to the reference
  67892. * @param reference define the Vector3 to update
  67893. * @returns the updated Vector3
  67894. */
  67895. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67896. /**
  67897. * Creates a new Vector3 copied from the current Vector3
  67898. * @returns the new Vector3
  67899. */
  67900. clone(): Vector3;
  67901. /**
  67902. * Copies the given vector coordinates to the current Vector3 ones
  67903. * @param source defines the source Vector3
  67904. * @returns the current updated Vector3
  67905. */
  67906. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67907. /**
  67908. * Copies the given floats to the current Vector3 coordinates
  67909. * @param x defines the x coordinate of the operand
  67910. * @param y defines the y coordinate of the operand
  67911. * @param z defines the z coordinate of the operand
  67912. * @returns the current updated Vector3
  67913. */
  67914. copyFromFloats(x: number, y: number, z: number): Vector3;
  67915. /**
  67916. * Copies the given floats to the current Vector3 coordinates
  67917. * @param x defines the x coordinate of the operand
  67918. * @param y defines the y coordinate of the operand
  67919. * @param z defines the z coordinate of the operand
  67920. * @returns the current updated Vector3
  67921. */
  67922. set(x: number, y: number, z: number): Vector3;
  67923. /**
  67924. * Copies the given float to the current Vector3 coordinates
  67925. * @param v defines the x, y and z coordinates of the operand
  67926. * @returns the current updated Vector3
  67927. */
  67928. setAll(v: number): Vector3;
  67929. /**
  67930. * Get the clip factor between two vectors
  67931. * @param vector0 defines the first operand
  67932. * @param vector1 defines the second operand
  67933. * @param axis defines the axis to use
  67934. * @param size defines the size along the axis
  67935. * @returns the clip factor
  67936. */
  67937. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67938. /**
  67939. * Get angle between two vectors
  67940. * @param vector0 angle between vector0 and vector1
  67941. * @param vector1 angle between vector0 and vector1
  67942. * @param normal direction of the normal
  67943. * @return the angle between vector0 and vector1
  67944. */
  67945. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67946. /**
  67947. * Returns a new Vector3 set from the index "offset" of the given array
  67948. * @param array defines the source array
  67949. * @param offset defines the offset in the source array
  67950. * @returns the new Vector3
  67951. */
  67952. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67953. /**
  67954. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67955. * This function is deprecated. Use FromArray instead
  67956. * @param array defines the source array
  67957. * @param offset defines the offset in the source array
  67958. * @returns the new Vector3
  67959. */
  67960. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67961. /**
  67962. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67963. * @param array defines the source array
  67964. * @param offset defines the offset in the source array
  67965. * @param result defines the Vector3 where to store the result
  67966. */
  67967. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67968. /**
  67969. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67970. * This function is deprecated. Use FromArrayToRef instead.
  67971. * @param array defines the source array
  67972. * @param offset defines the offset in the source array
  67973. * @param result defines the Vector3 where to store the result
  67974. */
  67975. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67976. /**
  67977. * Sets the given vector "result" with the given floats.
  67978. * @param x defines the x coordinate of the source
  67979. * @param y defines the y coordinate of the source
  67980. * @param z defines the z coordinate of the source
  67981. * @param result defines the Vector3 where to store the result
  67982. */
  67983. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67984. /**
  67985. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67986. * @returns a new empty Vector3
  67987. */
  67988. static Zero(): Vector3;
  67989. /**
  67990. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67991. * @returns a new unit Vector3
  67992. */
  67993. static One(): Vector3;
  67994. /**
  67995. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67996. * @returns a new up Vector3
  67997. */
  67998. static Up(): Vector3;
  67999. /**
  68000. * Gets a up Vector3 that must not be updated
  68001. */
  68002. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68003. /**
  68004. * Gets a zero Vector3 that must not be updated
  68005. */
  68006. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68007. /**
  68008. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68009. * @returns a new down Vector3
  68010. */
  68011. static Down(): Vector3;
  68012. /**
  68013. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68014. * @returns a new forward Vector3
  68015. */
  68016. static Forward(): Vector3;
  68017. /**
  68018. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68019. * @returns a new forward Vector3
  68020. */
  68021. static Backward(): Vector3;
  68022. /**
  68023. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68024. * @returns a new right Vector3
  68025. */
  68026. static Right(): Vector3;
  68027. /**
  68028. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68029. * @returns a new left Vector3
  68030. */
  68031. static Left(): Vector3;
  68032. /**
  68033. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68034. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68035. * @param vector defines the Vector3 to transform
  68036. * @param transformation defines the transformation matrix
  68037. * @returns the transformed Vector3
  68038. */
  68039. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68040. /**
  68041. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68042. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68043. * @param vector defines the Vector3 to transform
  68044. * @param transformation defines the transformation matrix
  68045. * @param result defines the Vector3 where to store the result
  68046. */
  68047. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68048. /**
  68049. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68050. * This method computes tranformed coordinates only, not transformed direction vectors
  68051. * @param x define the x coordinate of the source vector
  68052. * @param y define the y coordinate of the source vector
  68053. * @param z define the z coordinate of the source vector
  68054. * @param transformation defines the transformation matrix
  68055. * @param result defines the Vector3 where to store the result
  68056. */
  68057. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68058. /**
  68059. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68060. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68061. * @param vector defines the Vector3 to transform
  68062. * @param transformation defines the transformation matrix
  68063. * @returns the new Vector3
  68064. */
  68065. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68066. /**
  68067. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68068. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68069. * @param vector defines the Vector3 to transform
  68070. * @param transformation defines the transformation matrix
  68071. * @param result defines the Vector3 where to store the result
  68072. */
  68073. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68074. /**
  68075. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68076. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68077. * @param x define the x coordinate of the source vector
  68078. * @param y define the y coordinate of the source vector
  68079. * @param z define the z coordinate of the source vector
  68080. * @param transformation defines the transformation matrix
  68081. * @param result defines the Vector3 where to store the result
  68082. */
  68083. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68084. /**
  68085. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68086. * @param value1 defines the first control point
  68087. * @param value2 defines the second control point
  68088. * @param value3 defines the third control point
  68089. * @param value4 defines the fourth control point
  68090. * @param amount defines the amount on the spline to use
  68091. * @returns the new Vector3
  68092. */
  68093. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68094. /**
  68095. * 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"
  68096. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68097. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68098. * @param value defines the current value
  68099. * @param min defines the lower range value
  68100. * @param max defines the upper range value
  68101. * @returns the new Vector3
  68102. */
  68103. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68104. /**
  68105. * 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"
  68106. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68107. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68108. * @param value defines the current value
  68109. * @param min defines the lower range value
  68110. * @param max defines the upper range value
  68111. * @param result defines the Vector3 where to store the result
  68112. */
  68113. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68114. /**
  68115. * Checks if a given vector is inside a specific range
  68116. * @param v defines the vector to test
  68117. * @param min defines the minimum range
  68118. * @param max defines the maximum range
  68119. */
  68120. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68121. /**
  68122. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68123. * @param value1 defines the first control point
  68124. * @param tangent1 defines the first tangent vector
  68125. * @param value2 defines the second control point
  68126. * @param tangent2 defines the second tangent vector
  68127. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68128. * @returns the new Vector3
  68129. */
  68130. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68131. /**
  68132. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68133. * @param start defines the start value
  68134. * @param end defines the end value
  68135. * @param amount max defines amount between both (between 0 and 1)
  68136. * @returns the new Vector3
  68137. */
  68138. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68139. /**
  68140. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68141. * @param start defines the start value
  68142. * @param end defines the end value
  68143. * @param amount max defines amount between both (between 0 and 1)
  68144. * @param result defines the Vector3 where to store the result
  68145. */
  68146. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68147. /**
  68148. * Returns the dot product (float) between the vectors "left" and "right"
  68149. * @param left defines the left operand
  68150. * @param right defines the right operand
  68151. * @returns the dot product
  68152. */
  68153. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68154. /**
  68155. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68156. * The cross product is then orthogonal to both "left" and "right"
  68157. * @param left defines the left operand
  68158. * @param right defines the right operand
  68159. * @returns the cross product
  68160. */
  68161. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68162. /**
  68163. * Sets the given vector "result" with the cross product of "left" and "right"
  68164. * The cross product is then orthogonal to both "left" and "right"
  68165. * @param left defines the left operand
  68166. * @param right defines the right operand
  68167. * @param result defines the Vector3 where to store the result
  68168. */
  68169. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68170. /**
  68171. * Returns a new Vector3 as the normalization of the given vector
  68172. * @param vector defines the Vector3 to normalize
  68173. * @returns the new Vector3
  68174. */
  68175. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68176. /**
  68177. * Sets the given vector "result" with the normalization of the given first vector
  68178. * @param vector defines the Vector3 to normalize
  68179. * @param result defines the Vector3 where to store the result
  68180. */
  68181. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68182. /**
  68183. * Project a Vector3 onto screen space
  68184. * @param vector defines the Vector3 to project
  68185. * @param world defines the world matrix to use
  68186. * @param transform defines the transform (view x projection) matrix to use
  68187. * @param viewport defines the screen viewport to use
  68188. * @returns the new Vector3
  68189. */
  68190. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68191. /** @hidden */
  68192. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68193. /**
  68194. * Unproject from screen space to object space
  68195. * @param source defines the screen space Vector3 to use
  68196. * @param viewportWidth defines the current width of the viewport
  68197. * @param viewportHeight defines the current height of the viewport
  68198. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68199. * @param transform defines the transform (view x projection) matrix to use
  68200. * @returns the new Vector3
  68201. */
  68202. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68203. /**
  68204. * Unproject from screen space to object space
  68205. * @param source defines the screen space Vector3 to use
  68206. * @param viewportWidth defines the current width of the viewport
  68207. * @param viewportHeight defines the current height of the viewport
  68208. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68209. * @param view defines the view matrix to use
  68210. * @param projection defines the projection matrix to use
  68211. * @returns the new Vector3
  68212. */
  68213. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68214. /**
  68215. * Unproject from screen space to object space
  68216. * @param source defines the screen space Vector3 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 UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68225. /**
  68226. * Unproject from screen space to object space
  68227. * @param sourceX defines the screen space x coordinate to use
  68228. * @param sourceY defines the screen space y coordinate to use
  68229. * @param sourceZ defines the screen space z coordinate to use
  68230. * @param viewportWidth defines the current width of the viewport
  68231. * @param viewportHeight defines the current height of the viewport
  68232. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68233. * @param view defines the view matrix to use
  68234. * @param projection defines the projection matrix to use
  68235. * @param result defines the Vector3 where to store the result
  68236. */
  68237. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68238. /**
  68239. * Gets the minimal coordinate values between two Vector3
  68240. * @param left defines the first operand
  68241. * @param right defines the second operand
  68242. * @returns the new Vector3
  68243. */
  68244. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68245. /**
  68246. * Gets the maximal coordinate values between two Vector3
  68247. * @param left defines the first operand
  68248. * @param right defines the second operand
  68249. * @returns the new Vector3
  68250. */
  68251. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68252. /**
  68253. * Returns the distance between the vectors "value1" and "value2"
  68254. * @param value1 defines the first operand
  68255. * @param value2 defines the second operand
  68256. * @returns the distance
  68257. */
  68258. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68259. /**
  68260. * Returns the squared distance between the vectors "value1" and "value2"
  68261. * @param value1 defines the first operand
  68262. * @param value2 defines the second operand
  68263. * @returns the squared distance
  68264. */
  68265. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68266. /**
  68267. * Returns a new Vector3 located at the center between "value1" and "value2"
  68268. * @param value1 defines the first operand
  68269. * @param value2 defines the second operand
  68270. * @returns the new Vector3
  68271. */
  68272. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68273. /**
  68274. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68275. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68276. * to something in order to rotate it from its local system to the given target system
  68277. * Note: axis1, axis2 and axis3 are normalized during this operation
  68278. * @param axis1 defines the first axis
  68279. * @param axis2 defines the second axis
  68280. * @param axis3 defines the third axis
  68281. * @returns a new Vector3
  68282. */
  68283. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68284. /**
  68285. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68286. * @param axis1 defines the first axis
  68287. * @param axis2 defines the second axis
  68288. * @param axis3 defines the third axis
  68289. * @param ref defines the Vector3 where to store the result
  68290. */
  68291. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68292. }
  68293. /**
  68294. * Vector4 class created for EulerAngle class conversion to Quaternion
  68295. */
  68296. export class Vector4 {
  68297. /** x value of the vector */
  68298. x: number;
  68299. /** y value of the vector */
  68300. y: number;
  68301. /** z value of the vector */
  68302. z: number;
  68303. /** w value of the vector */
  68304. w: number;
  68305. /**
  68306. * Creates a Vector4 object from the given floats.
  68307. * @param x x value of the vector
  68308. * @param y y value of the vector
  68309. * @param z z value of the vector
  68310. * @param w w value of the vector
  68311. */
  68312. constructor(
  68313. /** x value of the vector */
  68314. x: number,
  68315. /** y value of the vector */
  68316. y: number,
  68317. /** z value of the vector */
  68318. z: number,
  68319. /** w value of the vector */
  68320. w: number);
  68321. /**
  68322. * Returns the string with the Vector4 coordinates.
  68323. * @returns a string containing all the vector values
  68324. */
  68325. toString(): string;
  68326. /**
  68327. * Returns the string "Vector4".
  68328. * @returns "Vector4"
  68329. */
  68330. getClassName(): string;
  68331. /**
  68332. * Returns the Vector4 hash code.
  68333. * @returns a unique hash code
  68334. */
  68335. getHashCode(): number;
  68336. /**
  68337. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68338. * @returns the resulting array
  68339. */
  68340. asArray(): number[];
  68341. /**
  68342. * Populates the given array from the given index with the Vector4 coordinates.
  68343. * @param array array to populate
  68344. * @param index index of the array to start at (default: 0)
  68345. * @returns the Vector4.
  68346. */
  68347. toArray(array: FloatArray, index?: number): Vector4;
  68348. /**
  68349. * Adds the given vector to the current Vector4.
  68350. * @param otherVector the vector to add
  68351. * @returns the updated Vector4.
  68352. */
  68353. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68354. /**
  68355. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68356. * @param otherVector the vector to add
  68357. * @returns the resulting vector
  68358. */
  68359. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68360. /**
  68361. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68362. * @param otherVector the vector to add
  68363. * @param result the vector to store the result
  68364. * @returns the current Vector4.
  68365. */
  68366. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68367. /**
  68368. * Subtract in place the given vector from the current Vector4.
  68369. * @param otherVector the vector to subtract
  68370. * @returns the updated Vector4.
  68371. */
  68372. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68373. /**
  68374. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68375. * @param otherVector the vector to add
  68376. * @returns the new vector with the result
  68377. */
  68378. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68379. /**
  68380. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68381. * @param otherVector the vector to subtract
  68382. * @param result the vector to store the result
  68383. * @returns the current Vector4.
  68384. */
  68385. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68386. /**
  68387. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68388. */
  68389. /**
  68390. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68391. * @param x value to subtract
  68392. * @param y value to subtract
  68393. * @param z value to subtract
  68394. * @param w value to subtract
  68395. * @returns new vector containing the result
  68396. */
  68397. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68398. /**
  68399. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68400. * @param x value to subtract
  68401. * @param y value to subtract
  68402. * @param z value to subtract
  68403. * @param w value to subtract
  68404. * @param result the vector to store the result in
  68405. * @returns the current Vector4.
  68406. */
  68407. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68408. /**
  68409. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68410. * @returns a new vector with the negated values
  68411. */
  68412. negate(): Vector4;
  68413. /**
  68414. * Multiplies the current Vector4 coordinates by scale (float).
  68415. * @param scale the number to scale with
  68416. * @returns the updated Vector4.
  68417. */
  68418. scaleInPlace(scale: number): Vector4;
  68419. /**
  68420. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68421. * @param scale the number to scale with
  68422. * @returns a new vector with the result
  68423. */
  68424. scale(scale: number): Vector4;
  68425. /**
  68426. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68427. * @param scale the number to scale with
  68428. * @param result a vector to store the result in
  68429. * @returns the current Vector4.
  68430. */
  68431. scaleToRef(scale: number, result: Vector4): Vector4;
  68432. /**
  68433. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68434. * @param scale defines the scale factor
  68435. * @param result defines the Vector4 object where to store the result
  68436. * @returns the unmodified current Vector4
  68437. */
  68438. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68439. /**
  68440. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68441. * @param otherVector the vector to compare against
  68442. * @returns true if they are equal
  68443. */
  68444. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68445. /**
  68446. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68447. * @param otherVector vector to compare against
  68448. * @param epsilon (Default: very small number)
  68449. * @returns true if they are equal
  68450. */
  68451. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68452. /**
  68453. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68454. * @param x x value to compare against
  68455. * @param y y value to compare against
  68456. * @param z z value to compare against
  68457. * @param w w value to compare against
  68458. * @returns true if equal
  68459. */
  68460. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68461. /**
  68462. * Multiplies in place the current Vector4 by the given one.
  68463. * @param otherVector vector to multiple with
  68464. * @returns the updated Vector4.
  68465. */
  68466. multiplyInPlace(otherVector: Vector4): Vector4;
  68467. /**
  68468. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68469. * @param otherVector vector to multiple with
  68470. * @returns resulting new vector
  68471. */
  68472. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68473. /**
  68474. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68475. * @param otherVector vector to multiple with
  68476. * @param result vector to store the result
  68477. * @returns the current Vector4.
  68478. */
  68479. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68480. /**
  68481. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68482. * @param x x value multiply with
  68483. * @param y y value multiply with
  68484. * @param z z value multiply with
  68485. * @param w w value multiply with
  68486. * @returns resulting new vector
  68487. */
  68488. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68489. /**
  68490. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68491. * @param otherVector vector to devide with
  68492. * @returns resulting new vector
  68493. */
  68494. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68495. /**
  68496. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68497. * @param otherVector vector to devide with
  68498. * @param result vector to store the result
  68499. * @returns the current Vector4.
  68500. */
  68501. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68502. /**
  68503. * Divides the current Vector3 coordinates by the given ones.
  68504. * @param otherVector vector to devide with
  68505. * @returns the updated Vector3.
  68506. */
  68507. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68508. /**
  68509. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68510. * @param other defines the second operand
  68511. * @returns the current updated Vector4
  68512. */
  68513. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68514. /**
  68515. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68516. * @param other defines the second operand
  68517. * @returns the current updated Vector4
  68518. */
  68519. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68520. /**
  68521. * Gets a new Vector4 from current Vector4 floored values
  68522. * @returns a new Vector4
  68523. */
  68524. floor(): Vector4;
  68525. /**
  68526. * Gets a new Vector4 from current Vector3 floored values
  68527. * @returns a new Vector4
  68528. */
  68529. fract(): Vector4;
  68530. /**
  68531. * Returns the Vector4 length (float).
  68532. * @returns the length
  68533. */
  68534. length(): number;
  68535. /**
  68536. * Returns the Vector4 squared length (float).
  68537. * @returns the length squared
  68538. */
  68539. lengthSquared(): number;
  68540. /**
  68541. * Normalizes in place the Vector4.
  68542. * @returns the updated Vector4.
  68543. */
  68544. normalize(): Vector4;
  68545. /**
  68546. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68547. * @returns this converted to a new vector3
  68548. */
  68549. toVector3(): Vector3;
  68550. /**
  68551. * Returns a new Vector4 copied from the current one.
  68552. * @returns the new cloned vector
  68553. */
  68554. clone(): Vector4;
  68555. /**
  68556. * Updates the current Vector4 with the given one coordinates.
  68557. * @param source the source vector to copy from
  68558. * @returns the updated Vector4.
  68559. */
  68560. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68561. /**
  68562. * Updates the current Vector4 coordinates with the given floats.
  68563. * @param x float to copy from
  68564. * @param y float to copy from
  68565. * @param z float to copy from
  68566. * @param w float to copy from
  68567. * @returns the updated Vector4.
  68568. */
  68569. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68570. /**
  68571. * Updates the current Vector4 coordinates with the given floats.
  68572. * @param x float to set from
  68573. * @param y float to set from
  68574. * @param z float to set from
  68575. * @param w float to set from
  68576. * @returns the updated Vector4.
  68577. */
  68578. set(x: number, y: number, z: number, w: number): Vector4;
  68579. /**
  68580. * Copies the given float to the current Vector3 coordinates
  68581. * @param v defines the x, y, z and w coordinates of the operand
  68582. * @returns the current updated Vector3
  68583. */
  68584. setAll(v: number): Vector4;
  68585. /**
  68586. * Returns a new Vector4 set from the starting index of the given array.
  68587. * @param array the array to pull values from
  68588. * @param offset the offset into the array to start at
  68589. * @returns the new vector
  68590. */
  68591. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68592. /**
  68593. * Updates the given vector "result" from the starting index of the given array.
  68594. * @param array the array to pull values from
  68595. * @param offset the offset into the array to start at
  68596. * @param result the vector to store the result in
  68597. */
  68598. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68599. /**
  68600. * Updates the given vector "result" from the starting index of the given Float32Array.
  68601. * @param array the array to pull values from
  68602. * @param offset the offset into the array to start at
  68603. * @param result the vector to store the result in
  68604. */
  68605. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68606. /**
  68607. * Updates the given vector "result" coordinates from the given floats.
  68608. * @param x float to set from
  68609. * @param y float to set from
  68610. * @param z float to set from
  68611. * @param w float to set from
  68612. * @param result the vector to the floats in
  68613. */
  68614. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68615. /**
  68616. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68617. * @returns the new vector
  68618. */
  68619. static Zero(): Vector4;
  68620. /**
  68621. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68622. * @returns the new vector
  68623. */
  68624. static One(): Vector4;
  68625. /**
  68626. * Returns a new normalized Vector4 from the given one.
  68627. * @param vector the vector to normalize
  68628. * @returns the vector
  68629. */
  68630. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68631. /**
  68632. * Updates the given vector "result" from the normalization of the given one.
  68633. * @param vector the vector to normalize
  68634. * @param result the vector to store the result in
  68635. */
  68636. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68637. /**
  68638. * Returns a vector with the minimum values from the left and right vectors
  68639. * @param left left vector to minimize
  68640. * @param right right vector to minimize
  68641. * @returns a new vector with the minimum of the left and right vector values
  68642. */
  68643. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68644. /**
  68645. * Returns a vector with the maximum values from the left and right vectors
  68646. * @param left left vector to maximize
  68647. * @param right right vector to maximize
  68648. * @returns a new vector with the maximum of the left and right vector values
  68649. */
  68650. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68651. /**
  68652. * Returns the distance (float) between the vectors "value1" and "value2".
  68653. * @param value1 value to calulate the distance between
  68654. * @param value2 value to calulate the distance between
  68655. * @return the distance between the two vectors
  68656. */
  68657. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68658. /**
  68659. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68660. * @param value1 value to calulate the distance between
  68661. * @param value2 value to calulate the distance between
  68662. * @return the distance between the two vectors squared
  68663. */
  68664. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68665. /**
  68666. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68667. * @param value1 value to calulate the center between
  68668. * @param value2 value to calulate the center between
  68669. * @return the center between the two vectors
  68670. */
  68671. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68672. /**
  68673. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68674. * This methods computes transformed normalized direction vectors only.
  68675. * @param vector the vector to transform
  68676. * @param transformation the transformation matrix to apply
  68677. * @returns the new vector
  68678. */
  68679. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68680. /**
  68681. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68682. * This methods computes transformed normalized direction vectors only.
  68683. * @param vector the vector to transform
  68684. * @param transformation the transformation matrix to apply
  68685. * @param result the vector to store the result in
  68686. */
  68687. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68688. /**
  68689. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68690. * This methods computes transformed normalized direction vectors only.
  68691. * @param x value to transform
  68692. * @param y value to transform
  68693. * @param z value to transform
  68694. * @param w value to transform
  68695. * @param transformation the transformation matrix to apply
  68696. * @param result the vector to store the results in
  68697. */
  68698. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68699. /**
  68700. * Creates a new Vector4 from a Vector3
  68701. * @param source defines the source data
  68702. * @param w defines the 4th component (default is 0)
  68703. * @returns a new Vector4
  68704. */
  68705. static FromVector3(source: Vector3, w?: number): Vector4;
  68706. }
  68707. /**
  68708. * Class used to store quaternion data
  68709. * @see https://en.wikipedia.org/wiki/Quaternion
  68710. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68711. */
  68712. export class Quaternion {
  68713. /** defines the first component (0 by default) */
  68714. x: number;
  68715. /** defines the second component (0 by default) */
  68716. y: number;
  68717. /** defines the third component (0 by default) */
  68718. z: number;
  68719. /** defines the fourth component (1.0 by default) */
  68720. w: number;
  68721. /**
  68722. * Creates a new Quaternion from the given floats
  68723. * @param x defines the first component (0 by default)
  68724. * @param y defines the second component (0 by default)
  68725. * @param z defines the third component (0 by default)
  68726. * @param w defines the fourth component (1.0 by default)
  68727. */
  68728. constructor(
  68729. /** defines the first component (0 by default) */
  68730. x?: number,
  68731. /** defines the second component (0 by default) */
  68732. y?: number,
  68733. /** defines the third component (0 by default) */
  68734. z?: number,
  68735. /** defines the fourth component (1.0 by default) */
  68736. w?: number);
  68737. /**
  68738. * Gets a string representation for the current quaternion
  68739. * @returns a string with the Quaternion coordinates
  68740. */
  68741. toString(): string;
  68742. /**
  68743. * Gets the class name of the quaternion
  68744. * @returns the string "Quaternion"
  68745. */
  68746. getClassName(): string;
  68747. /**
  68748. * Gets a hash code for this quaternion
  68749. * @returns the quaternion hash code
  68750. */
  68751. getHashCode(): number;
  68752. /**
  68753. * Copy the quaternion to an array
  68754. * @returns a new array populated with 4 elements from the quaternion coordinates
  68755. */
  68756. asArray(): number[];
  68757. /**
  68758. * Check if two quaternions are equals
  68759. * @param otherQuaternion defines the second operand
  68760. * @return true if the current quaternion and the given one coordinates are strictly equals
  68761. */
  68762. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68763. /**
  68764. * Clone the current quaternion
  68765. * @returns a new quaternion copied from the current one
  68766. */
  68767. clone(): Quaternion;
  68768. /**
  68769. * Copy a quaternion to the current one
  68770. * @param other defines the other quaternion
  68771. * @returns the updated current quaternion
  68772. */
  68773. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68774. /**
  68775. * Updates the current quaternion with the given float coordinates
  68776. * @param x defines the x coordinate
  68777. * @param y defines the y coordinate
  68778. * @param z defines the z coordinate
  68779. * @param w defines the w coordinate
  68780. * @returns the updated current quaternion
  68781. */
  68782. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68783. /**
  68784. * Updates the current quaternion from the given float coordinates
  68785. * @param x defines the x coordinate
  68786. * @param y defines the y coordinate
  68787. * @param z defines the z coordinate
  68788. * @param w defines the w coordinate
  68789. * @returns the updated current quaternion
  68790. */
  68791. set(x: number, y: number, z: number, w: number): Quaternion;
  68792. /**
  68793. * Adds two quaternions
  68794. * @param other defines the second operand
  68795. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68796. */
  68797. add(other: DeepImmutable<Quaternion>): Quaternion;
  68798. /**
  68799. * Add a quaternion to the current one
  68800. * @param other defines the quaternion to add
  68801. * @returns the current quaternion
  68802. */
  68803. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68804. /**
  68805. * Subtract two quaternions
  68806. * @param other defines the second operand
  68807. * @returns a new quaternion as the subtraction result of the given one from the current one
  68808. */
  68809. subtract(other: Quaternion): Quaternion;
  68810. /**
  68811. * Multiplies the current quaternion by a scale factor
  68812. * @param value defines the scale factor
  68813. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68814. */
  68815. scale(value: number): Quaternion;
  68816. /**
  68817. * Scale the current quaternion values by a factor and stores 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. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68823. /**
  68824. * Multiplies in place the current quaternion by a scale factor
  68825. * @param value defines the scale factor
  68826. * @returns the current modified quaternion
  68827. */
  68828. scaleInPlace(value: number): Quaternion;
  68829. /**
  68830. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68831. * @param scale defines the scale factor
  68832. * @param result defines the Quaternion object where to store the result
  68833. * @returns the unmodified current quaternion
  68834. */
  68835. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68836. /**
  68837. * Multiplies two quaternions
  68838. * @param q1 defines the second operand
  68839. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68840. */
  68841. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68842. /**
  68843. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68844. * @param q1 defines the second operand
  68845. * @param result defines the target quaternion
  68846. * @returns the current quaternion
  68847. */
  68848. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68849. /**
  68850. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68851. * @param q1 defines the second operand
  68852. * @returns the currentupdated quaternion
  68853. */
  68854. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68855. /**
  68856. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68857. * @param ref defines the target quaternion
  68858. * @returns the current quaternion
  68859. */
  68860. conjugateToRef(ref: Quaternion): Quaternion;
  68861. /**
  68862. * Conjugates in place (1-q) the current quaternion
  68863. * @returns the current updated quaternion
  68864. */
  68865. conjugateInPlace(): Quaternion;
  68866. /**
  68867. * Conjugates in place (1-q) the current quaternion
  68868. * @returns a new quaternion
  68869. */
  68870. conjugate(): Quaternion;
  68871. /**
  68872. * Gets length of current quaternion
  68873. * @returns the quaternion length (float)
  68874. */
  68875. length(): number;
  68876. /**
  68877. * Normalize in place the current quaternion
  68878. * @returns the current updated quaternion
  68879. */
  68880. normalize(): Quaternion;
  68881. /**
  68882. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68883. * @param order is a reserved parameter and is ignore for now
  68884. * @returns a new Vector3 containing the Euler angles
  68885. */
  68886. toEulerAngles(order?: string): Vector3;
  68887. /**
  68888. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68889. * @param result defines the vector which will be filled with the Euler angles
  68890. * @param order is a reserved parameter and is ignore for now
  68891. * @returns the current unchanged quaternion
  68892. */
  68893. toEulerAnglesToRef(result: Vector3): Quaternion;
  68894. /**
  68895. * Updates the given rotation matrix with the current quaternion values
  68896. * @param result defines the target matrix
  68897. * @returns the current unchanged quaternion
  68898. */
  68899. toRotationMatrix(result: Matrix): Quaternion;
  68900. /**
  68901. * Updates the current quaternion from the given rotation matrix values
  68902. * @param matrix defines the source matrix
  68903. * @returns the current updated quaternion
  68904. */
  68905. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68906. /**
  68907. * Creates a new quaternion from a rotation matrix
  68908. * @param matrix defines the source matrix
  68909. * @returns a new quaternion created from the given rotation matrix values
  68910. */
  68911. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68912. /**
  68913. * Updates the given quaternion with the given rotation matrix values
  68914. * @param matrix defines the source matrix
  68915. * @param result defines the target quaternion
  68916. */
  68917. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68918. /**
  68919. * Returns the dot product (float) between the quaternions "left" and "right"
  68920. * @param left defines the left operand
  68921. * @param right defines the right operand
  68922. * @returns the dot product
  68923. */
  68924. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68925. /**
  68926. * Checks if the two quaternions are close to each other
  68927. * @param quat0 defines the first quaternion to check
  68928. * @param quat1 defines the second quaternion to check
  68929. * @returns true if the two quaternions are close to each other
  68930. */
  68931. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68932. /**
  68933. * Creates an empty quaternion
  68934. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68935. */
  68936. static Zero(): Quaternion;
  68937. /**
  68938. * Inverse a given quaternion
  68939. * @param q defines the source quaternion
  68940. * @returns a new quaternion as the inverted current quaternion
  68941. */
  68942. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68943. /**
  68944. * Inverse a given quaternion
  68945. * @param q defines the source quaternion
  68946. * @param result the quaternion the result will be stored in
  68947. * @returns the result quaternion
  68948. */
  68949. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68950. /**
  68951. * Creates an identity quaternion
  68952. * @returns the identity quaternion
  68953. */
  68954. static Identity(): Quaternion;
  68955. /**
  68956. * Gets a boolean indicating if the given quaternion is identity
  68957. * @param quaternion defines the quaternion to check
  68958. * @returns true if the quaternion is identity
  68959. */
  68960. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68961. /**
  68962. * Creates a quaternion from a rotation around an axis
  68963. * @param axis defines the axis to use
  68964. * @param angle defines the angle to use
  68965. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68966. */
  68967. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68968. /**
  68969. * Creates a rotation around an axis and stores it into the given quaternion
  68970. * @param axis defines the axis to use
  68971. * @param angle defines the angle to use
  68972. * @param result defines the target quaternion
  68973. * @returns the target quaternion
  68974. */
  68975. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68976. /**
  68977. * Creates a new quaternion from data stored into an array
  68978. * @param array defines the data source
  68979. * @param offset defines the offset in the source array where the data starts
  68980. * @returns a new quaternion
  68981. */
  68982. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68983. /**
  68984. * Create a quaternion from Euler rotation angles
  68985. * @param x Pitch
  68986. * @param y Yaw
  68987. * @param z Roll
  68988. * @returns the new Quaternion
  68989. */
  68990. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68991. /**
  68992. * Updates a quaternion from Euler rotation angles
  68993. * @param x Pitch
  68994. * @param y Yaw
  68995. * @param z Roll
  68996. * @param result the quaternion to store the result
  68997. * @returns the updated quaternion
  68998. */
  68999. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69000. /**
  69001. * Create a quaternion from Euler rotation vector
  69002. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69003. * @returns the new Quaternion
  69004. */
  69005. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69006. /**
  69007. * Updates a quaternion from Euler rotation vector
  69008. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69009. * @param result the quaternion to store the result
  69010. * @returns the updated quaternion
  69011. */
  69012. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69013. /**
  69014. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69015. * @param yaw defines the rotation around Y axis
  69016. * @param pitch defines the rotation around X axis
  69017. * @param roll defines the rotation around Z axis
  69018. * @returns the new quaternion
  69019. */
  69020. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69021. /**
  69022. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69023. * @param yaw defines the rotation around Y axis
  69024. * @param pitch defines the rotation around X axis
  69025. * @param roll defines the rotation around Z axis
  69026. * @param result defines the target quaternion
  69027. */
  69028. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69029. /**
  69030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69031. * @param alpha defines the rotation around first axis
  69032. * @param beta defines the rotation around second axis
  69033. * @param gamma defines the rotation around third axis
  69034. * @returns the new quaternion
  69035. */
  69036. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69037. /**
  69038. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69039. * @param alpha defines the rotation around first axis
  69040. * @param beta defines the rotation around second axis
  69041. * @param gamma defines the rotation around third axis
  69042. * @param result defines the target quaternion
  69043. */
  69044. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69045. /**
  69046. * 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)
  69047. * @param axis1 defines the first axis
  69048. * @param axis2 defines the second axis
  69049. * @param axis3 defines the third axis
  69050. * @returns the new quaternion
  69051. */
  69052. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69053. /**
  69054. * 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
  69055. * @param axis1 defines the first axis
  69056. * @param axis2 defines the second axis
  69057. * @param axis3 defines the third axis
  69058. * @param ref defines the target quaternion
  69059. */
  69060. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69061. /**
  69062. * Interpolates between two quaternions
  69063. * @param left defines first quaternion
  69064. * @param right defines second quaternion
  69065. * @param amount defines the gradient to use
  69066. * @returns the new interpolated quaternion
  69067. */
  69068. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69069. /**
  69070. * Interpolates between two quaternions and stores it into a target quaternion
  69071. * @param left defines first quaternion
  69072. * @param right defines second quaternion
  69073. * @param amount defines the gradient to use
  69074. * @param result defines the target quaternion
  69075. */
  69076. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69077. /**
  69078. * Interpolate between two quaternions using Hermite interpolation
  69079. * @param value1 defines first quaternion
  69080. * @param tangent1 defines the incoming tangent
  69081. * @param value2 defines second quaternion
  69082. * @param tangent2 defines the outgoing tangent
  69083. * @param amount defines the target quaternion
  69084. * @returns the new interpolated quaternion
  69085. */
  69086. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69087. }
  69088. /**
  69089. * Class used to store matrix data (4x4)
  69090. */
  69091. export class Matrix {
  69092. private static _updateFlagSeed;
  69093. private static _identityReadOnly;
  69094. private _isIdentity;
  69095. private _isIdentityDirty;
  69096. private _isIdentity3x2;
  69097. private _isIdentity3x2Dirty;
  69098. /**
  69099. * Gets the update flag of the matrix which is an unique number for the matrix.
  69100. * It will be incremented every time the matrix data change.
  69101. * You can use it to speed the comparison between two versions of the same matrix.
  69102. */
  69103. updateFlag: number;
  69104. private readonly _m;
  69105. /**
  69106. * Gets the internal data of the matrix
  69107. */
  69108. readonly m: DeepImmutable<Float32Array>;
  69109. /** @hidden */
  69110. _markAsUpdated(): void;
  69111. /** @hidden */
  69112. private _updateIdentityStatus;
  69113. /**
  69114. * Creates an empty matrix (filled with zeros)
  69115. */
  69116. constructor();
  69117. /**
  69118. * Check if the current matrix is identity
  69119. * @returns true is the matrix is the identity matrix
  69120. */
  69121. isIdentity(): boolean;
  69122. /**
  69123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69124. * @returns true is the matrix is the identity matrix
  69125. */
  69126. isIdentityAs3x2(): boolean;
  69127. /**
  69128. * Gets the determinant of the matrix
  69129. * @returns the matrix determinant
  69130. */
  69131. determinant(): number;
  69132. /**
  69133. * Returns the matrix as a Float32Array
  69134. * @returns the matrix underlying array
  69135. */
  69136. toArray(): DeepImmutable<Float32Array>;
  69137. /**
  69138. * Returns the matrix as a Float32Array
  69139. * @returns the matrix underlying array.
  69140. */
  69141. asArray(): DeepImmutable<Float32Array>;
  69142. /**
  69143. * Inverts the current matrix in place
  69144. * @returns the current inverted matrix
  69145. */
  69146. invert(): Matrix;
  69147. /**
  69148. * Sets all the matrix elements to zero
  69149. * @returns the current matrix
  69150. */
  69151. reset(): Matrix;
  69152. /**
  69153. * Adds the current matrix with a second one
  69154. * @param other defines the matrix to add
  69155. * @returns a new matrix as the addition of the current matrix and the given one
  69156. */
  69157. add(other: DeepImmutable<Matrix>): Matrix;
  69158. /**
  69159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69160. * @param other defines the matrix to add
  69161. * @param result defines the target matrix
  69162. * @returns the current matrix
  69163. */
  69164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69165. /**
  69166. * Adds in place the given matrix to the current matrix
  69167. * @param other defines the second operand
  69168. * @returns the current updated matrix
  69169. */
  69170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69171. /**
  69172. * Sets the given matrix to the current inverted Matrix
  69173. * @param other defines the target matrix
  69174. * @returns the unmodified current matrix
  69175. */
  69176. invertToRef(other: Matrix): Matrix;
  69177. /**
  69178. * add a value at the specified position in the current Matrix
  69179. * @param index the index of the value within the matrix. between 0 and 15.
  69180. * @param value the value to be added
  69181. * @returns the current updated matrix
  69182. */
  69183. addAtIndex(index: number, value: number): Matrix;
  69184. /**
  69185. * mutiply the specified position in the current Matrix by a value
  69186. * @param index the index of the value within the matrix. between 0 and 15.
  69187. * @param value the value to be added
  69188. * @returns the current updated matrix
  69189. */
  69190. multiplyAtIndex(index: number, value: number): Matrix;
  69191. /**
  69192. * Inserts the translation vector (using 3 floats) in the current matrix
  69193. * @param x defines the 1st component of the translation
  69194. * @param y defines the 2nd component of the translation
  69195. * @param z defines the 3rd component of the translation
  69196. * @returns the current updated matrix
  69197. */
  69198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69199. /**
  69200. * Adds the translation vector (using 3 floats) in the current matrix
  69201. * @param x defines the 1st component of the translation
  69202. * @param y defines the 2nd component of the translation
  69203. * @param z defines the 3rd component of the translation
  69204. * @returns the current updated matrix
  69205. */
  69206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69207. /**
  69208. * Inserts the translation vector in the current matrix
  69209. * @param vector3 defines the translation to insert
  69210. * @returns the current updated matrix
  69211. */
  69212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69213. /**
  69214. * Gets the translation value of the current matrix
  69215. * @returns a new Vector3 as the extracted translation from the matrix
  69216. */
  69217. getTranslation(): Vector3;
  69218. /**
  69219. * Fill a Vector3 with the extracted translation from the matrix
  69220. * @param result defines the Vector3 where to store the translation
  69221. * @returns the current matrix
  69222. */
  69223. getTranslationToRef(result: Vector3): Matrix;
  69224. /**
  69225. * Remove rotation and scaling part from the matrix
  69226. * @returns the updated matrix
  69227. */
  69228. removeRotationAndScaling(): Matrix;
  69229. /**
  69230. * Multiply two matrices
  69231. * @param other defines the second operand
  69232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69233. */
  69234. multiply(other: DeepImmutable<Matrix>): Matrix;
  69235. /**
  69236. * Copy the current matrix from the given one
  69237. * @param other defines the source matrix
  69238. * @returns the current updated matrix
  69239. */
  69240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69241. /**
  69242. * Populates the given array from the starting index with the current matrix values
  69243. * @param array defines the target array
  69244. * @param offset defines the offset in the target array where to start storing values
  69245. * @returns the current matrix
  69246. */
  69247. copyToArray(array: Float32Array, offset?: number): Matrix;
  69248. /**
  69249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69250. * @param other defines the second operand
  69251. * @param result defines the matrix where to store the multiplication
  69252. * @returns the current matrix
  69253. */
  69254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69255. /**
  69256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69257. * @param other defines the second operand
  69258. * @param result defines the array where to store the multiplication
  69259. * @param offset defines the offset in the target array where to start storing values
  69260. * @returns the current matrix
  69261. */
  69262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69263. /**
  69264. * Check equality between this matrix and a second one
  69265. * @param value defines the second matrix to compare
  69266. * @returns true is the current matrix and the given one values are strictly equal
  69267. */
  69268. equals(value: DeepImmutable<Matrix>): boolean;
  69269. /**
  69270. * Clone the current matrix
  69271. * @returns a new matrix from the current matrix
  69272. */
  69273. clone(): Matrix;
  69274. /**
  69275. * Returns the name of the current matrix class
  69276. * @returns the string "Matrix"
  69277. */
  69278. getClassName(): string;
  69279. /**
  69280. * Gets the hash code of the current matrix
  69281. * @returns the hash code
  69282. */
  69283. getHashCode(): number;
  69284. /**
  69285. * Decomposes the current Matrix into a translation, rotation and scaling components
  69286. * @param scale defines the scale vector3 given as a reference to update
  69287. * @param rotation defines the rotation quaternion given as a reference to update
  69288. * @param translation defines the translation vector3 given as a reference to update
  69289. * @returns true if operation was successful
  69290. */
  69291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69292. /**
  69293. * Gets specific row of the matrix
  69294. * @param index defines the number of the row to get
  69295. * @returns the index-th row of the current matrix as a new Vector4
  69296. */
  69297. getRow(index: number): Nullable<Vector4>;
  69298. /**
  69299. * Sets the index-th row of the current matrix to the vector4 values
  69300. * @param index defines the number of the row to set
  69301. * @param row defines the target vector4
  69302. * @returns the updated current matrix
  69303. */
  69304. setRow(index: number, row: Vector4): Matrix;
  69305. /**
  69306. * Compute the transpose of the matrix
  69307. * @returns the new transposed matrix
  69308. */
  69309. transpose(): Matrix;
  69310. /**
  69311. * Compute the transpose of the matrix and store it in a given matrix
  69312. * @param result defines the target matrix
  69313. * @returns the current matrix
  69314. */
  69315. transposeToRef(result: Matrix): Matrix;
  69316. /**
  69317. * Sets the index-th row of the current matrix with the given 4 x float values
  69318. * @param index defines the row index
  69319. * @param x defines the x component to set
  69320. * @param y defines the y component to set
  69321. * @param z defines the z component to set
  69322. * @param w defines the w component to set
  69323. * @returns the updated current matrix
  69324. */
  69325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69326. /**
  69327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69328. * @param scale defines the scale factor
  69329. * @returns a new matrix
  69330. */
  69331. scale(scale: number): Matrix;
  69332. /**
  69333. * Scale the current matrix values by a factor to a given result matrix
  69334. * @param scale defines the scale factor
  69335. * @param result defines the matrix to store the result
  69336. * @returns the current matrix
  69337. */
  69338. scaleToRef(scale: number, result: Matrix): Matrix;
  69339. /**
  69340. * Scale the current matrix values by a factor and add the result to a given matrix
  69341. * @param scale defines the scale factor
  69342. * @param result defines the Matrix to store the result
  69343. * @returns the current matrix
  69344. */
  69345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69346. /**
  69347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69348. * @param ref matrix to store the result
  69349. */
  69350. toNormalMatrix(ref: Matrix): void;
  69351. /**
  69352. * Gets only rotation part of the current matrix
  69353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69354. */
  69355. getRotationMatrix(): Matrix;
  69356. /**
  69357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69358. * @param result defines the target matrix to store data to
  69359. * @returns the current matrix
  69360. */
  69361. getRotationMatrixToRef(result: Matrix): Matrix;
  69362. /**
  69363. * Toggles model matrix from being right handed to left handed in place and vice versa
  69364. */
  69365. toggleModelMatrixHandInPlace(): void;
  69366. /**
  69367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69368. */
  69369. toggleProjectionMatrixHandInPlace(): void;
  69370. /**
  69371. * Creates a matrix from an array
  69372. * @param array defines the source array
  69373. * @param offset defines an offset in the source array
  69374. * @returns a new Matrix set from the starting index of the given array
  69375. */
  69376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69377. /**
  69378. * Copy the content of an array into a given matrix
  69379. * @param array defines the source array
  69380. * @param offset defines an offset in the source array
  69381. * @param result defines the target matrix
  69382. */
  69383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69384. /**
  69385. * Stores an array into a matrix after having multiplied each component by a given factor
  69386. * @param array defines the source array
  69387. * @param offset defines the offset in the source array
  69388. * @param scale defines the scaling factor
  69389. * @param result defines the target matrix
  69390. */
  69391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69392. /**
  69393. * Gets an identity matrix that must not be updated
  69394. */
  69395. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69396. /**
  69397. * Stores a list of values (16) inside a given matrix
  69398. * @param initialM11 defines 1st value of 1st row
  69399. * @param initialM12 defines 2nd value of 1st row
  69400. * @param initialM13 defines 3rd value of 1st row
  69401. * @param initialM14 defines 4th value of 1st row
  69402. * @param initialM21 defines 1st value of 2nd row
  69403. * @param initialM22 defines 2nd value of 2nd row
  69404. * @param initialM23 defines 3rd value of 2nd row
  69405. * @param initialM24 defines 4th value of 2nd row
  69406. * @param initialM31 defines 1st value of 3rd row
  69407. * @param initialM32 defines 2nd value of 3rd row
  69408. * @param initialM33 defines 3rd value of 3rd row
  69409. * @param initialM34 defines 4th value of 3rd row
  69410. * @param initialM41 defines 1st value of 4th row
  69411. * @param initialM42 defines 2nd value of 4th row
  69412. * @param initialM43 defines 3rd value of 4th row
  69413. * @param initialM44 defines 4th value of 4th row
  69414. * @param result defines the target matrix
  69415. */
  69416. 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;
  69417. /**
  69418. * Creates new matrix from a list of values (16)
  69419. * @param initialM11 defines 1st value of 1st row
  69420. * @param initialM12 defines 2nd value of 1st row
  69421. * @param initialM13 defines 3rd value of 1st row
  69422. * @param initialM14 defines 4th value of 1st row
  69423. * @param initialM21 defines 1st value of 2nd row
  69424. * @param initialM22 defines 2nd value of 2nd row
  69425. * @param initialM23 defines 3rd value of 2nd row
  69426. * @param initialM24 defines 4th value of 2nd row
  69427. * @param initialM31 defines 1st value of 3rd row
  69428. * @param initialM32 defines 2nd value of 3rd row
  69429. * @param initialM33 defines 3rd value of 3rd row
  69430. * @param initialM34 defines 4th value of 3rd row
  69431. * @param initialM41 defines 1st value of 4th row
  69432. * @param initialM42 defines 2nd value of 4th row
  69433. * @param initialM43 defines 3rd value of 4th row
  69434. * @param initialM44 defines 4th value of 4th row
  69435. * @returns the new matrix
  69436. */
  69437. 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;
  69438. /**
  69439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69440. * @param scale defines the scale vector3
  69441. * @param rotation defines the rotation quaternion
  69442. * @param translation defines the translation vector3
  69443. * @returns a new matrix
  69444. */
  69445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69446. /**
  69447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69448. * @param scale defines the scale vector3
  69449. * @param rotation defines the rotation quaternion
  69450. * @param translation defines the translation vector3
  69451. * @param result defines the target matrix
  69452. */
  69453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69454. /**
  69455. * Creates a new identity matrix
  69456. * @returns a new identity matrix
  69457. */
  69458. static Identity(): Matrix;
  69459. /**
  69460. * Creates a new identity matrix and stores the result in a given matrix
  69461. * @param result defines the target matrix
  69462. */
  69463. static IdentityToRef(result: Matrix): void;
  69464. /**
  69465. * Creates a new zero matrix
  69466. * @returns a new zero matrix
  69467. */
  69468. static Zero(): Matrix;
  69469. /**
  69470. * Creates a new rotation matrix for "angle" radians around the X axis
  69471. * @param angle defines the angle (in radians) to use
  69472. * @return the new matrix
  69473. */
  69474. static RotationX(angle: number): Matrix;
  69475. /**
  69476. * Creates a new matrix as the invert of a given matrix
  69477. * @param source defines the source matrix
  69478. * @returns the new matrix
  69479. */
  69480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69481. /**
  69482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69483. * @param angle defines the angle (in radians) to use
  69484. * @param result defines the target matrix
  69485. */
  69486. static RotationXToRef(angle: number, result: Matrix): void;
  69487. /**
  69488. * Creates a new rotation matrix for "angle" radians around the Y axis
  69489. * @param angle defines the angle (in radians) to use
  69490. * @return the new matrix
  69491. */
  69492. static RotationY(angle: number): Matrix;
  69493. /**
  69494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69495. * @param angle defines the angle (in radians) to use
  69496. * @param result defines the target matrix
  69497. */
  69498. static RotationYToRef(angle: number, result: Matrix): void;
  69499. /**
  69500. * Creates a new rotation matrix for "angle" radians around the Z axis
  69501. * @param angle defines the angle (in radians) to use
  69502. * @return the new matrix
  69503. */
  69504. static RotationZ(angle: number): Matrix;
  69505. /**
  69506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69507. * @param angle defines the angle (in radians) to use
  69508. * @param result defines the target matrix
  69509. */
  69510. static RotationZToRef(angle: number, result: Matrix): void;
  69511. /**
  69512. * Creates a new rotation matrix for "angle" radians around the given axis
  69513. * @param axis defines the axis to use
  69514. * @param angle defines the angle (in radians) to use
  69515. * @return the new matrix
  69516. */
  69517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69518. /**
  69519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69520. * @param axis defines the axis to use
  69521. * @param angle defines the angle (in radians) to use
  69522. * @param result defines the target matrix
  69523. */
  69524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69525. /**
  69526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69528. * @param from defines the vector to align
  69529. * @param to defines the vector to align to
  69530. * @param result defines the target matrix
  69531. */
  69532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69533. /**
  69534. * Creates a rotation matrix
  69535. * @param yaw defines the yaw angle in radians (Y axis)
  69536. * @param pitch defines the pitch angle in radians (X axis)
  69537. * @param roll defines the roll angle in radians (X axis)
  69538. * @returns the new rotation matrix
  69539. */
  69540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69541. /**
  69542. * Creates a rotation matrix and stores it in a given matrix
  69543. * @param yaw defines the yaw angle in radians (Y axis)
  69544. * @param pitch defines the pitch angle in radians (X axis)
  69545. * @param roll defines the roll angle in radians (X axis)
  69546. * @param result defines the target matrix
  69547. */
  69548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69549. /**
  69550. * Creates a scaling matrix
  69551. * @param x defines the scale factor on X axis
  69552. * @param y defines the scale factor on Y axis
  69553. * @param z defines the scale factor on Z axis
  69554. * @returns the new matrix
  69555. */
  69556. static Scaling(x: number, y: number, z: number): Matrix;
  69557. /**
  69558. * Creates a scaling matrix and stores it in a given matrix
  69559. * @param x defines the scale factor on X axis
  69560. * @param y defines the scale factor on Y axis
  69561. * @param z defines the scale factor on Z axis
  69562. * @param result defines the target matrix
  69563. */
  69564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69565. /**
  69566. * Creates a translation matrix
  69567. * @param x defines the translation on X axis
  69568. * @param y defines the translation on Y axis
  69569. * @param z defines the translationon Z axis
  69570. * @returns the new matrix
  69571. */
  69572. static Translation(x: number, y: number, z: number): Matrix;
  69573. /**
  69574. * Creates a translation matrix and stores it in a given matrix
  69575. * @param x defines the translation on X axis
  69576. * @param y defines the translation on Y axis
  69577. * @param z defines the translationon Z axis
  69578. * @param result defines the target matrix
  69579. */
  69580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69581. /**
  69582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69583. * @param startValue defines the start value
  69584. * @param endValue defines the end value
  69585. * @param gradient defines the gradient factor
  69586. * @returns the new matrix
  69587. */
  69588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69589. /**
  69590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69591. * @param startValue defines the start value
  69592. * @param endValue defines the end value
  69593. * @param gradient defines the gradient factor
  69594. * @param result defines the Matrix object where to store data
  69595. */
  69596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69597. /**
  69598. * Builds a new matrix whose values are computed by:
  69599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69602. * @param startValue defines the first matrix
  69603. * @param endValue defines the second matrix
  69604. * @param gradient defines the gradient between the two matrices
  69605. * @returns the new matrix
  69606. */
  69607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69608. /**
  69609. * Update a matrix to values which are computed by:
  69610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69613. * @param startValue defines the first matrix
  69614. * @param endValue defines the second matrix
  69615. * @param gradient defines the gradient between the two matrices
  69616. * @param result defines the target matrix
  69617. */
  69618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69619. /**
  69620. * 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"
  69621. * This function works in left handed mode
  69622. * @param eye defines the final position of the entity
  69623. * @param target defines where the entity should look at
  69624. * @param up defines the up vector for the entity
  69625. * @returns the new matrix
  69626. */
  69627. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69628. /**
  69629. * 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".
  69630. * This function works in left handed mode
  69631. * @param eye defines the final position of the entity
  69632. * @param target defines where the entity should look at
  69633. * @param up defines the up vector for the entity
  69634. * @param result defines the target matrix
  69635. */
  69636. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69637. /**
  69638. * 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"
  69639. * This function works in right handed mode
  69640. * @param eye defines the final position of the entity
  69641. * @param target defines where the entity should look at
  69642. * @param up defines the up vector for the entity
  69643. * @returns the new matrix
  69644. */
  69645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69646. /**
  69647. * 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".
  69648. * This function works in right handed mode
  69649. * @param eye defines the final position of the entity
  69650. * @param target defines where the entity should look at
  69651. * @param up defines the up vector for the entity
  69652. * @param result defines the target matrix
  69653. */
  69654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69655. /**
  69656. * Create a left-handed orthographic projection matrix
  69657. * @param width defines the viewport width
  69658. * @param height defines the viewport height
  69659. * @param znear defines the near clip plane
  69660. * @param zfar defines the far clip plane
  69661. * @returns a new matrix as a left-handed orthographic projection matrix
  69662. */
  69663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69664. /**
  69665. * Store a left-handed orthographic projection to a given matrix
  69666. * @param width defines the viewport width
  69667. * @param height defines the viewport height
  69668. * @param znear defines the near clip plane
  69669. * @param zfar defines the far clip plane
  69670. * @param result defines the target matrix
  69671. */
  69672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69673. /**
  69674. * Create a left-handed orthographic projection matrix
  69675. * @param left defines the viewport left coordinate
  69676. * @param right defines the viewport right coordinate
  69677. * @param bottom defines the viewport bottom coordinate
  69678. * @param top defines the viewport top coordinate
  69679. * @param znear defines the near clip plane
  69680. * @param zfar defines the far clip plane
  69681. * @returns a new matrix as a left-handed orthographic projection matrix
  69682. */
  69683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69684. /**
  69685. * Stores a left-handed orthographic projection into a given matrix
  69686. * @param left defines the viewport left coordinate
  69687. * @param right defines the viewport right coordinate
  69688. * @param bottom defines the viewport bottom coordinate
  69689. * @param top defines the viewport top coordinate
  69690. * @param znear defines the near clip plane
  69691. * @param zfar defines the far clip plane
  69692. * @param result defines the target matrix
  69693. */
  69694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69695. /**
  69696. * Creates a right-handed orthographic projection matrix
  69697. * @param left defines the viewport left coordinate
  69698. * @param right defines the viewport right coordinate
  69699. * @param bottom defines the viewport bottom coordinate
  69700. * @param top defines the viewport top coordinate
  69701. * @param znear defines the near clip plane
  69702. * @param zfar defines the far clip plane
  69703. * @returns a new matrix as a right-handed orthographic projection matrix
  69704. */
  69705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69706. /**
  69707. * Stores a right-handed orthographic projection into a given matrix
  69708. * @param left defines the viewport left coordinate
  69709. * @param right defines the viewport right coordinate
  69710. * @param bottom defines the viewport bottom coordinate
  69711. * @param top defines the viewport top coordinate
  69712. * @param znear defines the near clip plane
  69713. * @param zfar defines the far clip plane
  69714. * @param result defines the target matrix
  69715. */
  69716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69717. /**
  69718. * Creates a left-handed perspective projection matrix
  69719. * @param width defines the viewport width
  69720. * @param height defines the viewport height
  69721. * @param znear defines the near clip plane
  69722. * @param zfar defines the far clip plane
  69723. * @returns a new matrix as a left-handed perspective projection matrix
  69724. */
  69725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69726. /**
  69727. * Creates a left-handed perspective projection matrix
  69728. * @param fov defines the horizontal field of view
  69729. * @param aspect defines the aspect ratio
  69730. * @param znear defines the near clip plane
  69731. * @param zfar defines the far clip plane
  69732. * @returns a new matrix as a left-handed perspective projection matrix
  69733. */
  69734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69735. /**
  69736. * Stores a left-handed perspective projection into a given matrix
  69737. * @param fov defines the horizontal field of view
  69738. * @param aspect defines the aspect ratio
  69739. * @param znear defines the near clip plane
  69740. * @param zfar defines the far clip plane
  69741. * @param result defines the target matrix
  69742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69743. */
  69744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69745. /**
  69746. * Creates a right-handed perspective projection matrix
  69747. * @param fov defines the horizontal field of view
  69748. * @param aspect defines the aspect ratio
  69749. * @param znear defines the near clip plane
  69750. * @param zfar defines the far clip plane
  69751. * @returns a new matrix as a right-handed perspective projection matrix
  69752. */
  69753. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69754. /**
  69755. * Stores a right-handed perspective projection into a given matrix
  69756. * @param fov defines the horizontal field of view
  69757. * @param aspect defines the aspect ratio
  69758. * @param znear defines the near clip plane
  69759. * @param zfar defines the far clip plane
  69760. * @param result defines the target matrix
  69761. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69762. */
  69763. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69764. /**
  69765. * Stores a perspective projection for WebVR info a given matrix
  69766. * @param fov defines the field of view
  69767. * @param znear defines the near clip plane
  69768. * @param zfar defines the far clip plane
  69769. * @param result defines the target matrix
  69770. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69771. */
  69772. static PerspectiveFovWebVRToRef(fov: {
  69773. upDegrees: number;
  69774. downDegrees: number;
  69775. leftDegrees: number;
  69776. rightDegrees: number;
  69777. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69778. /**
  69779. * Computes a complete transformation matrix
  69780. * @param viewport defines the viewport to use
  69781. * @param world defines the world matrix
  69782. * @param view defines the view matrix
  69783. * @param projection defines the projection matrix
  69784. * @param zmin defines the near clip plane
  69785. * @param zmax defines the far clip plane
  69786. * @returns the transformation matrix
  69787. */
  69788. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69789. /**
  69790. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69791. * @param matrix defines the matrix to use
  69792. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69793. */
  69794. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69795. /**
  69796. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69797. * @param matrix defines the matrix to use
  69798. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69799. */
  69800. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69801. /**
  69802. * Compute the transpose of a given matrix
  69803. * @param matrix defines the matrix to transpose
  69804. * @returns the new matrix
  69805. */
  69806. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69807. /**
  69808. * Compute the transpose of a matrix and store it in a target matrix
  69809. * @param matrix defines the matrix to transpose
  69810. * @param result defines the target matrix
  69811. */
  69812. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69813. /**
  69814. * Computes a reflection matrix from a plane
  69815. * @param plane defines the reflection plane
  69816. * @returns a new matrix
  69817. */
  69818. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69819. /**
  69820. * Computes a reflection matrix from a plane
  69821. * @param plane defines the reflection plane
  69822. * @param result defines the target matrix
  69823. */
  69824. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69825. /**
  69826. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69827. * @param xaxis defines the value of the 1st axis
  69828. * @param yaxis defines the value of the 2nd axis
  69829. * @param zaxis defines the value of the 3rd axis
  69830. * @param result defines the target matrix
  69831. */
  69832. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69833. /**
  69834. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69835. * @param quat defines the quaternion to use
  69836. * @param result defines the target matrix
  69837. */
  69838. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69839. }
  69840. /**
  69841. * @hidden
  69842. */
  69843. export class TmpVectors {
  69844. static Vector2: Vector2[];
  69845. static Vector3: Vector3[];
  69846. static Vector4: Vector4[];
  69847. static Quaternion: Quaternion[];
  69848. static Matrix: Matrix[];
  69849. }
  69850. }
  69851. declare module BABYLON {
  69852. /** Defines the cross module used constants to avoid circular dependncies */
  69853. export class Constants {
  69854. /** Defines that alpha blending is disabled */
  69855. static readonly ALPHA_DISABLE: number;
  69856. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69857. static readonly ALPHA_ADD: number;
  69858. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69859. static readonly ALPHA_COMBINE: number;
  69860. /** Defines that alpha blending to DEST - SRC * DEST */
  69861. static readonly ALPHA_SUBTRACT: number;
  69862. /** Defines that alpha blending to SRC * DEST */
  69863. static readonly ALPHA_MULTIPLY: number;
  69864. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69865. static readonly ALPHA_MAXIMIZED: number;
  69866. /** Defines that alpha blending to SRC + DEST */
  69867. static readonly ALPHA_ONEONE: number;
  69868. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69869. static readonly ALPHA_PREMULTIPLIED: number;
  69870. /**
  69871. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69872. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69873. */
  69874. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69875. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69876. static readonly ALPHA_INTERPOLATE: number;
  69877. /**
  69878. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69879. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69880. */
  69881. static readonly ALPHA_SCREENMODE: number;
  69882. /** Defines that the ressource is not delayed*/
  69883. static readonly DELAYLOADSTATE_NONE: number;
  69884. /** Defines that the ressource was successfully delay loaded */
  69885. static readonly DELAYLOADSTATE_LOADED: number;
  69886. /** Defines that the ressource is currently delay loading */
  69887. static readonly DELAYLOADSTATE_LOADING: number;
  69888. /** Defines that the ressource is delayed and has not started loading */
  69889. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69890. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69891. static readonly NEVER: number;
  69892. /** 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 */
  69893. static readonly ALWAYS: number;
  69894. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69895. static readonly LESS: number;
  69896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69897. static readonly EQUAL: number;
  69898. /** 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 */
  69899. static readonly LEQUAL: number;
  69900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69901. static readonly GREATER: number;
  69902. /** 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 */
  69903. static readonly GEQUAL: number;
  69904. /** 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 */
  69905. static readonly NOTEQUAL: number;
  69906. /** Passed to stencilOperation to specify that stencil value must be kept */
  69907. static readonly KEEP: number;
  69908. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69909. static readonly REPLACE: number;
  69910. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69911. static readonly INCR: number;
  69912. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69913. static readonly DECR: number;
  69914. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69915. static readonly INVERT: number;
  69916. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69917. static readonly INCR_WRAP: number;
  69918. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69919. static readonly DECR_WRAP: number;
  69920. /** Texture is not repeating outside of 0..1 UVs */
  69921. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69922. /** Texture is repeating outside of 0..1 UVs */
  69923. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69924. /** Texture is repeating and mirrored */
  69925. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69926. /** ALPHA */
  69927. static readonly TEXTUREFORMAT_ALPHA: number;
  69928. /** LUMINANCE */
  69929. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69930. /** LUMINANCE_ALPHA */
  69931. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69932. /** RGB */
  69933. static readonly TEXTUREFORMAT_RGB: number;
  69934. /** RGBA */
  69935. static readonly TEXTUREFORMAT_RGBA: number;
  69936. /** RED */
  69937. static readonly TEXTUREFORMAT_RED: number;
  69938. /** RED (2nd reference) */
  69939. static readonly TEXTUREFORMAT_R: number;
  69940. /** RG */
  69941. static readonly TEXTUREFORMAT_RG: number;
  69942. /** RED_INTEGER */
  69943. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69944. /** RED_INTEGER (2nd reference) */
  69945. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69946. /** RG_INTEGER */
  69947. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69948. /** RGB_INTEGER */
  69949. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69950. /** RGBA_INTEGER */
  69951. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69952. /** UNSIGNED_BYTE */
  69953. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69954. /** UNSIGNED_BYTE (2nd reference) */
  69955. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69956. /** FLOAT */
  69957. static readonly TEXTURETYPE_FLOAT: number;
  69958. /** HALF_FLOAT */
  69959. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69960. /** BYTE */
  69961. static readonly TEXTURETYPE_BYTE: number;
  69962. /** SHORT */
  69963. static readonly TEXTURETYPE_SHORT: number;
  69964. /** UNSIGNED_SHORT */
  69965. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69966. /** INT */
  69967. static readonly TEXTURETYPE_INT: number;
  69968. /** UNSIGNED_INT */
  69969. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69970. /** UNSIGNED_SHORT_4_4_4_4 */
  69971. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69972. /** UNSIGNED_SHORT_5_5_5_1 */
  69973. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69974. /** UNSIGNED_SHORT_5_6_5 */
  69975. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69976. /** UNSIGNED_INT_2_10_10_10_REV */
  69977. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69978. /** UNSIGNED_INT_24_8 */
  69979. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69980. /** UNSIGNED_INT_10F_11F_11F_REV */
  69981. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69982. /** UNSIGNED_INT_5_9_9_9_REV */
  69983. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69984. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69985. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69986. /** nearest is mag = nearest and min = nearest and mip = linear */
  69987. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69989. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69990. /** Trilinear is mag = linear and min = linear and mip = linear */
  69991. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69992. /** nearest is mag = nearest and min = nearest and mip = linear */
  69993. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69994. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69995. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69996. /** Trilinear is mag = linear and min = linear and mip = linear */
  69997. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69998. /** mag = nearest and min = nearest and mip = nearest */
  69999. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70000. /** mag = nearest and min = linear and mip = nearest */
  70001. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70002. /** mag = nearest and min = linear and mip = linear */
  70003. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70004. /** mag = nearest and min = linear and mip = none */
  70005. static readonly TEXTURE_NEAREST_LINEAR: number;
  70006. /** mag = nearest and min = nearest and mip = none */
  70007. static readonly TEXTURE_NEAREST_NEAREST: number;
  70008. /** mag = linear and min = nearest and mip = nearest */
  70009. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70010. /** mag = linear and min = nearest and mip = linear */
  70011. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70012. /** mag = linear and min = linear and mip = none */
  70013. static readonly TEXTURE_LINEAR_LINEAR: number;
  70014. /** mag = linear and min = nearest and mip = none */
  70015. static readonly TEXTURE_LINEAR_NEAREST: number;
  70016. /** Explicit coordinates mode */
  70017. static readonly TEXTURE_EXPLICIT_MODE: number;
  70018. /** Spherical coordinates mode */
  70019. static readonly TEXTURE_SPHERICAL_MODE: number;
  70020. /** Planar coordinates mode */
  70021. static readonly TEXTURE_PLANAR_MODE: number;
  70022. /** Cubic coordinates mode */
  70023. static readonly TEXTURE_CUBIC_MODE: number;
  70024. /** Projection coordinates mode */
  70025. static readonly TEXTURE_PROJECTION_MODE: number;
  70026. /** Skybox coordinates mode */
  70027. static readonly TEXTURE_SKYBOX_MODE: number;
  70028. /** Inverse Cubic coordinates mode */
  70029. static readonly TEXTURE_INVCUBIC_MODE: number;
  70030. /** Equirectangular coordinates mode */
  70031. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70032. /** Equirectangular Fixed coordinates mode */
  70033. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70034. /** Equirectangular Fixed Mirrored coordinates mode */
  70035. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70036. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70037. static readonly SCALEMODE_FLOOR: number;
  70038. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70039. static readonly SCALEMODE_NEAREST: number;
  70040. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70041. static readonly SCALEMODE_CEILING: number;
  70042. /**
  70043. * The dirty texture flag value
  70044. */
  70045. static readonly MATERIAL_TextureDirtyFlag: number;
  70046. /**
  70047. * The dirty light flag value
  70048. */
  70049. static readonly MATERIAL_LightDirtyFlag: number;
  70050. /**
  70051. * The dirty fresnel flag value
  70052. */
  70053. static readonly MATERIAL_FresnelDirtyFlag: number;
  70054. /**
  70055. * The dirty attribute flag value
  70056. */
  70057. static readonly MATERIAL_AttributesDirtyFlag: number;
  70058. /**
  70059. * The dirty misc flag value
  70060. */
  70061. static readonly MATERIAL_MiscDirtyFlag: number;
  70062. /**
  70063. * The all dirty flag value
  70064. */
  70065. static readonly MATERIAL_AllDirtyFlag: number;
  70066. /**
  70067. * Returns the triangle fill mode
  70068. */
  70069. static readonly MATERIAL_TriangleFillMode: number;
  70070. /**
  70071. * Returns the wireframe mode
  70072. */
  70073. static readonly MATERIAL_WireFrameFillMode: number;
  70074. /**
  70075. * Returns the point fill mode
  70076. */
  70077. static readonly MATERIAL_PointFillMode: number;
  70078. /**
  70079. * Returns the point list draw mode
  70080. */
  70081. static readonly MATERIAL_PointListDrawMode: number;
  70082. /**
  70083. * Returns the line list draw mode
  70084. */
  70085. static readonly MATERIAL_LineListDrawMode: number;
  70086. /**
  70087. * Returns the line loop draw mode
  70088. */
  70089. static readonly MATERIAL_LineLoopDrawMode: number;
  70090. /**
  70091. * Returns the line strip draw mode
  70092. */
  70093. static readonly MATERIAL_LineStripDrawMode: number;
  70094. /**
  70095. * Returns the triangle strip draw mode
  70096. */
  70097. static readonly MATERIAL_TriangleStripDrawMode: number;
  70098. /**
  70099. * Returns the triangle fan draw mode
  70100. */
  70101. static readonly MATERIAL_TriangleFanDrawMode: number;
  70102. /**
  70103. * Stores the clock-wise side orientation
  70104. */
  70105. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70106. /**
  70107. * Stores the counter clock-wise side orientation
  70108. */
  70109. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70110. /**
  70111. * Nothing
  70112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70113. */
  70114. static readonly ACTION_NothingTrigger: number;
  70115. /**
  70116. * On pick
  70117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70118. */
  70119. static readonly ACTION_OnPickTrigger: number;
  70120. /**
  70121. * On left pick
  70122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70123. */
  70124. static readonly ACTION_OnLeftPickTrigger: number;
  70125. /**
  70126. * On right pick
  70127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70128. */
  70129. static readonly ACTION_OnRightPickTrigger: number;
  70130. /**
  70131. * On center pick
  70132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70133. */
  70134. static readonly ACTION_OnCenterPickTrigger: number;
  70135. /**
  70136. * On pick down
  70137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70138. */
  70139. static readonly ACTION_OnPickDownTrigger: number;
  70140. /**
  70141. * On double pick
  70142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70143. */
  70144. static readonly ACTION_OnDoublePickTrigger: number;
  70145. /**
  70146. * On pick up
  70147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70148. */
  70149. static readonly ACTION_OnPickUpTrigger: number;
  70150. /**
  70151. * On pick out.
  70152. * This trigger will only be raised if you also declared a OnPickDown
  70153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70154. */
  70155. static readonly ACTION_OnPickOutTrigger: number;
  70156. /**
  70157. * On long press
  70158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70159. */
  70160. static readonly ACTION_OnLongPressTrigger: number;
  70161. /**
  70162. * On pointer over
  70163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70164. */
  70165. static readonly ACTION_OnPointerOverTrigger: number;
  70166. /**
  70167. * On pointer out
  70168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70169. */
  70170. static readonly ACTION_OnPointerOutTrigger: number;
  70171. /**
  70172. * On every frame
  70173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70174. */
  70175. static readonly ACTION_OnEveryFrameTrigger: number;
  70176. /**
  70177. * On intersection enter
  70178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70179. */
  70180. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70181. /**
  70182. * On intersection exit
  70183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70184. */
  70185. static readonly ACTION_OnIntersectionExitTrigger: number;
  70186. /**
  70187. * On key down
  70188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70189. */
  70190. static readonly ACTION_OnKeyDownTrigger: number;
  70191. /**
  70192. * On key up
  70193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70194. */
  70195. static readonly ACTION_OnKeyUpTrigger: number;
  70196. /**
  70197. * Billboard mode will only apply to Y axis
  70198. */
  70199. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70200. /**
  70201. * Billboard mode will apply to all axes
  70202. */
  70203. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70204. /**
  70205. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70206. */
  70207. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70208. /**
  70209. * Gets or sets base Assets URL
  70210. */
  70211. static PARTICLES_BaseAssetsUrl: string;
  70212. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70213. * Test order :
  70214. * Is the bounding sphere outside the frustum ?
  70215. * If not, are the bounding box vertices outside the frustum ?
  70216. * It not, then the cullable object is in the frustum.
  70217. */
  70218. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70219. /** Culling strategy : Bounding Sphere Only.
  70220. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70221. * It's also less accurate than the standard because some not visible objects can still be selected.
  70222. * Test : is the bounding sphere outside the frustum ?
  70223. * If not, then the cullable object is in the frustum.
  70224. */
  70225. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70226. /** Culling strategy : Optimistic Inclusion.
  70227. * This in an inclusion test first, then the standard exclusion test.
  70228. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70229. * 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.
  70230. * Anyway, it's as accurate as the standard strategy.
  70231. * Test :
  70232. * Is the cullable object bounding sphere center in the frustum ?
  70233. * If not, apply the default culling strategy.
  70234. */
  70235. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70236. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70237. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70238. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70239. * 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.
  70240. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70241. * Test :
  70242. * Is the cullable object bounding sphere center in the frustum ?
  70243. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70244. */
  70245. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70246. /**
  70247. * No logging while loading
  70248. */
  70249. static readonly SCENELOADER_NO_LOGGING: number;
  70250. /**
  70251. * Minimal logging while loading
  70252. */
  70253. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70254. /**
  70255. * Summary logging while loading
  70256. */
  70257. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70258. /**
  70259. * Detailled logging while loading
  70260. */
  70261. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70262. }
  70263. }
  70264. declare module BABYLON {
  70265. /**
  70266. * Class used to store and describe the pipeline context associated with an effect
  70267. */
  70268. export interface IPipelineContext {
  70269. /**
  70270. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70271. */
  70272. isAsync: boolean;
  70273. /**
  70274. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70275. */
  70276. isReady: boolean;
  70277. /** @hidden */
  70278. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70279. }
  70280. }
  70281. declare module BABYLON {
  70282. /** @hidden */
  70283. export interface IShaderProcessor {
  70284. attributeProcessor?: (attribute: string) => string;
  70285. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70286. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70287. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70288. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70289. lineProcessor?: (line: string, isFragment: boolean) => string;
  70290. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70291. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70292. }
  70293. }
  70294. declare module BABYLON {
  70295. /** @hidden */
  70296. export interface ProcessingOptions {
  70297. defines: string[];
  70298. indexParameters: any;
  70299. isFragment: boolean;
  70300. shouldUseHighPrecisionShader: boolean;
  70301. supportsUniformBuffers: boolean;
  70302. shadersRepository: string;
  70303. includesShadersStore: {
  70304. [key: string]: string;
  70305. };
  70306. processor?: IShaderProcessor;
  70307. version: string;
  70308. platformName: string;
  70309. lookForClosingBracketForUniformBuffer?: boolean;
  70310. }
  70311. }
  70312. declare module BABYLON {
  70313. /**
  70314. * Helper to manipulate strings
  70315. */
  70316. export class StringTools {
  70317. /**
  70318. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70319. * @param str Source string
  70320. * @param suffix Suffix to search for in the source string
  70321. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70322. */
  70323. static EndsWith(str: string, suffix: string): boolean;
  70324. /**
  70325. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70326. * @param str Source string
  70327. * @param suffix Suffix to search for in the source string
  70328. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70329. */
  70330. static StartsWith(str: string, suffix: string): boolean;
  70331. }
  70332. }
  70333. declare module BABYLON {
  70334. /** @hidden */
  70335. export class ShaderCodeNode {
  70336. line: string;
  70337. children: ShaderCodeNode[];
  70338. additionalDefineKey?: string;
  70339. additionalDefineValue?: string;
  70340. isValid(preprocessors: {
  70341. [key: string]: string;
  70342. }): boolean;
  70343. process(preprocessors: {
  70344. [key: string]: string;
  70345. }, options: ProcessingOptions): string;
  70346. }
  70347. }
  70348. declare module BABYLON {
  70349. /** @hidden */
  70350. export class ShaderCodeCursor {
  70351. private _lines;
  70352. lineIndex: number;
  70353. readonly currentLine: string;
  70354. readonly canRead: boolean;
  70355. lines: string[];
  70356. }
  70357. }
  70358. declare module BABYLON {
  70359. /** @hidden */
  70360. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70361. process(preprocessors: {
  70362. [key: string]: string;
  70363. }, options: ProcessingOptions): string;
  70364. }
  70365. }
  70366. declare module BABYLON {
  70367. /** @hidden */
  70368. export class ShaderDefineExpression {
  70369. isTrue(preprocessors: {
  70370. [key: string]: string;
  70371. }): boolean;
  70372. }
  70373. }
  70374. declare module BABYLON {
  70375. /** @hidden */
  70376. export class ShaderCodeTestNode extends ShaderCodeNode {
  70377. testExpression: ShaderDefineExpression;
  70378. isValid(preprocessors: {
  70379. [key: string]: string;
  70380. }): boolean;
  70381. }
  70382. }
  70383. declare module BABYLON {
  70384. /** @hidden */
  70385. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70386. define: string;
  70387. not: boolean;
  70388. constructor(define: string, not?: boolean);
  70389. isTrue(preprocessors: {
  70390. [key: string]: string;
  70391. }): boolean;
  70392. }
  70393. }
  70394. declare module BABYLON {
  70395. /** @hidden */
  70396. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70397. leftOperand: ShaderDefineExpression;
  70398. rightOperand: ShaderDefineExpression;
  70399. isTrue(preprocessors: {
  70400. [key: string]: string;
  70401. }): boolean;
  70402. }
  70403. }
  70404. declare module BABYLON {
  70405. /** @hidden */
  70406. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70407. leftOperand: ShaderDefineExpression;
  70408. rightOperand: ShaderDefineExpression;
  70409. isTrue(preprocessors: {
  70410. [key: string]: string;
  70411. }): boolean;
  70412. }
  70413. }
  70414. declare module BABYLON {
  70415. /** @hidden */
  70416. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70417. define: string;
  70418. operand: string;
  70419. testValue: string;
  70420. constructor(define: string, operand: string, testValue: string);
  70421. isTrue(preprocessors: {
  70422. [key: string]: string;
  70423. }): boolean;
  70424. }
  70425. }
  70426. declare module BABYLON {
  70427. /**
  70428. * @ignore
  70429. * Application error to support additional information when loading a file
  70430. */
  70431. export class LoadFileError extends Error {
  70432. /** defines the optional web request */
  70433. request?: WebRequest | undefined;
  70434. private static _setPrototypeOf;
  70435. /**
  70436. * Creates a new LoadFileError
  70437. * @param message defines the message of the error
  70438. * @param request defines the optional web request
  70439. */
  70440. constructor(message: string,
  70441. /** defines the optional web request */
  70442. request?: WebRequest | undefined);
  70443. }
  70444. }
  70445. declare module BABYLON {
  70446. /**
  70447. * Class used to enable access to offline support
  70448. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70449. */
  70450. export interface IOfflineProvider {
  70451. /**
  70452. * Gets a boolean indicating if scene must be saved in the database
  70453. */
  70454. enableSceneOffline: boolean;
  70455. /**
  70456. * Gets a boolean indicating if textures must be saved in the database
  70457. */
  70458. enableTexturesOffline: boolean;
  70459. /**
  70460. * Open the offline support and make it available
  70461. * @param successCallback defines the callback to call on success
  70462. * @param errorCallback defines the callback to call on error
  70463. */
  70464. open(successCallback: () => void, errorCallback: () => void): void;
  70465. /**
  70466. * Loads an image from the offline support
  70467. * @param url defines the url to load from
  70468. * @param image defines the target DOM image
  70469. */
  70470. loadImage(url: string, image: HTMLImageElement): void;
  70471. /**
  70472. * Loads a file from offline support
  70473. * @param url defines the URL to load from
  70474. * @param sceneLoaded defines a callback to call on success
  70475. * @param progressCallBack defines a callback to call when progress changed
  70476. * @param errorCallback defines a callback to call on error
  70477. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70478. */
  70479. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70480. }
  70481. }
  70482. declare module BABYLON {
  70483. /**
  70484. * Class used to help managing file picking and drag'n'drop
  70485. * File Storage
  70486. */
  70487. export class FilesInputStore {
  70488. /**
  70489. * List of files ready to be loaded
  70490. */
  70491. static FilesToLoad: {
  70492. [key: string]: File;
  70493. };
  70494. }
  70495. }
  70496. declare module BABYLON {
  70497. /**
  70498. * Class used to define a retry strategy when error happens while loading assets
  70499. */
  70500. export class RetryStrategy {
  70501. /**
  70502. * Function used to defines an exponential back off strategy
  70503. * @param maxRetries defines the maximum number of retries (3 by default)
  70504. * @param baseInterval defines the interval between retries
  70505. * @returns the strategy function to use
  70506. */
  70507. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70508. }
  70509. }
  70510. declare module BABYLON {
  70511. /**
  70512. * @hidden
  70513. */
  70514. export class FileTools {
  70515. /**
  70516. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70517. */
  70518. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70519. /**
  70520. * Gets or sets the base URL to use to load assets
  70521. */
  70522. static BaseUrl: string;
  70523. /**
  70524. * Default behaviour for cors in the application.
  70525. * It can be a string if the expected behavior is identical in the entire app.
  70526. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70527. */
  70528. static CorsBehavior: string | ((url: string | string[]) => string);
  70529. /**
  70530. * Gets or sets a function used to pre-process url before using them to load assets
  70531. */
  70532. static PreprocessUrl: (url: string) => string;
  70533. /**
  70534. * Removes unwanted characters from an url
  70535. * @param url defines the url to clean
  70536. * @returns the cleaned url
  70537. */
  70538. private static _CleanUrl;
  70539. /**
  70540. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70541. * @param url define the url we are trying
  70542. * @param element define the dom element where to configure the cors policy
  70543. */
  70544. static SetCorsBehavior(url: string | string[], element: {
  70545. crossOrigin: string | null;
  70546. }): void;
  70547. /**
  70548. * Loads an image as an HTMLImageElement.
  70549. * @param input url string, ArrayBuffer, or Blob to load
  70550. * @param onLoad callback called when the image successfully loads
  70551. * @param onError callback called when the image fails to load
  70552. * @param offlineProvider offline provider for caching
  70553. * @returns the HTMLImageElement of the loaded image
  70554. */
  70555. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70556. /**
  70557. * Loads a file
  70558. * @param fileToLoad defines the file to load
  70559. * @param callback defines the callback to call when data is loaded
  70560. * @param progressCallBack defines the callback to call during loading process
  70561. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70562. * @returns a file request object
  70563. */
  70564. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70565. /**
  70566. * Loads a file
  70567. * @param url url string, ArrayBuffer, or Blob to load
  70568. * @param onSuccess callback called when the file successfully loads
  70569. * @param onProgress callback called while file is loading (if the server supports this mode)
  70570. * @param offlineProvider defines the offline provider for caching
  70571. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70572. * @param onError callback called when the file fails to load
  70573. * @returns a file request object
  70574. */
  70575. 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;
  70576. /**
  70577. * Checks if the loaded document was accessed via `file:`-Protocol.
  70578. * @returns boolean
  70579. */
  70580. static IsFileURL(): boolean;
  70581. }
  70582. }
  70583. declare module BABYLON {
  70584. /** @hidden */
  70585. export class ShaderProcessor {
  70586. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70587. private static _ProcessPrecision;
  70588. private static _ExtractOperation;
  70589. private static _BuildSubExpression;
  70590. private static _BuildExpression;
  70591. private static _MoveCursorWithinIf;
  70592. private static _MoveCursor;
  70593. private static _EvaluatePreProcessors;
  70594. private static _PreparePreProcessors;
  70595. private static _ProcessShaderConversion;
  70596. private static _ProcessIncludes;
  70597. }
  70598. }
  70599. declare module BABYLON {
  70600. /**
  70601. * Class used to hold a RBG color
  70602. */
  70603. export class Color3 {
  70604. /**
  70605. * Defines the red component (between 0 and 1, default is 0)
  70606. */
  70607. r: number;
  70608. /**
  70609. * Defines the green component (between 0 and 1, default is 0)
  70610. */
  70611. g: number;
  70612. /**
  70613. * Defines the blue component (between 0 and 1, default is 0)
  70614. */
  70615. b: number;
  70616. /**
  70617. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70618. * @param r defines the red component (between 0 and 1, default is 0)
  70619. * @param g defines the green component (between 0 and 1, default is 0)
  70620. * @param b defines the blue component (between 0 and 1, default is 0)
  70621. */
  70622. constructor(
  70623. /**
  70624. * Defines the red component (between 0 and 1, default is 0)
  70625. */
  70626. r?: number,
  70627. /**
  70628. * Defines the green component (between 0 and 1, default is 0)
  70629. */
  70630. g?: number,
  70631. /**
  70632. * Defines the blue component (between 0 and 1, default is 0)
  70633. */
  70634. b?: number);
  70635. /**
  70636. * Creates a string with the Color3 current values
  70637. * @returns the string representation of the Color3 object
  70638. */
  70639. toString(): string;
  70640. /**
  70641. * Returns the string "Color3"
  70642. * @returns "Color3"
  70643. */
  70644. getClassName(): string;
  70645. /**
  70646. * Compute the Color3 hash code
  70647. * @returns an unique number that can be used to hash Color3 objects
  70648. */
  70649. getHashCode(): number;
  70650. /**
  70651. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70652. * @param array defines the array where to store the r,g,b components
  70653. * @param index defines an optional index in the target array to define where to start storing values
  70654. * @returns the current Color3 object
  70655. */
  70656. toArray(array: FloatArray, index?: number): Color3;
  70657. /**
  70658. * Returns a new Color4 object from the current Color3 and the given alpha
  70659. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70660. * @returns a new Color4 object
  70661. */
  70662. toColor4(alpha?: number): Color4;
  70663. /**
  70664. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70665. * @returns the new array
  70666. */
  70667. asArray(): number[];
  70668. /**
  70669. * Returns the luminance value
  70670. * @returns a float value
  70671. */
  70672. toLuminance(): number;
  70673. /**
  70674. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70675. * @param otherColor defines the second operand
  70676. * @returns the new Color3 object
  70677. */
  70678. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70679. /**
  70680. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70681. * @param otherColor defines the second operand
  70682. * @param result defines the Color3 object where to store the result
  70683. * @returns the current Color3
  70684. */
  70685. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70686. /**
  70687. * Determines equality between Color3 objects
  70688. * @param otherColor defines the second operand
  70689. * @returns true if the rgb values are equal to the given ones
  70690. */
  70691. equals(otherColor: DeepImmutable<Color3>): boolean;
  70692. /**
  70693. * Determines equality between the current Color3 object and a set of r,b,g values
  70694. * @param r defines the red component to check
  70695. * @param g defines the green component to check
  70696. * @param b defines the blue component to check
  70697. * @returns true if the rgb values are equal to the given ones
  70698. */
  70699. equalsFloats(r: number, g: number, b: number): boolean;
  70700. /**
  70701. * Multiplies in place each rgb value by scale
  70702. * @param scale defines the scaling factor
  70703. * @returns the updated Color3
  70704. */
  70705. scale(scale: number): Color3;
  70706. /**
  70707. * Multiplies the rgb values by scale and stores the result into "result"
  70708. * @param scale defines the scaling factor
  70709. * @param result defines the Color3 object where to store the result
  70710. * @returns the unmodified current Color3
  70711. */
  70712. scaleToRef(scale: number, result: Color3): Color3;
  70713. /**
  70714. * Scale the current Color3 values by a factor and add the result to a given Color3
  70715. * @param scale defines the scale factor
  70716. * @param result defines color to store the result into
  70717. * @returns the unmodified current Color3
  70718. */
  70719. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70720. /**
  70721. * Clamps the rgb values by the min and max values and stores the result into "result"
  70722. * @param min defines minimum clamping value (default is 0)
  70723. * @param max defines maximum clamping value (default is 1)
  70724. * @param result defines color to store the result into
  70725. * @returns the original Color3
  70726. */
  70727. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70728. /**
  70729. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70730. * @param otherColor defines the second operand
  70731. * @returns the new Color3
  70732. */
  70733. add(otherColor: DeepImmutable<Color3>): Color3;
  70734. /**
  70735. * Stores the result of the addition of the current Color3 and given one 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. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70741. /**
  70742. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70743. * @param otherColor defines the second operand
  70744. * @returns the new Color3
  70745. */
  70746. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70747. /**
  70748. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70749. * @param otherColor defines the second operand
  70750. * @param result defines Color3 object to store the result into
  70751. * @returns the unmodified current Color3
  70752. */
  70753. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70754. /**
  70755. * Copy the current object
  70756. * @returns a new Color3 copied the current one
  70757. */
  70758. clone(): Color3;
  70759. /**
  70760. * Copies the rgb values from the source in the current Color3
  70761. * @param source defines the source Color3 object
  70762. * @returns the updated Color3 object
  70763. */
  70764. copyFrom(source: DeepImmutable<Color3>): Color3;
  70765. /**
  70766. * Updates the Color3 rgb values from the given floats
  70767. * @param r defines the red component to read from
  70768. * @param g defines the green component to read from
  70769. * @param b defines the blue component to read from
  70770. * @returns the current Color3 object
  70771. */
  70772. copyFromFloats(r: number, g: number, b: number): Color3;
  70773. /**
  70774. * Updates the Color3 rgb values from the given floats
  70775. * @param r defines the red component to read from
  70776. * @param g defines the green component to read from
  70777. * @param b defines the blue component to read from
  70778. * @returns the current Color3 object
  70779. */
  70780. set(r: number, g: number, b: number): Color3;
  70781. /**
  70782. * Compute the Color3 hexadecimal code as a string
  70783. * @returns a string containing the hexadecimal representation of the Color3 object
  70784. */
  70785. toHexString(): string;
  70786. /**
  70787. * Computes a new Color3 converted from the current one to linear space
  70788. * @returns a new Color3 object
  70789. */
  70790. toLinearSpace(): Color3;
  70791. /**
  70792. * Converts current color in rgb space to HSV values
  70793. * @returns a new color3 representing the HSV values
  70794. */
  70795. toHSV(): Color3;
  70796. /**
  70797. * Converts current color in rgb space to HSV values
  70798. * @param result defines the Color3 where to store the HSV values
  70799. */
  70800. toHSVToRef(result: Color3): void;
  70801. /**
  70802. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70803. * @param convertedColor defines the Color3 object where to store the linear space version
  70804. * @returns the unmodified Color3
  70805. */
  70806. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70807. /**
  70808. * Computes a new Color3 converted from the current one to gamma space
  70809. * @returns a new Color3 object
  70810. */
  70811. toGammaSpace(): Color3;
  70812. /**
  70813. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70814. * @param convertedColor defines the Color3 object where to store the gamma space version
  70815. * @returns the unmodified Color3
  70816. */
  70817. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70818. private static _BlackReadOnly;
  70819. /**
  70820. * Convert Hue, saturation and value to a Color3 (RGB)
  70821. * @param hue defines the hue
  70822. * @param saturation defines the saturation
  70823. * @param value defines the value
  70824. * @param result defines the Color3 where to store the RGB values
  70825. */
  70826. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70827. /**
  70828. * Creates a new Color3 from the string containing valid hexadecimal values
  70829. * @param hex defines a string containing valid hexadecimal values
  70830. * @returns a new Color3 object
  70831. */
  70832. static FromHexString(hex: string): Color3;
  70833. /**
  70834. * Creates a new Color3 from the starting index of the given array
  70835. * @param array defines the source array
  70836. * @param offset defines an offset in the source array
  70837. * @returns a new Color3 object
  70838. */
  70839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70840. /**
  70841. * Creates a new Color3 from integer values (< 256)
  70842. * @param r defines the red component to read from (value between 0 and 255)
  70843. * @param g defines the green component to read from (value between 0 and 255)
  70844. * @param b defines the blue component to read from (value between 0 and 255)
  70845. * @returns a new Color3 object
  70846. */
  70847. static FromInts(r: number, g: number, b: number): Color3;
  70848. /**
  70849. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70850. * @param start defines the start Color3 value
  70851. * @param end defines the end Color3 value
  70852. * @param amount defines the gradient value between start and end
  70853. * @returns a new Color3 object
  70854. */
  70855. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70856. /**
  70857. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70858. * @param left defines the start value
  70859. * @param right defines the end value
  70860. * @param amount defines the gradient factor
  70861. * @param result defines the Color3 object where to store the result
  70862. */
  70863. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70864. /**
  70865. * Returns a Color3 value containing a red color
  70866. * @returns a new Color3 object
  70867. */
  70868. static Red(): Color3;
  70869. /**
  70870. * Returns a Color3 value containing a green color
  70871. * @returns a new Color3 object
  70872. */
  70873. static Green(): Color3;
  70874. /**
  70875. * Returns a Color3 value containing a blue color
  70876. * @returns a new Color3 object
  70877. */
  70878. static Blue(): Color3;
  70879. /**
  70880. * Returns a Color3 value containing a black color
  70881. * @returns a new Color3 object
  70882. */
  70883. static Black(): Color3;
  70884. /**
  70885. * Gets a Color3 value containing a black color that must not be updated
  70886. */
  70887. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70888. /**
  70889. * Returns a Color3 value containing a white color
  70890. * @returns a new Color3 object
  70891. */
  70892. static White(): Color3;
  70893. /**
  70894. * Returns a Color3 value containing a purple color
  70895. * @returns a new Color3 object
  70896. */
  70897. static Purple(): Color3;
  70898. /**
  70899. * Returns a Color3 value containing a magenta color
  70900. * @returns a new Color3 object
  70901. */
  70902. static Magenta(): Color3;
  70903. /**
  70904. * Returns a Color3 value containing a yellow color
  70905. * @returns a new Color3 object
  70906. */
  70907. static Yellow(): Color3;
  70908. /**
  70909. * Returns a Color3 value containing a gray color
  70910. * @returns a new Color3 object
  70911. */
  70912. static Gray(): Color3;
  70913. /**
  70914. * Returns a Color3 value containing a teal color
  70915. * @returns a new Color3 object
  70916. */
  70917. static Teal(): Color3;
  70918. /**
  70919. * Returns a Color3 value containing a random color
  70920. * @returns a new Color3 object
  70921. */
  70922. static Random(): Color3;
  70923. }
  70924. /**
  70925. * Class used to hold a RBGA color
  70926. */
  70927. export class Color4 {
  70928. /**
  70929. * Defines the red component (between 0 and 1, default is 0)
  70930. */
  70931. r: number;
  70932. /**
  70933. * Defines the green component (between 0 and 1, default is 0)
  70934. */
  70935. g: number;
  70936. /**
  70937. * Defines the blue component (between 0 and 1, default is 0)
  70938. */
  70939. b: number;
  70940. /**
  70941. * Defines the alpha component (between 0 and 1, default is 1)
  70942. */
  70943. a: number;
  70944. /**
  70945. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70946. * @param r defines the red component (between 0 and 1, default is 0)
  70947. * @param g defines the green component (between 0 and 1, default is 0)
  70948. * @param b defines the blue component (between 0 and 1, default is 0)
  70949. * @param a defines the alpha component (between 0 and 1, default is 1)
  70950. */
  70951. constructor(
  70952. /**
  70953. * Defines the red component (between 0 and 1, default is 0)
  70954. */
  70955. r?: number,
  70956. /**
  70957. * Defines the green component (between 0 and 1, default is 0)
  70958. */
  70959. g?: number,
  70960. /**
  70961. * Defines the blue component (between 0 and 1, default is 0)
  70962. */
  70963. b?: number,
  70964. /**
  70965. * Defines the alpha component (between 0 and 1, default is 1)
  70966. */
  70967. a?: number);
  70968. /**
  70969. * Adds in place the given Color4 values to the current Color4 object
  70970. * @param right defines the second operand
  70971. * @returns the current updated Color4 object
  70972. */
  70973. addInPlace(right: DeepImmutable<Color4>): Color4;
  70974. /**
  70975. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70976. * @returns the new array
  70977. */
  70978. asArray(): number[];
  70979. /**
  70980. * Stores from the starting index in the given array the Color4 successive values
  70981. * @param array defines the array where to store the r,g,b components
  70982. * @param index defines an optional index in the target array to define where to start storing values
  70983. * @returns the current Color4 object
  70984. */
  70985. toArray(array: number[], index?: number): Color4;
  70986. /**
  70987. * Determines equality between Color4 objects
  70988. * @param otherColor defines the second operand
  70989. * @returns true if the rgba values are equal to the given ones
  70990. */
  70991. equals(otherColor: DeepImmutable<Color4>): boolean;
  70992. /**
  70993. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70994. * @param right defines the second operand
  70995. * @returns a new Color4 object
  70996. */
  70997. add(right: DeepImmutable<Color4>): Color4;
  70998. /**
  70999. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71000. * @param right defines the second operand
  71001. * @returns a new Color4 object
  71002. */
  71003. subtract(right: DeepImmutable<Color4>): Color4;
  71004. /**
  71005. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71006. * @param right defines the second operand
  71007. * @param result defines the Color4 object where to store the result
  71008. * @returns the current Color4 object
  71009. */
  71010. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  71011. /**
  71012. * Creates a new Color4 with the current Color4 values multiplied by scale
  71013. * @param scale defines the scaling factor to apply
  71014. * @returns a new Color4 object
  71015. */
  71016. scale(scale: number): Color4;
  71017. /**
  71018. * Multiplies the current Color4 values by scale and stores the result in "result"
  71019. * @param scale defines the scaling factor to apply
  71020. * @param result defines the Color4 object where to store the result
  71021. * @returns the current unmodified Color4
  71022. */
  71023. scaleToRef(scale: number, result: Color4): Color4;
  71024. /**
  71025. * Scale the current Color4 values by a factor and add the result to a given Color4
  71026. * @param scale defines the scale factor
  71027. * @param result defines the Color4 object where to store the result
  71028. * @returns the unmodified current Color4
  71029. */
  71030. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71031. /**
  71032. * Clamps the rgb values by the min and max values and stores the result into "result"
  71033. * @param min defines minimum clamping value (default is 0)
  71034. * @param max defines maximum clamping value (default is 1)
  71035. * @param result defines color to store the result into.
  71036. * @returns the cuurent Color4
  71037. */
  71038. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71039. /**
  71040. * Multipy an Color4 value by another and return a new Color4 object
  71041. * @param color defines the Color4 value to multiply by
  71042. * @returns a new Color4 object
  71043. */
  71044. multiply(color: Color4): Color4;
  71045. /**
  71046. * Multipy a Color4 value by another and push the result in a reference value
  71047. * @param color defines the Color4 value to multiply by
  71048. * @param result defines the Color4 to fill the result in
  71049. * @returns the result Color4
  71050. */
  71051. multiplyToRef(color: Color4, result: Color4): Color4;
  71052. /**
  71053. * Creates a string with the Color4 current values
  71054. * @returns the string representation of the Color4 object
  71055. */
  71056. toString(): string;
  71057. /**
  71058. * Returns the string "Color4"
  71059. * @returns "Color4"
  71060. */
  71061. getClassName(): string;
  71062. /**
  71063. * Compute the Color4 hash code
  71064. * @returns an unique number that can be used to hash Color4 objects
  71065. */
  71066. getHashCode(): number;
  71067. /**
  71068. * Creates a new Color4 copied from the current one
  71069. * @returns a new Color4 object
  71070. */
  71071. clone(): Color4;
  71072. /**
  71073. * Copies the given Color4 values into the current one
  71074. * @param source defines the source Color4 object
  71075. * @returns the current updated Color4 object
  71076. */
  71077. copyFrom(source: Color4): Color4;
  71078. /**
  71079. * Copies the given float values into the current one
  71080. * @param r defines the red component to read from
  71081. * @param g defines the green component to read from
  71082. * @param b defines the blue component to read from
  71083. * @param a defines the alpha component to read from
  71084. * @returns the current updated Color4 object
  71085. */
  71086. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71087. /**
  71088. * Copies the given float values into the current one
  71089. * @param r defines the red component to read from
  71090. * @param g defines the green component to read from
  71091. * @param b defines the blue component to read from
  71092. * @param a defines the alpha component to read from
  71093. * @returns the current updated Color4 object
  71094. */
  71095. set(r: number, g: number, b: number, a: number): Color4;
  71096. /**
  71097. * Compute the Color4 hexadecimal code as a string
  71098. * @returns a string containing the hexadecimal representation of the Color4 object
  71099. */
  71100. toHexString(): string;
  71101. /**
  71102. * Computes a new Color4 converted from the current one to linear space
  71103. * @returns a new Color4 object
  71104. */
  71105. toLinearSpace(): Color4;
  71106. /**
  71107. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71108. * @param convertedColor defines the Color4 object where to store the linear space version
  71109. * @returns the unmodified Color4
  71110. */
  71111. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71112. /**
  71113. * Computes a new Color4 converted from the current one to gamma space
  71114. * @returns a new Color4 object
  71115. */
  71116. toGammaSpace(): Color4;
  71117. /**
  71118. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71119. * @param convertedColor defines the Color4 object where to store the gamma space version
  71120. * @returns the unmodified Color4
  71121. */
  71122. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71123. /**
  71124. * Creates a new Color4 from the string containing valid hexadecimal values
  71125. * @param hex defines a string containing valid hexadecimal values
  71126. * @returns a new Color4 object
  71127. */
  71128. static FromHexString(hex: string): Color4;
  71129. /**
  71130. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71131. * @param left defines the start value
  71132. * @param right defines the end value
  71133. * @param amount defines the gradient factor
  71134. * @returns a new Color4 object
  71135. */
  71136. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71137. /**
  71138. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71139. * @param left defines the start value
  71140. * @param right defines the end value
  71141. * @param amount defines the gradient factor
  71142. * @param result defines the Color4 object where to store data
  71143. */
  71144. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71145. /**
  71146. * Creates a new Color4 from a Color3 and an alpha value
  71147. * @param color3 defines the source Color3 to read from
  71148. * @param alpha defines the alpha component (1.0 by default)
  71149. * @returns a new Color4 object
  71150. */
  71151. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71152. /**
  71153. * Creates a new Color4 from the starting index element of the given array
  71154. * @param array defines the source array to read from
  71155. * @param offset defines the offset in the source array
  71156. * @returns a new Color4 object
  71157. */
  71158. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71159. /**
  71160. * Creates a new Color3 from integer values (< 256)
  71161. * @param r defines the red component to read from (value between 0 and 255)
  71162. * @param g defines the green component to read from (value between 0 and 255)
  71163. * @param b defines the blue component to read from (value between 0 and 255)
  71164. * @param a defines the alpha component to read from (value between 0 and 255)
  71165. * @returns a new Color3 object
  71166. */
  71167. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71168. /**
  71169. * Check the content of a given array and convert it to an array containing RGBA data
  71170. * If the original array was already containing count * 4 values then it is returned directly
  71171. * @param colors defines the array to check
  71172. * @param count defines the number of RGBA data to expect
  71173. * @returns an array containing count * 4 values (RGBA)
  71174. */
  71175. static CheckColors4(colors: number[], count: number): number[];
  71176. }
  71177. /**
  71178. * @hidden
  71179. */
  71180. export class TmpColors {
  71181. static Color3: Color3[];
  71182. static Color4: Color4[];
  71183. }
  71184. }
  71185. declare module BABYLON {
  71186. /**
  71187. * Class representing spherical harmonics coefficients to the 3rd degree
  71188. */
  71189. export class SphericalHarmonics {
  71190. /**
  71191. * Defines whether or not the harmonics have been prescaled for rendering.
  71192. */
  71193. preScaled: boolean;
  71194. /**
  71195. * The l0,0 coefficients of the spherical harmonics
  71196. */
  71197. l00: Vector3;
  71198. /**
  71199. * The l1,-1 coefficients of the spherical harmonics
  71200. */
  71201. l1_1: Vector3;
  71202. /**
  71203. * The l1,0 coefficients of the spherical harmonics
  71204. */
  71205. l10: Vector3;
  71206. /**
  71207. * The l1,1 coefficients of the spherical harmonics
  71208. */
  71209. l11: Vector3;
  71210. /**
  71211. * The l2,-2 coefficients of the spherical harmonics
  71212. */
  71213. l2_2: Vector3;
  71214. /**
  71215. * The l2,-1 coefficients of the spherical harmonics
  71216. */
  71217. l2_1: Vector3;
  71218. /**
  71219. * The l2,0 coefficients of the spherical harmonics
  71220. */
  71221. l20: Vector3;
  71222. /**
  71223. * The l2,1 coefficients of the spherical harmonics
  71224. */
  71225. l21: Vector3;
  71226. /**
  71227. * The l2,2 coefficients of the spherical harmonics
  71228. */
  71229. l22: Vector3;
  71230. /**
  71231. * Adds a light to the spherical harmonics
  71232. * @param direction the direction of the light
  71233. * @param color the color of the light
  71234. * @param deltaSolidAngle the delta solid angle of the light
  71235. */
  71236. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71237. /**
  71238. * Scales the spherical harmonics by the given amount
  71239. * @param scale the amount to scale
  71240. */
  71241. scaleInPlace(scale: number): void;
  71242. /**
  71243. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71244. *
  71245. * ```
  71246. * E_lm = A_l * L_lm
  71247. * ```
  71248. *
  71249. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71250. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71251. * the scaling factors are given in equation 9.
  71252. */
  71253. convertIncidentRadianceToIrradiance(): void;
  71254. /**
  71255. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71256. *
  71257. * ```
  71258. * L = (1/pi) * E * rho
  71259. * ```
  71260. *
  71261. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71262. */
  71263. convertIrradianceToLambertianRadiance(): void;
  71264. /**
  71265. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71266. * required operations at run time.
  71267. *
  71268. * This is simply done by scaling back the SH with Ylm constants parameter.
  71269. * The trigonometric part being applied by the shader at run time.
  71270. */
  71271. preScaleForRendering(): void;
  71272. /**
  71273. * Constructs a spherical harmonics from an array.
  71274. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71275. * @returns the spherical harmonics
  71276. */
  71277. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71278. /**
  71279. * Gets the spherical harmonics from polynomial
  71280. * @param polynomial the spherical polynomial
  71281. * @returns the spherical harmonics
  71282. */
  71283. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71284. }
  71285. /**
  71286. * Class representing spherical polynomial coefficients to the 3rd degree
  71287. */
  71288. export class SphericalPolynomial {
  71289. private _harmonics;
  71290. /**
  71291. * The spherical harmonics used to create the polynomials.
  71292. */
  71293. readonly preScaledHarmonics: SphericalHarmonics;
  71294. /**
  71295. * The x coefficients of the spherical polynomial
  71296. */
  71297. x: Vector3;
  71298. /**
  71299. * The y coefficients of the spherical polynomial
  71300. */
  71301. y: Vector3;
  71302. /**
  71303. * The z coefficients of the spherical polynomial
  71304. */
  71305. z: Vector3;
  71306. /**
  71307. * The xx coefficients of the spherical polynomial
  71308. */
  71309. xx: Vector3;
  71310. /**
  71311. * The yy coefficients of the spherical polynomial
  71312. */
  71313. yy: Vector3;
  71314. /**
  71315. * The zz coefficients of the spherical polynomial
  71316. */
  71317. zz: Vector3;
  71318. /**
  71319. * The xy coefficients of the spherical polynomial
  71320. */
  71321. xy: Vector3;
  71322. /**
  71323. * The yz coefficients of the spherical polynomial
  71324. */
  71325. yz: Vector3;
  71326. /**
  71327. * The zx coefficients of the spherical polynomial
  71328. */
  71329. zx: Vector3;
  71330. /**
  71331. * Adds an ambient color to the spherical polynomial
  71332. * @param color the color to add
  71333. */
  71334. addAmbient(color: Color3): void;
  71335. /**
  71336. * Scales the spherical polynomial by the given amount
  71337. * @param scale the amount to scale
  71338. */
  71339. scaleInPlace(scale: number): void;
  71340. /**
  71341. * Gets the spherical polynomial from harmonics
  71342. * @param harmonics the spherical harmonics
  71343. * @returns the spherical polynomial
  71344. */
  71345. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71346. /**
  71347. * Constructs a spherical polynomial from an array.
  71348. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71349. * @returns the spherical polynomial
  71350. */
  71351. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71352. }
  71353. }
  71354. declare module BABYLON {
  71355. /**
  71356. * Define options used to create a render target texture
  71357. */
  71358. export class RenderTargetCreationOptions {
  71359. /**
  71360. * Specifies is mipmaps must be generated
  71361. */
  71362. generateMipMaps?: boolean;
  71363. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71364. generateDepthBuffer?: boolean;
  71365. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71366. generateStencilBuffer?: boolean;
  71367. /** Defines texture type (int by default) */
  71368. type?: number;
  71369. /** Defines sampling mode (trilinear by default) */
  71370. samplingMode?: number;
  71371. /** Defines format (RGBA by default) */
  71372. format?: number;
  71373. }
  71374. }
  71375. declare module BABYLON {
  71376. /**
  71377. * @hidden
  71378. **/
  71379. export class _AlphaState {
  71380. private _isAlphaBlendDirty;
  71381. private _isBlendFunctionParametersDirty;
  71382. private _isBlendEquationParametersDirty;
  71383. private _isBlendConstantsDirty;
  71384. private _alphaBlend;
  71385. private _blendFunctionParameters;
  71386. private _blendEquationParameters;
  71387. private _blendConstants;
  71388. /**
  71389. * Initializes the state.
  71390. */
  71391. constructor();
  71392. readonly isDirty: boolean;
  71393. alphaBlend: boolean;
  71394. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71395. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71396. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71397. reset(): void;
  71398. apply(gl: WebGLRenderingContext): void;
  71399. }
  71400. }
  71401. declare module BABYLON {
  71402. /**
  71403. * @hidden
  71404. **/
  71405. export class _DepthCullingState {
  71406. private _isDepthTestDirty;
  71407. private _isDepthMaskDirty;
  71408. private _isDepthFuncDirty;
  71409. private _isCullFaceDirty;
  71410. private _isCullDirty;
  71411. private _isZOffsetDirty;
  71412. private _isFrontFaceDirty;
  71413. private _depthTest;
  71414. private _depthMask;
  71415. private _depthFunc;
  71416. private _cull;
  71417. private _cullFace;
  71418. private _zOffset;
  71419. private _frontFace;
  71420. /**
  71421. * Initializes the state.
  71422. */
  71423. constructor();
  71424. readonly isDirty: boolean;
  71425. zOffset: number;
  71426. cullFace: Nullable<number>;
  71427. cull: Nullable<boolean>;
  71428. depthFunc: Nullable<number>;
  71429. depthMask: boolean;
  71430. depthTest: boolean;
  71431. frontFace: Nullable<number>;
  71432. reset(): void;
  71433. apply(gl: WebGLRenderingContext): void;
  71434. }
  71435. }
  71436. declare module BABYLON {
  71437. /**
  71438. * @hidden
  71439. **/
  71440. export class _StencilState {
  71441. /** 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 */
  71442. static readonly ALWAYS: number;
  71443. /** Passed to stencilOperation to specify that stencil value must be kept */
  71444. static readonly KEEP: number;
  71445. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71446. static readonly REPLACE: number;
  71447. private _isStencilTestDirty;
  71448. private _isStencilMaskDirty;
  71449. private _isStencilFuncDirty;
  71450. private _isStencilOpDirty;
  71451. private _stencilTest;
  71452. private _stencilMask;
  71453. private _stencilFunc;
  71454. private _stencilFuncRef;
  71455. private _stencilFuncMask;
  71456. private _stencilOpStencilFail;
  71457. private _stencilOpDepthFail;
  71458. private _stencilOpStencilDepthPass;
  71459. readonly isDirty: boolean;
  71460. stencilFunc: number;
  71461. stencilFuncRef: number;
  71462. stencilFuncMask: number;
  71463. stencilOpStencilFail: number;
  71464. stencilOpDepthFail: number;
  71465. stencilOpStencilDepthPass: number;
  71466. stencilMask: number;
  71467. stencilTest: boolean;
  71468. constructor();
  71469. reset(): void;
  71470. apply(gl: WebGLRenderingContext): void;
  71471. }
  71472. }
  71473. declare module BABYLON {
  71474. /**
  71475. * @hidden
  71476. **/
  71477. export class _TimeToken {
  71478. _startTimeQuery: Nullable<WebGLQuery>;
  71479. _endTimeQuery: Nullable<WebGLQuery>;
  71480. _timeElapsedQuery: Nullable<WebGLQuery>;
  71481. _timeElapsedQueryEnded: boolean;
  71482. }
  71483. }
  71484. declare module BABYLON {
  71485. /**
  71486. * Class used to evalaute queries containing `and` and `or` operators
  71487. */
  71488. export class AndOrNotEvaluator {
  71489. /**
  71490. * Evaluate a query
  71491. * @param query defines the query to evaluate
  71492. * @param evaluateCallback defines the callback used to filter result
  71493. * @returns true if the query matches
  71494. */
  71495. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71496. private static _HandleParenthesisContent;
  71497. private static _SimplifyNegation;
  71498. }
  71499. }
  71500. declare module BABYLON {
  71501. /**
  71502. * Class used to store custom tags
  71503. */
  71504. export class Tags {
  71505. /**
  71506. * Adds support for tags on the given object
  71507. * @param obj defines the object to use
  71508. */
  71509. static EnableFor(obj: any): void;
  71510. /**
  71511. * Removes tags support
  71512. * @param obj defines the object to use
  71513. */
  71514. static DisableFor(obj: any): void;
  71515. /**
  71516. * Gets a boolean indicating if the given object has tags
  71517. * @param obj defines the object to use
  71518. * @returns a boolean
  71519. */
  71520. static HasTags(obj: any): boolean;
  71521. /**
  71522. * Gets the tags available on a given object
  71523. * @param obj defines the object to use
  71524. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71525. * @returns the tags
  71526. */
  71527. static GetTags(obj: any, asString?: boolean): any;
  71528. /**
  71529. * Adds tags to an object
  71530. * @param obj defines the object to use
  71531. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71532. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71533. */
  71534. static AddTagsTo(obj: any, tagsString: string): void;
  71535. /**
  71536. * @hidden
  71537. */
  71538. static _AddTagTo(obj: any, tag: string): void;
  71539. /**
  71540. * Removes specific tags from a specific object
  71541. * @param obj defines the object to use
  71542. * @param tagsString defines the tags to remove
  71543. */
  71544. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71545. /**
  71546. * @hidden
  71547. */
  71548. static _RemoveTagFrom(obj: any, tag: string): void;
  71549. /**
  71550. * Defines if tags hosted on an object match a given query
  71551. * @param obj defines the object to use
  71552. * @param tagsQuery defines the tag query
  71553. * @returns a boolean
  71554. */
  71555. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71556. }
  71557. }
  71558. declare module BABYLON {
  71559. /**
  71560. * Defines potential orientation for back face culling
  71561. */
  71562. export enum Orientation {
  71563. /**
  71564. * Clockwise
  71565. */
  71566. CW = 0,
  71567. /** Counter clockwise */
  71568. CCW = 1
  71569. }
  71570. /** Class used to represent a Bezier curve */
  71571. export class BezierCurve {
  71572. /**
  71573. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71574. * @param t defines the time
  71575. * @param x1 defines the left coordinate on X axis
  71576. * @param y1 defines the left coordinate on Y axis
  71577. * @param x2 defines the right coordinate on X axis
  71578. * @param y2 defines the right coordinate on Y axis
  71579. * @returns the interpolated value
  71580. */
  71581. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71582. }
  71583. /**
  71584. * Defines angle representation
  71585. */
  71586. export class Angle {
  71587. private _radians;
  71588. /**
  71589. * Creates an Angle object of "radians" radians (float).
  71590. * @param radians the angle in radians
  71591. */
  71592. constructor(radians: number);
  71593. /**
  71594. * Get value in degrees
  71595. * @returns the Angle value in degrees (float)
  71596. */
  71597. degrees(): number;
  71598. /**
  71599. * Get value in radians
  71600. * @returns the Angle value in radians (float)
  71601. */
  71602. radians(): number;
  71603. /**
  71604. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71605. * @param a defines first vector
  71606. * @param b defines second vector
  71607. * @returns a new Angle
  71608. */
  71609. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71610. /**
  71611. * Gets a new Angle object from the given float in radians
  71612. * @param radians defines the angle value in radians
  71613. * @returns a new Angle
  71614. */
  71615. static FromRadians(radians: number): Angle;
  71616. /**
  71617. * Gets a new Angle object from the given float in degrees
  71618. * @param degrees defines the angle value in degrees
  71619. * @returns a new Angle
  71620. */
  71621. static FromDegrees(degrees: number): Angle;
  71622. }
  71623. /**
  71624. * This represents an arc in a 2d space.
  71625. */
  71626. export class Arc2 {
  71627. /** Defines the start point of the arc */
  71628. startPoint: Vector2;
  71629. /** Defines the mid point of the arc */
  71630. midPoint: Vector2;
  71631. /** Defines the end point of the arc */
  71632. endPoint: Vector2;
  71633. /**
  71634. * Defines the center point of the arc.
  71635. */
  71636. centerPoint: Vector2;
  71637. /**
  71638. * Defines the radius of the arc.
  71639. */
  71640. radius: number;
  71641. /**
  71642. * Defines the angle of the arc (from mid point to end point).
  71643. */
  71644. angle: Angle;
  71645. /**
  71646. * Defines the start angle of the arc (from start point to middle point).
  71647. */
  71648. startAngle: Angle;
  71649. /**
  71650. * Defines the orientation of the arc (clock wise/counter clock wise).
  71651. */
  71652. orientation: Orientation;
  71653. /**
  71654. * Creates an Arc object from the three given points : start, middle and end.
  71655. * @param startPoint Defines the start point of the arc
  71656. * @param midPoint Defines the midlle point of the arc
  71657. * @param endPoint Defines the end point of the arc
  71658. */
  71659. constructor(
  71660. /** Defines the start point of the arc */
  71661. startPoint: Vector2,
  71662. /** Defines the mid point of the arc */
  71663. midPoint: Vector2,
  71664. /** Defines the end point of the arc */
  71665. endPoint: Vector2);
  71666. }
  71667. /**
  71668. * Represents a 2D path made up of multiple 2D points
  71669. */
  71670. export class Path2 {
  71671. private _points;
  71672. private _length;
  71673. /**
  71674. * If the path start and end point are the same
  71675. */
  71676. closed: boolean;
  71677. /**
  71678. * Creates a Path2 object from the starting 2D coordinates x and y.
  71679. * @param x the starting points x value
  71680. * @param y the starting points y value
  71681. */
  71682. constructor(x: number, y: number);
  71683. /**
  71684. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71685. * @param x the added points x value
  71686. * @param y the added points y value
  71687. * @returns the updated Path2.
  71688. */
  71689. addLineTo(x: number, y: number): Path2;
  71690. /**
  71691. * 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.
  71692. * @param midX middle point x value
  71693. * @param midY middle point y value
  71694. * @param endX end point x value
  71695. * @param endY end point y value
  71696. * @param numberOfSegments (default: 36)
  71697. * @returns the updated Path2.
  71698. */
  71699. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71700. /**
  71701. * Closes the Path2.
  71702. * @returns the Path2.
  71703. */
  71704. close(): Path2;
  71705. /**
  71706. * Gets the sum of the distance between each sequential point in the path
  71707. * @returns the Path2 total length (float).
  71708. */
  71709. length(): number;
  71710. /**
  71711. * Gets the points which construct the path
  71712. * @returns the Path2 internal array of points.
  71713. */
  71714. getPoints(): Vector2[];
  71715. /**
  71716. * Retreives the point at the distance aways from the starting point
  71717. * @param normalizedLengthPosition the length along the path to retreive the point from
  71718. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71719. */
  71720. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71721. /**
  71722. * Creates a new path starting from an x and y position
  71723. * @param x starting x value
  71724. * @param y starting y value
  71725. * @returns a new Path2 starting at the coordinates (x, y).
  71726. */
  71727. static StartingAt(x: number, y: number): Path2;
  71728. }
  71729. /**
  71730. * Represents a 3D path made up of multiple 3D points
  71731. */
  71732. export class Path3D {
  71733. /**
  71734. * an array of Vector3, the curve axis of the Path3D
  71735. */
  71736. path: Vector3[];
  71737. private _curve;
  71738. private _distances;
  71739. private _tangents;
  71740. private _normals;
  71741. private _binormals;
  71742. private _raw;
  71743. /**
  71744. * new Path3D(path, normal, raw)
  71745. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71746. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71747. * @param path an array of Vector3, the curve axis of the Path3D
  71748. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71749. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71750. */
  71751. constructor(
  71752. /**
  71753. * an array of Vector3, the curve axis of the Path3D
  71754. */
  71755. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71756. /**
  71757. * Returns the Path3D array of successive Vector3 designing its curve.
  71758. * @returns the Path3D array of successive Vector3 designing its curve.
  71759. */
  71760. getCurve(): Vector3[];
  71761. /**
  71762. * Returns an array populated with tangent vectors on each Path3D curve point.
  71763. * @returns an array populated with tangent vectors on each Path3D curve point.
  71764. */
  71765. getTangents(): Vector3[];
  71766. /**
  71767. * Returns an array populated with normal vectors on each Path3D curve point.
  71768. * @returns an array populated with normal vectors on each Path3D curve point.
  71769. */
  71770. getNormals(): Vector3[];
  71771. /**
  71772. * Returns an array populated with binormal vectors on each Path3D curve point.
  71773. * @returns an array populated with binormal vectors on each Path3D curve point.
  71774. */
  71775. getBinormals(): Vector3[];
  71776. /**
  71777. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71778. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71779. */
  71780. getDistances(): number[];
  71781. /**
  71782. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71783. * @param path path which all values are copied into the curves points
  71784. * @param firstNormal which should be projected onto the curve
  71785. * @returns the same object updated.
  71786. */
  71787. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71788. private _compute;
  71789. private _getFirstNonNullVector;
  71790. private _getLastNonNullVector;
  71791. private _normalVector;
  71792. }
  71793. /**
  71794. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71795. * A Curve3 is designed from a series of successive Vector3.
  71796. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71797. */
  71798. export class Curve3 {
  71799. private _points;
  71800. private _length;
  71801. /**
  71802. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71803. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71804. * @param v1 (Vector3) the control point
  71805. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71806. * @param nbPoints (integer) the wanted number of points in the curve
  71807. * @returns the created Curve3
  71808. */
  71809. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71810. /**
  71811. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71812. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71813. * @param v1 (Vector3) the first control point
  71814. * @param v2 (Vector3) the second control point
  71815. * @param v3 (Vector3) the end point of the Cubic Bezier
  71816. * @param nbPoints (integer) the wanted number of points in the curve
  71817. * @returns the created Curve3
  71818. */
  71819. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71820. /**
  71821. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71822. * @param p1 (Vector3) the origin point of the Hermite Spline
  71823. * @param t1 (Vector3) the tangent vector at the origin point
  71824. * @param p2 (Vector3) the end point of the Hermite Spline
  71825. * @param t2 (Vector3) the tangent vector at the end point
  71826. * @param nbPoints (integer) the wanted number of points in the curve
  71827. * @returns the created Curve3
  71828. */
  71829. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71830. /**
  71831. * Returns a Curve3 object along a CatmullRom Spline curve :
  71832. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71833. * @param nbPoints (integer) the wanted number of points between each curve control points
  71834. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71835. * @returns the created Curve3
  71836. */
  71837. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71838. /**
  71839. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71840. * A Curve3 is designed from a series of successive Vector3.
  71841. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71842. * @param points points which make up the curve
  71843. */
  71844. constructor(points: Vector3[]);
  71845. /**
  71846. * @returns the Curve3 stored array of successive Vector3
  71847. */
  71848. getPoints(): Vector3[];
  71849. /**
  71850. * @returns the computed length (float) of the curve.
  71851. */
  71852. length(): number;
  71853. /**
  71854. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71855. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71856. * curveA and curveB keep unchanged.
  71857. * @param curve the curve to continue from this curve
  71858. * @returns the newly constructed curve
  71859. */
  71860. continue(curve: DeepImmutable<Curve3>): Curve3;
  71861. private _computeLength;
  71862. }
  71863. }
  71864. declare module BABYLON {
  71865. /**
  71866. * This represents the main contract an easing function should follow.
  71867. * Easing functions are used throughout the animation system.
  71868. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71869. */
  71870. export interface IEasingFunction {
  71871. /**
  71872. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71873. * of the easing function.
  71874. * The link below provides some of the most common examples of easing functions.
  71875. * @see https://easings.net/
  71876. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71877. * @returns the corresponding value on the curve defined by the easing function
  71878. */
  71879. ease(gradient: number): number;
  71880. }
  71881. /**
  71882. * Base class used for every default easing function.
  71883. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71884. */
  71885. export class EasingFunction implements IEasingFunction {
  71886. /**
  71887. * Interpolation follows the mathematical formula associated with the easing function.
  71888. */
  71889. static readonly EASINGMODE_EASEIN: number;
  71890. /**
  71891. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71892. */
  71893. static readonly EASINGMODE_EASEOUT: number;
  71894. /**
  71895. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71896. */
  71897. static readonly EASINGMODE_EASEINOUT: number;
  71898. private _easingMode;
  71899. /**
  71900. * Sets the easing mode of the current function.
  71901. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71902. */
  71903. setEasingMode(easingMode: number): void;
  71904. /**
  71905. * Gets the current easing mode.
  71906. * @returns the easing mode
  71907. */
  71908. getEasingMode(): number;
  71909. /**
  71910. * @hidden
  71911. */
  71912. easeInCore(gradient: number): number;
  71913. /**
  71914. * Given an input gradient between 0 and 1, this returns the corresponding value
  71915. * of the easing function.
  71916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71917. * @returns the corresponding value on the curve defined by the easing function
  71918. */
  71919. ease(gradient: number): number;
  71920. }
  71921. /**
  71922. * Easing function with a circle shape (see link below).
  71923. * @see https://easings.net/#easeInCirc
  71924. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71925. */
  71926. export class CircleEase extends EasingFunction implements IEasingFunction {
  71927. /** @hidden */
  71928. easeInCore(gradient: number): number;
  71929. }
  71930. /**
  71931. * Easing function with a ease back shape (see link below).
  71932. * @see https://easings.net/#easeInBack
  71933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71934. */
  71935. export class BackEase extends EasingFunction implements IEasingFunction {
  71936. /** Defines the amplitude of the function */
  71937. amplitude: number;
  71938. /**
  71939. * Instantiates a back ease easing
  71940. * @see https://easings.net/#easeInBack
  71941. * @param amplitude Defines the amplitude of the function
  71942. */
  71943. constructor(
  71944. /** Defines the amplitude of the function */
  71945. amplitude?: number);
  71946. /** @hidden */
  71947. easeInCore(gradient: number): number;
  71948. }
  71949. /**
  71950. * Easing function with a bouncing shape (see link below).
  71951. * @see https://easings.net/#easeInBounce
  71952. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71953. */
  71954. export class BounceEase extends EasingFunction implements IEasingFunction {
  71955. /** Defines the number of bounces */
  71956. bounces: number;
  71957. /** Defines the amplitude of the bounce */
  71958. bounciness: number;
  71959. /**
  71960. * Instantiates a bounce easing
  71961. * @see https://easings.net/#easeInBounce
  71962. * @param bounces Defines the number of bounces
  71963. * @param bounciness Defines the amplitude of the bounce
  71964. */
  71965. constructor(
  71966. /** Defines the number of bounces */
  71967. bounces?: number,
  71968. /** Defines the amplitude of the bounce */
  71969. bounciness?: number);
  71970. /** @hidden */
  71971. easeInCore(gradient: number): number;
  71972. }
  71973. /**
  71974. * Easing function with a power of 3 shape (see link below).
  71975. * @see https://easings.net/#easeInCubic
  71976. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71977. */
  71978. export class CubicEase extends EasingFunction implements IEasingFunction {
  71979. /** @hidden */
  71980. easeInCore(gradient: number): number;
  71981. }
  71982. /**
  71983. * Easing function with an elastic shape (see link below).
  71984. * @see https://easings.net/#easeInElastic
  71985. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71986. */
  71987. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71988. /** Defines the number of oscillations*/
  71989. oscillations: number;
  71990. /** Defines the amplitude of the oscillations*/
  71991. springiness: number;
  71992. /**
  71993. * Instantiates an elastic easing function
  71994. * @see https://easings.net/#easeInElastic
  71995. * @param oscillations Defines the number of oscillations
  71996. * @param springiness Defines the amplitude of the oscillations
  71997. */
  71998. constructor(
  71999. /** Defines the number of oscillations*/
  72000. oscillations?: number,
  72001. /** Defines the amplitude of the oscillations*/
  72002. springiness?: number);
  72003. /** @hidden */
  72004. easeInCore(gradient: number): number;
  72005. }
  72006. /**
  72007. * Easing function with an exponential shape (see link below).
  72008. * @see https://easings.net/#easeInExpo
  72009. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72010. */
  72011. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72012. /** Defines the exponent of the function */
  72013. exponent: number;
  72014. /**
  72015. * Instantiates an exponential easing function
  72016. * @see https://easings.net/#easeInExpo
  72017. * @param exponent Defines the exponent of the function
  72018. */
  72019. constructor(
  72020. /** Defines the exponent of the function */
  72021. exponent?: number);
  72022. /** @hidden */
  72023. easeInCore(gradient: number): number;
  72024. }
  72025. /**
  72026. * Easing function with a power shape (see link below).
  72027. * @see https://easings.net/#easeInQuad
  72028. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72029. */
  72030. export class PowerEase extends EasingFunction implements IEasingFunction {
  72031. /** Defines the power of the function */
  72032. power: number;
  72033. /**
  72034. * Instantiates an power base easing function
  72035. * @see https://easings.net/#easeInQuad
  72036. * @param power Defines the power of the function
  72037. */
  72038. constructor(
  72039. /** Defines the power of the function */
  72040. power?: number);
  72041. /** @hidden */
  72042. easeInCore(gradient: number): number;
  72043. }
  72044. /**
  72045. * Easing function with a power of 2 shape (see link below).
  72046. * @see https://easings.net/#easeInQuad
  72047. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72048. */
  72049. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72050. /** @hidden */
  72051. easeInCore(gradient: number): number;
  72052. }
  72053. /**
  72054. * Easing function with a power of 4 shape (see link below).
  72055. * @see https://easings.net/#easeInQuart
  72056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72057. */
  72058. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72059. /** @hidden */
  72060. easeInCore(gradient: number): number;
  72061. }
  72062. /**
  72063. * Easing function with a power of 5 shape (see link below).
  72064. * @see https://easings.net/#easeInQuint
  72065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72066. */
  72067. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72068. /** @hidden */
  72069. easeInCore(gradient: number): number;
  72070. }
  72071. /**
  72072. * Easing function with a sin shape (see link below).
  72073. * @see https://easings.net/#easeInSine
  72074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72075. */
  72076. export class SineEase extends EasingFunction implements IEasingFunction {
  72077. /** @hidden */
  72078. easeInCore(gradient: number): number;
  72079. }
  72080. /**
  72081. * Easing function with a bezier shape (see link below).
  72082. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72084. */
  72085. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72086. /** Defines the x component of the start tangent in the bezier curve */
  72087. x1: number;
  72088. /** Defines the y component of the start tangent in the bezier curve */
  72089. y1: number;
  72090. /** Defines the x component of the end tangent in the bezier curve */
  72091. x2: number;
  72092. /** Defines the y component of the end tangent in the bezier curve */
  72093. y2: number;
  72094. /**
  72095. * Instantiates a bezier function
  72096. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72097. * @param x1 Defines the x component of the start tangent in the bezier curve
  72098. * @param y1 Defines the y component of the start tangent in the bezier curve
  72099. * @param x2 Defines the x component of the end tangent in the bezier curve
  72100. * @param y2 Defines the y component of the end tangent in the bezier curve
  72101. */
  72102. constructor(
  72103. /** Defines the x component of the start tangent in the bezier curve */
  72104. x1?: number,
  72105. /** Defines the y component of the start tangent in the bezier curve */
  72106. y1?: number,
  72107. /** Defines the x component of the end tangent in the bezier curve */
  72108. x2?: number,
  72109. /** Defines the y component of the end tangent in the bezier curve */
  72110. y2?: number);
  72111. /** @hidden */
  72112. easeInCore(gradient: number): number;
  72113. }
  72114. }
  72115. declare module BABYLON {
  72116. /**
  72117. * Defines an interface which represents an animation key frame
  72118. */
  72119. export interface IAnimationKey {
  72120. /**
  72121. * Frame of the key frame
  72122. */
  72123. frame: number;
  72124. /**
  72125. * Value at the specifies key frame
  72126. */
  72127. value: any;
  72128. /**
  72129. * The input tangent for the cubic hermite spline
  72130. */
  72131. inTangent?: any;
  72132. /**
  72133. * The output tangent for the cubic hermite spline
  72134. */
  72135. outTangent?: any;
  72136. /**
  72137. * The animation interpolation type
  72138. */
  72139. interpolation?: AnimationKeyInterpolation;
  72140. }
  72141. /**
  72142. * Enum for the animation key frame interpolation type
  72143. */
  72144. export enum AnimationKeyInterpolation {
  72145. /**
  72146. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72147. */
  72148. STEP = 1
  72149. }
  72150. }
  72151. declare module BABYLON {
  72152. /**
  72153. * Represents the range of an animation
  72154. */
  72155. export class AnimationRange {
  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. * Initializes the range of an animation
  72164. * @param name The name of the animation range
  72165. * @param from The starting frame of the animation
  72166. * @param to The ending frame of the animation
  72167. */
  72168. constructor(
  72169. /**The name of the animation range**/
  72170. name: string,
  72171. /**The starting frame of the animation */
  72172. from: number,
  72173. /**The ending frame of the animation*/
  72174. to: number);
  72175. /**
  72176. * Makes a copy of the animation range
  72177. * @returns A copy of the animation range
  72178. */
  72179. clone(): AnimationRange;
  72180. }
  72181. }
  72182. declare module BABYLON {
  72183. /**
  72184. * Composed of a frame, and an action function
  72185. */
  72186. export class AnimationEvent {
  72187. /** The frame for which the event is triggered **/
  72188. frame: number;
  72189. /** The event to perform when triggered **/
  72190. action: (currentFrame: number) => void;
  72191. /** Specifies if the event should be triggered only once**/
  72192. onlyOnce?: boolean | undefined;
  72193. /**
  72194. * Specifies if the animation event is done
  72195. */
  72196. isDone: boolean;
  72197. /**
  72198. * Initializes the animation event
  72199. * @param frame The frame for which the event is triggered
  72200. * @param action The event to perform when triggered
  72201. * @param onlyOnce Specifies if the event should be triggered only once
  72202. */
  72203. constructor(
  72204. /** The frame for which the event is triggered **/
  72205. frame: number,
  72206. /** The event to perform when triggered **/
  72207. action: (currentFrame: number) => void,
  72208. /** Specifies if the event should be triggered only once**/
  72209. onlyOnce?: boolean | undefined);
  72210. /** @hidden */
  72211. _clone(): AnimationEvent;
  72212. }
  72213. }
  72214. declare module BABYLON {
  72215. /**
  72216. * Interface used to define a behavior
  72217. */
  72218. export interface Behavior<T> {
  72219. /** gets or sets behavior's name */
  72220. name: string;
  72221. /**
  72222. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72223. */
  72224. init(): void;
  72225. /**
  72226. * Called when the behavior is attached to a target
  72227. * @param target defines the target where the behavior is attached to
  72228. */
  72229. attach(target: T): void;
  72230. /**
  72231. * Called when the behavior is detached from its target
  72232. */
  72233. detach(): void;
  72234. }
  72235. /**
  72236. * Interface implemented by classes supporting behaviors
  72237. */
  72238. export interface IBehaviorAware<T> {
  72239. /**
  72240. * Attach a behavior
  72241. * @param behavior defines the behavior to attach
  72242. * @returns the current host
  72243. */
  72244. addBehavior(behavior: Behavior<T>): T;
  72245. /**
  72246. * Remove a behavior from the current object
  72247. * @param behavior defines the behavior to detach
  72248. * @returns the current host
  72249. */
  72250. removeBehavior(behavior: Behavior<T>): T;
  72251. /**
  72252. * Gets a behavior using its name to search
  72253. * @param name defines the name to search
  72254. * @returns the behavior or null if not found
  72255. */
  72256. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72257. }
  72258. }
  72259. declare module BABYLON {
  72260. /**
  72261. * Defines an array and its length.
  72262. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72263. */
  72264. export interface ISmartArrayLike<T> {
  72265. /**
  72266. * The data of the array.
  72267. */
  72268. data: Array<T>;
  72269. /**
  72270. * The active length of the array.
  72271. */
  72272. length: number;
  72273. }
  72274. /**
  72275. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72276. */
  72277. export class SmartArray<T> implements ISmartArrayLike<T> {
  72278. /**
  72279. * The full set of data from the array.
  72280. */
  72281. data: Array<T>;
  72282. /**
  72283. * The active length of the array.
  72284. */
  72285. length: number;
  72286. protected _id: number;
  72287. /**
  72288. * Instantiates a Smart Array.
  72289. * @param capacity defines the default capacity of the array.
  72290. */
  72291. constructor(capacity: number);
  72292. /**
  72293. * Pushes a value at the end of the active data.
  72294. * @param value defines the object to push in the array.
  72295. */
  72296. push(value: T): void;
  72297. /**
  72298. * Iterates over the active data and apply the lambda to them.
  72299. * @param func defines the action to apply on each value.
  72300. */
  72301. forEach(func: (content: T) => void): void;
  72302. /**
  72303. * Sorts the full sets of data.
  72304. * @param compareFn defines the comparison function to apply.
  72305. */
  72306. sort(compareFn: (a: T, b: T) => number): void;
  72307. /**
  72308. * Resets the active data to an empty array.
  72309. */
  72310. reset(): void;
  72311. /**
  72312. * Releases all the data from the array as well as the array.
  72313. */
  72314. dispose(): void;
  72315. /**
  72316. * Concats the active data with a given array.
  72317. * @param array defines the data to concatenate with.
  72318. */
  72319. concat(array: any): void;
  72320. /**
  72321. * Returns the position of a value in the active data.
  72322. * @param value defines the value to find the index for
  72323. * @returns the index if found in the active data otherwise -1
  72324. */
  72325. indexOf(value: T): number;
  72326. /**
  72327. * Returns whether an element is part of the active data.
  72328. * @param value defines the value to look for
  72329. * @returns true if found in the active data otherwise false
  72330. */
  72331. contains(value: T): boolean;
  72332. private static _GlobalId;
  72333. }
  72334. /**
  72335. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72336. * The data in this array can only be present once
  72337. */
  72338. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72339. private _duplicateId;
  72340. /**
  72341. * Pushes a value at the end of the active data.
  72342. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72343. * @param value defines the object to push in the array.
  72344. */
  72345. push(value: T): void;
  72346. /**
  72347. * Pushes a value at the end of the active data.
  72348. * If the data is already present, it won t be added again
  72349. * @param value defines the object to push in the array.
  72350. * @returns true if added false if it was already present
  72351. */
  72352. pushNoDuplicate(value: T): boolean;
  72353. /**
  72354. * Resets the active data to an empty array.
  72355. */
  72356. reset(): void;
  72357. /**
  72358. * Concats the active data with a given array.
  72359. * This ensures no dupplicate will be present in the result.
  72360. * @param array defines the data to concatenate with.
  72361. */
  72362. concatWithNoDuplicate(array: any): void;
  72363. }
  72364. }
  72365. declare module BABYLON {
  72366. /**
  72367. * @ignore
  72368. * This is a list of all the different input types that are available in the application.
  72369. * Fo instance: ArcRotateCameraGamepadInput...
  72370. */
  72371. export var CameraInputTypes: {};
  72372. /**
  72373. * This is the contract to implement in order to create a new input class.
  72374. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72375. */
  72376. export interface ICameraInput<TCamera extends Camera> {
  72377. /**
  72378. * Defines the camera the input is attached to.
  72379. */
  72380. camera: Nullable<TCamera>;
  72381. /**
  72382. * Gets the class name of the current intput.
  72383. * @returns the class name
  72384. */
  72385. getClassName(): string;
  72386. /**
  72387. * Get the friendly name associated with the input class.
  72388. * @returns the input friendly name
  72389. */
  72390. getSimpleName(): string;
  72391. /**
  72392. * Attach the input controls to a specific dom element to get the input from.
  72393. * @param element Defines the element the controls should be listened from
  72394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72395. */
  72396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72397. /**
  72398. * Detach the current controls from the specified dom element.
  72399. * @param element Defines the element to stop listening the inputs from
  72400. */
  72401. detachControl(element: Nullable<HTMLElement>): void;
  72402. /**
  72403. * Update the current camera state depending on the inputs that have been used this frame.
  72404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72405. */
  72406. checkInputs?: () => void;
  72407. }
  72408. /**
  72409. * Represents a map of input types to input instance or input index to input instance.
  72410. */
  72411. export interface CameraInputsMap<TCamera extends Camera> {
  72412. /**
  72413. * Accessor to the input by input type.
  72414. */
  72415. [name: string]: ICameraInput<TCamera>;
  72416. /**
  72417. * Accessor to the input by input index.
  72418. */
  72419. [idx: number]: ICameraInput<TCamera>;
  72420. }
  72421. /**
  72422. * This represents the input manager used within a camera.
  72423. * It helps dealing with all the different kind of input attached to a camera.
  72424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72425. */
  72426. export class CameraInputsManager<TCamera extends Camera> {
  72427. /**
  72428. * Defines the list of inputs attahed to the camera.
  72429. */
  72430. attached: CameraInputsMap<TCamera>;
  72431. /**
  72432. * Defines the dom element the camera is collecting inputs from.
  72433. * This is null if the controls have not been attached.
  72434. */
  72435. attachedElement: Nullable<HTMLElement>;
  72436. /**
  72437. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72438. */
  72439. noPreventDefault: boolean;
  72440. /**
  72441. * Defined the camera the input manager belongs to.
  72442. */
  72443. camera: TCamera;
  72444. /**
  72445. * Update the current camera state depending on the inputs that have been used this frame.
  72446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72447. */
  72448. checkInputs: () => void;
  72449. /**
  72450. * Instantiate a new Camera Input Manager.
  72451. * @param camera Defines the camera the input manager blongs to
  72452. */
  72453. constructor(camera: TCamera);
  72454. /**
  72455. * Add an input method to a camera
  72456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72457. * @param input camera input method
  72458. */
  72459. add(input: ICameraInput<TCamera>): void;
  72460. /**
  72461. * Remove a specific input method from a camera
  72462. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72463. * @param inputToRemove camera input method
  72464. */
  72465. remove(inputToRemove: ICameraInput<TCamera>): void;
  72466. /**
  72467. * Remove a specific input type from a camera
  72468. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72469. * @param inputType the type of the input to remove
  72470. */
  72471. removeByType(inputType: string): void;
  72472. private _addCheckInputs;
  72473. /**
  72474. * Attach the input controls to the currently attached dom element to listen the events from.
  72475. * @param input Defines the input to attach
  72476. */
  72477. attachInput(input: ICameraInput<TCamera>): void;
  72478. /**
  72479. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72480. * @param element Defines the dom element to collect the events from
  72481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72482. */
  72483. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72484. /**
  72485. * Detach the current manager inputs controls from a specific dom element.
  72486. * @param element Defines the dom element to collect the events from
  72487. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72488. */
  72489. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72490. /**
  72491. * Rebuild the dynamic inputCheck function from the current list of
  72492. * defined inputs in the manager.
  72493. */
  72494. rebuildInputCheck(): void;
  72495. /**
  72496. * Remove all attached input methods from a camera
  72497. */
  72498. clear(): void;
  72499. /**
  72500. * Serialize the current input manager attached to a camera.
  72501. * This ensures than once parsed,
  72502. * the input associated to the camera will be identical to the current ones
  72503. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72504. */
  72505. serialize(serializedCamera: any): void;
  72506. /**
  72507. * Parses an input manager serialized JSON to restore the previous list of inputs
  72508. * and states associated to a camera.
  72509. * @param parsedCamera Defines the JSON to parse
  72510. */
  72511. parse(parsedCamera: any): void;
  72512. }
  72513. }
  72514. declare module BABYLON {
  72515. /**
  72516. * @hidden
  72517. */
  72518. export class IntersectionInfo {
  72519. bu: Nullable<number>;
  72520. bv: Nullable<number>;
  72521. distance: number;
  72522. faceId: number;
  72523. subMeshId: number;
  72524. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72525. }
  72526. }
  72527. declare module BABYLON {
  72528. /**
  72529. * Represens a plane by the equation ax + by + cz + d = 0
  72530. */
  72531. export class Plane {
  72532. private static _TmpMatrix;
  72533. /**
  72534. * Normal of the plane (a,b,c)
  72535. */
  72536. normal: Vector3;
  72537. /**
  72538. * d component of the plane
  72539. */
  72540. d: number;
  72541. /**
  72542. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72543. * @param a a component of the plane
  72544. * @param b b component of the plane
  72545. * @param c c component of the plane
  72546. * @param d d component of the plane
  72547. */
  72548. constructor(a: number, b: number, c: number, d: number);
  72549. /**
  72550. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72551. */
  72552. asArray(): number[];
  72553. /**
  72554. * @returns a new plane copied from the current Plane.
  72555. */
  72556. clone(): Plane;
  72557. /**
  72558. * @returns the string "Plane".
  72559. */
  72560. getClassName(): string;
  72561. /**
  72562. * @returns the Plane hash code.
  72563. */
  72564. getHashCode(): number;
  72565. /**
  72566. * Normalize the current Plane in place.
  72567. * @returns the updated Plane.
  72568. */
  72569. normalize(): Plane;
  72570. /**
  72571. * Applies a transformation the plane and returns the result
  72572. * @param transformation the transformation matrix to be applied to the plane
  72573. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72574. */
  72575. transform(transformation: DeepImmutable<Matrix>): Plane;
  72576. /**
  72577. * Calcualtte the dot product between the point and the plane normal
  72578. * @param point point to calculate the dot product with
  72579. * @returns the dot product (float) of the point coordinates and the plane normal.
  72580. */
  72581. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72582. /**
  72583. * Updates the current Plane from the plane defined by the three given points.
  72584. * @param point1 one of the points used to contruct the plane
  72585. * @param point2 one of the points used to contruct the plane
  72586. * @param point3 one of the points used to contruct the plane
  72587. * @returns the updated Plane.
  72588. */
  72589. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72590. /**
  72591. * Checks if the plane is facing a given direction
  72592. * @param direction the direction to check if the plane is facing
  72593. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72594. * @returns True is the vector "direction" is the same side than the plane normal.
  72595. */
  72596. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72597. /**
  72598. * Calculates the distance to a point
  72599. * @param point point to calculate distance to
  72600. * @returns the signed distance (float) from the given point to the Plane.
  72601. */
  72602. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72603. /**
  72604. * Creates a plane from an array
  72605. * @param array the array to create a plane from
  72606. * @returns a new Plane from the given array.
  72607. */
  72608. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72609. /**
  72610. * Creates a plane from three points
  72611. * @param point1 point used to create the plane
  72612. * @param point2 point used to create the plane
  72613. * @param point3 point used to create the plane
  72614. * @returns a new Plane defined by the three given points.
  72615. */
  72616. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72617. /**
  72618. * Creates a plane from an origin point and a normal
  72619. * @param origin origin of the plane to be constructed
  72620. * @param normal normal of the plane to be constructed
  72621. * @returns a new Plane the normal vector to this plane at the given origin point.
  72622. * Note : the vector "normal" is updated because normalized.
  72623. */
  72624. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72625. /**
  72626. * Calculates the distance from a plane and a point
  72627. * @param origin origin of the plane to be constructed
  72628. * @param normal normal of the plane to be constructed
  72629. * @param point point to calculate distance to
  72630. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72631. */
  72632. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72633. }
  72634. }
  72635. declare module BABYLON {
  72636. /**
  72637. * Class used to store bounding sphere information
  72638. */
  72639. export class BoundingSphere {
  72640. /**
  72641. * Gets the center of the bounding sphere in local space
  72642. */
  72643. readonly center: Vector3;
  72644. /**
  72645. * Radius of the bounding sphere in local space
  72646. */
  72647. radius: number;
  72648. /**
  72649. * Gets the center of the bounding sphere in world space
  72650. */
  72651. readonly centerWorld: Vector3;
  72652. /**
  72653. * Radius of the bounding sphere in world space
  72654. */
  72655. radiusWorld: number;
  72656. /**
  72657. * Gets the minimum vector in local space
  72658. */
  72659. readonly minimum: Vector3;
  72660. /**
  72661. * Gets the maximum vector in local space
  72662. */
  72663. readonly maximum: Vector3;
  72664. private _worldMatrix;
  72665. private static readonly TmpVector3;
  72666. /**
  72667. * Creates a new bounding sphere
  72668. * @param min defines the minimum vector (in local space)
  72669. * @param max defines the maximum vector (in local space)
  72670. * @param worldMatrix defines the new world matrix
  72671. */
  72672. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72673. /**
  72674. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72675. * @param min defines the new minimum vector (in local space)
  72676. * @param max defines the new maximum vector (in local space)
  72677. * @param worldMatrix defines the new world matrix
  72678. */
  72679. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72680. /**
  72681. * Scale the current bounding sphere by applying a scale factor
  72682. * @param factor defines the scale factor to apply
  72683. * @returns the current bounding box
  72684. */
  72685. scale(factor: number): BoundingSphere;
  72686. /**
  72687. * Gets the world matrix of the bounding box
  72688. * @returns a matrix
  72689. */
  72690. getWorldMatrix(): DeepImmutable<Matrix>;
  72691. /** @hidden */
  72692. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72693. /**
  72694. * Tests if the bounding sphere is intersecting the frustum planes
  72695. * @param frustumPlanes defines the frustum planes to test
  72696. * @returns true if there is an intersection
  72697. */
  72698. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72699. /**
  72700. * Tests if the bounding sphere center is in between the frustum planes.
  72701. * Used for optimistic fast inclusion.
  72702. * @param frustumPlanes defines the frustum planes to test
  72703. * @returns true if the sphere center is in between the frustum planes
  72704. */
  72705. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72706. /**
  72707. * Tests if a point is inside the bounding sphere
  72708. * @param point defines the point to test
  72709. * @returns true if the point is inside the bounding sphere
  72710. */
  72711. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72712. /**
  72713. * Checks if two sphere intersct
  72714. * @param sphere0 sphere 0
  72715. * @param sphere1 sphere 1
  72716. * @returns true if the speres intersect
  72717. */
  72718. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72719. }
  72720. }
  72721. declare module BABYLON {
  72722. /**
  72723. * Class used to store bounding box information
  72724. */
  72725. export class BoundingBox implements ICullable {
  72726. /**
  72727. * Gets the 8 vectors representing the bounding box in local space
  72728. */
  72729. readonly vectors: Vector3[];
  72730. /**
  72731. * Gets the center of the bounding box in local space
  72732. */
  72733. readonly center: Vector3;
  72734. /**
  72735. * Gets the center of the bounding box in world space
  72736. */
  72737. readonly centerWorld: Vector3;
  72738. /**
  72739. * Gets the extend size in local space
  72740. */
  72741. readonly extendSize: Vector3;
  72742. /**
  72743. * Gets the extend size in world space
  72744. */
  72745. readonly extendSizeWorld: Vector3;
  72746. /**
  72747. * Gets the OBB (object bounding box) directions
  72748. */
  72749. readonly directions: Vector3[];
  72750. /**
  72751. * Gets the 8 vectors representing the bounding box in world space
  72752. */
  72753. readonly vectorsWorld: Vector3[];
  72754. /**
  72755. * Gets the minimum vector in world space
  72756. */
  72757. readonly minimumWorld: Vector3;
  72758. /**
  72759. * Gets the maximum vector in world space
  72760. */
  72761. readonly maximumWorld: Vector3;
  72762. /**
  72763. * Gets the minimum vector in local space
  72764. */
  72765. readonly minimum: Vector3;
  72766. /**
  72767. * Gets the maximum vector in local space
  72768. */
  72769. readonly maximum: Vector3;
  72770. private _worldMatrix;
  72771. private static readonly TmpVector3;
  72772. /**
  72773. * @hidden
  72774. */
  72775. _tag: number;
  72776. /**
  72777. * Creates a new bounding box
  72778. * @param min defines the minimum vector (in local space)
  72779. * @param max defines the maximum vector (in local space)
  72780. * @param worldMatrix defines the new world matrix
  72781. */
  72782. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72783. /**
  72784. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72785. * @param min defines the new minimum vector (in local space)
  72786. * @param max defines the new maximum vector (in local space)
  72787. * @param worldMatrix defines the new world matrix
  72788. */
  72789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72790. /**
  72791. * Scale the current bounding box by applying a scale factor
  72792. * @param factor defines the scale factor to apply
  72793. * @returns the current bounding box
  72794. */
  72795. scale(factor: number): BoundingBox;
  72796. /**
  72797. * Gets the world matrix of the bounding box
  72798. * @returns a matrix
  72799. */
  72800. getWorldMatrix(): DeepImmutable<Matrix>;
  72801. /** @hidden */
  72802. _update(world: DeepImmutable<Matrix>): void;
  72803. /**
  72804. * Tests if the bounding box is intersecting the frustum planes
  72805. * @param frustumPlanes defines the frustum planes to test
  72806. * @returns true if there is an intersection
  72807. */
  72808. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72809. /**
  72810. * Tests if the bounding box is entirely inside the frustum planes
  72811. * @param frustumPlanes defines the frustum planes to test
  72812. * @returns true if there is an inclusion
  72813. */
  72814. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72815. /**
  72816. * Tests if a point is inside the bounding box
  72817. * @param point defines the point to test
  72818. * @returns true if the point is inside the bounding box
  72819. */
  72820. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72821. /**
  72822. * Tests if the bounding box intersects with a bounding sphere
  72823. * @param sphere defines the sphere to test
  72824. * @returns true if there is an intersection
  72825. */
  72826. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72827. /**
  72828. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72829. * @param min defines the min vector to use
  72830. * @param max defines the max vector to use
  72831. * @returns true if there is an intersection
  72832. */
  72833. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72834. /**
  72835. * Tests if two bounding boxes are intersections
  72836. * @param box0 defines the first box to test
  72837. * @param box1 defines the second box to test
  72838. * @returns true if there is an intersection
  72839. */
  72840. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72841. /**
  72842. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72843. * @param minPoint defines the minimum vector of the bounding box
  72844. * @param maxPoint defines the maximum vector of the bounding box
  72845. * @param sphereCenter defines the sphere center
  72846. * @param sphereRadius defines the sphere radius
  72847. * @returns true if there is an intersection
  72848. */
  72849. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72850. /**
  72851. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72852. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72853. * @param frustumPlanes defines the frustum planes to test
  72854. * @return true if there is an inclusion
  72855. */
  72856. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72857. /**
  72858. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72859. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72860. * @param frustumPlanes defines the frustum planes to test
  72861. * @return true if there is an intersection
  72862. */
  72863. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72864. }
  72865. }
  72866. declare module BABYLON {
  72867. /** @hidden */
  72868. export class Collider {
  72869. /** Define if a collision was found */
  72870. collisionFound: boolean;
  72871. /**
  72872. * Define last intersection point in local space
  72873. */
  72874. intersectionPoint: Vector3;
  72875. /**
  72876. * Define last collided mesh
  72877. */
  72878. collidedMesh: Nullable<AbstractMesh>;
  72879. private _collisionPoint;
  72880. private _planeIntersectionPoint;
  72881. private _tempVector;
  72882. private _tempVector2;
  72883. private _tempVector3;
  72884. private _tempVector4;
  72885. private _edge;
  72886. private _baseToVertex;
  72887. private _destinationPoint;
  72888. private _slidePlaneNormal;
  72889. private _displacementVector;
  72890. /** @hidden */
  72891. _radius: Vector3;
  72892. /** @hidden */
  72893. _retry: number;
  72894. private _velocity;
  72895. private _basePoint;
  72896. private _epsilon;
  72897. /** @hidden */
  72898. _velocityWorldLength: number;
  72899. /** @hidden */
  72900. _basePointWorld: Vector3;
  72901. private _velocityWorld;
  72902. private _normalizedVelocity;
  72903. /** @hidden */
  72904. _initialVelocity: Vector3;
  72905. /** @hidden */
  72906. _initialPosition: Vector3;
  72907. private _nearestDistance;
  72908. private _collisionMask;
  72909. collisionMask: number;
  72910. /**
  72911. * Gets the plane normal used to compute the sliding response (in local space)
  72912. */
  72913. readonly slidePlaneNormal: Vector3;
  72914. /** @hidden */
  72915. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72916. /** @hidden */
  72917. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72918. /** @hidden */
  72919. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72920. /** @hidden */
  72921. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72922. /** @hidden */
  72923. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72924. /** @hidden */
  72925. _getResponse(pos: Vector3, vel: Vector3): void;
  72926. }
  72927. }
  72928. declare module BABYLON {
  72929. /**
  72930. * Interface for cullable objects
  72931. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72932. */
  72933. export interface ICullable {
  72934. /**
  72935. * Checks if the object or part of the object is in the frustum
  72936. * @param frustumPlanes Camera near/planes
  72937. * @returns true if the object is in frustum otherwise false
  72938. */
  72939. isInFrustum(frustumPlanes: Plane[]): boolean;
  72940. /**
  72941. * Checks if a cullable object (mesh...) is in the camera frustum
  72942. * Unlike isInFrustum this cheks the full bounding box
  72943. * @param frustumPlanes Camera near/planes
  72944. * @returns true if the object is in frustum otherwise false
  72945. */
  72946. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72947. }
  72948. /**
  72949. * Info for a bounding data of a mesh
  72950. */
  72951. export class BoundingInfo implements ICullable {
  72952. /**
  72953. * Bounding box for the mesh
  72954. */
  72955. readonly boundingBox: BoundingBox;
  72956. /**
  72957. * Bounding sphere for the mesh
  72958. */
  72959. readonly boundingSphere: BoundingSphere;
  72960. private _isLocked;
  72961. private static readonly TmpVector3;
  72962. /**
  72963. * Constructs bounding info
  72964. * @param minimum min vector of the bounding box/sphere
  72965. * @param maximum max vector of the bounding box/sphere
  72966. * @param worldMatrix defines the new world matrix
  72967. */
  72968. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72969. /**
  72970. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72971. * @param min defines the new minimum vector (in local space)
  72972. * @param max defines the new maximum vector (in local space)
  72973. * @param worldMatrix defines the new world matrix
  72974. */
  72975. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72976. /**
  72977. * min vector of the bounding box/sphere
  72978. */
  72979. readonly minimum: Vector3;
  72980. /**
  72981. * max vector of the bounding box/sphere
  72982. */
  72983. readonly maximum: Vector3;
  72984. /**
  72985. * If the info is locked and won't be updated to avoid perf overhead
  72986. */
  72987. isLocked: boolean;
  72988. /**
  72989. * Updates the bounding sphere and box
  72990. * @param world world matrix to be used to update
  72991. */
  72992. update(world: DeepImmutable<Matrix>): void;
  72993. /**
  72994. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72995. * @param center New center of the bounding info
  72996. * @param extend New extend of the bounding info
  72997. * @returns the current bounding info
  72998. */
  72999. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73000. /**
  73001. * Scale the current bounding info by applying a scale factor
  73002. * @param factor defines the scale factor to apply
  73003. * @returns the current bounding info
  73004. */
  73005. scale(factor: number): BoundingInfo;
  73006. /**
  73007. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73008. * @param frustumPlanes defines the frustum to test
  73009. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73010. * @returns true if the bounding info is in the frustum planes
  73011. */
  73012. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73013. /**
  73014. * Gets the world distance between the min and max points of the bounding box
  73015. */
  73016. readonly diagonalLength: number;
  73017. /**
  73018. * Checks if a cullable object (mesh...) is in the camera frustum
  73019. * Unlike isInFrustum this cheks the full bounding box
  73020. * @param frustumPlanes Camera near/planes
  73021. * @returns true if the object is in frustum otherwise false
  73022. */
  73023. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73024. /** @hidden */
  73025. _checkCollision(collider: Collider): boolean;
  73026. /**
  73027. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73028. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73029. * @param point the point to check intersection with
  73030. * @returns if the point intersects
  73031. */
  73032. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73033. /**
  73034. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73035. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73036. * @param boundingInfo the bounding info to check intersection with
  73037. * @param precise if the intersection should be done using OBB
  73038. * @returns if the bounding info intersects
  73039. */
  73040. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73041. }
  73042. }
  73043. declare module BABYLON {
  73044. /**
  73045. * Extracts minimum and maximum values from a list of indexed positions
  73046. * @param positions defines the positions to use
  73047. * @param indices defines the indices to the positions
  73048. * @param indexStart defines the start index
  73049. * @param indexCount defines the end index
  73050. * @param bias defines bias value to add to the result
  73051. * @return minimum and maximum values
  73052. */
  73053. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73054. minimum: Vector3;
  73055. maximum: Vector3;
  73056. };
  73057. /**
  73058. * Extracts minimum and maximum values from a list of positions
  73059. * @param positions defines the positions to use
  73060. * @param start defines the start index in the positions array
  73061. * @param count defines the number of positions to handle
  73062. * @param bias defines bias value to add to the result
  73063. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73064. * @return minimum and maximum values
  73065. */
  73066. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73067. minimum: Vector3;
  73068. maximum: Vector3;
  73069. };
  73070. }
  73071. declare module BABYLON {
  73072. /**
  73073. * Enum that determines the text-wrapping mode to use.
  73074. */
  73075. export enum InspectableType {
  73076. /**
  73077. * Checkbox for booleans
  73078. */
  73079. Checkbox = 0,
  73080. /**
  73081. * Sliders for numbers
  73082. */
  73083. Slider = 1,
  73084. /**
  73085. * Vector3
  73086. */
  73087. Vector3 = 2,
  73088. /**
  73089. * Quaternions
  73090. */
  73091. Quaternion = 3,
  73092. /**
  73093. * Color3
  73094. */
  73095. Color3 = 4,
  73096. /**
  73097. * String
  73098. */
  73099. String = 5
  73100. }
  73101. /**
  73102. * Interface used to define custom inspectable properties.
  73103. * This interface is used by the inspector to display custom property grids
  73104. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73105. */
  73106. export interface IInspectable {
  73107. /**
  73108. * Gets the label to display
  73109. */
  73110. label: string;
  73111. /**
  73112. * Gets the name of the property to edit
  73113. */
  73114. propertyName: string;
  73115. /**
  73116. * Gets the type of the editor to use
  73117. */
  73118. type: InspectableType;
  73119. /**
  73120. * Gets the minimum value of the property when using in "slider" mode
  73121. */
  73122. min?: number;
  73123. /**
  73124. * Gets the maximum value of the property when using in "slider" mode
  73125. */
  73126. max?: number;
  73127. /**
  73128. * Gets the setp to use when using in "slider" mode
  73129. */
  73130. step?: number;
  73131. }
  73132. }
  73133. declare module BABYLON {
  73134. /**
  73135. * Class used to provide helper for timing
  73136. */
  73137. export class TimingTools {
  73138. /**
  73139. * Polyfill for setImmediate
  73140. * @param action defines the action to execute after the current execution block
  73141. */
  73142. static SetImmediate(action: () => void): void;
  73143. }
  73144. }
  73145. declare module BABYLON {
  73146. /**
  73147. * Class used to enable instatition of objects by class name
  73148. */
  73149. export class InstantiationTools {
  73150. /**
  73151. * Use this object to register external classes like custom textures or material
  73152. * to allow the laoders to instantiate them
  73153. */
  73154. static RegisteredExternalClasses: {
  73155. [key: string]: Object;
  73156. };
  73157. /**
  73158. * Tries to instantiate a new object from a given class name
  73159. * @param className defines the class name to instantiate
  73160. * @returns the new object or null if the system was not able to do the instantiation
  73161. */
  73162. static Instantiate(className: string): any;
  73163. }
  73164. }
  73165. declare module BABYLON {
  73166. /**
  73167. * This represents the required contract to create a new type of texture loader.
  73168. */
  73169. export interface IInternalTextureLoader {
  73170. /**
  73171. * Defines wether the loader supports cascade loading the different faces.
  73172. */
  73173. supportCascades: boolean;
  73174. /**
  73175. * This returns if the loader support the current file information.
  73176. * @param extension defines the file extension of the file being loaded
  73177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73178. * @param fallback defines the fallback internal texture if any
  73179. * @param isBase64 defines whether the texture is encoded as a base64
  73180. * @param isBuffer defines whether the texture data are stored as a buffer
  73181. * @returns true if the loader can load the specified file
  73182. */
  73183. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73184. /**
  73185. * Transform the url before loading if required.
  73186. * @param rootUrl the url of the texture
  73187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73188. * @returns the transformed texture
  73189. */
  73190. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73191. /**
  73192. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73193. * @param rootUrl the url of the texture
  73194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73195. * @returns the fallback texture
  73196. */
  73197. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73198. /**
  73199. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73200. * @param data contains the texture data
  73201. * @param texture defines the BabylonJS internal texture
  73202. * @param createPolynomials will be true if polynomials have been requested
  73203. * @param onLoad defines the callback to trigger once the texture is ready
  73204. * @param onError defines the callback to trigger in case of error
  73205. */
  73206. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73207. /**
  73208. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73209. * @param data contains the texture data
  73210. * @param texture defines the BabylonJS internal texture
  73211. * @param callback defines the method to call once ready to upload
  73212. */
  73213. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73214. }
  73215. }
  73216. declare module BABYLON {
  73217. interface Engine {
  73218. /**
  73219. * Creates a depth stencil cube texture.
  73220. * This is only available in WebGL 2.
  73221. * @param size The size of face edge in the cube texture.
  73222. * @param options The options defining the cube texture.
  73223. * @returns The cube texture
  73224. */
  73225. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73226. /**
  73227. * Creates a cube texture
  73228. * @param rootUrl defines the url where the files to load is located
  73229. * @param scene defines the current scene
  73230. * @param files defines the list of files to load (1 per face)
  73231. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73232. * @param onLoad defines an optional callback raised when the texture is loaded
  73233. * @param onError defines an optional callback raised if there is an issue to load the texture
  73234. * @param format defines the format of the data
  73235. * @param forcedExtension defines the extension to use to pick the right loader
  73236. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73237. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73238. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73239. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73240. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73241. * @returns the cube texture as an InternalTexture
  73242. */
  73243. 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;
  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. * @returns the cube texture as an InternalTexture
  73255. */
  73256. 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;
  73257. /**
  73258. * Creates a cube texture
  73259. * @param rootUrl defines the url where the files to load is located
  73260. * @param scene defines the current scene
  73261. * @param files defines the list of files to load (1 per face)
  73262. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73263. * @param onLoad defines an optional callback raised when the texture is loaded
  73264. * @param onError defines an optional callback raised if there is an issue to load the texture
  73265. * @param format defines the format of the data
  73266. * @param forcedExtension defines the extension to use to pick the right loader
  73267. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73268. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73269. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73270. * @returns the cube texture as an InternalTexture
  73271. */
  73272. 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;
  73273. /** @hidden */
  73274. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73275. /** @hidden */
  73276. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73277. /** @hidden */
  73278. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73279. /** @hidden */
  73280. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73281. }
  73282. }
  73283. declare module BABYLON {
  73284. /**
  73285. * Class for creating a cube texture
  73286. */
  73287. export class CubeTexture extends BaseTexture {
  73288. private _delayedOnLoad;
  73289. /**
  73290. * The url of the texture
  73291. */
  73292. url: string;
  73293. /**
  73294. * Gets or sets the center of the bounding box associated with the cube texture.
  73295. * It must define where the camera used to render the texture was set
  73296. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73297. */
  73298. boundingBoxPosition: Vector3;
  73299. private _boundingBoxSize;
  73300. /**
  73301. * Gets or sets the size of the bounding box associated with the cube texture
  73302. * When defined, the cubemap will switch to local mode
  73303. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73304. * @example https://www.babylonjs-playground.com/#RNASML
  73305. */
  73306. /**
  73307. * Returns the bounding box size
  73308. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73309. */
  73310. boundingBoxSize: Vector3;
  73311. protected _rotationY: number;
  73312. /**
  73313. * Sets texture matrix rotation angle around Y axis in radians.
  73314. */
  73315. /**
  73316. * Gets texture matrix rotation angle around Y axis radians.
  73317. */
  73318. rotationY: number;
  73319. /**
  73320. * Are mip maps generated for this texture or not.
  73321. */
  73322. readonly noMipmap: boolean;
  73323. private _noMipmap;
  73324. private _files;
  73325. private _extensions;
  73326. private _textureMatrix;
  73327. private _format;
  73328. private _createPolynomials;
  73329. /** @hidden */
  73330. _prefiltered: boolean;
  73331. /**
  73332. * Creates a cube texture from an array of image urls
  73333. * @param files defines an array of image urls
  73334. * @param scene defines the hosting scene
  73335. * @param noMipmap specifies if mip maps are not used
  73336. * @returns a cube texture
  73337. */
  73338. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73339. /**
  73340. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73341. * @param url defines the url of the prefiltered texture
  73342. * @param scene defines the scene the texture is attached to
  73343. * @param forcedExtension defines the extension of the file if different from the url
  73344. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73345. * @return the prefiltered texture
  73346. */
  73347. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73348. /**
  73349. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73350. * as prefiltered data.
  73351. * @param rootUrl defines the url of the texture or the root name of the six images
  73352. * @param scene defines the scene the texture is attached to
  73353. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73354. * @param noMipmap defines if mipmaps should be created or not
  73355. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73356. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73357. * @param onError defines a callback triggered in case of error during load
  73358. * @param format defines the internal format to use for the texture once loaded
  73359. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73360. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73361. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73362. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73363. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73364. * @return the cube texture
  73365. */
  73366. 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);
  73367. /**
  73368. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73369. */
  73370. readonly isPrefiltered: boolean;
  73371. /**
  73372. * Get the current class name of the texture useful for serialization or dynamic coding.
  73373. * @returns "CubeTexture"
  73374. */
  73375. getClassName(): string;
  73376. /**
  73377. * Update the url (and optional buffer) of this texture if url was null during construction.
  73378. * @param url the url of the texture
  73379. * @param forcedExtension defines the extension to use
  73380. * @param onLoad callback called when the texture is loaded (defaults to null)
  73381. */
  73382. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73383. /**
  73384. * Delays loading of the cube texture
  73385. * @param forcedExtension defines the extension to use
  73386. */
  73387. delayLoad(forcedExtension?: string): void;
  73388. /**
  73389. * Returns the reflection texture matrix
  73390. * @returns the reflection texture matrix
  73391. */
  73392. getReflectionTextureMatrix(): Matrix;
  73393. /**
  73394. * Sets the reflection texture matrix
  73395. * @param value Reflection texture matrix
  73396. */
  73397. setReflectionTextureMatrix(value: Matrix): void;
  73398. /**
  73399. * Parses text to create a cube texture
  73400. * @param parsedTexture define the serialized text to read from
  73401. * @param scene defines the hosting scene
  73402. * @param rootUrl defines the root url of the cube texture
  73403. * @returns a cube texture
  73404. */
  73405. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73406. /**
  73407. * Makes a clone, or deep copy, of the cube texture
  73408. * @returns a new cube texture
  73409. */
  73410. clone(): CubeTexture;
  73411. }
  73412. }
  73413. declare module BABYLON {
  73414. /**
  73415. * Manages the defines for the Material
  73416. */
  73417. export class MaterialDefines {
  73418. /** @hidden */
  73419. protected _keys: string[];
  73420. private _isDirty;
  73421. /** @hidden */
  73422. _renderId: number;
  73423. /** @hidden */
  73424. _areLightsDirty: boolean;
  73425. /** @hidden */
  73426. _areLightsDisposed: boolean;
  73427. /** @hidden */
  73428. _areAttributesDirty: boolean;
  73429. /** @hidden */
  73430. _areTexturesDirty: boolean;
  73431. /** @hidden */
  73432. _areFresnelDirty: boolean;
  73433. /** @hidden */
  73434. _areMiscDirty: boolean;
  73435. /** @hidden */
  73436. _areImageProcessingDirty: boolean;
  73437. /** @hidden */
  73438. _normals: boolean;
  73439. /** @hidden */
  73440. _uvs: boolean;
  73441. /** @hidden */
  73442. _needNormals: boolean;
  73443. /** @hidden */
  73444. _needUVs: boolean;
  73445. [id: string]: any;
  73446. /**
  73447. * Specifies if the material needs to be re-calculated
  73448. */
  73449. readonly isDirty: boolean;
  73450. /**
  73451. * Marks the material to indicate that it has been re-calculated
  73452. */
  73453. markAsProcessed(): void;
  73454. /**
  73455. * Marks the material to indicate that it needs to be re-calculated
  73456. */
  73457. markAsUnprocessed(): void;
  73458. /**
  73459. * Marks the material to indicate all of its defines need to be re-calculated
  73460. */
  73461. markAllAsDirty(): void;
  73462. /**
  73463. * Marks the material to indicate that image processing needs to be re-calculated
  73464. */
  73465. markAsImageProcessingDirty(): void;
  73466. /**
  73467. * Marks the material to indicate the lights need to be re-calculated
  73468. * @param disposed Defines whether the light is dirty due to dispose or not
  73469. */
  73470. markAsLightDirty(disposed?: boolean): void;
  73471. /**
  73472. * Marks the attribute state as changed
  73473. */
  73474. markAsAttributesDirty(): void;
  73475. /**
  73476. * Marks the texture state as changed
  73477. */
  73478. markAsTexturesDirty(): void;
  73479. /**
  73480. * Marks the fresnel state as changed
  73481. */
  73482. markAsFresnelDirty(): void;
  73483. /**
  73484. * Marks the misc state as changed
  73485. */
  73486. markAsMiscDirty(): void;
  73487. /**
  73488. * Rebuilds the material defines
  73489. */
  73490. rebuild(): void;
  73491. /**
  73492. * Specifies if two material defines are equal
  73493. * @param other - A material define instance to compare to
  73494. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73495. */
  73496. isEqual(other: MaterialDefines): boolean;
  73497. /**
  73498. * Clones this instance's defines to another instance
  73499. * @param other - material defines to clone values to
  73500. */
  73501. cloneTo(other: MaterialDefines): void;
  73502. /**
  73503. * Resets the material define values
  73504. */
  73505. reset(): void;
  73506. /**
  73507. * Converts the material define values to a string
  73508. * @returns - String of material define information
  73509. */
  73510. toString(): string;
  73511. }
  73512. }
  73513. declare module BABYLON {
  73514. /**
  73515. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73516. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73517. * 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;
  73518. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73519. */
  73520. export class ColorCurves {
  73521. private _dirty;
  73522. private _tempColor;
  73523. private _globalCurve;
  73524. private _highlightsCurve;
  73525. private _midtonesCurve;
  73526. private _shadowsCurve;
  73527. private _positiveCurve;
  73528. private _negativeCurve;
  73529. private _globalHue;
  73530. private _globalDensity;
  73531. private _globalSaturation;
  73532. private _globalExposure;
  73533. /**
  73534. * Gets the global Hue value.
  73535. * 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).
  73536. */
  73537. /**
  73538. * Sets the global Hue value.
  73539. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73540. */
  73541. globalHue: number;
  73542. /**
  73543. * Gets the global Density value.
  73544. * 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.
  73545. * Values less than zero provide a filter of opposite hue.
  73546. */
  73547. /**
  73548. * Sets the global Density value.
  73549. * 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.
  73550. * Values less than zero provide a filter of opposite hue.
  73551. */
  73552. globalDensity: number;
  73553. /**
  73554. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  73556. */
  73557. /**
  73558. * Sets the global Saturation value.
  73559. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73560. */
  73561. globalSaturation: number;
  73562. /**
  73563. * Gets the global Exposure value.
  73564. * 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.
  73565. */
  73566. /**
  73567. * Sets the global Exposure value.
  73568. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73569. */
  73570. globalExposure: number;
  73571. private _highlightsHue;
  73572. private _highlightsDensity;
  73573. private _highlightsSaturation;
  73574. private _highlightsExposure;
  73575. /**
  73576. * Gets the highlights Hue value.
  73577. * 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).
  73578. */
  73579. /**
  73580. * Sets the highlights Hue value.
  73581. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73582. */
  73583. highlightsHue: number;
  73584. /**
  73585. * Gets the highlights Density value.
  73586. * 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.
  73587. * Values less than zero provide a filter of opposite hue.
  73588. */
  73589. /**
  73590. * Sets the highlights Density value.
  73591. * 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.
  73592. * Values less than zero provide a filter of opposite hue.
  73593. */
  73594. highlightsDensity: number;
  73595. /**
  73596. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  73598. */
  73599. /**
  73600. * Sets the highlights Saturation value.
  73601. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73602. */
  73603. highlightsSaturation: number;
  73604. /**
  73605. * Gets the highlights Exposure value.
  73606. * 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.
  73607. */
  73608. /**
  73609. * Sets the highlights Exposure value.
  73610. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73611. */
  73612. highlightsExposure: number;
  73613. private _midtonesHue;
  73614. private _midtonesDensity;
  73615. private _midtonesSaturation;
  73616. private _midtonesExposure;
  73617. /**
  73618. * Gets the midtones Hue value.
  73619. * 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).
  73620. */
  73621. /**
  73622. * Sets the midtones Hue value.
  73623. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73624. */
  73625. midtonesHue: number;
  73626. /**
  73627. * Gets the midtones Density value.
  73628. * 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.
  73629. * Values less than zero provide a filter of opposite hue.
  73630. */
  73631. /**
  73632. * Sets the midtones Density value.
  73633. * 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.
  73634. * Values less than zero provide a filter of opposite hue.
  73635. */
  73636. midtonesDensity: number;
  73637. /**
  73638. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  73640. */
  73641. /**
  73642. * Sets the midtones Saturation value.
  73643. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73644. */
  73645. midtonesSaturation: number;
  73646. /**
  73647. * Gets the midtones Exposure value.
  73648. * 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.
  73649. */
  73650. /**
  73651. * Sets the midtones Exposure value.
  73652. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73653. */
  73654. midtonesExposure: number;
  73655. private _shadowsHue;
  73656. private _shadowsDensity;
  73657. private _shadowsSaturation;
  73658. private _shadowsExposure;
  73659. /**
  73660. * Gets the shadows Hue value.
  73661. * 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).
  73662. */
  73663. /**
  73664. * Sets the shadows Hue value.
  73665. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  73666. */
  73667. shadowsHue: number;
  73668. /**
  73669. * Gets the shadows Density value.
  73670. * 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.
  73671. * Values less than zero provide a filter of opposite hue.
  73672. */
  73673. /**
  73674. * Sets the shadows Density value.
  73675. * 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.
  73676. * Values less than zero provide a filter of opposite hue.
  73677. */
  73678. shadowsDensity: number;
  73679. /**
  73680. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  73682. */
  73683. /**
  73684. * Sets the shadows Saturation value.
  73685. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  73686. */
  73687. shadowsSaturation: number;
  73688. /**
  73689. * Gets the shadows Exposure value.
  73690. * 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.
  73691. */
  73692. /**
  73693. * Sets the shadows Exposure value.
  73694. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  73695. */
  73696. shadowsExposure: number;
  73697. /**
  73698. * Returns the class name
  73699. * @returns The class name
  73700. */
  73701. getClassName(): string;
  73702. /**
  73703. * Binds the color curves to the shader.
  73704. * @param colorCurves The color curve to bind
  73705. * @param effect The effect to bind to
  73706. * @param positiveUniform The positive uniform shader parameter
  73707. * @param neutralUniform The neutral uniform shader parameter
  73708. * @param negativeUniform The negative uniform shader parameter
  73709. */
  73710. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73711. /**
  73712. * Prepare the list of uniforms associated with the ColorCurves effects.
  73713. * @param uniformsList The list of uniforms used in the effect
  73714. */
  73715. static PrepareUniforms(uniformsList: string[]): void;
  73716. /**
  73717. * Returns color grading data based on a hue, density, saturation and exposure value.
  73718. * @param filterHue The hue of the color filter.
  73719. * @param filterDensity The density of the color filter.
  73720. * @param saturation The saturation.
  73721. * @param exposure The exposure.
  73722. * @param result The result data container.
  73723. */
  73724. private getColorGradingDataToRef;
  73725. /**
  73726. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73727. * @param value The input slider value in range [-100,100].
  73728. * @returns Adjusted value.
  73729. */
  73730. private static applyColorGradingSliderNonlinear;
  73731. /**
  73732. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73733. * @param hue The hue (H) input.
  73734. * @param saturation The saturation (S) input.
  73735. * @param brightness The brightness (B) input.
  73736. * @result An RGBA color represented as Vector4.
  73737. */
  73738. private static fromHSBToRef;
  73739. /**
  73740. * Returns a value clamped between min and max
  73741. * @param value The value to clamp
  73742. * @param min The minimum of value
  73743. * @param max The maximum of value
  73744. * @returns The clamped value.
  73745. */
  73746. private static clamp;
  73747. /**
  73748. * Clones the current color curve instance.
  73749. * @return The cloned curves
  73750. */
  73751. clone(): ColorCurves;
  73752. /**
  73753. * Serializes the current color curve instance to a json representation.
  73754. * @return a JSON representation
  73755. */
  73756. serialize(): any;
  73757. /**
  73758. * Parses the color curve from a json representation.
  73759. * @param source the JSON source to parse
  73760. * @return The parsed curves
  73761. */
  73762. static Parse(source: any): ColorCurves;
  73763. }
  73764. }
  73765. declare module BABYLON {
  73766. /**
  73767. * Interface to follow in your material defines to integrate easily the
  73768. * Image proccessing functions.
  73769. * @hidden
  73770. */
  73771. export interface IImageProcessingConfigurationDefines {
  73772. IMAGEPROCESSING: boolean;
  73773. VIGNETTE: boolean;
  73774. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73775. VIGNETTEBLENDMODEOPAQUE: boolean;
  73776. TONEMAPPING: boolean;
  73777. TONEMAPPING_ACES: boolean;
  73778. CONTRAST: boolean;
  73779. EXPOSURE: boolean;
  73780. COLORCURVES: boolean;
  73781. COLORGRADING: boolean;
  73782. COLORGRADING3D: boolean;
  73783. SAMPLER3DGREENDEPTH: boolean;
  73784. SAMPLER3DBGRMAP: boolean;
  73785. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73786. }
  73787. /**
  73788. * @hidden
  73789. */
  73790. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73791. IMAGEPROCESSING: boolean;
  73792. VIGNETTE: boolean;
  73793. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73794. VIGNETTEBLENDMODEOPAQUE: boolean;
  73795. TONEMAPPING: boolean;
  73796. TONEMAPPING_ACES: boolean;
  73797. CONTRAST: boolean;
  73798. COLORCURVES: boolean;
  73799. COLORGRADING: boolean;
  73800. COLORGRADING3D: boolean;
  73801. SAMPLER3DGREENDEPTH: boolean;
  73802. SAMPLER3DBGRMAP: boolean;
  73803. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73804. EXPOSURE: boolean;
  73805. constructor();
  73806. }
  73807. /**
  73808. * This groups together the common properties used for image processing either in direct forward pass
  73809. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73810. * or not.
  73811. */
  73812. export class ImageProcessingConfiguration {
  73813. /**
  73814. * Default tone mapping applied in BabylonJS.
  73815. */
  73816. static readonly TONEMAPPING_STANDARD: number;
  73817. /**
  73818. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73819. * to other engines rendering to increase portability.
  73820. */
  73821. static readonly TONEMAPPING_ACES: number;
  73822. /**
  73823. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73824. */
  73825. colorCurves: Nullable<ColorCurves>;
  73826. private _colorCurvesEnabled;
  73827. /**
  73828. * Gets wether the color curves effect is enabled.
  73829. */
  73830. /**
  73831. * Sets wether the color curves effect is enabled.
  73832. */
  73833. colorCurvesEnabled: boolean;
  73834. private _colorGradingTexture;
  73835. /**
  73836. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73837. */
  73838. /**
  73839. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73840. */
  73841. colorGradingTexture: Nullable<BaseTexture>;
  73842. private _colorGradingEnabled;
  73843. /**
  73844. * Gets wether the color grading effect is enabled.
  73845. */
  73846. /**
  73847. * Sets wether the color grading effect is enabled.
  73848. */
  73849. colorGradingEnabled: boolean;
  73850. private _colorGradingWithGreenDepth;
  73851. /**
  73852. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73853. */
  73854. /**
  73855. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73856. */
  73857. colorGradingWithGreenDepth: boolean;
  73858. private _colorGradingBGR;
  73859. /**
  73860. * Gets wether the color grading texture contains BGR values.
  73861. */
  73862. /**
  73863. * Sets wether the color grading texture contains BGR values.
  73864. */
  73865. colorGradingBGR: boolean;
  73866. /** @hidden */
  73867. _exposure: number;
  73868. /**
  73869. * Gets the Exposure used in the effect.
  73870. */
  73871. /**
  73872. * Sets the Exposure used in the effect.
  73873. */
  73874. exposure: number;
  73875. private _toneMappingEnabled;
  73876. /**
  73877. * Gets wether the tone mapping effect is enabled.
  73878. */
  73879. /**
  73880. * Sets wether the tone mapping effect is enabled.
  73881. */
  73882. toneMappingEnabled: boolean;
  73883. private _toneMappingType;
  73884. /**
  73885. * Gets the type of tone mapping effect.
  73886. */
  73887. /**
  73888. * Sets the type of tone mapping effect used in BabylonJS.
  73889. */
  73890. toneMappingType: number;
  73891. protected _contrast: number;
  73892. /**
  73893. * Gets the contrast used in the effect.
  73894. */
  73895. /**
  73896. * Sets the contrast used in the effect.
  73897. */
  73898. contrast: number;
  73899. /**
  73900. * Vignette stretch size.
  73901. */
  73902. vignetteStretch: number;
  73903. /**
  73904. * Vignette centre X Offset.
  73905. */
  73906. vignetteCentreX: number;
  73907. /**
  73908. * Vignette centre Y Offset.
  73909. */
  73910. vignetteCentreY: number;
  73911. /**
  73912. * Vignette weight or intensity of the vignette effect.
  73913. */
  73914. vignetteWeight: number;
  73915. /**
  73916. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73917. * if vignetteEnabled is set to true.
  73918. */
  73919. vignetteColor: Color4;
  73920. /**
  73921. * Camera field of view used by the Vignette effect.
  73922. */
  73923. vignetteCameraFov: number;
  73924. private _vignetteBlendMode;
  73925. /**
  73926. * Gets the vignette blend mode allowing different kind of effect.
  73927. */
  73928. /**
  73929. * Sets the vignette blend mode allowing different kind of effect.
  73930. */
  73931. vignetteBlendMode: number;
  73932. private _vignetteEnabled;
  73933. /**
  73934. * Gets wether the vignette effect is enabled.
  73935. */
  73936. /**
  73937. * Sets wether the vignette effect is enabled.
  73938. */
  73939. vignetteEnabled: boolean;
  73940. private _applyByPostProcess;
  73941. /**
  73942. * Gets wether the image processing is applied through a post process or not.
  73943. */
  73944. /**
  73945. * Sets wether the image processing is applied through a post process or not.
  73946. */
  73947. applyByPostProcess: boolean;
  73948. private _isEnabled;
  73949. /**
  73950. * Gets wether the image processing is enabled or not.
  73951. */
  73952. /**
  73953. * Sets wether the image processing is enabled or not.
  73954. */
  73955. isEnabled: boolean;
  73956. /**
  73957. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73958. */
  73959. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73960. /**
  73961. * Method called each time the image processing information changes requires to recompile the effect.
  73962. */
  73963. protected _updateParameters(): void;
  73964. /**
  73965. * Gets the current class name.
  73966. * @return "ImageProcessingConfiguration"
  73967. */
  73968. getClassName(): string;
  73969. /**
  73970. * Prepare the list of uniforms associated with the Image Processing effects.
  73971. * @param uniforms The list of uniforms used in the effect
  73972. * @param defines the list of defines currently in use
  73973. */
  73974. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73975. /**
  73976. * Prepare the list of samplers associated with the Image Processing effects.
  73977. * @param samplersList The list of uniforms used in the effect
  73978. * @param defines the list of defines currently in use
  73979. */
  73980. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73981. /**
  73982. * Prepare the list of defines associated to the shader.
  73983. * @param defines the list of defines to complete
  73984. * @param forPostProcess Define if we are currently in post process mode or not
  73985. */
  73986. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73987. /**
  73988. * Returns true if all the image processing information are ready.
  73989. * @returns True if ready, otherwise, false
  73990. */
  73991. isReady(): boolean;
  73992. /**
  73993. * Binds the image processing to the shader.
  73994. * @param effect The effect to bind to
  73995. * @param aspectRatio Define the current aspect ratio of the effect
  73996. */
  73997. bind(effect: Effect, aspectRatio?: number): void;
  73998. /**
  73999. * Clones the current image processing instance.
  74000. * @return The cloned image processing
  74001. */
  74002. clone(): ImageProcessingConfiguration;
  74003. /**
  74004. * Serializes the current image processing instance to a json representation.
  74005. * @return a JSON representation
  74006. */
  74007. serialize(): any;
  74008. /**
  74009. * Parses the image processing from a json representation.
  74010. * @param source the JSON source to parse
  74011. * @return The parsed image processing
  74012. */
  74013. static Parse(source: any): ImageProcessingConfiguration;
  74014. private static _VIGNETTEMODE_MULTIPLY;
  74015. private static _VIGNETTEMODE_OPAQUE;
  74016. /**
  74017. * Used to apply the vignette as a mix with the pixel color.
  74018. */
  74019. static readonly VIGNETTEMODE_MULTIPLY: number;
  74020. /**
  74021. * Used to apply the vignette as a replacement of the pixel color.
  74022. */
  74023. static readonly VIGNETTEMODE_OPAQUE: number;
  74024. }
  74025. }
  74026. declare module BABYLON {
  74027. /** @hidden */
  74028. export var postprocessVertexShader: {
  74029. name: string;
  74030. shader: string;
  74031. };
  74032. }
  74033. declare module BABYLON {
  74034. /** Defines supported spaces */
  74035. export enum Space {
  74036. /** Local (object) space */
  74037. LOCAL = 0,
  74038. /** World space */
  74039. WORLD = 1,
  74040. /** Bone space */
  74041. BONE = 2
  74042. }
  74043. /** Defines the 3 main axes */
  74044. export class Axis {
  74045. /** X axis */
  74046. static X: Vector3;
  74047. /** Y axis */
  74048. static Y: Vector3;
  74049. /** Z axis */
  74050. static Z: Vector3;
  74051. }
  74052. }
  74053. declare module BABYLON {
  74054. /**
  74055. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74056. * This is the base of the follow, arc rotate cameras and Free camera
  74057. * @see http://doc.babylonjs.com/features/cameras
  74058. */
  74059. export class TargetCamera extends Camera {
  74060. private static _RigCamTransformMatrix;
  74061. private static _TargetTransformMatrix;
  74062. private static _TargetFocalPoint;
  74063. /**
  74064. * Define the current direction the camera is moving to
  74065. */
  74066. cameraDirection: Vector3;
  74067. /**
  74068. * Define the current rotation the camera is rotating to
  74069. */
  74070. cameraRotation: Vector2;
  74071. /**
  74072. * When set, the up vector of the camera will be updated by the rotation of the camera
  74073. */
  74074. updateUpVectorFromRotation: boolean;
  74075. private _tmpQuaternion;
  74076. /**
  74077. * Define the current rotation of the camera
  74078. */
  74079. rotation: Vector3;
  74080. /**
  74081. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74082. */
  74083. rotationQuaternion: Quaternion;
  74084. /**
  74085. * Define the current speed of the camera
  74086. */
  74087. speed: number;
  74088. /**
  74089. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74090. * around all axis.
  74091. */
  74092. noRotationConstraint: boolean;
  74093. /**
  74094. * Define the current target of the camera as an object or a position.
  74095. */
  74096. lockedTarget: any;
  74097. /** @hidden */
  74098. _currentTarget: Vector3;
  74099. /** @hidden */
  74100. _initialFocalDistance: number;
  74101. /** @hidden */
  74102. _viewMatrix: Matrix;
  74103. /** @hidden */
  74104. _camMatrix: Matrix;
  74105. /** @hidden */
  74106. _cameraTransformMatrix: Matrix;
  74107. /** @hidden */
  74108. _cameraRotationMatrix: Matrix;
  74109. /** @hidden */
  74110. _referencePoint: Vector3;
  74111. /** @hidden */
  74112. _transformedReferencePoint: Vector3;
  74113. protected _globalCurrentTarget: Vector3;
  74114. protected _globalCurrentUpVector: Vector3;
  74115. /** @hidden */
  74116. _reset: () => void;
  74117. private _defaultUp;
  74118. /**
  74119. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74120. * This is the base of the follow, arc rotate cameras and Free camera
  74121. * @see http://doc.babylonjs.com/features/cameras
  74122. * @param name Defines the name of the camera in the scene
  74123. * @param position Defines the start position of the camera in the scene
  74124. * @param scene Defines the scene the camera belongs to
  74125. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74126. */
  74127. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74128. /**
  74129. * Gets the position in front of the camera at a given distance.
  74130. * @param distance The distance from the camera we want the position to be
  74131. * @returns the position
  74132. */
  74133. getFrontPosition(distance: number): Vector3;
  74134. /** @hidden */
  74135. _getLockedTargetPosition(): Nullable<Vector3>;
  74136. private _storedPosition;
  74137. private _storedRotation;
  74138. private _storedRotationQuaternion;
  74139. /**
  74140. * Store current camera state of the camera (fov, position, rotation, etc..)
  74141. * @returns the camera
  74142. */
  74143. storeState(): Camera;
  74144. /**
  74145. * Restored camera state. You must call storeState() first
  74146. * @returns whether it was successful or not
  74147. * @hidden
  74148. */
  74149. _restoreStateValues(): boolean;
  74150. /** @hidden */
  74151. _initCache(): void;
  74152. /** @hidden */
  74153. _updateCache(ignoreParentClass?: boolean): void;
  74154. /** @hidden */
  74155. _isSynchronizedViewMatrix(): boolean;
  74156. /** @hidden */
  74157. _computeLocalCameraSpeed(): number;
  74158. /**
  74159. * Defines the target the camera should look at.
  74160. * @param target Defines the new target as a Vector or a mesh
  74161. */
  74162. setTarget(target: Vector3): void;
  74163. /**
  74164. * Return the current target position of the camera. This value is expressed in local space.
  74165. * @returns the target position
  74166. */
  74167. getTarget(): Vector3;
  74168. /** @hidden */
  74169. _decideIfNeedsToMove(): boolean;
  74170. /** @hidden */
  74171. _updatePosition(): void;
  74172. /** @hidden */
  74173. _checkInputs(): void;
  74174. protected _updateCameraRotationMatrix(): void;
  74175. /**
  74176. * 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)
  74177. * @returns the current camera
  74178. */
  74179. private _rotateUpVectorWithCameraRotationMatrix;
  74180. private _cachedRotationZ;
  74181. private _cachedQuaternionRotationZ;
  74182. /** @hidden */
  74183. _getViewMatrix(): Matrix;
  74184. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74185. /**
  74186. * @hidden
  74187. */
  74188. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74189. /**
  74190. * @hidden
  74191. */
  74192. _updateRigCameras(): void;
  74193. private _getRigCamPositionAndTarget;
  74194. /**
  74195. * Gets the current object class name.
  74196. * @return the class name
  74197. */
  74198. getClassName(): string;
  74199. }
  74200. }
  74201. declare module BABYLON {
  74202. /**
  74203. * Gather the list of keyboard event types as constants.
  74204. */
  74205. export class KeyboardEventTypes {
  74206. /**
  74207. * The keydown event is fired when a key becomes active (pressed).
  74208. */
  74209. static readonly KEYDOWN: number;
  74210. /**
  74211. * The keyup event is fired when a key has been released.
  74212. */
  74213. static readonly KEYUP: number;
  74214. }
  74215. /**
  74216. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74217. */
  74218. export class KeyboardInfo {
  74219. /**
  74220. * Defines the type of event (KeyboardEventTypes)
  74221. */
  74222. type: number;
  74223. /**
  74224. * Defines the related dom event
  74225. */
  74226. event: KeyboardEvent;
  74227. /**
  74228. * Instantiates a new keyboard info.
  74229. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74230. * @param type Defines the type of event (KeyboardEventTypes)
  74231. * @param event Defines the related dom event
  74232. */
  74233. constructor(
  74234. /**
  74235. * Defines the type of event (KeyboardEventTypes)
  74236. */
  74237. type: number,
  74238. /**
  74239. * Defines the related dom event
  74240. */
  74241. event: KeyboardEvent);
  74242. }
  74243. /**
  74244. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74245. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74246. */
  74247. export class KeyboardInfoPre extends KeyboardInfo {
  74248. /**
  74249. * Defines the type of event (KeyboardEventTypes)
  74250. */
  74251. type: number;
  74252. /**
  74253. * Defines the related dom event
  74254. */
  74255. event: KeyboardEvent;
  74256. /**
  74257. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74258. */
  74259. skipOnPointerObservable: boolean;
  74260. /**
  74261. * Instantiates a new keyboard pre info.
  74262. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74263. * @param type Defines the type of event (KeyboardEventTypes)
  74264. * @param event Defines the related dom event
  74265. */
  74266. constructor(
  74267. /**
  74268. * Defines the type of event (KeyboardEventTypes)
  74269. */
  74270. type: number,
  74271. /**
  74272. * Defines the related dom event
  74273. */
  74274. event: KeyboardEvent);
  74275. }
  74276. }
  74277. declare module BABYLON {
  74278. /**
  74279. * Manage the keyboard inputs to control the movement of a free camera.
  74280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74281. */
  74282. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74283. /**
  74284. * Defines the camera the input is attached to.
  74285. */
  74286. camera: FreeCamera;
  74287. /**
  74288. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74289. */
  74290. keysUp: number[];
  74291. /**
  74292. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74293. */
  74294. keysDown: number[];
  74295. /**
  74296. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74297. */
  74298. keysLeft: number[];
  74299. /**
  74300. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74301. */
  74302. keysRight: number[];
  74303. private _keys;
  74304. private _onCanvasBlurObserver;
  74305. private _onKeyboardObserver;
  74306. private _engine;
  74307. private _scene;
  74308. /**
  74309. * Attach the input controls to a specific dom element to get the input from.
  74310. * @param element Defines the element the controls should be listened from
  74311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74312. */
  74313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74314. /**
  74315. * Detach the current controls from the specified dom element.
  74316. * @param element Defines the element to stop listening the inputs from
  74317. */
  74318. detachControl(element: Nullable<HTMLElement>): void;
  74319. /**
  74320. * Update the current camera state depending on the inputs that have been used this frame.
  74321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74322. */
  74323. checkInputs(): void;
  74324. /**
  74325. * Gets the class name of the current intput.
  74326. * @returns the class name
  74327. */
  74328. getClassName(): string;
  74329. /** @hidden */
  74330. _onLostFocus(): void;
  74331. /**
  74332. * Get the friendly name associated with the input class.
  74333. * @returns the input friendly name
  74334. */
  74335. getSimpleName(): string;
  74336. }
  74337. }
  74338. declare module BABYLON {
  74339. /**
  74340. * Interface describing all the common properties and methods a shadow light needs to implement.
  74341. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74342. * as well as binding the different shadow properties to the effects.
  74343. */
  74344. export interface IShadowLight extends Light {
  74345. /**
  74346. * The light id in the scene (used in scene.findLighById for instance)
  74347. */
  74348. id: string;
  74349. /**
  74350. * The position the shdow will be casted from.
  74351. */
  74352. position: Vector3;
  74353. /**
  74354. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74355. */
  74356. direction: Vector3;
  74357. /**
  74358. * The transformed position. Position of the light in world space taking parenting in account.
  74359. */
  74360. transformedPosition: Vector3;
  74361. /**
  74362. * The transformed direction. Direction of the light in world space taking parenting in account.
  74363. */
  74364. transformedDirection: Vector3;
  74365. /**
  74366. * The friendly name of the light in the scene.
  74367. */
  74368. name: string;
  74369. /**
  74370. * Defines the shadow projection clipping minimum z value.
  74371. */
  74372. shadowMinZ: number;
  74373. /**
  74374. * Defines the shadow projection clipping maximum z value.
  74375. */
  74376. shadowMaxZ: number;
  74377. /**
  74378. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74379. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74380. */
  74381. computeTransformedInformation(): boolean;
  74382. /**
  74383. * Gets the scene the light belongs to.
  74384. * @returns The scene
  74385. */
  74386. getScene(): Scene;
  74387. /**
  74388. * Callback defining a custom Projection Matrix Builder.
  74389. * This can be used to override the default projection matrix computation.
  74390. */
  74391. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74392. /**
  74393. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74394. * @param matrix The materix to updated with the projection information
  74395. * @param viewMatrix The transform matrix of the light
  74396. * @param renderList The list of mesh to render in the map
  74397. * @returns The current light
  74398. */
  74399. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74400. /**
  74401. * Gets the current depth scale used in ESM.
  74402. * @returns The scale
  74403. */
  74404. getDepthScale(): number;
  74405. /**
  74406. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74407. * @returns true if a cube texture needs to be use
  74408. */
  74409. needCube(): boolean;
  74410. /**
  74411. * Detects if the projection matrix requires to be recomputed this frame.
  74412. * @returns true if it requires to be recomputed otherwise, false.
  74413. */
  74414. needProjectionMatrixCompute(): boolean;
  74415. /**
  74416. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74417. */
  74418. forceProjectionMatrixCompute(): void;
  74419. /**
  74420. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74421. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74422. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74423. */
  74424. getShadowDirection(faceIndex?: number): Vector3;
  74425. /**
  74426. * Gets the minZ used for shadow according to both the scene and the light.
  74427. * @param activeCamera The camera we are returning the min for
  74428. * @returns the depth min z
  74429. */
  74430. getDepthMinZ(activeCamera: Camera): number;
  74431. /**
  74432. * Gets the maxZ used for shadow according to both the scene and the light.
  74433. * @param activeCamera The camera we are returning the max for
  74434. * @returns the depth max z
  74435. */
  74436. getDepthMaxZ(activeCamera: Camera): number;
  74437. }
  74438. /**
  74439. * Base implementation IShadowLight
  74440. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74441. */
  74442. export abstract class ShadowLight extends Light implements IShadowLight {
  74443. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74444. protected _position: Vector3;
  74445. protected _setPosition(value: Vector3): void;
  74446. /**
  74447. * Sets the position the shadow will be casted from. Also use as the light position for both
  74448. * point and spot lights.
  74449. */
  74450. /**
  74451. * Sets the position the shadow will be casted from. Also use as the light position for both
  74452. * point and spot lights.
  74453. */
  74454. position: Vector3;
  74455. protected _direction: Vector3;
  74456. protected _setDirection(value: Vector3): void;
  74457. /**
  74458. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74459. * Also use as the light direction on spot and directional lights.
  74460. */
  74461. /**
  74462. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74463. * Also use as the light direction on spot and directional lights.
  74464. */
  74465. direction: Vector3;
  74466. private _shadowMinZ;
  74467. /**
  74468. * Gets the shadow projection clipping minimum z value.
  74469. */
  74470. /**
  74471. * Sets the shadow projection clipping minimum z value.
  74472. */
  74473. shadowMinZ: number;
  74474. private _shadowMaxZ;
  74475. /**
  74476. * Sets the shadow projection clipping maximum z value.
  74477. */
  74478. /**
  74479. * Gets the shadow projection clipping maximum z value.
  74480. */
  74481. shadowMaxZ: number;
  74482. /**
  74483. * Callback defining a custom Projection Matrix Builder.
  74484. * This can be used to override the default projection matrix computation.
  74485. */
  74486. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74487. /**
  74488. * The transformed position. Position of the light in world space taking parenting in account.
  74489. */
  74490. transformedPosition: Vector3;
  74491. /**
  74492. * The transformed direction. Direction of the light in world space taking parenting in account.
  74493. */
  74494. transformedDirection: Vector3;
  74495. private _needProjectionMatrixCompute;
  74496. /**
  74497. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74498. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74499. */
  74500. computeTransformedInformation(): boolean;
  74501. /**
  74502. * Return the depth scale used for the shadow map.
  74503. * @returns the depth scale.
  74504. */
  74505. getDepthScale(): number;
  74506. /**
  74507. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74508. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74509. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74510. */
  74511. getShadowDirection(faceIndex?: number): Vector3;
  74512. /**
  74513. * Returns the ShadowLight absolute position in the World.
  74514. * @returns the position vector in world space
  74515. */
  74516. getAbsolutePosition(): Vector3;
  74517. /**
  74518. * Sets the ShadowLight direction toward the passed target.
  74519. * @param target The point to target in local space
  74520. * @returns the updated ShadowLight direction
  74521. */
  74522. setDirectionToTarget(target: Vector3): Vector3;
  74523. /**
  74524. * Returns the light rotation in euler definition.
  74525. * @returns the x y z rotation in local space.
  74526. */
  74527. getRotation(): Vector3;
  74528. /**
  74529. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74530. * @returns true if a cube texture needs to be use
  74531. */
  74532. needCube(): boolean;
  74533. /**
  74534. * Detects if the projection matrix requires to be recomputed this frame.
  74535. * @returns true if it requires to be recomputed otherwise, false.
  74536. */
  74537. needProjectionMatrixCompute(): boolean;
  74538. /**
  74539. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74540. */
  74541. forceProjectionMatrixCompute(): void;
  74542. /** @hidden */
  74543. _initCache(): void;
  74544. /** @hidden */
  74545. _isSynchronized(): boolean;
  74546. /**
  74547. * Computes the world matrix of the node
  74548. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74549. * @returns the world matrix
  74550. */
  74551. computeWorldMatrix(force?: boolean): Matrix;
  74552. /**
  74553. * Gets the minZ used for shadow according to both the scene and the light.
  74554. * @param activeCamera The camera we are returning the min for
  74555. * @returns the depth min z
  74556. */
  74557. getDepthMinZ(activeCamera: Camera): number;
  74558. /**
  74559. * Gets the maxZ used for shadow according to both the scene and the light.
  74560. * @param activeCamera The camera we are returning the max for
  74561. * @returns the depth max z
  74562. */
  74563. getDepthMaxZ(activeCamera: Camera): number;
  74564. /**
  74565. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74566. * @param matrix The materix to updated with the projection information
  74567. * @param viewMatrix The transform matrix of the light
  74568. * @param renderList The list of mesh to render in the map
  74569. * @returns The current light
  74570. */
  74571. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74572. }
  74573. }
  74574. declare module BABYLON {
  74575. /**
  74576. * "Static Class" containing the most commonly used helper while dealing with material for
  74577. * rendering purpose.
  74578. *
  74579. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74580. *
  74581. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74582. */
  74583. export class MaterialHelper {
  74584. /**
  74585. * Bind the current view position to an effect.
  74586. * @param effect The effect to be bound
  74587. * @param scene The scene the eyes position is used from
  74588. */
  74589. static BindEyePosition(effect: Effect, scene: Scene): void;
  74590. /**
  74591. * Helps preparing the defines values about the UVs in used in the effect.
  74592. * UVs are shared as much as we can accross channels in the shaders.
  74593. * @param texture The texture we are preparing the UVs for
  74594. * @param defines The defines to update
  74595. * @param key The channel key "diffuse", "specular"... used in the shader
  74596. */
  74597. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74598. /**
  74599. * Binds a texture matrix value to its corrsponding uniform
  74600. * @param texture The texture to bind the matrix for
  74601. * @param uniformBuffer The uniform buffer receivin the data
  74602. * @param key The channel key "diffuse", "specular"... used in the shader
  74603. */
  74604. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74605. /**
  74606. * Gets the current status of the fog (should it be enabled?)
  74607. * @param mesh defines the mesh to evaluate for fog support
  74608. * @param scene defines the hosting scene
  74609. * @returns true if fog must be enabled
  74610. */
  74611. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74612. /**
  74613. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74614. * @param mesh defines the current mesh
  74615. * @param scene defines the current scene
  74616. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74617. * @param pointsCloud defines if point cloud rendering has to be turned on
  74618. * @param fogEnabled defines if fog has to be turned on
  74619. * @param alphaTest defines if alpha testing has to be turned on
  74620. * @param defines defines the current list of defines
  74621. */
  74622. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74623. /**
  74624. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74625. * @param scene defines the current scene
  74626. * @param engine defines the current engine
  74627. * @param defines specifies the list of active defines
  74628. * @param useInstances defines if instances have to be turned on
  74629. * @param useClipPlane defines if clip plane have to be turned on
  74630. */
  74631. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74632. /**
  74633. * Prepares the defines for bones
  74634. * @param mesh The mesh containing the geometry data we will draw
  74635. * @param defines The defines to update
  74636. */
  74637. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74638. /**
  74639. * Prepares the defines for morph targets
  74640. * @param mesh The mesh containing the geometry data we will draw
  74641. * @param defines The defines to update
  74642. */
  74643. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74644. /**
  74645. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74646. * @param mesh The mesh containing the geometry data we will draw
  74647. * @param defines The defines to update
  74648. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74649. * @param useBones Precise whether bones should be used or not (override mesh info)
  74650. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74651. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74652. * @returns false if defines are considered not dirty and have not been checked
  74653. */
  74654. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74655. /**
  74656. * Prepares the defines related to multiview
  74657. * @param scene The scene we are intending to draw
  74658. * @param defines The defines to update
  74659. */
  74660. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74661. /**
  74662. * Prepares the defines related to the light information passed in parameter
  74663. * @param scene The scene we are intending to draw
  74664. * @param mesh The mesh the effect is compiling for
  74665. * @param light The light the effect is compiling for
  74666. * @param lightIndex The index of the light
  74667. * @param defines The defines to update
  74668. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74669. * @param state Defines the current state regarding what is needed (normals, etc...)
  74670. */
  74671. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74672. needNormals: boolean;
  74673. needRebuild: boolean;
  74674. shadowEnabled: boolean;
  74675. specularEnabled: boolean;
  74676. lightmapMode: boolean;
  74677. }): void;
  74678. /**
  74679. * Prepares the defines related to the light information passed in parameter
  74680. * @param scene The scene we are intending to draw
  74681. * @param mesh The mesh the effect is compiling for
  74682. * @param defines The defines to update
  74683. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74684. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74685. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74686. * @returns true if normals will be required for the rest of the effect
  74687. */
  74688. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74689. /**
  74690. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74691. * @param lightIndex defines the light index
  74692. * @param uniformsList The uniform list
  74693. * @param samplersList The sampler list
  74694. * @param projectedLightTexture defines if projected texture must be used
  74695. * @param uniformBuffersList defines an optional list of uniform buffers
  74696. */
  74697. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74698. /**
  74699. * Prepares the uniforms and samplers list to be used in the effect
  74700. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74701. * @param samplersList The sampler list
  74702. * @param defines The defines helping in the list generation
  74703. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74704. */
  74705. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74706. /**
  74707. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74708. * @param defines The defines to update while falling back
  74709. * @param fallbacks The authorized effect fallbacks
  74710. * @param maxSimultaneousLights The maximum number of lights allowed
  74711. * @param rank the current rank of the Effect
  74712. * @returns The newly affected rank
  74713. */
  74714. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74715. private static _TmpMorphInfluencers;
  74716. /**
  74717. * Prepares the list of attributes required for morph targets according to the effect defines.
  74718. * @param attribs The current list of supported attribs
  74719. * @param mesh The mesh to prepare the morph targets attributes for
  74720. * @param influencers The number of influencers
  74721. */
  74722. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74723. /**
  74724. * Prepares the list of attributes required for morph targets according to the effect defines.
  74725. * @param attribs The current list of supported attribs
  74726. * @param mesh The mesh to prepare the morph targets attributes for
  74727. * @param defines The current Defines of the effect
  74728. */
  74729. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74730. /**
  74731. * Prepares the list of attributes required for bones according to the effect defines.
  74732. * @param attribs The current list of supported attribs
  74733. * @param mesh The mesh to prepare the bones attributes for
  74734. * @param defines The current Defines of the effect
  74735. * @param fallbacks The current efffect fallback strategy
  74736. */
  74737. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74738. /**
  74739. * Check and prepare the list of attributes required for instances according to the effect defines.
  74740. * @param attribs The current list of supported attribs
  74741. * @param defines The current MaterialDefines of the effect
  74742. */
  74743. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74744. /**
  74745. * Add the list of attributes required for instances to the attribs array.
  74746. * @param attribs The current list of supported attribs
  74747. */
  74748. static PushAttributesForInstances(attribs: string[]): void;
  74749. /**
  74750. * Binds the light shadow information to the effect for the given mesh.
  74751. * @param light The light containing the generator
  74752. * @param scene The scene the lights belongs to
  74753. * @param mesh The mesh we are binding the information to render
  74754. * @param lightIndex The light index in the effect used to render the mesh
  74755. * @param effect The effect we are binding the data to
  74756. */
  74757. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74758. /**
  74759. * Binds the light information to the effect.
  74760. * @param light The light containing the generator
  74761. * @param effect The effect we are binding the data to
  74762. * @param lightIndex The light index in the effect used to render
  74763. */
  74764. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74765. /**
  74766. * Binds the lights information from the scene to the effect for the given mesh.
  74767. * @param light Light to bind
  74768. * @param lightIndex Light index
  74769. * @param scene The scene where the light belongs to
  74770. * @param mesh The mesh we are binding the information to render
  74771. * @param effect The effect we are binding the data to
  74772. * @param useSpecular Defines if specular is supported
  74773. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74774. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74775. */
  74776. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74777. /**
  74778. * Binds the lights information from the scene to the effect for the given mesh.
  74779. * @param scene The scene the lights belongs to
  74780. * @param mesh The mesh we are binding the information to render
  74781. * @param effect The effect we are binding the data to
  74782. * @param defines The generated defines for the effect
  74783. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74784. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74785. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74786. */
  74787. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74788. private static _tempFogColor;
  74789. /**
  74790. * Binds the fog information from the scene to the effect for the given mesh.
  74791. * @param scene The scene the lights belongs to
  74792. * @param mesh The mesh we are binding the information to render
  74793. * @param effect The effect we are binding the data to
  74794. * @param linearSpace Defines if the fog effect is applied in linear space
  74795. */
  74796. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74797. /**
  74798. * Binds the bones information from the mesh to the effect.
  74799. * @param mesh The mesh we are binding the information to render
  74800. * @param effect The effect we are binding the data to
  74801. */
  74802. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74803. /**
  74804. * Binds the morph targets information from the mesh to the effect.
  74805. * @param abstractMesh The mesh we are binding the information to render
  74806. * @param effect The effect we are binding the data to
  74807. */
  74808. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74809. /**
  74810. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74811. * @param defines The generated defines used in the effect
  74812. * @param effect The effect we are binding the data to
  74813. * @param scene The scene we are willing to render with logarithmic scale for
  74814. */
  74815. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74816. /**
  74817. * Binds the clip plane information from the scene to the effect.
  74818. * @param scene The scene the clip plane information are extracted from
  74819. * @param effect The effect we are binding the data to
  74820. */
  74821. static BindClipPlane(effect: Effect, scene: Scene): void;
  74822. }
  74823. }
  74824. declare module BABYLON {
  74825. /** @hidden */
  74826. export var packingFunctions: {
  74827. name: string;
  74828. shader: string;
  74829. };
  74830. }
  74831. declare module BABYLON {
  74832. /** @hidden */
  74833. export var shadowMapPixelShader: {
  74834. name: string;
  74835. shader: string;
  74836. };
  74837. }
  74838. declare module BABYLON {
  74839. /** @hidden */
  74840. export var bonesDeclaration: {
  74841. name: string;
  74842. shader: string;
  74843. };
  74844. }
  74845. declare module BABYLON {
  74846. /** @hidden */
  74847. export var morphTargetsVertexGlobalDeclaration: {
  74848. name: string;
  74849. shader: string;
  74850. };
  74851. }
  74852. declare module BABYLON {
  74853. /** @hidden */
  74854. export var morphTargetsVertexDeclaration: {
  74855. name: string;
  74856. shader: string;
  74857. };
  74858. }
  74859. declare module BABYLON {
  74860. /** @hidden */
  74861. export var instancesDeclaration: {
  74862. name: string;
  74863. shader: string;
  74864. };
  74865. }
  74866. declare module BABYLON {
  74867. /** @hidden */
  74868. export var helperFunctions: {
  74869. name: string;
  74870. shader: string;
  74871. };
  74872. }
  74873. declare module BABYLON {
  74874. /** @hidden */
  74875. export var morphTargetsVertex: {
  74876. name: string;
  74877. shader: string;
  74878. };
  74879. }
  74880. declare module BABYLON {
  74881. /** @hidden */
  74882. export var instancesVertex: {
  74883. name: string;
  74884. shader: string;
  74885. };
  74886. }
  74887. declare module BABYLON {
  74888. /** @hidden */
  74889. export var bonesVertex: {
  74890. name: string;
  74891. shader: string;
  74892. };
  74893. }
  74894. declare module BABYLON {
  74895. /** @hidden */
  74896. export var shadowMapVertexShader: {
  74897. name: string;
  74898. shader: string;
  74899. };
  74900. }
  74901. declare module BABYLON {
  74902. /** @hidden */
  74903. export var depthBoxBlurPixelShader: {
  74904. name: string;
  74905. shader: string;
  74906. };
  74907. }
  74908. declare module BABYLON {
  74909. /**
  74910. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74911. */
  74912. export interface ICustomShaderOptions {
  74913. /**
  74914. * Gets or sets the custom shader name to use
  74915. */
  74916. shaderName: string;
  74917. /**
  74918. * The list of attribute names used in the shader
  74919. */
  74920. attributes?: string[];
  74921. /**
  74922. * The list of unifrom names used in the shader
  74923. */
  74924. uniforms?: string[];
  74925. /**
  74926. * The list of sampler names used in the shader
  74927. */
  74928. samplers?: string[];
  74929. /**
  74930. * The list of defines used in the shader
  74931. */
  74932. defines?: string[];
  74933. }
  74934. /**
  74935. * Interface to implement to create a shadow generator compatible with BJS.
  74936. */
  74937. export interface IShadowGenerator {
  74938. /**
  74939. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74940. * @returns The render target texture if present otherwise, null
  74941. */
  74942. getShadowMap(): Nullable<RenderTargetTexture>;
  74943. /**
  74944. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74945. * @returns The render target texture if the shadow map is present otherwise, null
  74946. */
  74947. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74948. /**
  74949. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74950. * @param subMesh The submesh we want to render in the shadow map
  74951. * @param useInstances Defines wether will draw in the map using instances
  74952. * @returns true if ready otherwise, false
  74953. */
  74954. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74955. /**
  74956. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74957. * @param defines Defines of the material we want to update
  74958. * @param lightIndex Index of the light in the enabled light list of the material
  74959. */
  74960. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74961. /**
  74962. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74963. * defined in the generator but impacting the effect).
  74964. * It implies the unifroms available on the materials are the standard BJS ones.
  74965. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74966. * @param effect The effect we are binfing the information for
  74967. */
  74968. bindShadowLight(lightIndex: string, effect: Effect): void;
  74969. /**
  74970. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74971. * (eq to shadow prjection matrix * light transform matrix)
  74972. * @returns The transform matrix used to create the shadow map
  74973. */
  74974. getTransformMatrix(): Matrix;
  74975. /**
  74976. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74977. * Cube and 2D textures for instance.
  74978. */
  74979. recreateShadowMap(): void;
  74980. /**
  74981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74982. * @param onCompiled Callback triggered at the and of the effects compilation
  74983. * @param options Sets of optional options forcing the compilation with different modes
  74984. */
  74985. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74986. useInstances: boolean;
  74987. }>): void;
  74988. /**
  74989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74990. * @param options Sets of optional options forcing the compilation with different modes
  74991. * @returns A promise that resolves when the compilation completes
  74992. */
  74993. forceCompilationAsync(options?: Partial<{
  74994. useInstances: boolean;
  74995. }>): Promise<void>;
  74996. /**
  74997. * Serializes the shadow generator setup to a json object.
  74998. * @returns The serialized JSON object
  74999. */
  75000. serialize(): any;
  75001. /**
  75002. * Disposes the Shadow map and related Textures and effects.
  75003. */
  75004. dispose(): void;
  75005. }
  75006. /**
  75007. * Default implementation IShadowGenerator.
  75008. * This is the main object responsible of generating shadows in the framework.
  75009. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75010. */
  75011. export class ShadowGenerator implements IShadowGenerator {
  75012. /**
  75013. * Shadow generator mode None: no filtering applied.
  75014. */
  75015. static readonly FILTER_NONE: number;
  75016. /**
  75017. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75018. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75019. */
  75020. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75021. /**
  75022. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75023. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75024. */
  75025. static readonly FILTER_POISSONSAMPLING: number;
  75026. /**
  75027. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75028. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75029. */
  75030. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75031. /**
  75032. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75033. * edge artifacts on steep falloff.
  75034. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75035. */
  75036. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75037. /**
  75038. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75039. * edge artifacts on steep falloff.
  75040. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75041. */
  75042. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75043. /**
  75044. * Shadow generator mode PCF: Percentage Closer Filtering
  75045. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75046. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75047. */
  75048. static readonly FILTER_PCF: number;
  75049. /**
  75050. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75051. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75052. * Contact Hardening
  75053. */
  75054. static readonly FILTER_PCSS: number;
  75055. /**
  75056. * Reserved for PCF and PCSS
  75057. * Highest Quality.
  75058. *
  75059. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75060. *
  75061. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75062. */
  75063. static readonly QUALITY_HIGH: number;
  75064. /**
  75065. * Reserved for PCF and PCSS
  75066. * Good tradeoff for quality/perf cross devices
  75067. *
  75068. * Execute PCF on a 3*3 kernel.
  75069. *
  75070. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75071. */
  75072. static readonly QUALITY_MEDIUM: number;
  75073. /**
  75074. * Reserved for PCF and PCSS
  75075. * The lowest quality but the fastest.
  75076. *
  75077. * Execute PCF on a 1*1 kernel.
  75078. *
  75079. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75080. */
  75081. static readonly QUALITY_LOW: number;
  75082. /** Gets or sets the custom shader name to use */
  75083. customShaderOptions: ICustomShaderOptions;
  75084. /**
  75085. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75086. */
  75087. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75088. /**
  75089. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75090. */
  75091. onAfterShadowMapRenderObservable: Observable<Effect>;
  75092. /**
  75093. * Observable triggered before a mesh is rendered in the shadow map.
  75094. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75095. */
  75096. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75097. /**
  75098. * Observable triggered after a mesh is rendered in the shadow map.
  75099. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75100. */
  75101. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75102. private _bias;
  75103. /**
  75104. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75105. */
  75106. /**
  75107. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75108. */
  75109. bias: number;
  75110. private _normalBias;
  75111. /**
  75112. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75113. */
  75114. /**
  75115. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75116. */
  75117. normalBias: number;
  75118. private _blurBoxOffset;
  75119. /**
  75120. * Gets the blur box offset: offset applied during the blur pass.
  75121. * Only useful if useKernelBlur = false
  75122. */
  75123. /**
  75124. * Sets the blur box offset: offset applied during the blur pass.
  75125. * Only useful if useKernelBlur = false
  75126. */
  75127. blurBoxOffset: number;
  75128. private _blurScale;
  75129. /**
  75130. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75131. * 2 means half of the size.
  75132. */
  75133. /**
  75134. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75135. * 2 means half of the size.
  75136. */
  75137. blurScale: number;
  75138. private _blurKernel;
  75139. /**
  75140. * Gets the blur kernel: kernel size of the blur pass.
  75141. * Only useful if useKernelBlur = true
  75142. */
  75143. /**
  75144. * Sets the blur kernel: kernel size of the blur pass.
  75145. * Only useful if useKernelBlur = true
  75146. */
  75147. blurKernel: number;
  75148. private _useKernelBlur;
  75149. /**
  75150. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75151. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75152. */
  75153. /**
  75154. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75155. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75156. */
  75157. useKernelBlur: boolean;
  75158. private _depthScale;
  75159. /**
  75160. * Gets the depth scale used in ESM mode.
  75161. */
  75162. /**
  75163. * Sets the depth scale used in ESM mode.
  75164. * This can override the scale stored on the light.
  75165. */
  75166. depthScale: number;
  75167. private _filter;
  75168. /**
  75169. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75170. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75171. */
  75172. /**
  75173. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75174. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75175. */
  75176. filter: number;
  75177. /**
  75178. * Gets if the current filter is set to Poisson Sampling.
  75179. */
  75180. /**
  75181. * Sets the current filter to Poisson Sampling.
  75182. */
  75183. usePoissonSampling: boolean;
  75184. /**
  75185. * Gets if the current filter is set to ESM.
  75186. */
  75187. /**
  75188. * Sets the current filter is to ESM.
  75189. */
  75190. useExponentialShadowMap: boolean;
  75191. /**
  75192. * Gets if the current filter is set to filtered ESM.
  75193. */
  75194. /**
  75195. * Gets if the current filter is set to filtered ESM.
  75196. */
  75197. useBlurExponentialShadowMap: boolean;
  75198. /**
  75199. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75200. * exponential to prevent steep falloff artifacts).
  75201. */
  75202. /**
  75203. * Sets the current filter to "close ESM" (using the inverse of the
  75204. * exponential to prevent steep falloff artifacts).
  75205. */
  75206. useCloseExponentialShadowMap: boolean;
  75207. /**
  75208. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75209. * exponential to prevent steep falloff artifacts).
  75210. */
  75211. /**
  75212. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75213. * exponential to prevent steep falloff artifacts).
  75214. */
  75215. useBlurCloseExponentialShadowMap: boolean;
  75216. /**
  75217. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75218. */
  75219. /**
  75220. * Sets the current filter to "PCF" (percentage closer filtering).
  75221. */
  75222. usePercentageCloserFiltering: boolean;
  75223. private _filteringQuality;
  75224. /**
  75225. * Gets the PCF or PCSS Quality.
  75226. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75227. */
  75228. /**
  75229. * Sets the PCF or PCSS Quality.
  75230. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75231. */
  75232. filteringQuality: number;
  75233. /**
  75234. * Gets if the current filter is set to "PCSS" (contact hardening).
  75235. */
  75236. /**
  75237. * Sets the current filter to "PCSS" (contact hardening).
  75238. */
  75239. useContactHardeningShadow: boolean;
  75240. private _contactHardeningLightSizeUVRatio;
  75241. /**
  75242. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75243. * Using a ratio helps keeping shape stability independently of the map size.
  75244. *
  75245. * It does not account for the light projection as it was having too much
  75246. * instability during the light setup or during light position changes.
  75247. *
  75248. * Only valid if useContactHardeningShadow is true.
  75249. */
  75250. /**
  75251. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75252. * Using a ratio helps keeping shape stability independently of the map size.
  75253. *
  75254. * It does not account for the light projection as it was having too much
  75255. * instability during the light setup or during light position changes.
  75256. *
  75257. * Only valid if useContactHardeningShadow is true.
  75258. */
  75259. contactHardeningLightSizeUVRatio: number;
  75260. private _darkness;
  75261. /** Gets or sets the actual darkness of a shadow */
  75262. darkness: number;
  75263. /**
  75264. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75265. * 0 means strongest and 1 would means no shadow.
  75266. * @returns the darkness.
  75267. */
  75268. getDarkness(): number;
  75269. /**
  75270. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75271. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75272. * @returns the shadow generator allowing fluent coding.
  75273. */
  75274. setDarkness(darkness: number): ShadowGenerator;
  75275. private _transparencyShadow;
  75276. /** Gets or sets the ability to have transparent shadow */
  75277. transparencyShadow: boolean;
  75278. /**
  75279. * Sets the ability to have transparent shadow (boolean).
  75280. * @param transparent True if transparent else False
  75281. * @returns the shadow generator allowing fluent coding
  75282. */
  75283. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75284. private _shadowMap;
  75285. private _shadowMap2;
  75286. /**
  75287. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75288. * @returns The render target texture if present otherwise, null
  75289. */
  75290. getShadowMap(): Nullable<RenderTargetTexture>;
  75291. /**
  75292. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75293. * @returns The render target texture if the shadow map is present otherwise, null
  75294. */
  75295. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75296. /**
  75297. * Gets the class name of that object
  75298. * @returns "ShadowGenerator"
  75299. */
  75300. getClassName(): string;
  75301. /**
  75302. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75303. * @param mesh Mesh to add
  75304. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75305. * @returns the Shadow Generator itself
  75306. */
  75307. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75308. /**
  75309. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75310. * @param mesh Mesh to remove
  75311. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75312. * @returns the Shadow Generator itself
  75313. */
  75314. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75315. /**
  75316. * Controls the extent to which the shadows fade out at the edge of the frustum
  75317. * Used only by directionals and spots
  75318. */
  75319. frustumEdgeFalloff: number;
  75320. private _light;
  75321. /**
  75322. * Returns the associated light object.
  75323. * @returns the light generating the shadow
  75324. */
  75325. getLight(): IShadowLight;
  75326. /**
  75327. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75328. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75329. * It might on the other hand introduce peter panning.
  75330. */
  75331. forceBackFacesOnly: boolean;
  75332. private _scene;
  75333. private _lightDirection;
  75334. private _effect;
  75335. private _viewMatrix;
  75336. private _projectionMatrix;
  75337. private _transformMatrix;
  75338. private _cachedPosition;
  75339. private _cachedDirection;
  75340. private _cachedDefines;
  75341. private _currentRenderID;
  75342. private _boxBlurPostprocess;
  75343. private _kernelBlurXPostprocess;
  75344. private _kernelBlurYPostprocess;
  75345. private _blurPostProcesses;
  75346. private _mapSize;
  75347. private _currentFaceIndex;
  75348. private _currentFaceIndexCache;
  75349. private _textureType;
  75350. private _defaultTextureMatrix;
  75351. /** @hidden */
  75352. static _SceneComponentInitialization: (scene: Scene) => void;
  75353. /**
  75354. * Creates a ShadowGenerator object.
  75355. * A ShadowGenerator is the required tool to use the shadows.
  75356. * Each light casting shadows needs to use its own ShadowGenerator.
  75357. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75358. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75359. * @param light The light object generating the shadows.
  75360. * @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.
  75361. */
  75362. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75363. private _initializeGenerator;
  75364. private _initializeShadowMap;
  75365. private _initializeBlurRTTAndPostProcesses;
  75366. private _renderForShadowMap;
  75367. private _renderSubMeshForShadowMap;
  75368. private _applyFilterValues;
  75369. /**
  75370. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75371. * @param onCompiled Callback triggered at the and of the effects compilation
  75372. * @param options Sets of optional options forcing the compilation with different modes
  75373. */
  75374. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75375. useInstances: boolean;
  75376. }>): void;
  75377. /**
  75378. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75379. * @param options Sets of optional options forcing the compilation with different modes
  75380. * @returns A promise that resolves when the compilation completes
  75381. */
  75382. forceCompilationAsync(options?: Partial<{
  75383. useInstances: boolean;
  75384. }>): Promise<void>;
  75385. /**
  75386. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75387. * @param subMesh The submesh we want to render in the shadow map
  75388. * @param useInstances Defines wether will draw in the map using instances
  75389. * @returns true if ready otherwise, false
  75390. */
  75391. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75392. /**
  75393. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75394. * @param defines Defines of the material we want to update
  75395. * @param lightIndex Index of the light in the enabled light list of the material
  75396. */
  75397. prepareDefines(defines: any, lightIndex: number): void;
  75398. /**
  75399. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75400. * defined in the generator but impacting the effect).
  75401. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75402. * @param effect The effect we are binfing the information for
  75403. */
  75404. bindShadowLight(lightIndex: string, effect: Effect): void;
  75405. /**
  75406. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75407. * (eq to shadow prjection matrix * light transform matrix)
  75408. * @returns The transform matrix used to create the shadow map
  75409. */
  75410. getTransformMatrix(): Matrix;
  75411. /**
  75412. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75413. * Cube and 2D textures for instance.
  75414. */
  75415. recreateShadowMap(): void;
  75416. private _disposeBlurPostProcesses;
  75417. private _disposeRTTandPostProcesses;
  75418. /**
  75419. * Disposes the ShadowGenerator.
  75420. * Returns nothing.
  75421. */
  75422. dispose(): void;
  75423. /**
  75424. * Serializes the shadow generator setup to a json object.
  75425. * @returns The serialized JSON object
  75426. */
  75427. serialize(): any;
  75428. /**
  75429. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75430. * @param parsedShadowGenerator The JSON object to parse
  75431. * @param scene The scene to create the shadow map for
  75432. * @returns The parsed shadow generator
  75433. */
  75434. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75435. }
  75436. }
  75437. declare module BABYLON {
  75438. /**
  75439. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75440. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75441. * 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.
  75442. */
  75443. export abstract class Light extends Node {
  75444. /**
  75445. * Falloff Default: light is falling off following the material specification:
  75446. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75447. */
  75448. static readonly FALLOFF_DEFAULT: number;
  75449. /**
  75450. * Falloff Physical: light is falling off following the inverse squared distance law.
  75451. */
  75452. static readonly FALLOFF_PHYSICAL: number;
  75453. /**
  75454. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75455. * to enhance interoperability with other engines.
  75456. */
  75457. static readonly FALLOFF_GLTF: number;
  75458. /**
  75459. * Falloff Standard: light is falling off like in the standard material
  75460. * to enhance interoperability with other materials.
  75461. */
  75462. static readonly FALLOFF_STANDARD: number;
  75463. /**
  75464. * If every light affecting the material is in this lightmapMode,
  75465. * material.lightmapTexture adds or multiplies
  75466. * (depends on material.useLightmapAsShadowmap)
  75467. * after every other light calculations.
  75468. */
  75469. static readonly LIGHTMAP_DEFAULT: number;
  75470. /**
  75471. * material.lightmapTexture as only diffuse lighting from this light
  75472. * adds only specular lighting from this light
  75473. * adds dynamic shadows
  75474. */
  75475. static readonly LIGHTMAP_SPECULAR: number;
  75476. /**
  75477. * material.lightmapTexture as only lighting
  75478. * no light calculation from this light
  75479. * only adds dynamic shadows from this light
  75480. */
  75481. static readonly LIGHTMAP_SHADOWSONLY: number;
  75482. /**
  75483. * Each light type uses the default quantity according to its type:
  75484. * point/spot lights use luminous intensity
  75485. * directional lights use illuminance
  75486. */
  75487. static readonly INTENSITYMODE_AUTOMATIC: number;
  75488. /**
  75489. * lumen (lm)
  75490. */
  75491. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75492. /**
  75493. * candela (lm/sr)
  75494. */
  75495. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75496. /**
  75497. * lux (lm/m^2)
  75498. */
  75499. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75500. /**
  75501. * nit (cd/m^2)
  75502. */
  75503. static readonly INTENSITYMODE_LUMINANCE: number;
  75504. /**
  75505. * Light type const id of the point light.
  75506. */
  75507. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75508. /**
  75509. * Light type const id of the directional light.
  75510. */
  75511. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75512. /**
  75513. * Light type const id of the spot light.
  75514. */
  75515. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75516. /**
  75517. * Light type const id of the hemispheric light.
  75518. */
  75519. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75520. /**
  75521. * Diffuse gives the basic color to an object.
  75522. */
  75523. diffuse: Color3;
  75524. /**
  75525. * Specular produces a highlight color on an object.
  75526. * Note: This is note affecting PBR materials.
  75527. */
  75528. specular: Color3;
  75529. /**
  75530. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75531. * falling off base on range or angle.
  75532. * This can be set to any values in Light.FALLOFF_x.
  75533. *
  75534. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75535. * other types of materials.
  75536. */
  75537. falloffType: number;
  75538. /**
  75539. * Strength of the light.
  75540. * Note: By default it is define in the framework own unit.
  75541. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75542. */
  75543. intensity: number;
  75544. private _range;
  75545. protected _inverseSquaredRange: number;
  75546. /**
  75547. * Defines how far from the source the light is impacting in scene units.
  75548. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75549. */
  75550. /**
  75551. * Defines how far from the source the light is impacting in scene units.
  75552. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75553. */
  75554. range: number;
  75555. /**
  75556. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75557. * of light.
  75558. */
  75559. private _photometricScale;
  75560. private _intensityMode;
  75561. /**
  75562. * Gets the photometric scale used to interpret the intensity.
  75563. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75564. */
  75565. /**
  75566. * Sets the photometric scale used to interpret the intensity.
  75567. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75568. */
  75569. intensityMode: number;
  75570. private _radius;
  75571. /**
  75572. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75573. */
  75574. /**
  75575. * sets the light radius used by PBR Materials to simulate soft area lights.
  75576. */
  75577. radius: number;
  75578. private _renderPriority;
  75579. /**
  75580. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75581. * exceeding the number allowed of the materials.
  75582. */
  75583. renderPriority: number;
  75584. private _shadowEnabled;
  75585. /**
  75586. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75587. * the current shadow generator.
  75588. */
  75589. /**
  75590. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75591. * the current shadow generator.
  75592. */
  75593. shadowEnabled: boolean;
  75594. private _includedOnlyMeshes;
  75595. /**
  75596. * Gets the only meshes impacted by this light.
  75597. */
  75598. /**
  75599. * Sets the only meshes impacted by this light.
  75600. */
  75601. includedOnlyMeshes: AbstractMesh[];
  75602. private _excludedMeshes;
  75603. /**
  75604. * Gets the meshes not impacted by this light.
  75605. */
  75606. /**
  75607. * Sets the meshes not impacted by this light.
  75608. */
  75609. excludedMeshes: AbstractMesh[];
  75610. private _excludeWithLayerMask;
  75611. /**
  75612. * Gets the layer id use to find what meshes are not impacted by the light.
  75613. * Inactive if 0
  75614. */
  75615. /**
  75616. * Sets the layer id use to find what meshes are not impacted by the light.
  75617. * Inactive if 0
  75618. */
  75619. excludeWithLayerMask: number;
  75620. private _includeOnlyWithLayerMask;
  75621. /**
  75622. * Gets the layer id use to find what meshes are impacted by the light.
  75623. * Inactive if 0
  75624. */
  75625. /**
  75626. * Sets the layer id use to find what meshes are impacted by the light.
  75627. * Inactive if 0
  75628. */
  75629. includeOnlyWithLayerMask: number;
  75630. private _lightmapMode;
  75631. /**
  75632. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75633. */
  75634. /**
  75635. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75636. */
  75637. lightmapMode: number;
  75638. /**
  75639. * Shadow generator associted to the light.
  75640. * @hidden Internal use only.
  75641. */
  75642. _shadowGenerator: Nullable<IShadowGenerator>;
  75643. /**
  75644. * @hidden Internal use only.
  75645. */
  75646. _excludedMeshesIds: string[];
  75647. /**
  75648. * @hidden Internal use only.
  75649. */
  75650. _includedOnlyMeshesIds: string[];
  75651. /**
  75652. * The current light unifom buffer.
  75653. * @hidden Internal use only.
  75654. */
  75655. _uniformBuffer: UniformBuffer;
  75656. /**
  75657. * Creates a Light object in the scene.
  75658. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75659. * @param name The firendly name of the light
  75660. * @param scene The scene the light belongs too
  75661. */
  75662. constructor(name: string, scene: Scene);
  75663. protected abstract _buildUniformLayout(): void;
  75664. /**
  75665. * Sets the passed Effect "effect" with the Light information.
  75666. * @param effect The effect to update
  75667. * @param lightIndex The index of the light in the effect to update
  75668. * @returns The light
  75669. */
  75670. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75671. /**
  75672. * Sets the passed Effect "effect" with the Light information.
  75673. * @param effect The effect to update
  75674. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75675. * @returns The light
  75676. */
  75677. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75678. /**
  75679. * Returns the string "Light".
  75680. * @returns the class name
  75681. */
  75682. getClassName(): string;
  75683. /** @hidden */
  75684. readonly _isLight: boolean;
  75685. /**
  75686. * Converts the light information to a readable string for debug purpose.
  75687. * @param fullDetails Supports for multiple levels of logging within scene loading
  75688. * @returns the human readable light info
  75689. */
  75690. toString(fullDetails?: boolean): string;
  75691. /** @hidden */
  75692. protected _syncParentEnabledState(): void;
  75693. /**
  75694. * Set the enabled state of this node.
  75695. * @param value - the new enabled state
  75696. */
  75697. setEnabled(value: boolean): void;
  75698. /**
  75699. * Returns the Light associated shadow generator if any.
  75700. * @return the associated shadow generator.
  75701. */
  75702. getShadowGenerator(): Nullable<IShadowGenerator>;
  75703. /**
  75704. * Returns a Vector3, the absolute light position in the World.
  75705. * @returns the world space position of the light
  75706. */
  75707. getAbsolutePosition(): Vector3;
  75708. /**
  75709. * Specifies if the light will affect the passed mesh.
  75710. * @param mesh The mesh to test against the light
  75711. * @return true the mesh is affected otherwise, false.
  75712. */
  75713. canAffectMesh(mesh: AbstractMesh): boolean;
  75714. /**
  75715. * Sort function to order lights for rendering.
  75716. * @param a First Light object to compare to second.
  75717. * @param b Second Light object to compare first.
  75718. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75719. */
  75720. static CompareLightsPriority(a: Light, b: Light): number;
  75721. /**
  75722. * Releases resources associated with this node.
  75723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75725. */
  75726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75727. /**
  75728. * Returns the light type ID (integer).
  75729. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75730. */
  75731. getTypeID(): number;
  75732. /**
  75733. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75734. * @returns the scaled intensity in intensity mode unit
  75735. */
  75736. getScaledIntensity(): number;
  75737. /**
  75738. * Returns a new Light object, named "name", from the current one.
  75739. * @param name The name of the cloned light
  75740. * @returns the new created light
  75741. */
  75742. clone(name: string): Nullable<Light>;
  75743. /**
  75744. * Serializes the current light into a Serialization object.
  75745. * @returns the serialized object.
  75746. */
  75747. serialize(): any;
  75748. /**
  75749. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75750. * This new light is named "name" and added to the passed scene.
  75751. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75752. * @param name The friendly name of the light
  75753. * @param scene The scene the new light will belong to
  75754. * @returns the constructor function
  75755. */
  75756. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75757. /**
  75758. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75759. * @param parsedLight The JSON representation of the light
  75760. * @param scene The scene to create the parsed light in
  75761. * @returns the created light after parsing
  75762. */
  75763. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75764. private _hookArrayForExcluded;
  75765. private _hookArrayForIncludedOnly;
  75766. private _resyncMeshes;
  75767. /**
  75768. * Forces the meshes to update their light related information in their rendering used effects
  75769. * @hidden Internal Use Only
  75770. */
  75771. _markMeshesAsLightDirty(): void;
  75772. /**
  75773. * Recomputes the cached photometric scale if needed.
  75774. */
  75775. private _computePhotometricScale;
  75776. /**
  75777. * Returns the Photometric Scale according to the light type and intensity mode.
  75778. */
  75779. private _getPhotometricScale;
  75780. /**
  75781. * Reorder the light in the scene according to their defined priority.
  75782. * @hidden Internal Use Only
  75783. */
  75784. _reorderLightsInScene(): void;
  75785. /**
  75786. * Prepares the list of defines specific to the light type.
  75787. * @param defines the list of defines
  75788. * @param lightIndex defines the index of the light for the effect
  75789. */
  75790. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75791. }
  75792. }
  75793. declare module BABYLON {
  75794. /**
  75795. * Interface used to define Action
  75796. */
  75797. export interface IAction {
  75798. /**
  75799. * Trigger for the action
  75800. */
  75801. trigger: number;
  75802. /** Options of the trigger */
  75803. triggerOptions: any;
  75804. /**
  75805. * Gets the trigger parameters
  75806. * @returns the trigger parameters
  75807. */
  75808. getTriggerParameter(): any;
  75809. /**
  75810. * Internal only - executes current action event
  75811. * @hidden
  75812. */
  75813. _executeCurrent(evt?: ActionEvent): void;
  75814. /**
  75815. * Serialize placeholder for child classes
  75816. * @param parent of child
  75817. * @returns the serialized object
  75818. */
  75819. serialize(parent: any): any;
  75820. /**
  75821. * Internal only
  75822. * @hidden
  75823. */
  75824. _prepare(): void;
  75825. /**
  75826. * Internal only - manager for action
  75827. * @hidden
  75828. */
  75829. _actionManager: AbstractActionManager;
  75830. /**
  75831. * Adds action to chain of actions, may be a DoNothingAction
  75832. * @param action defines the next action to execute
  75833. * @returns The action passed in
  75834. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75835. */
  75836. then(action: IAction): IAction;
  75837. }
  75838. /**
  75839. * The action to be carried out following a trigger
  75840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75841. */
  75842. export class Action implements IAction {
  75843. /** the trigger, with or without parameters, for the action */
  75844. triggerOptions: any;
  75845. /**
  75846. * Trigger for the action
  75847. */
  75848. trigger: number;
  75849. /**
  75850. * Internal only - manager for action
  75851. * @hidden
  75852. */
  75853. _actionManager: ActionManager;
  75854. private _nextActiveAction;
  75855. private _child;
  75856. private _condition?;
  75857. private _triggerParameter;
  75858. /**
  75859. * An event triggered prior to action being executed.
  75860. */
  75861. onBeforeExecuteObservable: Observable<Action>;
  75862. /**
  75863. * Creates a new Action
  75864. * @param triggerOptions the trigger, with or without parameters, for the action
  75865. * @param condition an optional determinant of action
  75866. */
  75867. constructor(
  75868. /** the trigger, with or without parameters, for the action */
  75869. triggerOptions: any, condition?: Condition);
  75870. /**
  75871. * Internal only
  75872. * @hidden
  75873. */
  75874. _prepare(): void;
  75875. /**
  75876. * Gets the trigger parameters
  75877. * @returns the trigger parameters
  75878. */
  75879. getTriggerParameter(): any;
  75880. /**
  75881. * Internal only - executes current action event
  75882. * @hidden
  75883. */
  75884. _executeCurrent(evt?: ActionEvent): void;
  75885. /**
  75886. * Execute placeholder for child classes
  75887. * @param evt optional action event
  75888. */
  75889. execute(evt?: ActionEvent): void;
  75890. /**
  75891. * Skips to next active action
  75892. */
  75893. skipToNextActiveAction(): void;
  75894. /**
  75895. * Adds action to chain of actions, may be a DoNothingAction
  75896. * @param action defines the next action to execute
  75897. * @returns The action passed in
  75898. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75899. */
  75900. then(action: Action): Action;
  75901. /**
  75902. * Internal only
  75903. * @hidden
  75904. */
  75905. _getProperty(propertyPath: string): string;
  75906. /**
  75907. * Internal only
  75908. * @hidden
  75909. */
  75910. _getEffectiveTarget(target: any, propertyPath: string): any;
  75911. /**
  75912. * Serialize placeholder for child classes
  75913. * @param parent of child
  75914. * @returns the serialized object
  75915. */
  75916. serialize(parent: any): any;
  75917. /**
  75918. * Internal only called by serialize
  75919. * @hidden
  75920. */
  75921. protected _serialize(serializedAction: any, parent?: any): any;
  75922. /**
  75923. * Internal only
  75924. * @hidden
  75925. */
  75926. static _SerializeValueAsString: (value: any) => string;
  75927. /**
  75928. * Internal only
  75929. * @hidden
  75930. */
  75931. static _GetTargetProperty: (target: Node | Scene) => {
  75932. name: string;
  75933. targetType: string;
  75934. value: string;
  75935. };
  75936. }
  75937. }
  75938. declare module BABYLON {
  75939. /**
  75940. * A Condition applied to an Action
  75941. */
  75942. export class Condition {
  75943. /**
  75944. * Internal only - manager for action
  75945. * @hidden
  75946. */
  75947. _actionManager: ActionManager;
  75948. /**
  75949. * Internal only
  75950. * @hidden
  75951. */
  75952. _evaluationId: number;
  75953. /**
  75954. * Internal only
  75955. * @hidden
  75956. */
  75957. _currentResult: boolean;
  75958. /**
  75959. * Creates a new Condition
  75960. * @param actionManager the manager of the action the condition is applied to
  75961. */
  75962. constructor(actionManager: ActionManager);
  75963. /**
  75964. * Check if the current condition is valid
  75965. * @returns a boolean
  75966. */
  75967. isValid(): boolean;
  75968. /**
  75969. * Internal only
  75970. * @hidden
  75971. */
  75972. _getProperty(propertyPath: string): string;
  75973. /**
  75974. * Internal only
  75975. * @hidden
  75976. */
  75977. _getEffectiveTarget(target: any, propertyPath: string): any;
  75978. /**
  75979. * Serialize placeholder for child classes
  75980. * @returns the serialized object
  75981. */
  75982. serialize(): any;
  75983. /**
  75984. * Internal only
  75985. * @hidden
  75986. */
  75987. protected _serialize(serializedCondition: any): any;
  75988. }
  75989. /**
  75990. * Defines specific conditional operators as extensions of Condition
  75991. */
  75992. export class ValueCondition extends Condition {
  75993. /** path to specify the property of the target the conditional operator uses */
  75994. propertyPath: string;
  75995. /** the value compared by the conditional operator against the current value of the property */
  75996. value: any;
  75997. /** the conditional operator, default ValueCondition.IsEqual */
  75998. operator: number;
  75999. /**
  76000. * Internal only
  76001. * @hidden
  76002. */
  76003. private static _IsEqual;
  76004. /**
  76005. * Internal only
  76006. * @hidden
  76007. */
  76008. private static _IsDifferent;
  76009. /**
  76010. * Internal only
  76011. * @hidden
  76012. */
  76013. private static _IsGreater;
  76014. /**
  76015. * Internal only
  76016. * @hidden
  76017. */
  76018. private static _IsLesser;
  76019. /**
  76020. * returns the number for IsEqual
  76021. */
  76022. static readonly IsEqual: number;
  76023. /**
  76024. * Returns the number for IsDifferent
  76025. */
  76026. static readonly IsDifferent: number;
  76027. /**
  76028. * Returns the number for IsGreater
  76029. */
  76030. static readonly IsGreater: number;
  76031. /**
  76032. * Returns the number for IsLesser
  76033. */
  76034. static readonly IsLesser: number;
  76035. /**
  76036. * Internal only The action manager for the condition
  76037. * @hidden
  76038. */
  76039. _actionManager: ActionManager;
  76040. /**
  76041. * Internal only
  76042. * @hidden
  76043. */
  76044. private _target;
  76045. /**
  76046. * Internal only
  76047. * @hidden
  76048. */
  76049. private _effectiveTarget;
  76050. /**
  76051. * Internal only
  76052. * @hidden
  76053. */
  76054. private _property;
  76055. /**
  76056. * Creates a new ValueCondition
  76057. * @param actionManager manager for the action the condition applies to
  76058. * @param target for the action
  76059. * @param propertyPath path to specify the property of the target the conditional operator uses
  76060. * @param value the value compared by the conditional operator against the current value of the property
  76061. * @param operator the conditional operator, default ValueCondition.IsEqual
  76062. */
  76063. constructor(actionManager: ActionManager, target: any,
  76064. /** path to specify the property of the target the conditional operator uses */
  76065. propertyPath: string,
  76066. /** the value compared by the conditional operator against the current value of the property */
  76067. value: any,
  76068. /** the conditional operator, default ValueCondition.IsEqual */
  76069. operator?: number);
  76070. /**
  76071. * Compares the given value with the property value for the specified conditional operator
  76072. * @returns the result of the comparison
  76073. */
  76074. isValid(): boolean;
  76075. /**
  76076. * Serialize the ValueCondition into a JSON compatible object
  76077. * @returns serialization object
  76078. */
  76079. serialize(): any;
  76080. /**
  76081. * Gets the name of the conditional operator for the ValueCondition
  76082. * @param operator the conditional operator
  76083. * @returns the name
  76084. */
  76085. static GetOperatorName(operator: number): string;
  76086. }
  76087. /**
  76088. * Defines a predicate condition as an extension of Condition
  76089. */
  76090. export class PredicateCondition extends Condition {
  76091. /** defines the predicate function used to validate the condition */
  76092. predicate: () => boolean;
  76093. /**
  76094. * Internal only - manager for action
  76095. * @hidden
  76096. */
  76097. _actionManager: ActionManager;
  76098. /**
  76099. * Creates a new PredicateCondition
  76100. * @param actionManager manager for the action the condition applies to
  76101. * @param predicate defines the predicate function used to validate the condition
  76102. */
  76103. constructor(actionManager: ActionManager,
  76104. /** defines the predicate function used to validate the condition */
  76105. predicate: () => boolean);
  76106. /**
  76107. * @returns the validity of the predicate condition
  76108. */
  76109. isValid(): boolean;
  76110. }
  76111. /**
  76112. * Defines a state condition as an extension of Condition
  76113. */
  76114. export class StateCondition extends Condition {
  76115. /** Value to compare with target state */
  76116. value: string;
  76117. /**
  76118. * Internal only - manager for action
  76119. * @hidden
  76120. */
  76121. _actionManager: ActionManager;
  76122. /**
  76123. * Internal only
  76124. * @hidden
  76125. */
  76126. private _target;
  76127. /**
  76128. * Creates a new StateCondition
  76129. * @param actionManager manager for the action the condition applies to
  76130. * @param target of the condition
  76131. * @param value to compare with target state
  76132. */
  76133. constructor(actionManager: ActionManager, target: any,
  76134. /** Value to compare with target state */
  76135. value: string);
  76136. /**
  76137. * Gets a boolean indicating if the current condition is met
  76138. * @returns the validity of the state
  76139. */
  76140. isValid(): boolean;
  76141. /**
  76142. * Serialize the StateCondition into a JSON compatible object
  76143. * @returns serialization object
  76144. */
  76145. serialize(): any;
  76146. }
  76147. }
  76148. declare module BABYLON {
  76149. /**
  76150. * This defines an action responsible to toggle a boolean once triggered.
  76151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76152. */
  76153. export class SwitchBooleanAction extends Action {
  76154. /**
  76155. * The path to the boolean property in the target object
  76156. */
  76157. propertyPath: string;
  76158. private _target;
  76159. private _effectiveTarget;
  76160. private _property;
  76161. /**
  76162. * Instantiate the action
  76163. * @param triggerOptions defines the trigger options
  76164. * @param target defines the object containing the boolean
  76165. * @param propertyPath defines the path to the boolean property in the target object
  76166. * @param condition defines the trigger related conditions
  76167. */
  76168. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76169. /** @hidden */
  76170. _prepare(): void;
  76171. /**
  76172. * Execute the action toggle the boolean value.
  76173. */
  76174. execute(): void;
  76175. /**
  76176. * Serializes the actions and its related information.
  76177. * @param parent defines the object to serialize in
  76178. * @returns the serialized object
  76179. */
  76180. serialize(parent: any): any;
  76181. }
  76182. /**
  76183. * This defines an action responsible to set a the state field of the target
  76184. * to a desired value once triggered.
  76185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76186. */
  76187. export class SetStateAction extends Action {
  76188. /**
  76189. * The value to store in the state field.
  76190. */
  76191. value: string;
  76192. private _target;
  76193. /**
  76194. * Instantiate the action
  76195. * @param triggerOptions defines the trigger options
  76196. * @param target defines the object containing the state property
  76197. * @param value defines the value to store in the state field
  76198. * @param condition defines the trigger related conditions
  76199. */
  76200. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76201. /**
  76202. * Execute the action and store the value on the target state property.
  76203. */
  76204. execute(): void;
  76205. /**
  76206. * Serializes the actions and its related information.
  76207. * @param parent defines the object to serialize in
  76208. * @returns the serialized object
  76209. */
  76210. serialize(parent: any): any;
  76211. }
  76212. /**
  76213. * This defines an action responsible to set a property of the target
  76214. * to a desired value once triggered.
  76215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76216. */
  76217. export class SetValueAction extends Action {
  76218. /**
  76219. * The path of the property to set in the target.
  76220. */
  76221. propertyPath: string;
  76222. /**
  76223. * The value to set in the property
  76224. */
  76225. value: any;
  76226. private _target;
  76227. private _effectiveTarget;
  76228. private _property;
  76229. /**
  76230. * Instantiate the action
  76231. * @param triggerOptions defines the trigger options
  76232. * @param target defines the object containing the property
  76233. * @param propertyPath defines the path of the property to set in the target
  76234. * @param value defines the value to set in the property
  76235. * @param condition defines the trigger related conditions
  76236. */
  76237. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76238. /** @hidden */
  76239. _prepare(): void;
  76240. /**
  76241. * Execute the action and set the targetted property to the desired value.
  76242. */
  76243. execute(): void;
  76244. /**
  76245. * Serializes the actions and its related information.
  76246. * @param parent defines the object to serialize in
  76247. * @returns the serialized object
  76248. */
  76249. serialize(parent: any): any;
  76250. }
  76251. /**
  76252. * This defines an action responsible to increment the target value
  76253. * to a desired value once triggered.
  76254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76255. */
  76256. export class IncrementValueAction extends Action {
  76257. /**
  76258. * The path of the property to increment in the target.
  76259. */
  76260. propertyPath: string;
  76261. /**
  76262. * The value we should increment the property by.
  76263. */
  76264. value: any;
  76265. private _target;
  76266. private _effectiveTarget;
  76267. private _property;
  76268. /**
  76269. * Instantiate the action
  76270. * @param triggerOptions defines the trigger options
  76271. * @param target defines the object containing the property
  76272. * @param propertyPath defines the path of the property to increment in the target
  76273. * @param value defines the value value we should increment the property by
  76274. * @param condition defines the trigger related conditions
  76275. */
  76276. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76277. /** @hidden */
  76278. _prepare(): void;
  76279. /**
  76280. * Execute the action and increment the target of the value amount.
  76281. */
  76282. execute(): void;
  76283. /**
  76284. * Serializes the actions and its related information.
  76285. * @param parent defines the object to serialize in
  76286. * @returns the serialized object
  76287. */
  76288. serialize(parent: any): any;
  76289. }
  76290. /**
  76291. * This defines an action responsible to start an animation once triggered.
  76292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76293. */
  76294. export class PlayAnimationAction extends Action {
  76295. /**
  76296. * Where the animation should start (animation frame)
  76297. */
  76298. from: number;
  76299. /**
  76300. * Where the animation should stop (animation frame)
  76301. */
  76302. to: number;
  76303. /**
  76304. * Define if the animation should loop or stop after the first play.
  76305. */
  76306. loop?: boolean;
  76307. private _target;
  76308. /**
  76309. * Instantiate the action
  76310. * @param triggerOptions defines the trigger options
  76311. * @param target defines the target animation or animation name
  76312. * @param from defines from where the animation should start (animation frame)
  76313. * @param end defines where the animation should stop (animation frame)
  76314. * @param loop defines if the animation should loop or stop after the first play
  76315. * @param condition defines the trigger related conditions
  76316. */
  76317. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76318. /** @hidden */
  76319. _prepare(): void;
  76320. /**
  76321. * Execute the action and play the animation.
  76322. */
  76323. execute(): void;
  76324. /**
  76325. * Serializes the actions and its related information.
  76326. * @param parent defines the object to serialize in
  76327. * @returns the serialized object
  76328. */
  76329. serialize(parent: any): any;
  76330. }
  76331. /**
  76332. * This defines an action responsible to stop an animation once triggered.
  76333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76334. */
  76335. export class StopAnimationAction extends Action {
  76336. private _target;
  76337. /**
  76338. * Instantiate the action
  76339. * @param triggerOptions defines the trigger options
  76340. * @param target defines the target animation or animation name
  76341. * @param condition defines the trigger related conditions
  76342. */
  76343. constructor(triggerOptions: any, target: any, condition?: Condition);
  76344. /** @hidden */
  76345. _prepare(): void;
  76346. /**
  76347. * Execute the action and stop the animation.
  76348. */
  76349. execute(): void;
  76350. /**
  76351. * Serializes the actions and its related information.
  76352. * @param parent defines the object to serialize in
  76353. * @returns the serialized object
  76354. */
  76355. serialize(parent: any): any;
  76356. }
  76357. /**
  76358. * This defines an action responsible that does nothing once triggered.
  76359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76360. */
  76361. export class DoNothingAction extends Action {
  76362. /**
  76363. * Instantiate the action
  76364. * @param triggerOptions defines the trigger options
  76365. * @param condition defines the trigger related conditions
  76366. */
  76367. constructor(triggerOptions?: any, condition?: Condition);
  76368. /**
  76369. * Execute the action and do nothing.
  76370. */
  76371. execute(): void;
  76372. /**
  76373. * Serializes the actions and its related information.
  76374. * @param parent defines the object to serialize in
  76375. * @returns the serialized object
  76376. */
  76377. serialize(parent: any): any;
  76378. }
  76379. /**
  76380. * This defines an action responsible to trigger several actions once triggered.
  76381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76382. */
  76383. export class CombineAction extends Action {
  76384. /**
  76385. * The list of aggregated animations to run.
  76386. */
  76387. children: Action[];
  76388. /**
  76389. * Instantiate the action
  76390. * @param triggerOptions defines the trigger options
  76391. * @param children defines the list of aggregated animations to run
  76392. * @param condition defines the trigger related conditions
  76393. */
  76394. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76395. /** @hidden */
  76396. _prepare(): void;
  76397. /**
  76398. * Execute the action and executes all the aggregated actions.
  76399. */
  76400. execute(evt: ActionEvent): void;
  76401. /**
  76402. * Serializes the actions and its related information.
  76403. * @param parent defines the object to serialize in
  76404. * @returns the serialized object
  76405. */
  76406. serialize(parent: any): any;
  76407. }
  76408. /**
  76409. * This defines an action responsible to run code (external event) once triggered.
  76410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76411. */
  76412. export class ExecuteCodeAction extends Action {
  76413. /**
  76414. * The callback function to run.
  76415. */
  76416. func: (evt: ActionEvent) => void;
  76417. /**
  76418. * Instantiate the action
  76419. * @param triggerOptions defines the trigger options
  76420. * @param func defines the callback function to run
  76421. * @param condition defines the trigger related conditions
  76422. */
  76423. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76424. /**
  76425. * Execute the action and run the attached code.
  76426. */
  76427. execute(evt: ActionEvent): void;
  76428. }
  76429. /**
  76430. * This defines an action responsible to set the parent property of the target once triggered.
  76431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76432. */
  76433. export class SetParentAction extends Action {
  76434. private _parent;
  76435. private _target;
  76436. /**
  76437. * Instantiate the action
  76438. * @param triggerOptions defines the trigger options
  76439. * @param target defines the target containing the parent property
  76440. * @param parent defines from where the animation should start (animation frame)
  76441. * @param condition defines the trigger related conditions
  76442. */
  76443. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76444. /** @hidden */
  76445. _prepare(): void;
  76446. /**
  76447. * Execute the action and set the parent property.
  76448. */
  76449. execute(): void;
  76450. /**
  76451. * Serializes the actions and its related information.
  76452. * @param parent defines the object to serialize in
  76453. * @returns the serialized object
  76454. */
  76455. serialize(parent: any): any;
  76456. }
  76457. }
  76458. declare module BABYLON {
  76459. /**
  76460. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76461. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76463. */
  76464. export class ActionManager extends AbstractActionManager {
  76465. /**
  76466. * Nothing
  76467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76468. */
  76469. static readonly NothingTrigger: number;
  76470. /**
  76471. * On pick
  76472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76473. */
  76474. static readonly OnPickTrigger: number;
  76475. /**
  76476. * On left pick
  76477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76478. */
  76479. static readonly OnLeftPickTrigger: number;
  76480. /**
  76481. * On right pick
  76482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76483. */
  76484. static readonly OnRightPickTrigger: number;
  76485. /**
  76486. * On center pick
  76487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76488. */
  76489. static readonly OnCenterPickTrigger: number;
  76490. /**
  76491. * On pick down
  76492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76493. */
  76494. static readonly OnPickDownTrigger: number;
  76495. /**
  76496. * On double pick
  76497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76498. */
  76499. static readonly OnDoublePickTrigger: number;
  76500. /**
  76501. * On pick up
  76502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76503. */
  76504. static readonly OnPickUpTrigger: number;
  76505. /**
  76506. * On pick out.
  76507. * This trigger will only be raised if you also declared a OnPickDown
  76508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76509. */
  76510. static readonly OnPickOutTrigger: number;
  76511. /**
  76512. * On long press
  76513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76514. */
  76515. static readonly OnLongPressTrigger: number;
  76516. /**
  76517. * On pointer over
  76518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76519. */
  76520. static readonly OnPointerOverTrigger: number;
  76521. /**
  76522. * On pointer out
  76523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76524. */
  76525. static readonly OnPointerOutTrigger: number;
  76526. /**
  76527. * On every frame
  76528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76529. */
  76530. static readonly OnEveryFrameTrigger: number;
  76531. /**
  76532. * On intersection enter
  76533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76534. */
  76535. static readonly OnIntersectionEnterTrigger: number;
  76536. /**
  76537. * On intersection exit
  76538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76539. */
  76540. static readonly OnIntersectionExitTrigger: number;
  76541. /**
  76542. * On key down
  76543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76544. */
  76545. static readonly OnKeyDownTrigger: number;
  76546. /**
  76547. * On key up
  76548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76549. */
  76550. static readonly OnKeyUpTrigger: number;
  76551. private _scene;
  76552. /**
  76553. * Creates a new action manager
  76554. * @param scene defines the hosting scene
  76555. */
  76556. constructor(scene: Scene);
  76557. /**
  76558. * Releases all associated resources
  76559. */
  76560. dispose(): void;
  76561. /**
  76562. * Gets hosting scene
  76563. * @returns the hosting scene
  76564. */
  76565. getScene(): Scene;
  76566. /**
  76567. * Does this action manager handles actions of any of the given triggers
  76568. * @param triggers defines the triggers to be tested
  76569. * @return a boolean indicating whether one (or more) of the triggers is handled
  76570. */
  76571. hasSpecificTriggers(triggers: number[]): boolean;
  76572. /**
  76573. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76574. * speed.
  76575. * @param triggerA defines the trigger to be tested
  76576. * @param triggerB defines the trigger to be tested
  76577. * @return a boolean indicating whether one (or more) of the triggers is handled
  76578. */
  76579. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76580. /**
  76581. * Does this action manager handles actions of a given trigger
  76582. * @param trigger defines the trigger to be tested
  76583. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76584. * @return whether the trigger is handled
  76585. */
  76586. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76587. /**
  76588. * Does this action manager has pointer triggers
  76589. */
  76590. readonly hasPointerTriggers: boolean;
  76591. /**
  76592. * Does this action manager has pick triggers
  76593. */
  76594. readonly hasPickTriggers: boolean;
  76595. /**
  76596. * Registers an action to this action manager
  76597. * @param action defines the action to be registered
  76598. * @return the action amended (prepared) after registration
  76599. */
  76600. registerAction(action: IAction): Nullable<IAction>;
  76601. /**
  76602. * Unregisters an action to this action manager
  76603. * @param action defines the action to be unregistered
  76604. * @return a boolean indicating whether the action has been unregistered
  76605. */
  76606. unregisterAction(action: IAction): Boolean;
  76607. /**
  76608. * Process a specific trigger
  76609. * @param trigger defines the trigger to process
  76610. * @param evt defines the event details to be processed
  76611. */
  76612. processTrigger(trigger: number, evt?: IActionEvent): void;
  76613. /** @hidden */
  76614. _getEffectiveTarget(target: any, propertyPath: string): any;
  76615. /** @hidden */
  76616. _getProperty(propertyPath: string): string;
  76617. /**
  76618. * Serialize this manager to a JSON object
  76619. * @param name defines the property name to store this manager
  76620. * @returns a JSON representation of this manager
  76621. */
  76622. serialize(name: string): any;
  76623. /**
  76624. * Creates a new ActionManager from a JSON data
  76625. * @param parsedActions defines the JSON data to read from
  76626. * @param object defines the hosting mesh
  76627. * @param scene defines the hosting scene
  76628. */
  76629. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76630. /**
  76631. * Get a trigger name by index
  76632. * @param trigger defines the trigger index
  76633. * @returns a trigger name
  76634. */
  76635. static GetTriggerName(trigger: number): string;
  76636. }
  76637. }
  76638. declare module BABYLON {
  76639. /**
  76640. * Class representing a ray with position and direction
  76641. */
  76642. export class Ray {
  76643. /** origin point */
  76644. origin: Vector3;
  76645. /** direction */
  76646. direction: Vector3;
  76647. /** length of the ray */
  76648. length: number;
  76649. private static readonly TmpVector3;
  76650. private _tmpRay;
  76651. /**
  76652. * Creates a new ray
  76653. * @param origin origin point
  76654. * @param direction direction
  76655. * @param length length of the ray
  76656. */
  76657. constructor(
  76658. /** origin point */
  76659. origin: Vector3,
  76660. /** direction */
  76661. direction: Vector3,
  76662. /** length of the ray */
  76663. length?: number);
  76664. /**
  76665. * Checks if the ray intersects a box
  76666. * @param minimum bound of the box
  76667. * @param maximum bound of the box
  76668. * @param intersectionTreshold extra extend to be added to the box in all direction
  76669. * @returns if the box was hit
  76670. */
  76671. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76672. /**
  76673. * Checks if the ray intersects a box
  76674. * @param box the bounding box to check
  76675. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76676. * @returns if the box was hit
  76677. */
  76678. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76679. /**
  76680. * If the ray hits a sphere
  76681. * @param sphere the bounding sphere to check
  76682. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76683. * @returns true if it hits the sphere
  76684. */
  76685. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76686. /**
  76687. * If the ray hits a triange
  76688. * @param vertex0 triangle vertex
  76689. * @param vertex1 triangle vertex
  76690. * @param vertex2 triangle vertex
  76691. * @returns intersection information if hit
  76692. */
  76693. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76694. /**
  76695. * Checks if ray intersects a plane
  76696. * @param plane the plane to check
  76697. * @returns the distance away it was hit
  76698. */
  76699. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76700. /**
  76701. * Calculate the intercept of a ray on a given axis
  76702. * @param axis to check 'x' | 'y' | 'z'
  76703. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76704. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76705. */
  76706. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76707. /**
  76708. * Checks if ray intersects a mesh
  76709. * @param mesh the mesh to check
  76710. * @param fastCheck if only the bounding box should checked
  76711. * @returns picking info of the intersecton
  76712. */
  76713. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76714. /**
  76715. * Checks if ray intersects a mesh
  76716. * @param meshes the meshes to check
  76717. * @param fastCheck if only the bounding box should checked
  76718. * @param results array to store result in
  76719. * @returns Array of picking infos
  76720. */
  76721. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76722. private _comparePickingInfo;
  76723. private static smallnum;
  76724. private static rayl;
  76725. /**
  76726. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76727. * @param sega the first point of the segment to test the intersection against
  76728. * @param segb the second point of the segment to test the intersection against
  76729. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76730. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76731. */
  76732. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76733. /**
  76734. * Update the ray from viewport position
  76735. * @param x position
  76736. * @param y y position
  76737. * @param viewportWidth viewport width
  76738. * @param viewportHeight viewport height
  76739. * @param world world matrix
  76740. * @param view view matrix
  76741. * @param projection projection matrix
  76742. * @returns this ray updated
  76743. */
  76744. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76745. /**
  76746. * Creates a ray with origin and direction of 0,0,0
  76747. * @returns the new ray
  76748. */
  76749. static Zero(): Ray;
  76750. /**
  76751. * Creates a new ray from screen space and viewport
  76752. * @param x position
  76753. * @param y y position
  76754. * @param viewportWidth viewport width
  76755. * @param viewportHeight viewport height
  76756. * @param world world matrix
  76757. * @param view view matrix
  76758. * @param projection projection matrix
  76759. * @returns new ray
  76760. */
  76761. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76762. /**
  76763. * 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
  76764. * transformed to the given world matrix.
  76765. * @param origin The origin point
  76766. * @param end The end point
  76767. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76768. * @returns the new ray
  76769. */
  76770. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76771. /**
  76772. * Transforms a ray by a matrix
  76773. * @param ray ray to transform
  76774. * @param matrix matrix to apply
  76775. * @returns the resulting new ray
  76776. */
  76777. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76778. /**
  76779. * Transforms a ray by a matrix
  76780. * @param ray ray to transform
  76781. * @param matrix matrix to apply
  76782. * @param result ray to store result in
  76783. */
  76784. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76785. /**
  76786. * Unproject a ray from screen space to object space
  76787. * @param sourceX defines the screen space x coordinate to use
  76788. * @param sourceY defines the screen space y coordinate to use
  76789. * @param viewportWidth defines the current width of the viewport
  76790. * @param viewportHeight defines the current height of the viewport
  76791. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76792. * @param view defines the view matrix to use
  76793. * @param projection defines the projection matrix to use
  76794. */
  76795. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76796. }
  76797. /**
  76798. * Type used to define predicate used to select faces when a mesh intersection is detected
  76799. */
  76800. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76801. interface Scene {
  76802. /** @hidden */
  76803. _tempPickingRay: Nullable<Ray>;
  76804. /** @hidden */
  76805. _cachedRayForTransform: Ray;
  76806. /** @hidden */
  76807. _pickWithRayInverseMatrix: Matrix;
  76808. /** @hidden */
  76809. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76810. /** @hidden */
  76811. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76812. }
  76813. }
  76814. declare module BABYLON {
  76815. /**
  76816. * Groups all the scene component constants in one place to ease maintenance.
  76817. * @hidden
  76818. */
  76819. export class SceneComponentConstants {
  76820. static readonly NAME_EFFECTLAYER: string;
  76821. static readonly NAME_LAYER: string;
  76822. static readonly NAME_LENSFLARESYSTEM: string;
  76823. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76824. static readonly NAME_PARTICLESYSTEM: string;
  76825. static readonly NAME_GAMEPAD: string;
  76826. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76827. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76828. static readonly NAME_DEPTHRENDERER: string;
  76829. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76830. static readonly NAME_SPRITE: string;
  76831. static readonly NAME_OUTLINERENDERER: string;
  76832. static readonly NAME_PROCEDURALTEXTURE: string;
  76833. static readonly NAME_SHADOWGENERATOR: string;
  76834. static readonly NAME_OCTREE: string;
  76835. static readonly NAME_PHYSICSENGINE: string;
  76836. static readonly NAME_AUDIO: string;
  76837. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76838. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76839. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76840. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76841. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76842. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76843. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76844. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76845. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76846. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76847. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76848. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76849. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76850. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76851. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76852. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76853. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76854. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76855. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76856. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76857. static readonly STEP_AFTERRENDER_AUDIO: number;
  76858. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76859. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76860. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76861. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76862. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76863. static readonly STEP_POINTERMOVE_SPRITE: number;
  76864. static readonly STEP_POINTERDOWN_SPRITE: number;
  76865. static readonly STEP_POINTERUP_SPRITE: number;
  76866. }
  76867. /**
  76868. * This represents a scene component.
  76869. *
  76870. * This is used to decouple the dependency the scene is having on the different workloads like
  76871. * layers, post processes...
  76872. */
  76873. export interface ISceneComponent {
  76874. /**
  76875. * The name of the component. Each component must have a unique name.
  76876. */
  76877. name: string;
  76878. /**
  76879. * The scene the component belongs to.
  76880. */
  76881. scene: Scene;
  76882. /**
  76883. * Register the component to one instance of a scene.
  76884. */
  76885. register(): void;
  76886. /**
  76887. * Rebuilds the elements related to this component in case of
  76888. * context lost for instance.
  76889. */
  76890. rebuild(): void;
  76891. /**
  76892. * Disposes the component and the associated ressources.
  76893. */
  76894. dispose(): void;
  76895. }
  76896. /**
  76897. * This represents a SERIALIZABLE scene component.
  76898. *
  76899. * This extends Scene Component to add Serialization methods on top.
  76900. */
  76901. export interface ISceneSerializableComponent extends ISceneComponent {
  76902. /**
  76903. * Adds all the elements from the container to the scene
  76904. * @param container the container holding the elements
  76905. */
  76906. addFromContainer(container: AbstractScene): void;
  76907. /**
  76908. * Removes all the elements in the container from the scene
  76909. * @param container contains the elements to remove
  76910. * @param dispose if the removed element should be disposed (default: false)
  76911. */
  76912. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76913. /**
  76914. * Serializes the component data to the specified json object
  76915. * @param serializationObject The object to serialize to
  76916. */
  76917. serialize(serializationObject: any): void;
  76918. }
  76919. /**
  76920. * Strong typing of a Mesh related stage step action
  76921. */
  76922. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76923. /**
  76924. * Strong typing of a Evaluate Sub Mesh related stage step action
  76925. */
  76926. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76927. /**
  76928. * Strong typing of a Active Mesh related stage step action
  76929. */
  76930. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76931. /**
  76932. * Strong typing of a Camera related stage step action
  76933. */
  76934. export type CameraStageAction = (camera: Camera) => void;
  76935. /**
  76936. * Strong typing of a Camera Frame buffer related stage step action
  76937. */
  76938. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76939. /**
  76940. * Strong typing of a Render Target related stage step action
  76941. */
  76942. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76943. /**
  76944. * Strong typing of a RenderingGroup related stage step action
  76945. */
  76946. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76947. /**
  76948. * Strong typing of a Mesh Render related stage step action
  76949. */
  76950. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76951. /**
  76952. * Strong typing of a simple stage step action
  76953. */
  76954. export type SimpleStageAction = () => void;
  76955. /**
  76956. * Strong typing of a render target action.
  76957. */
  76958. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76959. /**
  76960. * Strong typing of a pointer move action.
  76961. */
  76962. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76963. /**
  76964. * Strong typing of a pointer up/down action.
  76965. */
  76966. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76967. /**
  76968. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76969. * @hidden
  76970. */
  76971. export class Stage<T extends Function> extends Array<{
  76972. index: number;
  76973. component: ISceneComponent;
  76974. action: T;
  76975. }> {
  76976. /**
  76977. * Hide ctor from the rest of the world.
  76978. * @param items The items to add.
  76979. */
  76980. private constructor();
  76981. /**
  76982. * Creates a new Stage.
  76983. * @returns A new instance of a Stage
  76984. */
  76985. static Create<T extends Function>(): Stage<T>;
  76986. /**
  76987. * Registers a step in an ordered way in the targeted stage.
  76988. * @param index Defines the position to register the step in
  76989. * @param component Defines the component attached to the step
  76990. * @param action Defines the action to launch during the step
  76991. */
  76992. registerStep(index: number, component: ISceneComponent, action: T): void;
  76993. /**
  76994. * Clears all the steps from the stage.
  76995. */
  76996. clear(): void;
  76997. }
  76998. }
  76999. declare module BABYLON {
  77000. interface Scene {
  77001. /** @hidden */
  77002. _pointerOverSprite: Nullable<Sprite>;
  77003. /** @hidden */
  77004. _pickedDownSprite: Nullable<Sprite>;
  77005. /** @hidden */
  77006. _tempSpritePickingRay: Nullable<Ray>;
  77007. /**
  77008. * All of the sprite managers added to this scene
  77009. * @see http://doc.babylonjs.com/babylon101/sprites
  77010. */
  77011. spriteManagers: Array<ISpriteManager>;
  77012. /**
  77013. * An event triggered when sprites rendering is about to start
  77014. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77015. */
  77016. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77017. /**
  77018. * An event triggered when sprites rendering is done
  77019. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77020. */
  77021. onAfterSpritesRenderingObservable: Observable<Scene>;
  77022. /** @hidden */
  77023. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77024. /** Launch a ray to try to pick a sprite in the scene
  77025. * @param x position on screen
  77026. * @param y position on screen
  77027. * @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
  77028. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77029. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77030. * @returns a PickingInfo
  77031. */
  77032. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77033. /** Use the given ray to pick a sprite in the scene
  77034. * @param ray The ray (in world space) to use to pick meshes
  77035. * @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
  77036. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77037. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77038. * @returns a PickingInfo
  77039. */
  77040. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77041. /** @hidden */
  77042. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77043. /** Launch a ray to try to pick sprites in the scene
  77044. * @param x position on screen
  77045. * @param y position on screen
  77046. * @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
  77047. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77048. * @returns a PickingInfo array
  77049. */
  77050. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77051. /** Use the given ray to pick sprites in the scene
  77052. * @param ray The ray (in world space) to use to pick meshes
  77053. * @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
  77054. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77055. * @returns a PickingInfo array
  77056. */
  77057. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77058. /**
  77059. * Force the sprite under the pointer
  77060. * @param sprite defines the sprite to use
  77061. */
  77062. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77063. /**
  77064. * Gets the sprite under the pointer
  77065. * @returns a Sprite or null if no sprite is under the pointer
  77066. */
  77067. getPointerOverSprite(): Nullable<Sprite>;
  77068. }
  77069. /**
  77070. * Defines the sprite scene component responsible to manage sprites
  77071. * in a given scene.
  77072. */
  77073. export class SpriteSceneComponent implements ISceneComponent {
  77074. /**
  77075. * The component name helpfull to identify the component in the list of scene components.
  77076. */
  77077. readonly name: string;
  77078. /**
  77079. * The scene the component belongs to.
  77080. */
  77081. scene: Scene;
  77082. /** @hidden */
  77083. private _spritePredicate;
  77084. /**
  77085. * Creates a new instance of the component for the given scene
  77086. * @param scene Defines the scene to register the component in
  77087. */
  77088. constructor(scene: Scene);
  77089. /**
  77090. * Registers the component in a given scene
  77091. */
  77092. register(): void;
  77093. /**
  77094. * Rebuilds the elements related to this component in case of
  77095. * context lost for instance.
  77096. */
  77097. rebuild(): void;
  77098. /**
  77099. * Disposes the component and the associated ressources.
  77100. */
  77101. dispose(): void;
  77102. private _pickSpriteButKeepRay;
  77103. private _pointerMove;
  77104. private _pointerDown;
  77105. private _pointerUp;
  77106. }
  77107. }
  77108. declare module BABYLON {
  77109. /** @hidden */
  77110. export var fogFragmentDeclaration: {
  77111. name: string;
  77112. shader: string;
  77113. };
  77114. }
  77115. declare module BABYLON {
  77116. /** @hidden */
  77117. export var fogFragment: {
  77118. name: string;
  77119. shader: string;
  77120. };
  77121. }
  77122. declare module BABYLON {
  77123. /** @hidden */
  77124. export var spritesPixelShader: {
  77125. name: string;
  77126. shader: string;
  77127. };
  77128. }
  77129. declare module BABYLON {
  77130. /** @hidden */
  77131. export var fogVertexDeclaration: {
  77132. name: string;
  77133. shader: string;
  77134. };
  77135. }
  77136. declare module BABYLON {
  77137. /** @hidden */
  77138. export var spritesVertexShader: {
  77139. name: string;
  77140. shader: string;
  77141. };
  77142. }
  77143. declare module BABYLON {
  77144. /**
  77145. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77146. */
  77147. export interface ISpriteManager extends IDisposable {
  77148. /**
  77149. * Restricts the camera to viewing objects with the same layerMask.
  77150. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77151. */
  77152. layerMask: number;
  77153. /**
  77154. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77155. */
  77156. isPickable: boolean;
  77157. /**
  77158. * Specifies the rendering group id for this mesh (0 by default)
  77159. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77160. */
  77161. renderingGroupId: number;
  77162. /**
  77163. * Defines the list of sprites managed by the manager.
  77164. */
  77165. sprites: Array<Sprite>;
  77166. /**
  77167. * Tests the intersection of a sprite with a specific ray.
  77168. * @param ray The ray we are sending to test the collision
  77169. * @param camera The camera space we are sending rays in
  77170. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77171. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77172. * @returns picking info or null.
  77173. */
  77174. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77175. /**
  77176. * Intersects the sprites with a ray
  77177. * @param ray defines the ray to intersect with
  77178. * @param camera defines the current active camera
  77179. * @param predicate defines a predicate used to select candidate sprites
  77180. * @returns null if no hit or a PickingInfo array
  77181. */
  77182. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77183. /**
  77184. * Renders the list of sprites on screen.
  77185. */
  77186. render(): void;
  77187. }
  77188. /**
  77189. * Class used to manage multiple sprites on the same spritesheet
  77190. * @see http://doc.babylonjs.com/babylon101/sprites
  77191. */
  77192. export class SpriteManager implements ISpriteManager {
  77193. /** defines the manager's name */
  77194. name: string;
  77195. /** Gets the list of sprites */
  77196. sprites: Sprite[];
  77197. /** Gets or sets the rendering group id (0 by default) */
  77198. renderingGroupId: number;
  77199. /** Gets or sets camera layer mask */
  77200. layerMask: number;
  77201. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77202. fogEnabled: boolean;
  77203. /** Gets or sets a boolean indicating if the sprites are pickable */
  77204. isPickable: boolean;
  77205. /** Defines the default width of a cell in the spritesheet */
  77206. cellWidth: number;
  77207. /** Defines the default height of a cell in the spritesheet */
  77208. cellHeight: number;
  77209. /** Associative array from JSON sprite data file */
  77210. private _cellData;
  77211. /** Array of sprite names from JSON sprite data file */
  77212. private _spriteMap;
  77213. /** True when packed cell data from JSON file is ready*/
  77214. private _packedAndReady;
  77215. /**
  77216. * An event triggered when the manager is disposed.
  77217. */
  77218. onDisposeObservable: Observable<SpriteManager>;
  77219. private _onDisposeObserver;
  77220. /**
  77221. * Callback called when the manager is disposed
  77222. */
  77223. onDispose: () => void;
  77224. private _capacity;
  77225. private _fromPacked;
  77226. private _spriteTexture;
  77227. private _epsilon;
  77228. private _scene;
  77229. private _vertexData;
  77230. private _buffer;
  77231. private _vertexBuffers;
  77232. private _indexBuffer;
  77233. private _effectBase;
  77234. private _effectFog;
  77235. /**
  77236. * Gets or sets the spritesheet texture
  77237. */
  77238. texture: Texture;
  77239. /**
  77240. * Creates a new sprite manager
  77241. * @param name defines the manager's name
  77242. * @param imgUrl defines the sprite sheet url
  77243. * @param capacity defines the maximum allowed number of sprites
  77244. * @param cellSize defines the size of a sprite cell
  77245. * @param scene defines the hosting scene
  77246. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77247. * @param samplingMode defines the smapling mode to use with spritesheet
  77248. * @param fromPacked set to false; do not alter
  77249. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77250. */
  77251. constructor(
  77252. /** defines the manager's name */
  77253. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77254. private _makePacked;
  77255. private _appendSpriteVertex;
  77256. /**
  77257. * Intersects the sprites with a ray
  77258. * @param ray defines the ray to intersect with
  77259. * @param camera defines the current active camera
  77260. * @param predicate defines a predicate used to select candidate sprites
  77261. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77262. * @returns null if no hit or a PickingInfo
  77263. */
  77264. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77265. /**
  77266. * Intersects the sprites with a ray
  77267. * @param ray defines the ray to intersect with
  77268. * @param camera defines the current active camera
  77269. * @param predicate defines a predicate used to select candidate sprites
  77270. * @returns null if no hit or a PickingInfo array
  77271. */
  77272. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77273. /**
  77274. * Render all child sprites
  77275. */
  77276. render(): void;
  77277. /**
  77278. * Release associated resources
  77279. */
  77280. dispose(): void;
  77281. }
  77282. }
  77283. declare module BABYLON {
  77284. /**
  77285. * Class used to represent a sprite
  77286. * @see http://doc.babylonjs.com/babylon101/sprites
  77287. */
  77288. export class Sprite {
  77289. /** defines the name */
  77290. name: string;
  77291. /** Gets or sets the current world position */
  77292. position: Vector3;
  77293. /** Gets or sets the main color */
  77294. color: Color4;
  77295. /** Gets or sets the width */
  77296. width: number;
  77297. /** Gets or sets the height */
  77298. height: number;
  77299. /** Gets or sets rotation angle */
  77300. angle: number;
  77301. /** Gets or sets the cell index in the sprite sheet */
  77302. cellIndex: number;
  77303. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77304. cellRef: string;
  77305. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77306. invertU: number;
  77307. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77308. invertV: number;
  77309. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77310. disposeWhenFinishedAnimating: boolean;
  77311. /** Gets the list of attached animations */
  77312. animations: Animation[];
  77313. /** Gets or sets a boolean indicating if the sprite can be picked */
  77314. isPickable: boolean;
  77315. /**
  77316. * Gets or sets the associated action manager
  77317. */
  77318. actionManager: Nullable<ActionManager>;
  77319. private _animationStarted;
  77320. private _loopAnimation;
  77321. private _fromIndex;
  77322. private _toIndex;
  77323. private _delay;
  77324. private _direction;
  77325. private _manager;
  77326. private _time;
  77327. private _onAnimationEnd;
  77328. /**
  77329. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77330. */
  77331. isVisible: boolean;
  77332. /**
  77333. * Gets or sets the sprite size
  77334. */
  77335. size: number;
  77336. /**
  77337. * Creates a new Sprite
  77338. * @param name defines the name
  77339. * @param manager defines the manager
  77340. */
  77341. constructor(
  77342. /** defines the name */
  77343. name: string, manager: ISpriteManager);
  77344. /**
  77345. * Starts an animation
  77346. * @param from defines the initial key
  77347. * @param to defines the end key
  77348. * @param loop defines if the animation must loop
  77349. * @param delay defines the start delay (in ms)
  77350. * @param onAnimationEnd defines a callback to call when animation ends
  77351. */
  77352. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77353. /** Stops current animation (if any) */
  77354. stopAnimation(): void;
  77355. /** @hidden */
  77356. _animate(deltaTime: number): void;
  77357. /** Release associated resources */
  77358. dispose(): void;
  77359. }
  77360. }
  77361. declare module BABYLON {
  77362. /**
  77363. * Information about the result of picking within a scene
  77364. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77365. */
  77366. export class PickingInfo {
  77367. /** @hidden */
  77368. _pickingUnavailable: boolean;
  77369. /**
  77370. * If the pick collided with an object
  77371. */
  77372. hit: boolean;
  77373. /**
  77374. * Distance away where the pick collided
  77375. */
  77376. distance: number;
  77377. /**
  77378. * The location of pick collision
  77379. */
  77380. pickedPoint: Nullable<Vector3>;
  77381. /**
  77382. * The mesh corresponding the the pick collision
  77383. */
  77384. pickedMesh: Nullable<AbstractMesh>;
  77385. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77386. bu: number;
  77387. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77388. bv: number;
  77389. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77390. faceId: number;
  77391. /** Id of the the submesh that was picked */
  77392. subMeshId: number;
  77393. /** If a sprite was picked, this will be the sprite the pick collided with */
  77394. pickedSprite: Nullable<Sprite>;
  77395. /**
  77396. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77397. */
  77398. originMesh: Nullable<AbstractMesh>;
  77399. /**
  77400. * The ray that was used to perform the picking.
  77401. */
  77402. ray: Nullable<Ray>;
  77403. /**
  77404. * Gets the normal correspodning to the face the pick collided with
  77405. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77406. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77407. * @returns The normal correspodning to the face the pick collided with
  77408. */
  77409. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77410. /**
  77411. * Gets the texture coordinates of where the pick occured
  77412. * @returns the vector containing the coordnates of the texture
  77413. */
  77414. getTextureCoordinates(): Nullable<Vector2>;
  77415. }
  77416. }
  77417. declare module BABYLON {
  77418. /**
  77419. * Gather the list of pointer event types as constants.
  77420. */
  77421. export class PointerEventTypes {
  77422. /**
  77423. * 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.
  77424. */
  77425. static readonly POINTERDOWN: number;
  77426. /**
  77427. * The pointerup event is fired when a pointer is no longer active.
  77428. */
  77429. static readonly POINTERUP: number;
  77430. /**
  77431. * The pointermove event is fired when a pointer changes coordinates.
  77432. */
  77433. static readonly POINTERMOVE: number;
  77434. /**
  77435. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77436. */
  77437. static readonly POINTERWHEEL: number;
  77438. /**
  77439. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77440. */
  77441. static readonly POINTERPICK: number;
  77442. /**
  77443. * The pointertap event is fired when a the object has been touched and released without drag.
  77444. */
  77445. static readonly POINTERTAP: number;
  77446. /**
  77447. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77448. */
  77449. static readonly POINTERDOUBLETAP: number;
  77450. }
  77451. /**
  77452. * Base class of pointer info types.
  77453. */
  77454. export class PointerInfoBase {
  77455. /**
  77456. * Defines the type of event (PointerEventTypes)
  77457. */
  77458. type: number;
  77459. /**
  77460. * Defines the related dom event
  77461. */
  77462. event: PointerEvent | MouseWheelEvent;
  77463. /**
  77464. * Instantiates the base class of pointers info.
  77465. * @param type Defines the type of event (PointerEventTypes)
  77466. * @param event Defines the related dom event
  77467. */
  77468. constructor(
  77469. /**
  77470. * Defines the type of event (PointerEventTypes)
  77471. */
  77472. type: number,
  77473. /**
  77474. * Defines the related dom event
  77475. */
  77476. event: PointerEvent | MouseWheelEvent);
  77477. }
  77478. /**
  77479. * This class is used to store pointer related info for the onPrePointerObservable event.
  77480. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77481. */
  77482. export class PointerInfoPre extends PointerInfoBase {
  77483. /**
  77484. * Ray from a pointer if availible (eg. 6dof controller)
  77485. */
  77486. ray: Nullable<Ray>;
  77487. /**
  77488. * Defines the local position of the pointer on the canvas.
  77489. */
  77490. localPosition: Vector2;
  77491. /**
  77492. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77493. */
  77494. skipOnPointerObservable: boolean;
  77495. /**
  77496. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77497. * @param type Defines the type of event (PointerEventTypes)
  77498. * @param event Defines the related dom event
  77499. * @param localX Defines the local x coordinates of the pointer when the event occured
  77500. * @param localY Defines the local y coordinates of the pointer when the event occured
  77501. */
  77502. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77503. }
  77504. /**
  77505. * This type contains all the data related to a pointer event in Babylon.js.
  77506. * 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.
  77507. */
  77508. export class PointerInfo extends PointerInfoBase {
  77509. /**
  77510. * Defines the picking info associated to the info (if any)\
  77511. */
  77512. pickInfo: Nullable<PickingInfo>;
  77513. /**
  77514. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77515. * @param type Defines the type of event (PointerEventTypes)
  77516. * @param event Defines the related dom event
  77517. * @param pickInfo Defines the picking info associated to the info (if any)\
  77518. */
  77519. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77520. /**
  77521. * Defines the picking info associated to the info (if any)\
  77522. */
  77523. pickInfo: Nullable<PickingInfo>);
  77524. }
  77525. /**
  77526. * Data relating to a touch event on the screen.
  77527. */
  77528. export interface PointerTouch {
  77529. /**
  77530. * X coordinate of touch.
  77531. */
  77532. x: number;
  77533. /**
  77534. * Y coordinate of touch.
  77535. */
  77536. y: number;
  77537. /**
  77538. * Id of touch. Unique for each finger.
  77539. */
  77540. pointerId: number;
  77541. /**
  77542. * Event type passed from DOM.
  77543. */
  77544. type: any;
  77545. }
  77546. }
  77547. declare module BABYLON {
  77548. /**
  77549. * Manage the mouse inputs to control the movement of a free camera.
  77550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77551. */
  77552. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77553. /**
  77554. * Define if touch is enabled in the mouse input
  77555. */
  77556. touchEnabled: boolean;
  77557. /**
  77558. * Defines the camera the input is attached to.
  77559. */
  77560. camera: FreeCamera;
  77561. /**
  77562. * Defines the buttons associated with the input to handle camera move.
  77563. */
  77564. buttons: number[];
  77565. /**
  77566. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77567. */
  77568. angularSensibility: number;
  77569. private _pointerInput;
  77570. private _onMouseMove;
  77571. private _observer;
  77572. private previousPosition;
  77573. /**
  77574. * Observable for when a pointer move event occurs containing the move offset
  77575. */
  77576. onPointerMovedObservable: Observable<{
  77577. offsetX: number;
  77578. offsetY: number;
  77579. }>;
  77580. /**
  77581. * @hidden
  77582. * If the camera should be rotated automatically based on pointer movement
  77583. */
  77584. _allowCameraRotation: boolean;
  77585. /**
  77586. * Manage the mouse inputs to control the movement of a free camera.
  77587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77588. * @param touchEnabled Defines if touch is enabled or not
  77589. */
  77590. constructor(
  77591. /**
  77592. * Define if touch is enabled in the mouse input
  77593. */
  77594. touchEnabled?: boolean);
  77595. /**
  77596. * Attach the input controls to a specific dom element to get the input from.
  77597. * @param element Defines the element the controls should be listened from
  77598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77599. */
  77600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77601. /**
  77602. * Called on JS contextmenu event.
  77603. * Override this method to provide functionality.
  77604. */
  77605. protected onContextMenu(evt: PointerEvent): void;
  77606. /**
  77607. * Detach the current controls from the specified dom element.
  77608. * @param element Defines the element to stop listening the inputs from
  77609. */
  77610. detachControl(element: Nullable<HTMLElement>): void;
  77611. /**
  77612. * Gets the class name of the current intput.
  77613. * @returns the class name
  77614. */
  77615. getClassName(): string;
  77616. /**
  77617. * Get the friendly name associated with the input class.
  77618. * @returns the input friendly name
  77619. */
  77620. getSimpleName(): string;
  77621. }
  77622. }
  77623. declare module BABYLON {
  77624. /**
  77625. * Manage the touch inputs to control the movement of a free camera.
  77626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77627. */
  77628. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77629. /**
  77630. * Defines the camera the input is attached to.
  77631. */
  77632. camera: FreeCamera;
  77633. /**
  77634. * Defines the touch sensibility for rotation.
  77635. * The higher the faster.
  77636. */
  77637. touchAngularSensibility: number;
  77638. /**
  77639. * Defines the touch sensibility for move.
  77640. * The higher the faster.
  77641. */
  77642. touchMoveSensibility: number;
  77643. private _offsetX;
  77644. private _offsetY;
  77645. private _pointerPressed;
  77646. private _pointerInput;
  77647. private _observer;
  77648. private _onLostFocus;
  77649. /**
  77650. * Attach the input controls to a specific dom element to get the input from.
  77651. * @param element Defines the element the controls should be listened from
  77652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77653. */
  77654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77655. /**
  77656. * Detach the current controls from the specified dom element.
  77657. * @param element Defines the element to stop listening the inputs from
  77658. */
  77659. detachControl(element: Nullable<HTMLElement>): void;
  77660. /**
  77661. * Update the current camera state depending on the inputs that have been used this frame.
  77662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77663. */
  77664. checkInputs(): void;
  77665. /**
  77666. * Gets the class name of the current intput.
  77667. * @returns the class name
  77668. */
  77669. getClassName(): string;
  77670. /**
  77671. * Get the friendly name associated with the input class.
  77672. * @returns the input friendly name
  77673. */
  77674. getSimpleName(): string;
  77675. }
  77676. }
  77677. declare module BABYLON {
  77678. /**
  77679. * Default Inputs manager for the FreeCamera.
  77680. * It groups all the default supported inputs for ease of use.
  77681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77682. */
  77683. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77684. /**
  77685. * @hidden
  77686. */
  77687. _mouseInput: Nullable<FreeCameraMouseInput>;
  77688. /**
  77689. * Instantiates a new FreeCameraInputsManager.
  77690. * @param camera Defines the camera the inputs belong to
  77691. */
  77692. constructor(camera: FreeCamera);
  77693. /**
  77694. * Add keyboard input support to the input manager.
  77695. * @returns the current input manager
  77696. */
  77697. addKeyboard(): FreeCameraInputsManager;
  77698. /**
  77699. * Add mouse input support to the input manager.
  77700. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77701. * @returns the current input manager
  77702. */
  77703. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77704. /**
  77705. * Removes the mouse input support from the manager
  77706. * @returns the current input manager
  77707. */
  77708. removeMouse(): FreeCameraInputsManager;
  77709. /**
  77710. * Add touch input support to the input manager.
  77711. * @returns the current input manager
  77712. */
  77713. addTouch(): FreeCameraInputsManager;
  77714. /**
  77715. * Remove all attached input methods from a camera
  77716. */
  77717. clear(): void;
  77718. }
  77719. }
  77720. declare module BABYLON {
  77721. /**
  77722. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77723. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77724. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77725. */
  77726. export class FreeCamera extends TargetCamera {
  77727. /**
  77728. * Define the collision ellipsoid of the camera.
  77729. * This is helpful to simulate a camera body like the player body around the camera
  77730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77731. */
  77732. ellipsoid: Vector3;
  77733. /**
  77734. * Define an offset for the position of the ellipsoid around the camera.
  77735. * This can be helpful to determine the center of the body near the gravity center of the body
  77736. * instead of its head.
  77737. */
  77738. ellipsoidOffset: Vector3;
  77739. /**
  77740. * Enable or disable collisions of the camera with the rest of the scene objects.
  77741. */
  77742. checkCollisions: boolean;
  77743. /**
  77744. * Enable or disable gravity on the camera.
  77745. */
  77746. applyGravity: boolean;
  77747. /**
  77748. * Define the input manager associated to the camera.
  77749. */
  77750. inputs: FreeCameraInputsManager;
  77751. /**
  77752. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77753. * Higher values reduce sensitivity.
  77754. */
  77755. /**
  77756. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77757. * Higher values reduce sensitivity.
  77758. */
  77759. angularSensibility: number;
  77760. /**
  77761. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77762. */
  77763. keysUp: number[];
  77764. /**
  77765. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77766. */
  77767. keysDown: number[];
  77768. /**
  77769. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77770. */
  77771. keysLeft: number[];
  77772. /**
  77773. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77774. */
  77775. keysRight: number[];
  77776. /**
  77777. * Event raised when the camera collide with a mesh in the scene.
  77778. */
  77779. onCollide: (collidedMesh: AbstractMesh) => void;
  77780. private _collider;
  77781. private _needMoveForGravity;
  77782. private _oldPosition;
  77783. private _diffPosition;
  77784. private _newPosition;
  77785. /** @hidden */
  77786. _localDirection: Vector3;
  77787. /** @hidden */
  77788. _transformedDirection: Vector3;
  77789. /**
  77790. * Instantiates a Free Camera.
  77791. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77792. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77793. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77794. * @param name Define the name of the camera in the scene
  77795. * @param position Define the start position of the camera in the scene
  77796. * @param scene Define the scene the camera belongs to
  77797. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77798. */
  77799. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77800. /**
  77801. * Attached controls to the current camera.
  77802. * @param element Defines the element the controls should be listened from
  77803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77804. */
  77805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77806. /**
  77807. * Detach the current controls from the camera.
  77808. * The camera will stop reacting to inputs.
  77809. * @param element Defines the element to stop listening the inputs from
  77810. */
  77811. detachControl(element: HTMLElement): void;
  77812. private _collisionMask;
  77813. /**
  77814. * Define a collision mask to limit the list of object the camera can collide with
  77815. */
  77816. collisionMask: number;
  77817. /** @hidden */
  77818. _collideWithWorld(displacement: Vector3): void;
  77819. private _onCollisionPositionChange;
  77820. /** @hidden */
  77821. _checkInputs(): void;
  77822. /** @hidden */
  77823. _decideIfNeedsToMove(): boolean;
  77824. /** @hidden */
  77825. _updatePosition(): void;
  77826. /**
  77827. * Destroy the camera and release the current resources hold by it.
  77828. */
  77829. dispose(): void;
  77830. /**
  77831. * Gets the current object class name.
  77832. * @return the class name
  77833. */
  77834. getClassName(): string;
  77835. }
  77836. }
  77837. declare module BABYLON {
  77838. /**
  77839. * Represents a gamepad control stick position
  77840. */
  77841. export class StickValues {
  77842. /**
  77843. * The x component of the control stick
  77844. */
  77845. x: number;
  77846. /**
  77847. * The y component of the control stick
  77848. */
  77849. y: number;
  77850. /**
  77851. * Initializes the gamepad x and y control stick values
  77852. * @param x The x component of the gamepad control stick value
  77853. * @param y The y component of the gamepad control stick value
  77854. */
  77855. constructor(
  77856. /**
  77857. * The x component of the control stick
  77858. */
  77859. x: number,
  77860. /**
  77861. * The y component of the control stick
  77862. */
  77863. y: number);
  77864. }
  77865. /**
  77866. * An interface which manages callbacks for gamepad button changes
  77867. */
  77868. export interface GamepadButtonChanges {
  77869. /**
  77870. * Called when a gamepad has been changed
  77871. */
  77872. changed: boolean;
  77873. /**
  77874. * Called when a gamepad press event has been triggered
  77875. */
  77876. pressChanged: boolean;
  77877. /**
  77878. * Called when a touch event has been triggered
  77879. */
  77880. touchChanged: boolean;
  77881. /**
  77882. * Called when a value has changed
  77883. */
  77884. valueChanged: boolean;
  77885. }
  77886. /**
  77887. * Represents a gamepad
  77888. */
  77889. export class Gamepad {
  77890. /**
  77891. * The id of the gamepad
  77892. */
  77893. id: string;
  77894. /**
  77895. * The index of the gamepad
  77896. */
  77897. index: number;
  77898. /**
  77899. * The browser gamepad
  77900. */
  77901. browserGamepad: any;
  77902. /**
  77903. * Specifies what type of gamepad this represents
  77904. */
  77905. type: number;
  77906. private _leftStick;
  77907. private _rightStick;
  77908. /** @hidden */
  77909. _isConnected: boolean;
  77910. private _leftStickAxisX;
  77911. private _leftStickAxisY;
  77912. private _rightStickAxisX;
  77913. private _rightStickAxisY;
  77914. /**
  77915. * Triggered when the left control stick has been changed
  77916. */
  77917. private _onleftstickchanged;
  77918. /**
  77919. * Triggered when the right control stick has been changed
  77920. */
  77921. private _onrightstickchanged;
  77922. /**
  77923. * Represents a gamepad controller
  77924. */
  77925. static GAMEPAD: number;
  77926. /**
  77927. * Represents a generic controller
  77928. */
  77929. static GENERIC: number;
  77930. /**
  77931. * Represents an XBox controller
  77932. */
  77933. static XBOX: number;
  77934. /**
  77935. * Represents a pose-enabled controller
  77936. */
  77937. static POSE_ENABLED: number;
  77938. /**
  77939. * Represents an Dual Shock controller
  77940. */
  77941. static DUALSHOCK: number;
  77942. /**
  77943. * Specifies whether the left control stick should be Y-inverted
  77944. */
  77945. protected _invertLeftStickY: boolean;
  77946. /**
  77947. * Specifies if the gamepad has been connected
  77948. */
  77949. readonly isConnected: boolean;
  77950. /**
  77951. * Initializes the gamepad
  77952. * @param id The id of the gamepad
  77953. * @param index The index of the gamepad
  77954. * @param browserGamepad The browser gamepad
  77955. * @param leftStickX The x component of the left joystick
  77956. * @param leftStickY The y component of the left joystick
  77957. * @param rightStickX The x component of the right joystick
  77958. * @param rightStickY The y component of the right joystick
  77959. */
  77960. constructor(
  77961. /**
  77962. * The id of the gamepad
  77963. */
  77964. id: string,
  77965. /**
  77966. * The index of the gamepad
  77967. */
  77968. index: number,
  77969. /**
  77970. * The browser gamepad
  77971. */
  77972. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77973. /**
  77974. * Callback triggered when the left joystick has changed
  77975. * @param callback
  77976. */
  77977. onleftstickchanged(callback: (values: StickValues) => void): void;
  77978. /**
  77979. * Callback triggered when the right joystick has changed
  77980. * @param callback
  77981. */
  77982. onrightstickchanged(callback: (values: StickValues) => void): void;
  77983. /**
  77984. * Gets the left joystick
  77985. */
  77986. /**
  77987. * Sets the left joystick values
  77988. */
  77989. leftStick: StickValues;
  77990. /**
  77991. * Gets the right joystick
  77992. */
  77993. /**
  77994. * Sets the right joystick value
  77995. */
  77996. rightStick: StickValues;
  77997. /**
  77998. * Updates the gamepad joystick positions
  77999. */
  78000. update(): void;
  78001. /**
  78002. * Disposes the gamepad
  78003. */
  78004. dispose(): void;
  78005. }
  78006. /**
  78007. * Represents a generic gamepad
  78008. */
  78009. export class GenericPad extends Gamepad {
  78010. private _buttons;
  78011. private _onbuttondown;
  78012. private _onbuttonup;
  78013. /**
  78014. * Observable triggered when a button has been pressed
  78015. */
  78016. onButtonDownObservable: Observable<number>;
  78017. /**
  78018. * Observable triggered when a button has been released
  78019. */
  78020. onButtonUpObservable: Observable<number>;
  78021. /**
  78022. * Callback triggered when a button has been pressed
  78023. * @param callback Called when a button has been pressed
  78024. */
  78025. onbuttondown(callback: (buttonPressed: number) => void): void;
  78026. /**
  78027. * Callback triggered when a button has been released
  78028. * @param callback Called when a button has been released
  78029. */
  78030. onbuttonup(callback: (buttonReleased: number) => void): void;
  78031. /**
  78032. * Initializes the generic gamepad
  78033. * @param id The id of the generic gamepad
  78034. * @param index The index of the generic gamepad
  78035. * @param browserGamepad The browser gamepad
  78036. */
  78037. constructor(id: string, index: number, browserGamepad: any);
  78038. private _setButtonValue;
  78039. /**
  78040. * Updates the generic gamepad
  78041. */
  78042. update(): void;
  78043. /**
  78044. * Disposes the generic gamepad
  78045. */
  78046. dispose(): void;
  78047. }
  78048. }
  78049. declare module BABYLON {
  78050. interface Engine {
  78051. /**
  78052. * Creates a raw texture
  78053. * @param data defines the data to store in the texture
  78054. * @param width defines the width of the texture
  78055. * @param height defines the height of the texture
  78056. * @param format defines the format of the data
  78057. * @param generateMipMaps defines if the engine should generate the mip levels
  78058. * @param invertY defines if data must be stored with Y axis inverted
  78059. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78060. * @param compression defines the compression used (null by default)
  78061. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78062. * @returns the raw texture inside an InternalTexture
  78063. */
  78064. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78065. /**
  78066. * Update a raw texture
  78067. * @param texture defines the texture to update
  78068. * @param data defines the data to store in the texture
  78069. * @param format defines the format of the data
  78070. * @param invertY defines if data must be stored with Y axis inverted
  78071. */
  78072. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78073. /**
  78074. * Update a raw texture
  78075. * @param texture defines the texture to update
  78076. * @param data defines the data to store in the texture
  78077. * @param format defines the format of the data
  78078. * @param invertY defines if data must be stored with Y axis inverted
  78079. * @param compression defines the compression used (null by default)
  78080. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78081. */
  78082. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78083. /**
  78084. * Creates a new raw cube texture
  78085. * @param data defines the array of data to use to create each face
  78086. * @param size defines the size of the textures
  78087. * @param format defines the format of the data
  78088. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78089. * @param generateMipMaps defines if the engine should generate the mip levels
  78090. * @param invertY defines if data must be stored with Y axis inverted
  78091. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78092. * @param compression defines the compression used (null by default)
  78093. * @returns the cube texture as an InternalTexture
  78094. */
  78095. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78096. /**
  78097. * Update a raw cube texture
  78098. * @param texture defines the texture to udpdate
  78099. * @param data defines the data to store
  78100. * @param format defines the data format
  78101. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78102. * @param invertY defines if data must be stored with Y axis inverted
  78103. */
  78104. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78105. /**
  78106. * Update a raw cube texture
  78107. * @param texture defines the texture to udpdate
  78108. * @param data defines the data to store
  78109. * @param format defines the data format
  78110. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78111. * @param invertY defines if data must be stored with Y axis inverted
  78112. * @param compression defines the compression used (null by default)
  78113. */
  78114. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78115. /**
  78116. * Update a raw cube texture
  78117. * @param texture defines the texture to udpdate
  78118. * @param data defines the data to store
  78119. * @param format defines the data format
  78120. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78121. * @param invertY defines if data must be stored with Y axis inverted
  78122. * @param compression defines the compression used (null by default)
  78123. * @param level defines which level of the texture to update
  78124. */
  78125. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78126. /**
  78127. * Creates a new raw cube texture from a specified url
  78128. * @param url defines the url where the data is located
  78129. * @param scene defines the current scene
  78130. * @param size defines the size of the textures
  78131. * @param format defines the format of the data
  78132. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78133. * @param noMipmap defines if the engine should avoid generating the mip levels
  78134. * @param callback defines a callback used to extract texture data from loaded data
  78135. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78136. * @param onLoad defines a callback called when texture is loaded
  78137. * @param onError defines a callback called if there is an error
  78138. * @returns the cube texture as an InternalTexture
  78139. */
  78140. 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;
  78141. /**
  78142. * Creates a new raw cube texture from a specified url
  78143. * @param url defines the url where the data is located
  78144. * @param scene defines the current scene
  78145. * @param size defines the size of the textures
  78146. * @param format defines the format of the data
  78147. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78148. * @param noMipmap defines if the engine should avoid generating the mip levels
  78149. * @param callback defines a callback used to extract texture data from loaded data
  78150. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78151. * @param onLoad defines a callback called when texture is loaded
  78152. * @param onError defines a callback called if there is an error
  78153. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78154. * @param invertY defines if data must be stored with Y axis inverted
  78155. * @returns the cube texture as an InternalTexture
  78156. */
  78157. 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;
  78158. /**
  78159. * Creates a new raw 3D texture
  78160. * @param data defines the data used to create the texture
  78161. * @param width defines the width of the texture
  78162. * @param height defines the height of the texture
  78163. * @param depth defines the depth of the texture
  78164. * @param format defines the format of the texture
  78165. * @param generateMipMaps defines if the engine must generate mip levels
  78166. * @param invertY defines if data must be stored with Y axis inverted
  78167. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78168. * @param compression defines the compressed used (can be null)
  78169. * @param textureType defines the compressed used (can be null)
  78170. * @returns a new raw 3D texture (stored in an InternalTexture)
  78171. */
  78172. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78173. /**
  78174. * Update a raw 3D texture
  78175. * @param texture defines the texture to update
  78176. * @param data defines the data to store
  78177. * @param format defines the data format
  78178. * @param invertY defines if data must be stored with Y axis inverted
  78179. */
  78180. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78181. /**
  78182. * Update a raw 3D texture
  78183. * @param texture defines the texture to update
  78184. * @param data defines the data to store
  78185. * @param format defines the data format
  78186. * @param invertY defines if data must be stored with Y axis inverted
  78187. * @param compression defines the used compression (can be null)
  78188. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78189. */
  78190. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78191. }
  78192. }
  78193. declare module BABYLON {
  78194. /**
  78195. * Raw texture can help creating a texture directly from an array of data.
  78196. * This can be super useful if you either get the data from an uncompressed source or
  78197. * if you wish to create your texture pixel by pixel.
  78198. */
  78199. export class RawTexture extends Texture {
  78200. /**
  78201. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78202. */
  78203. format: number;
  78204. private _engine;
  78205. /**
  78206. * Instantiates a new RawTexture.
  78207. * Raw texture can help creating a texture directly from an array of data.
  78208. * This can be super useful if you either get the data from an uncompressed source or
  78209. * if you wish to create your texture pixel by pixel.
  78210. * @param data define the array of data to use to create the texture
  78211. * @param width define the width of the texture
  78212. * @param height define the height of the texture
  78213. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78214. * @param scene define the scene the texture belongs to
  78215. * @param generateMipMaps define whether mip maps should be generated or not
  78216. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78217. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78218. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78219. */
  78220. constructor(data: ArrayBufferView, width: number, height: number,
  78221. /**
  78222. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78223. */
  78224. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78225. /**
  78226. * Updates the texture underlying data.
  78227. * @param data Define the new data of the texture
  78228. */
  78229. update(data: ArrayBufferView): void;
  78230. /**
  78231. * Creates a luminance texture from some data.
  78232. * @param data Define the texture data
  78233. * @param width Define the width of the texture
  78234. * @param height Define the height of the texture
  78235. * @param scene Define the scene the texture belongs to
  78236. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78237. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78238. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78239. * @returns the luminance texture
  78240. */
  78241. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78242. /**
  78243. * Creates a luminance alpha texture from some data.
  78244. * @param data Define the texture data
  78245. * @param width Define the width of the texture
  78246. * @param height Define the height of the texture
  78247. * @param scene Define the scene the texture belongs to
  78248. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78249. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78250. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78251. * @returns the luminance alpha texture
  78252. */
  78253. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78254. /**
  78255. * Creates an alpha texture from some data.
  78256. * @param data Define the texture data
  78257. * @param width Define the width of the texture
  78258. * @param height Define the height of the texture
  78259. * @param scene Define the scene the texture belongs to
  78260. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78261. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78262. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78263. * @returns the alpha texture
  78264. */
  78265. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78266. /**
  78267. * Creates a RGB 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 RGB alpha texture
  78277. */
  78278. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78279. /**
  78280. * Creates a RGBA 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 RGBA texture
  78290. */
  78291. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78292. /**
  78293. * Creates a R texture from some data.
  78294. * @param data Define the texture data
  78295. * @param width Define the width of the texture
  78296. * @param height Define the height of the texture
  78297. * @param scene Define the scene the texture belongs to
  78298. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78299. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78300. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78301. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78302. * @returns the R texture
  78303. */
  78304. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78305. }
  78306. }
  78307. declare module BABYLON {
  78308. /**
  78309. * Interface for the size containing width and height
  78310. */
  78311. export interface ISize {
  78312. /**
  78313. * Width
  78314. */
  78315. width: number;
  78316. /**
  78317. * Heighht
  78318. */
  78319. height: number;
  78320. }
  78321. /**
  78322. * Size containing widht and height
  78323. */
  78324. export class Size implements ISize {
  78325. /**
  78326. * Width
  78327. */
  78328. width: number;
  78329. /**
  78330. * Height
  78331. */
  78332. height: number;
  78333. /**
  78334. * Creates a Size object from the given width and height (floats).
  78335. * @param width width of the new size
  78336. * @param height height of the new size
  78337. */
  78338. constructor(width: number, height: number);
  78339. /**
  78340. * Returns a string with the Size width and height
  78341. * @returns a string with the Size width and height
  78342. */
  78343. toString(): string;
  78344. /**
  78345. * "Size"
  78346. * @returns the string "Size"
  78347. */
  78348. getClassName(): string;
  78349. /**
  78350. * Returns the Size hash code.
  78351. * @returns a hash code for a unique width and height
  78352. */
  78353. getHashCode(): number;
  78354. /**
  78355. * Updates the current size from the given one.
  78356. * @param src the given size
  78357. */
  78358. copyFrom(src: Size): void;
  78359. /**
  78360. * Updates in place the current Size from the given floats.
  78361. * @param width width of the new size
  78362. * @param height height of the new size
  78363. * @returns the updated Size.
  78364. */
  78365. copyFromFloats(width: number, height: number): Size;
  78366. /**
  78367. * Updates in place the current Size from the given floats.
  78368. * @param width width to set
  78369. * @param height height to set
  78370. * @returns the updated Size.
  78371. */
  78372. set(width: number, height: number): Size;
  78373. /**
  78374. * Multiplies the width and height by numbers
  78375. * @param w factor to multiple the width by
  78376. * @param h factor to multiple the height by
  78377. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78378. */
  78379. multiplyByFloats(w: number, h: number): Size;
  78380. /**
  78381. * Clones the size
  78382. * @returns a new Size copied from the given one.
  78383. */
  78384. clone(): Size;
  78385. /**
  78386. * True if the current Size and the given one width and height are strictly equal.
  78387. * @param other the other size to compare against
  78388. * @returns True if the current Size and the given one width and height are strictly equal.
  78389. */
  78390. equals(other: Size): boolean;
  78391. /**
  78392. * The surface of the Size : width * height (float).
  78393. */
  78394. readonly surface: number;
  78395. /**
  78396. * Create a new size of zero
  78397. * @returns a new Size set to (0.0, 0.0)
  78398. */
  78399. static Zero(): Size;
  78400. /**
  78401. * Sums the width and height of two sizes
  78402. * @param otherSize size to add to this size
  78403. * @returns a new Size set as the addition result of the current Size and the given one.
  78404. */
  78405. add(otherSize: Size): Size;
  78406. /**
  78407. * Subtracts the width and height of two
  78408. * @param otherSize size to subtract to this size
  78409. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78410. */
  78411. subtract(otherSize: Size): Size;
  78412. /**
  78413. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78414. * @param start starting size to lerp between
  78415. * @param end end size to lerp between
  78416. * @param amount amount to lerp between the start and end values
  78417. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78418. */
  78419. static Lerp(start: Size, end: Size, amount: number): Size;
  78420. }
  78421. }
  78422. declare module BABYLON {
  78423. /**
  78424. * Defines a runtime animation
  78425. */
  78426. export class RuntimeAnimation {
  78427. private _events;
  78428. /**
  78429. * The current frame of the runtime animation
  78430. */
  78431. private _currentFrame;
  78432. /**
  78433. * The animation used by the runtime animation
  78434. */
  78435. private _animation;
  78436. /**
  78437. * The target of the runtime animation
  78438. */
  78439. private _target;
  78440. /**
  78441. * The initiating animatable
  78442. */
  78443. private _host;
  78444. /**
  78445. * The original value of the runtime animation
  78446. */
  78447. private _originalValue;
  78448. /**
  78449. * The original blend value of the runtime animation
  78450. */
  78451. private _originalBlendValue;
  78452. /**
  78453. * The offsets cache of the runtime animation
  78454. */
  78455. private _offsetsCache;
  78456. /**
  78457. * The high limits cache of the runtime animation
  78458. */
  78459. private _highLimitsCache;
  78460. /**
  78461. * Specifies if the runtime animation has been stopped
  78462. */
  78463. private _stopped;
  78464. /**
  78465. * The blending factor of the runtime animation
  78466. */
  78467. private _blendingFactor;
  78468. /**
  78469. * The BabylonJS scene
  78470. */
  78471. private _scene;
  78472. /**
  78473. * The current value of the runtime animation
  78474. */
  78475. private _currentValue;
  78476. /** @hidden */
  78477. _animationState: _IAnimationState;
  78478. /**
  78479. * The active target of the runtime animation
  78480. */
  78481. private _activeTargets;
  78482. private _currentActiveTarget;
  78483. private _directTarget;
  78484. /**
  78485. * The target path of the runtime animation
  78486. */
  78487. private _targetPath;
  78488. /**
  78489. * The weight of the runtime animation
  78490. */
  78491. private _weight;
  78492. /**
  78493. * The ratio offset of the runtime animation
  78494. */
  78495. private _ratioOffset;
  78496. /**
  78497. * The previous delay of the runtime animation
  78498. */
  78499. private _previousDelay;
  78500. /**
  78501. * The previous ratio of the runtime animation
  78502. */
  78503. private _previousRatio;
  78504. private _enableBlending;
  78505. private _keys;
  78506. private _minFrame;
  78507. private _maxFrame;
  78508. private _minValue;
  78509. private _maxValue;
  78510. private _targetIsArray;
  78511. /**
  78512. * Gets the current frame of the runtime animation
  78513. */
  78514. readonly currentFrame: number;
  78515. /**
  78516. * Gets the weight of the runtime animation
  78517. */
  78518. readonly weight: number;
  78519. /**
  78520. * Gets the current value of the runtime animation
  78521. */
  78522. readonly currentValue: any;
  78523. /**
  78524. * Gets the target path of the runtime animation
  78525. */
  78526. readonly targetPath: string;
  78527. /**
  78528. * Gets the actual target of the runtime animation
  78529. */
  78530. readonly target: any;
  78531. /** @hidden */
  78532. _onLoop: () => void;
  78533. /**
  78534. * Create a new RuntimeAnimation object
  78535. * @param target defines the target of the animation
  78536. * @param animation defines the source animation object
  78537. * @param scene defines the hosting scene
  78538. * @param host defines the initiating Animatable
  78539. */
  78540. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78541. private _preparePath;
  78542. /**
  78543. * Gets the animation from the runtime animation
  78544. */
  78545. readonly animation: Animation;
  78546. /**
  78547. * Resets the runtime animation to the beginning
  78548. * @param restoreOriginal defines whether to restore the target property to the original value
  78549. */
  78550. reset(restoreOriginal?: boolean): void;
  78551. /**
  78552. * Specifies if the runtime animation is stopped
  78553. * @returns Boolean specifying if the runtime animation is stopped
  78554. */
  78555. isStopped(): boolean;
  78556. /**
  78557. * Disposes of the runtime animation
  78558. */
  78559. dispose(): void;
  78560. /**
  78561. * Apply the interpolated value to the target
  78562. * @param currentValue defines the value computed by the animation
  78563. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78564. */
  78565. setValue(currentValue: any, weight: number): void;
  78566. private _getOriginalValues;
  78567. private _setValue;
  78568. /**
  78569. * Gets the loop pmode of the runtime animation
  78570. * @returns Loop Mode
  78571. */
  78572. private _getCorrectLoopMode;
  78573. /**
  78574. * Move the current animation to a given frame
  78575. * @param frame defines the frame to move to
  78576. */
  78577. goToFrame(frame: number): void;
  78578. /**
  78579. * @hidden Internal use only
  78580. */
  78581. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78582. /**
  78583. * Execute the current animation
  78584. * @param delay defines the delay to add to the current frame
  78585. * @param from defines the lower bound of the animation range
  78586. * @param to defines the upper bound of the animation range
  78587. * @param loop defines if the current animation must loop
  78588. * @param speedRatio defines the current speed ratio
  78589. * @param weight defines the weight of the animation (default is -1 so no weight)
  78590. * @param onLoop optional callback called when animation loops
  78591. * @returns a boolean indicating if the animation is running
  78592. */
  78593. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78594. }
  78595. }
  78596. declare module BABYLON {
  78597. /**
  78598. * Class used to store an actual running animation
  78599. */
  78600. export class Animatable {
  78601. /** defines the target object */
  78602. target: any;
  78603. /** defines the starting frame number (default is 0) */
  78604. fromFrame: number;
  78605. /** defines the ending frame number (default is 100) */
  78606. toFrame: number;
  78607. /** defines if the animation must loop (default is false) */
  78608. loopAnimation: boolean;
  78609. /** defines a callback to call when animation ends if it is not looping */
  78610. onAnimationEnd?: (() => void) | null | undefined;
  78611. /** defines a callback to call when animation loops */
  78612. onAnimationLoop?: (() => void) | null | undefined;
  78613. private _localDelayOffset;
  78614. private _pausedDelay;
  78615. private _runtimeAnimations;
  78616. private _paused;
  78617. private _scene;
  78618. private _speedRatio;
  78619. private _weight;
  78620. private _syncRoot;
  78621. /**
  78622. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78623. * This will only apply for non looping animation (default is true)
  78624. */
  78625. disposeOnEnd: boolean;
  78626. /**
  78627. * Gets a boolean indicating if the animation has started
  78628. */
  78629. animationStarted: boolean;
  78630. /**
  78631. * Observer raised when the animation ends
  78632. */
  78633. onAnimationEndObservable: Observable<Animatable>;
  78634. /**
  78635. * Observer raised when the animation loops
  78636. */
  78637. onAnimationLoopObservable: Observable<Animatable>;
  78638. /**
  78639. * Gets the root Animatable used to synchronize and normalize animations
  78640. */
  78641. readonly syncRoot: Nullable<Animatable>;
  78642. /**
  78643. * Gets the current frame of the first RuntimeAnimation
  78644. * Used to synchronize Animatables
  78645. */
  78646. readonly masterFrame: number;
  78647. /**
  78648. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78649. */
  78650. weight: number;
  78651. /**
  78652. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78653. */
  78654. speedRatio: number;
  78655. /**
  78656. * Creates a new Animatable
  78657. * @param scene defines the hosting scene
  78658. * @param target defines the target object
  78659. * @param fromFrame defines the starting frame number (default is 0)
  78660. * @param toFrame defines the ending frame number (default is 100)
  78661. * @param loopAnimation defines if the animation must loop (default is false)
  78662. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78663. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78664. * @param animations defines a group of animation to add to the new Animatable
  78665. * @param onAnimationLoop defines a callback to call when animation loops
  78666. */
  78667. constructor(scene: Scene,
  78668. /** defines the target object */
  78669. target: any,
  78670. /** defines the starting frame number (default is 0) */
  78671. fromFrame?: number,
  78672. /** defines the ending frame number (default is 100) */
  78673. toFrame?: number,
  78674. /** defines if the animation must loop (default is false) */
  78675. loopAnimation?: boolean, speedRatio?: number,
  78676. /** defines a callback to call when animation ends if it is not looping */
  78677. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78678. /** defines a callback to call when animation loops */
  78679. onAnimationLoop?: (() => void) | null | undefined);
  78680. /**
  78681. * Synchronize and normalize current Animatable with a source Animatable
  78682. * This is useful when using animation weights and when animations are not of the same length
  78683. * @param root defines the root Animatable to synchronize with
  78684. * @returns the current Animatable
  78685. */
  78686. syncWith(root: Animatable): Animatable;
  78687. /**
  78688. * Gets the list of runtime animations
  78689. * @returns an array of RuntimeAnimation
  78690. */
  78691. getAnimations(): RuntimeAnimation[];
  78692. /**
  78693. * Adds more animations to the current animatable
  78694. * @param target defines the target of the animations
  78695. * @param animations defines the new animations to add
  78696. */
  78697. appendAnimations(target: any, animations: Animation[]): void;
  78698. /**
  78699. * Gets the source animation for a specific property
  78700. * @param property defines the propertyu to look for
  78701. * @returns null or the source animation for the given property
  78702. */
  78703. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78704. /**
  78705. * Gets the runtime animation for a specific property
  78706. * @param property defines the propertyu to look for
  78707. * @returns null or the runtime animation for the given property
  78708. */
  78709. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78710. /**
  78711. * Resets the animatable to its original state
  78712. */
  78713. reset(): void;
  78714. /**
  78715. * Allows the animatable to blend with current running animations
  78716. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78717. * @param blendingSpeed defines the blending speed to use
  78718. */
  78719. enableBlending(blendingSpeed: number): void;
  78720. /**
  78721. * Disable animation blending
  78722. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78723. */
  78724. disableBlending(): void;
  78725. /**
  78726. * Jump directly to a given frame
  78727. * @param frame defines the frame to jump to
  78728. */
  78729. goToFrame(frame: number): void;
  78730. /**
  78731. * Pause the animation
  78732. */
  78733. pause(): void;
  78734. /**
  78735. * Restart the animation
  78736. */
  78737. restart(): void;
  78738. private _raiseOnAnimationEnd;
  78739. /**
  78740. * Stop and delete the current animation
  78741. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78742. * @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)
  78743. */
  78744. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78745. /**
  78746. * Wait asynchronously for the animation to end
  78747. * @returns a promise which will be fullfilled when the animation ends
  78748. */
  78749. waitAsync(): Promise<Animatable>;
  78750. /** @hidden */
  78751. _animate(delay: number): boolean;
  78752. }
  78753. interface Scene {
  78754. /** @hidden */
  78755. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78756. /** @hidden */
  78757. _processLateAnimationBindingsForMatrices(holder: {
  78758. totalWeight: number;
  78759. animations: RuntimeAnimation[];
  78760. originalValue: Matrix;
  78761. }): any;
  78762. /** @hidden */
  78763. _processLateAnimationBindingsForQuaternions(holder: {
  78764. totalWeight: number;
  78765. animations: RuntimeAnimation[];
  78766. originalValue: Quaternion;
  78767. }, refQuaternion: Quaternion): Quaternion;
  78768. /** @hidden */
  78769. _processLateAnimationBindings(): void;
  78770. /**
  78771. * Will start the animation sequence of a given target
  78772. * @param target defines the target
  78773. * @param from defines from which frame should animation start
  78774. * @param to defines until which frame should animation run.
  78775. * @param weight defines the weight to apply to the animation (1.0 by default)
  78776. * @param loop defines if the animation loops
  78777. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78778. * @param onAnimationEnd defines the function to be executed when the animation ends
  78779. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78780. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78781. * @param onAnimationLoop defines the callback to call when an animation loops
  78782. * @returns the animatable object created for this animation
  78783. */
  78784. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78785. /**
  78786. * Will start the animation sequence of a given target
  78787. * @param target defines the target
  78788. * @param from defines from which frame should animation start
  78789. * @param to defines until which frame should animation run.
  78790. * @param loop defines if the animation loops
  78791. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78792. * @param onAnimationEnd defines the function to be executed when the animation ends
  78793. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78794. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78795. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78796. * @param onAnimationLoop defines the callback to call when an animation loops
  78797. * @returns the animatable object created for this animation
  78798. */
  78799. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78800. /**
  78801. * Will start the animation sequence of a given target and its hierarchy
  78802. * @param target defines the target
  78803. * @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.
  78804. * @param from defines from which frame should animation start
  78805. * @param to defines until which frame should animation run.
  78806. * @param loop defines if the animation loops
  78807. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78808. * @param onAnimationEnd defines the function to be executed when the animation ends
  78809. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78810. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78811. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78812. * @param onAnimationLoop defines the callback to call when an animation loops
  78813. * @returns the list of created animatables
  78814. */
  78815. 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[];
  78816. /**
  78817. * Begin a new animation on a given node
  78818. * @param target defines the target where the animation will take place
  78819. * @param animations defines the list of animations to start
  78820. * @param from defines the initial value
  78821. * @param to defines the final value
  78822. * @param loop defines if you want animation to loop (off by default)
  78823. * @param speedRatio defines the speed ratio to apply to all animations
  78824. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78825. * @param onAnimationLoop defines the callback to call when an animation loops
  78826. * @returns the list of created animatables
  78827. */
  78828. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78829. /**
  78830. * Begin a new animation on a given node and its hierarchy
  78831. * @param target defines the root node where the animation will take place
  78832. * @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.
  78833. * @param animations defines the list of animations to start
  78834. * @param from defines the initial value
  78835. * @param to defines the final value
  78836. * @param loop defines if you want animation to loop (off by default)
  78837. * @param speedRatio defines the speed ratio to apply to all animations
  78838. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78839. * @param onAnimationLoop defines the callback to call when an animation loops
  78840. * @returns the list of animatables created for all nodes
  78841. */
  78842. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78843. /**
  78844. * Gets the animatable associated with a specific target
  78845. * @param target defines the target of the animatable
  78846. * @returns the required animatable if found
  78847. */
  78848. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78849. /**
  78850. * Gets all animatables associated with a given target
  78851. * @param target defines the target to look animatables for
  78852. * @returns an array of Animatables
  78853. */
  78854. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78855. /**
  78856. * Stops and removes all animations that have been applied to the scene
  78857. */
  78858. stopAllAnimations(): void;
  78859. }
  78860. interface Bone {
  78861. /**
  78862. * Copy an animation range from another bone
  78863. * @param source defines the source bone
  78864. * @param rangeName defines the range name to copy
  78865. * @param frameOffset defines the frame offset
  78866. * @param rescaleAsRequired defines if rescaling must be applied if required
  78867. * @param skelDimensionsRatio defines the scaling ratio
  78868. * @returns true if operation was successful
  78869. */
  78870. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78871. }
  78872. }
  78873. declare module BABYLON {
  78874. /**
  78875. * Class used to override all child animations of a given target
  78876. */
  78877. export class AnimationPropertiesOverride {
  78878. /**
  78879. * Gets or sets a value indicating if animation blending must be used
  78880. */
  78881. enableBlending: boolean;
  78882. /**
  78883. * Gets or sets the blending speed to use when enableBlending is true
  78884. */
  78885. blendingSpeed: number;
  78886. /**
  78887. * Gets or sets the default loop mode to use
  78888. */
  78889. loopMode: number;
  78890. }
  78891. }
  78892. declare module BABYLON {
  78893. /**
  78894. * Class used to handle skinning animations
  78895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78896. */
  78897. export class Skeleton implements IAnimatable {
  78898. /** defines the skeleton name */
  78899. name: string;
  78900. /** defines the skeleton Id */
  78901. id: string;
  78902. /**
  78903. * Defines the list of child bones
  78904. */
  78905. bones: Bone[];
  78906. /**
  78907. * Defines an estimate of the dimension of the skeleton at rest
  78908. */
  78909. dimensionsAtRest: Vector3;
  78910. /**
  78911. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78912. */
  78913. needInitialSkinMatrix: boolean;
  78914. /**
  78915. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78916. */
  78917. overrideMesh: Nullable<AbstractMesh>;
  78918. /**
  78919. * Gets the list of animations attached to this skeleton
  78920. */
  78921. animations: Array<Animation>;
  78922. private _scene;
  78923. private _isDirty;
  78924. private _transformMatrices;
  78925. private _transformMatrixTexture;
  78926. private _meshesWithPoseMatrix;
  78927. private _animatables;
  78928. private _identity;
  78929. private _synchronizedWithMesh;
  78930. private _ranges;
  78931. private _lastAbsoluteTransformsUpdateId;
  78932. private _canUseTextureForBones;
  78933. private _uniqueId;
  78934. /** @hidden */
  78935. _numBonesWithLinkedTransformNode: number;
  78936. /** @hidden */
  78937. _hasWaitingData: Nullable<boolean>;
  78938. /**
  78939. * Specifies if the skeleton should be serialized
  78940. */
  78941. doNotSerialize: boolean;
  78942. private _useTextureToStoreBoneMatrices;
  78943. /**
  78944. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78945. * Please note that this option is not available if the hardware does not support it
  78946. */
  78947. useTextureToStoreBoneMatrices: boolean;
  78948. private _animationPropertiesOverride;
  78949. /**
  78950. * Gets or sets the animation properties override
  78951. */
  78952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78953. /**
  78954. * List of inspectable custom properties (used by the Inspector)
  78955. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78956. */
  78957. inspectableCustomProperties: IInspectable[];
  78958. /**
  78959. * An observable triggered before computing the skeleton's matrices
  78960. */
  78961. onBeforeComputeObservable: Observable<Skeleton>;
  78962. /**
  78963. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78964. */
  78965. readonly isUsingTextureForMatrices: boolean;
  78966. /**
  78967. * Gets the unique ID of this skeleton
  78968. */
  78969. readonly uniqueId: number;
  78970. /**
  78971. * Creates a new skeleton
  78972. * @param name defines the skeleton name
  78973. * @param id defines the skeleton Id
  78974. * @param scene defines the hosting scene
  78975. */
  78976. constructor(
  78977. /** defines the skeleton name */
  78978. name: string,
  78979. /** defines the skeleton Id */
  78980. id: string, scene: Scene);
  78981. /**
  78982. * Gets the current object class name.
  78983. * @return the class name
  78984. */
  78985. getClassName(): string;
  78986. /**
  78987. * Returns an array containing the root bones
  78988. * @returns an array containing the root bones
  78989. */
  78990. getChildren(): Array<Bone>;
  78991. /**
  78992. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78993. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78994. * @returns a Float32Array containing matrices data
  78995. */
  78996. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78997. /**
  78998. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78999. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79000. * @returns a raw texture containing the data
  79001. */
  79002. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79003. /**
  79004. * Gets the current hosting scene
  79005. * @returns a scene object
  79006. */
  79007. getScene(): Scene;
  79008. /**
  79009. * Gets a string representing the current skeleton data
  79010. * @param fullDetails defines a boolean indicating if we want a verbose version
  79011. * @returns a string representing the current skeleton data
  79012. */
  79013. toString(fullDetails?: boolean): string;
  79014. /**
  79015. * Get bone's index searching by name
  79016. * @param name defines bone's name to search for
  79017. * @return the indice of the bone. Returns -1 if not found
  79018. */
  79019. getBoneIndexByName(name: string): number;
  79020. /**
  79021. * Creater a new animation range
  79022. * @param name defines the name of the range
  79023. * @param from defines the start key
  79024. * @param to defines the end key
  79025. */
  79026. createAnimationRange(name: string, from: number, to: number): void;
  79027. /**
  79028. * Delete a specific animation range
  79029. * @param name defines the name of the range
  79030. * @param deleteFrames defines if frames must be removed as well
  79031. */
  79032. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79033. /**
  79034. * Gets a specific animation range
  79035. * @param name defines the name of the range to look for
  79036. * @returns the requested animation range or null if not found
  79037. */
  79038. getAnimationRange(name: string): Nullable<AnimationRange>;
  79039. /**
  79040. * Gets the list of all animation ranges defined on this skeleton
  79041. * @returns an array
  79042. */
  79043. getAnimationRanges(): Nullable<AnimationRange>[];
  79044. /**
  79045. * Copy animation range from a source skeleton.
  79046. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79047. * @param source defines the source skeleton
  79048. * @param name defines the name of the range to copy
  79049. * @param rescaleAsRequired defines if rescaling must be applied if required
  79050. * @returns true if operation was successful
  79051. */
  79052. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79053. /**
  79054. * Forces the skeleton to go to rest pose
  79055. */
  79056. returnToRest(): void;
  79057. private _getHighestAnimationFrame;
  79058. /**
  79059. * Begin a specific animation range
  79060. * @param name defines the name of the range to start
  79061. * @param loop defines if looping must be turned on (false by default)
  79062. * @param speedRatio defines the speed ratio to apply (1 by default)
  79063. * @param onAnimationEnd defines a callback which will be called when animation will end
  79064. * @returns a new animatable
  79065. */
  79066. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79067. /** @hidden */
  79068. _markAsDirty(): void;
  79069. /** @hidden */
  79070. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79071. /** @hidden */
  79072. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79073. private _computeTransformMatrices;
  79074. /**
  79075. * Build all resources required to render a skeleton
  79076. */
  79077. prepare(): void;
  79078. /**
  79079. * Gets the list of animatables currently running for this skeleton
  79080. * @returns an array of animatables
  79081. */
  79082. getAnimatables(): IAnimatable[];
  79083. /**
  79084. * Clone the current skeleton
  79085. * @param name defines the name of the new skeleton
  79086. * @param id defines the id of the new skeleton
  79087. * @returns the new skeleton
  79088. */
  79089. clone(name: string, id: string): Skeleton;
  79090. /**
  79091. * Enable animation blending for this skeleton
  79092. * @param blendingSpeed defines the blending speed to apply
  79093. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79094. */
  79095. enableBlending(blendingSpeed?: number): void;
  79096. /**
  79097. * Releases all resources associated with the current skeleton
  79098. */
  79099. dispose(): void;
  79100. /**
  79101. * Serialize the skeleton in a JSON object
  79102. * @returns a JSON object
  79103. */
  79104. serialize(): any;
  79105. /**
  79106. * Creates a new skeleton from serialized data
  79107. * @param parsedSkeleton defines the serialized data
  79108. * @param scene defines the hosting scene
  79109. * @returns a new skeleton
  79110. */
  79111. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79112. /**
  79113. * Compute all node absolute transforms
  79114. * @param forceUpdate defines if computation must be done even if cache is up to date
  79115. */
  79116. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79117. /**
  79118. * Gets the root pose matrix
  79119. * @returns a matrix
  79120. */
  79121. getPoseMatrix(): Nullable<Matrix>;
  79122. /**
  79123. * Sorts bones per internal index
  79124. */
  79125. sortBones(): void;
  79126. private _sortBones;
  79127. }
  79128. }
  79129. declare module BABYLON {
  79130. /**
  79131. * Class used to store bone information
  79132. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79133. */
  79134. export class Bone extends Node {
  79135. /**
  79136. * defines the bone name
  79137. */
  79138. name: string;
  79139. private static _tmpVecs;
  79140. private static _tmpQuat;
  79141. private static _tmpMats;
  79142. /**
  79143. * Gets the list of child bones
  79144. */
  79145. children: Bone[];
  79146. /** Gets the animations associated with this bone */
  79147. animations: Animation[];
  79148. /**
  79149. * Gets or sets bone length
  79150. */
  79151. length: number;
  79152. /**
  79153. * @hidden Internal only
  79154. * Set this value to map this bone to a different index in the transform matrices
  79155. * Set this value to -1 to exclude the bone from the transform matrices
  79156. */
  79157. _index: Nullable<number>;
  79158. private _skeleton;
  79159. private _localMatrix;
  79160. private _restPose;
  79161. private _baseMatrix;
  79162. private _absoluteTransform;
  79163. private _invertedAbsoluteTransform;
  79164. private _parent;
  79165. private _scalingDeterminant;
  79166. private _worldTransform;
  79167. private _localScaling;
  79168. private _localRotation;
  79169. private _localPosition;
  79170. private _needToDecompose;
  79171. private _needToCompose;
  79172. /** @hidden */
  79173. _linkedTransformNode: Nullable<TransformNode>;
  79174. /** @hidden */
  79175. _waitingTransformNodeId: Nullable<string>;
  79176. /** @hidden */
  79177. /** @hidden */
  79178. _matrix: Matrix;
  79179. /**
  79180. * Create a new bone
  79181. * @param name defines the bone name
  79182. * @param skeleton defines the parent skeleton
  79183. * @param parentBone defines the parent (can be null if the bone is the root)
  79184. * @param localMatrix defines the local matrix
  79185. * @param restPose defines the rest pose matrix
  79186. * @param baseMatrix defines the base matrix
  79187. * @param index defines index of the bone in the hiearchy
  79188. */
  79189. constructor(
  79190. /**
  79191. * defines the bone name
  79192. */
  79193. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79194. /**
  79195. * Gets the current object class name.
  79196. * @return the class name
  79197. */
  79198. getClassName(): string;
  79199. /**
  79200. * Gets the parent skeleton
  79201. * @returns a skeleton
  79202. */
  79203. getSkeleton(): Skeleton;
  79204. /**
  79205. * Gets parent bone
  79206. * @returns a bone or null if the bone is the root of the bone hierarchy
  79207. */
  79208. getParent(): Nullable<Bone>;
  79209. /**
  79210. * Returns an array containing the root bones
  79211. * @returns an array containing the root bones
  79212. */
  79213. getChildren(): Array<Bone>;
  79214. /**
  79215. * Sets the parent bone
  79216. * @param parent defines the parent (can be null if the bone is the root)
  79217. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79218. */
  79219. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79220. /**
  79221. * Gets the local matrix
  79222. * @returns a matrix
  79223. */
  79224. getLocalMatrix(): Matrix;
  79225. /**
  79226. * Gets the base matrix (initial matrix which remains unchanged)
  79227. * @returns a matrix
  79228. */
  79229. getBaseMatrix(): Matrix;
  79230. /**
  79231. * Gets the rest pose matrix
  79232. * @returns a matrix
  79233. */
  79234. getRestPose(): Matrix;
  79235. /**
  79236. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79237. */
  79238. getWorldMatrix(): Matrix;
  79239. /**
  79240. * Sets the local matrix to rest pose matrix
  79241. */
  79242. returnToRest(): void;
  79243. /**
  79244. * Gets the inverse of the absolute transform matrix.
  79245. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79246. * @returns a matrix
  79247. */
  79248. getInvertedAbsoluteTransform(): Matrix;
  79249. /**
  79250. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79251. * @returns a matrix
  79252. */
  79253. getAbsoluteTransform(): Matrix;
  79254. /**
  79255. * Links with the given transform node.
  79256. * The local matrix of this bone is copied from the transform node every frame.
  79257. * @param transformNode defines the transform node to link to
  79258. */
  79259. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79260. /**
  79261. * Gets the node used to drive the bone's transformation
  79262. * @returns a transform node or null
  79263. */
  79264. getTransformNode(): Nullable<TransformNode>;
  79265. /** Gets or sets current position (in local space) */
  79266. position: Vector3;
  79267. /** Gets or sets current rotation (in local space) */
  79268. rotation: Vector3;
  79269. /** Gets or sets current rotation quaternion (in local space) */
  79270. rotationQuaternion: Quaternion;
  79271. /** Gets or sets current scaling (in local space) */
  79272. scaling: Vector3;
  79273. /**
  79274. * Gets the animation properties override
  79275. */
  79276. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79277. private _decompose;
  79278. private _compose;
  79279. /**
  79280. * Update the base and local matrices
  79281. * @param matrix defines the new base or local matrix
  79282. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79283. * @param updateLocalMatrix defines if the local matrix should be updated
  79284. */
  79285. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79286. /** @hidden */
  79287. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79288. /**
  79289. * Flag the bone as dirty (Forcing it to update everything)
  79290. */
  79291. markAsDirty(): void;
  79292. /** @hidden */
  79293. _markAsDirtyAndCompose(): void;
  79294. private _markAsDirtyAndDecompose;
  79295. /**
  79296. * Translate the bone in local or world space
  79297. * @param vec The amount to translate the bone
  79298. * @param space The space that the translation is in
  79299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79300. */
  79301. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79302. /**
  79303. * Set the postion of the bone in local or world space
  79304. * @param position The position to set the bone
  79305. * @param space The space that the position is in
  79306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79307. */
  79308. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79309. /**
  79310. * Set the absolute position of the bone (world space)
  79311. * @param position The position to set the bone
  79312. * @param mesh The mesh that this bone is attached to
  79313. */
  79314. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79315. /**
  79316. * Scale the bone on the x, y and z axes (in local space)
  79317. * @param x The amount to scale the bone on the x axis
  79318. * @param y The amount to scale the bone on the y axis
  79319. * @param z The amount to scale the bone on the z axis
  79320. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79321. */
  79322. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79323. /**
  79324. * Set the bone scaling in local space
  79325. * @param scale defines the scaling vector
  79326. */
  79327. setScale(scale: Vector3): void;
  79328. /**
  79329. * Gets the current scaling in local space
  79330. * @returns the current scaling vector
  79331. */
  79332. getScale(): Vector3;
  79333. /**
  79334. * Gets the current scaling in local space and stores it in a target vector
  79335. * @param result defines the target vector
  79336. */
  79337. getScaleToRef(result: Vector3): void;
  79338. /**
  79339. * Set the yaw, pitch, and roll of the bone in local or world space
  79340. * @param yaw The rotation of the bone on the y axis
  79341. * @param pitch The rotation of the bone on the x axis
  79342. * @param roll The rotation of the bone on the z axis
  79343. * @param space The space that the axes of rotation are in
  79344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79345. */
  79346. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79347. /**
  79348. * Add a rotation to the bone on an axis in local or world space
  79349. * @param axis The axis to rotate the bone on
  79350. * @param amount The amount to rotate the bone
  79351. * @param space The space that the axis is in
  79352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79353. */
  79354. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79355. /**
  79356. * Set the rotation of the bone to a particular axis angle in local or world space
  79357. * @param axis The axis to rotate the bone on
  79358. * @param angle The angle that the bone should be rotated to
  79359. * @param space The space that the axis is in
  79360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79361. */
  79362. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79363. /**
  79364. * Set the euler rotation of the bone in local of world space
  79365. * @param rotation The euler rotation that the bone should be set to
  79366. * @param space The space that the rotation is in
  79367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79368. */
  79369. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79370. /**
  79371. * Set the quaternion rotation of the bone in local of world space
  79372. * @param quat The quaternion rotation that the bone should be set to
  79373. * @param space The space that the rotation is in
  79374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79375. */
  79376. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79377. /**
  79378. * Set the rotation matrix of the bone in local of world space
  79379. * @param rotMat The rotation matrix that the bone should be set to
  79380. * @param space The space that the rotation is in
  79381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79382. */
  79383. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79384. private _rotateWithMatrix;
  79385. private _getNegativeRotationToRef;
  79386. /**
  79387. * Get the position of the bone in local or world space
  79388. * @param space The space that the returned position is in
  79389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79390. * @returns The position of the bone
  79391. */
  79392. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79393. /**
  79394. * Copy the position of the bone to a vector3 in local or world space
  79395. * @param space The space that the returned position is in
  79396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79397. * @param result The vector3 to copy the position to
  79398. */
  79399. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79400. /**
  79401. * Get the absolute position of the bone (world space)
  79402. * @param mesh The mesh that this bone is attached to
  79403. * @returns The absolute position of the bone
  79404. */
  79405. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79406. /**
  79407. * Copy the absolute position of the bone (world space) to the result param
  79408. * @param mesh The mesh that this bone is attached to
  79409. * @param result The vector3 to copy the absolute position to
  79410. */
  79411. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79412. /**
  79413. * Compute the absolute transforms of this bone and its children
  79414. */
  79415. computeAbsoluteTransforms(): void;
  79416. /**
  79417. * Get the world direction from an axis that is in the local space of the bone
  79418. * @param localAxis The local direction that is used to compute the world direction
  79419. * @param mesh The mesh that this bone is attached to
  79420. * @returns The world direction
  79421. */
  79422. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79423. /**
  79424. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79425. * @param localAxis The local direction that is used to compute the world direction
  79426. * @param mesh The mesh that this bone is attached to
  79427. * @param result The vector3 that the world direction will be copied to
  79428. */
  79429. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79430. /**
  79431. * Get the euler rotation of the bone in local or world space
  79432. * @param space The space that the rotation should be in
  79433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79434. * @returns The euler rotation
  79435. */
  79436. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79437. /**
  79438. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79439. * @param space The space that the rotation should be in
  79440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79441. * @param result The vector3 that the rotation should be copied to
  79442. */
  79443. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79444. /**
  79445. * Get the quaternion rotation of the bone in either local or world space
  79446. * @param space The space that the rotation should be in
  79447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79448. * @returns The quaternion rotation
  79449. */
  79450. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79451. /**
  79452. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79453. * @param space The space that the rotation should be in
  79454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79455. * @param result The quaternion that the rotation should be copied to
  79456. */
  79457. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79458. /**
  79459. * Get the rotation matrix of the bone in local or world space
  79460. * @param space The space that the rotation should be in
  79461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79462. * @returns The rotation matrix
  79463. */
  79464. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79465. /**
  79466. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79467. * @param space The space that the rotation should be in
  79468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79469. * @param result The quaternion that the rotation should be copied to
  79470. */
  79471. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79472. /**
  79473. * Get the world position of a point that is in the local space of the bone
  79474. * @param position The local position
  79475. * @param mesh The mesh that this bone is attached to
  79476. * @returns The world position
  79477. */
  79478. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79479. /**
  79480. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79481. * @param position The local position
  79482. * @param mesh The mesh that this bone is attached to
  79483. * @param result The vector3 that the world position should be copied to
  79484. */
  79485. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79486. /**
  79487. * Get the local position of a point that is in world space
  79488. * @param position The world position
  79489. * @param mesh The mesh that this bone is attached to
  79490. * @returns The local position
  79491. */
  79492. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79493. /**
  79494. * Get the local position of a point that is in world space and copy it to the result param
  79495. * @param position The world position
  79496. * @param mesh The mesh that this bone is attached to
  79497. * @param result The vector3 that the local position should be copied to
  79498. */
  79499. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79500. }
  79501. }
  79502. declare module BABYLON {
  79503. /**
  79504. * 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.
  79505. * @see https://doc.babylonjs.com/how_to/transformnode
  79506. */
  79507. export class TransformNode extends Node {
  79508. /**
  79509. * Object will not rotate to face the camera
  79510. */
  79511. static BILLBOARDMODE_NONE: number;
  79512. /**
  79513. * Object will rotate to face the camera but only on the x axis
  79514. */
  79515. static BILLBOARDMODE_X: number;
  79516. /**
  79517. * Object will rotate to face the camera but only on the y axis
  79518. */
  79519. static BILLBOARDMODE_Y: number;
  79520. /**
  79521. * Object will rotate to face the camera but only on the z axis
  79522. */
  79523. static BILLBOARDMODE_Z: number;
  79524. /**
  79525. * Object will rotate to face the camera
  79526. */
  79527. static BILLBOARDMODE_ALL: number;
  79528. /**
  79529. * Object will rotate to face the camera's position instead of orientation
  79530. */
  79531. static BILLBOARDMODE_USE_POSITION: number;
  79532. private _forward;
  79533. private _forwardInverted;
  79534. private _up;
  79535. private _right;
  79536. private _rightInverted;
  79537. private _position;
  79538. private _rotation;
  79539. private _rotationQuaternion;
  79540. protected _scaling: Vector3;
  79541. protected _isDirty: boolean;
  79542. private _transformToBoneReferal;
  79543. private _isAbsoluteSynced;
  79544. private _billboardMode;
  79545. /**
  79546. * Gets or sets the billboard mode. Default is 0.
  79547. *
  79548. * | Value | Type | Description |
  79549. * | --- | --- | --- |
  79550. * | 0 | BILLBOARDMODE_NONE | |
  79551. * | 1 | BILLBOARDMODE_X | |
  79552. * | 2 | BILLBOARDMODE_Y | |
  79553. * | 4 | BILLBOARDMODE_Z | |
  79554. * | 7 | BILLBOARDMODE_ALL | |
  79555. *
  79556. */
  79557. billboardMode: number;
  79558. private _preserveParentRotationForBillboard;
  79559. /**
  79560. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79561. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79562. */
  79563. preserveParentRotationForBillboard: boolean;
  79564. /**
  79565. * 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
  79566. */
  79567. scalingDeterminant: number;
  79568. private _infiniteDistance;
  79569. /**
  79570. * Gets or sets the distance of the object to max, often used by skybox
  79571. */
  79572. infiniteDistance: boolean;
  79573. /**
  79574. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79575. * By default the system will update normals to compensate
  79576. */
  79577. ignoreNonUniformScaling: boolean;
  79578. /**
  79579. * 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
  79580. */
  79581. reIntegrateRotationIntoRotationQuaternion: boolean;
  79582. /** @hidden */
  79583. _poseMatrix: Nullable<Matrix>;
  79584. /** @hidden */
  79585. _localMatrix: Matrix;
  79586. private _usePivotMatrix;
  79587. private _absolutePosition;
  79588. private _absoluteScaling;
  79589. private _absoluteRotationQuaternion;
  79590. private _pivotMatrix;
  79591. private _pivotMatrixInverse;
  79592. protected _postMultiplyPivotMatrix: boolean;
  79593. protected _isWorldMatrixFrozen: boolean;
  79594. /** @hidden */
  79595. _indexInSceneTransformNodesArray: number;
  79596. /**
  79597. * An event triggered after the world matrix is updated
  79598. */
  79599. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79600. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79601. /**
  79602. * Gets a string identifying the name of the class
  79603. * @returns "TransformNode" string
  79604. */
  79605. getClassName(): string;
  79606. /**
  79607. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79608. */
  79609. position: Vector3;
  79610. /**
  79611. * 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)).
  79612. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79613. */
  79614. rotation: Vector3;
  79615. /**
  79616. * 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)).
  79617. */
  79618. scaling: Vector3;
  79619. /**
  79620. * 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).
  79621. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79622. */
  79623. rotationQuaternion: Nullable<Quaternion>;
  79624. /**
  79625. * The forward direction of that transform in world space.
  79626. */
  79627. readonly forward: Vector3;
  79628. /**
  79629. * The up direction of that transform in world space.
  79630. */
  79631. readonly up: Vector3;
  79632. /**
  79633. * The right direction of that transform in world space.
  79634. */
  79635. readonly right: Vector3;
  79636. /**
  79637. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79638. * @param matrix the matrix to copy the pose from
  79639. * @returns this TransformNode.
  79640. */
  79641. updatePoseMatrix(matrix: Matrix): TransformNode;
  79642. /**
  79643. * Returns the mesh Pose matrix.
  79644. * @returns the pose matrix
  79645. */
  79646. getPoseMatrix(): Matrix;
  79647. /** @hidden */
  79648. _isSynchronized(): boolean;
  79649. /** @hidden */
  79650. _initCache(): void;
  79651. /**
  79652. * Flag the transform node as dirty (Forcing it to update everything)
  79653. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79654. * @returns this transform node
  79655. */
  79656. markAsDirty(property: string): TransformNode;
  79657. /**
  79658. * Returns the current mesh absolute position.
  79659. * Returns a Vector3.
  79660. */
  79661. readonly absolutePosition: Vector3;
  79662. /**
  79663. * Returns the current mesh absolute scaling.
  79664. * Returns a Vector3.
  79665. */
  79666. readonly absoluteScaling: Vector3;
  79667. /**
  79668. * Returns the current mesh absolute rotation.
  79669. * Returns a Quaternion.
  79670. */
  79671. readonly absoluteRotationQuaternion: Quaternion;
  79672. /**
  79673. * Sets a new matrix to apply before all other transformation
  79674. * @param matrix defines the transform matrix
  79675. * @returns the current TransformNode
  79676. */
  79677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79678. /**
  79679. * Sets a new pivot matrix to the current node
  79680. * @param matrix defines the new pivot matrix to use
  79681. * @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
  79682. * @returns the current TransformNode
  79683. */
  79684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79685. /**
  79686. * Returns the mesh pivot matrix.
  79687. * Default : Identity.
  79688. * @returns the matrix
  79689. */
  79690. getPivotMatrix(): Matrix;
  79691. /**
  79692. * Instantiate (when possible) or clone that node with its hierarchy
  79693. * @param newParent defines the new parent to use for the instance (or clone)
  79694. * @returns an instance (or a clone) of the current node with its hiearchy
  79695. */
  79696. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79697. /**
  79698. * Prevents the World matrix to be computed any longer
  79699. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79700. * @returns the TransformNode.
  79701. */
  79702. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79703. /**
  79704. * Allows back the World matrix computation.
  79705. * @returns the TransformNode.
  79706. */
  79707. unfreezeWorldMatrix(): this;
  79708. /**
  79709. * True if the World matrix has been frozen.
  79710. */
  79711. readonly isWorldMatrixFrozen: boolean;
  79712. /**
  79713. * Retuns the mesh absolute position in the World.
  79714. * @returns a Vector3.
  79715. */
  79716. getAbsolutePosition(): Vector3;
  79717. /**
  79718. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79719. * @param absolutePosition the absolute position to set
  79720. * @returns the TransformNode.
  79721. */
  79722. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79723. /**
  79724. * Sets the mesh position in its local space.
  79725. * @param vector3 the position to set in localspace
  79726. * @returns the TransformNode.
  79727. */
  79728. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79729. /**
  79730. * Returns the mesh position in the local space from the current World matrix values.
  79731. * @returns a new Vector3.
  79732. */
  79733. getPositionExpressedInLocalSpace(): Vector3;
  79734. /**
  79735. * Translates the mesh along the passed Vector3 in its local space.
  79736. * @param vector3 the distance to translate in localspace
  79737. * @returns the TransformNode.
  79738. */
  79739. locallyTranslate(vector3: Vector3): TransformNode;
  79740. private static _lookAtVectorCache;
  79741. /**
  79742. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79743. * @param targetPoint the position (must be in same space as current mesh) to look at
  79744. * @param yawCor optional yaw (y-axis) correction in radians
  79745. * @param pitchCor optional pitch (x-axis) correction in radians
  79746. * @param rollCor optional roll (z-axis) correction in radians
  79747. * @param space the choosen space of the target
  79748. * @returns the TransformNode.
  79749. */
  79750. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79751. /**
  79752. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79753. * This Vector3 is expressed in the World space.
  79754. * @param localAxis axis to rotate
  79755. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79756. */
  79757. getDirection(localAxis: Vector3): Vector3;
  79758. /**
  79759. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79760. * localAxis is expressed in the mesh local space.
  79761. * result is computed in the Wordl space from the mesh World matrix.
  79762. * @param localAxis axis to rotate
  79763. * @param result the resulting transformnode
  79764. * @returns this TransformNode.
  79765. */
  79766. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79767. /**
  79768. * Sets this transform node rotation to the given local axis.
  79769. * @param localAxis the axis in local space
  79770. * @param yawCor optional yaw (y-axis) correction in radians
  79771. * @param pitchCor optional pitch (x-axis) correction in radians
  79772. * @param rollCor optional roll (z-axis) correction in radians
  79773. * @returns this TransformNode
  79774. */
  79775. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79776. /**
  79777. * Sets a new pivot point to the current node
  79778. * @param point defines the new pivot point to use
  79779. * @param space defines if the point is in world or local space (local by default)
  79780. * @returns the current TransformNode
  79781. */
  79782. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79783. /**
  79784. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79785. * @returns the pivot point
  79786. */
  79787. getPivotPoint(): Vector3;
  79788. /**
  79789. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79790. * @param result the vector3 to store the result
  79791. * @returns this TransformNode.
  79792. */
  79793. getPivotPointToRef(result: Vector3): TransformNode;
  79794. /**
  79795. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79796. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79797. */
  79798. getAbsolutePivotPoint(): Vector3;
  79799. /**
  79800. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79801. * @param result vector3 to store the result
  79802. * @returns this TransformNode.
  79803. */
  79804. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79805. /**
  79806. * Defines the passed node as the parent of the current node.
  79807. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79808. * @see https://doc.babylonjs.com/how_to/parenting
  79809. * @param node the node ot set as the parent
  79810. * @returns this TransformNode.
  79811. */
  79812. setParent(node: Nullable<Node>): TransformNode;
  79813. private _nonUniformScaling;
  79814. /**
  79815. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79816. */
  79817. readonly nonUniformScaling: boolean;
  79818. /** @hidden */
  79819. _updateNonUniformScalingState(value: boolean): boolean;
  79820. /**
  79821. * Attach the current TransformNode to another TransformNode associated with a bone
  79822. * @param bone Bone affecting the TransformNode
  79823. * @param affectedTransformNode TransformNode associated with the bone
  79824. * @returns this object
  79825. */
  79826. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79827. /**
  79828. * Detach the transform node if its associated with a bone
  79829. * @returns this object
  79830. */
  79831. detachFromBone(): TransformNode;
  79832. private static _rotationAxisCache;
  79833. /**
  79834. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79835. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79837. * The passed axis is also normalized.
  79838. * @param axis the axis to rotate around
  79839. * @param amount the amount to rotate in radians
  79840. * @param space Space to rotate in (Default: local)
  79841. * @returns the TransformNode.
  79842. */
  79843. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79844. /**
  79845. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79846. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79847. * The passed axis is also normalized. .
  79848. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79849. * @param point the point to rotate around
  79850. * @param axis the axis to rotate around
  79851. * @param amount the amount to rotate in radians
  79852. * @returns the TransformNode
  79853. */
  79854. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79855. /**
  79856. * Translates the mesh along the axis vector for the passed distance in the given space.
  79857. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79858. * @param axis the axis to translate in
  79859. * @param distance the distance to translate
  79860. * @param space Space to rotate in (Default: local)
  79861. * @returns the TransformNode.
  79862. */
  79863. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79864. /**
  79865. * Adds a rotation step to the mesh current rotation.
  79866. * x, y, z are Euler angles expressed in radians.
  79867. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79868. * This means this rotation is made in the mesh local space only.
  79869. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79870. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79871. * ```javascript
  79872. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79873. * ```
  79874. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79875. * 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.
  79876. * @param x Rotation to add
  79877. * @param y Rotation to add
  79878. * @param z Rotation to add
  79879. * @returns the TransformNode.
  79880. */
  79881. addRotation(x: number, y: number, z: number): TransformNode;
  79882. /**
  79883. * @hidden
  79884. */
  79885. protected _getEffectiveParent(): Nullable<Node>;
  79886. /**
  79887. * Computes the world matrix of the node
  79888. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79889. * @returns the world matrix
  79890. */
  79891. computeWorldMatrix(force?: boolean): Matrix;
  79892. protected _afterComputeWorldMatrix(): void;
  79893. /**
  79894. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79895. * @param func callback function to add
  79896. *
  79897. * @returns the TransformNode.
  79898. */
  79899. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79900. /**
  79901. * Removes a registered callback function.
  79902. * @param func callback function to remove
  79903. * @returns the TransformNode.
  79904. */
  79905. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79906. /**
  79907. * Gets the position of the current mesh in camera space
  79908. * @param camera defines the camera to use
  79909. * @returns a position
  79910. */
  79911. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79912. /**
  79913. * Returns the distance from the mesh to the active camera
  79914. * @param camera defines the camera to use
  79915. * @returns the distance
  79916. */
  79917. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79918. /**
  79919. * Clone the current transform node
  79920. * @param name Name of the new clone
  79921. * @param newParent New parent for the clone
  79922. * @param doNotCloneChildren Do not clone children hierarchy
  79923. * @returns the new transform node
  79924. */
  79925. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79926. /**
  79927. * Serializes the objects information.
  79928. * @param currentSerializationObject defines the object to serialize in
  79929. * @returns the serialized object
  79930. */
  79931. serialize(currentSerializationObject?: any): any;
  79932. /**
  79933. * Returns a new TransformNode object parsed from the source provided.
  79934. * @param parsedTransformNode is the source.
  79935. * @param scene the scne the object belongs to
  79936. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79937. * @returns a new TransformNode object parsed from the source provided.
  79938. */
  79939. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79940. /**
  79941. * Get all child-transformNodes of this node
  79942. * @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
  79943. * @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
  79944. * @returns an array of TransformNode
  79945. */
  79946. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79947. /**
  79948. * Releases resources associated with this transform node.
  79949. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79950. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79951. */
  79952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79953. /**
  79954. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79955. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79956. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79957. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79958. * @returns the current mesh
  79959. */
  79960. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79961. private _syncAbsoluteScalingAndRotation;
  79962. }
  79963. }
  79964. declare module BABYLON {
  79965. /**
  79966. * Defines the types of pose enabled controllers that are supported
  79967. */
  79968. export enum PoseEnabledControllerType {
  79969. /**
  79970. * HTC Vive
  79971. */
  79972. VIVE = 0,
  79973. /**
  79974. * Oculus Rift
  79975. */
  79976. OCULUS = 1,
  79977. /**
  79978. * Windows mixed reality
  79979. */
  79980. WINDOWS = 2,
  79981. /**
  79982. * Samsung gear VR
  79983. */
  79984. GEAR_VR = 3,
  79985. /**
  79986. * Google Daydream
  79987. */
  79988. DAYDREAM = 4,
  79989. /**
  79990. * Generic
  79991. */
  79992. GENERIC = 5
  79993. }
  79994. /**
  79995. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79996. */
  79997. export interface MutableGamepadButton {
  79998. /**
  79999. * Value of the button/trigger
  80000. */
  80001. value: number;
  80002. /**
  80003. * If the button/trigger is currently touched
  80004. */
  80005. touched: boolean;
  80006. /**
  80007. * If the button/trigger is currently pressed
  80008. */
  80009. pressed: boolean;
  80010. }
  80011. /**
  80012. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80013. * @hidden
  80014. */
  80015. export interface ExtendedGamepadButton extends GamepadButton {
  80016. /**
  80017. * If the button/trigger is currently pressed
  80018. */
  80019. readonly pressed: boolean;
  80020. /**
  80021. * If the button/trigger is currently touched
  80022. */
  80023. readonly touched: boolean;
  80024. /**
  80025. * Value of the button/trigger
  80026. */
  80027. readonly value: number;
  80028. }
  80029. /** @hidden */
  80030. export interface _GamePadFactory {
  80031. /**
  80032. * Returns wether or not the current gamepad can be created for this type of controller.
  80033. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80034. * @returns true if it can be created, otherwise false
  80035. */
  80036. canCreate(gamepadInfo: any): boolean;
  80037. /**
  80038. * Creates a new instance of the Gamepad.
  80039. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80040. * @returns the new gamepad instance
  80041. */
  80042. create(gamepadInfo: any): Gamepad;
  80043. }
  80044. /**
  80045. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80046. */
  80047. export class PoseEnabledControllerHelper {
  80048. /** @hidden */
  80049. static _ControllerFactories: _GamePadFactory[];
  80050. /** @hidden */
  80051. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80052. /**
  80053. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80054. * @param vrGamepad the gamepad to initialized
  80055. * @returns a vr controller of the type the gamepad identified as
  80056. */
  80057. static InitiateController(vrGamepad: any): Gamepad;
  80058. }
  80059. /**
  80060. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80061. */
  80062. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80063. /**
  80064. * If the controller is used in a webXR session
  80065. */
  80066. isXR: boolean;
  80067. private _deviceRoomPosition;
  80068. private _deviceRoomRotationQuaternion;
  80069. /**
  80070. * The device position in babylon space
  80071. */
  80072. devicePosition: Vector3;
  80073. /**
  80074. * The device rotation in babylon space
  80075. */
  80076. deviceRotationQuaternion: Quaternion;
  80077. /**
  80078. * The scale factor of the device in babylon space
  80079. */
  80080. deviceScaleFactor: number;
  80081. /**
  80082. * (Likely devicePosition should be used instead) The device position in its room space
  80083. */
  80084. position: Vector3;
  80085. /**
  80086. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80087. */
  80088. rotationQuaternion: Quaternion;
  80089. /**
  80090. * The type of controller (Eg. Windows mixed reality)
  80091. */
  80092. controllerType: PoseEnabledControllerType;
  80093. protected _calculatedPosition: Vector3;
  80094. private _calculatedRotation;
  80095. /**
  80096. * The raw pose from the device
  80097. */
  80098. rawPose: DevicePose;
  80099. private _trackPosition;
  80100. private _maxRotationDistFromHeadset;
  80101. private _draggedRoomRotation;
  80102. /**
  80103. * @hidden
  80104. */
  80105. _disableTrackPosition(fixedPosition: Vector3): void;
  80106. /**
  80107. * Internal, the mesh attached to the controller
  80108. * @hidden
  80109. */
  80110. _mesh: Nullable<AbstractMesh>;
  80111. private _poseControlledCamera;
  80112. private _leftHandSystemQuaternion;
  80113. /**
  80114. * Internal, matrix used to convert room space to babylon space
  80115. * @hidden
  80116. */
  80117. _deviceToWorld: Matrix;
  80118. /**
  80119. * Node to be used when casting a ray from the controller
  80120. * @hidden
  80121. */
  80122. _pointingPoseNode: Nullable<TransformNode>;
  80123. /**
  80124. * Name of the child mesh that can be used to cast a ray from the controller
  80125. */
  80126. static readonly POINTING_POSE: string;
  80127. /**
  80128. * Creates a new PoseEnabledController from a gamepad
  80129. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80130. */
  80131. constructor(browserGamepad: any);
  80132. private _workingMatrix;
  80133. /**
  80134. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80135. */
  80136. update(): void;
  80137. /**
  80138. * Updates only the pose device and mesh without doing any button event checking
  80139. */
  80140. protected _updatePoseAndMesh(): void;
  80141. /**
  80142. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80143. * @param poseData raw pose fromthe device
  80144. */
  80145. updateFromDevice(poseData: DevicePose): void;
  80146. /**
  80147. * @hidden
  80148. */
  80149. _meshAttachedObservable: Observable<AbstractMesh>;
  80150. /**
  80151. * Attaches a mesh to the controller
  80152. * @param mesh the mesh to be attached
  80153. */
  80154. attachToMesh(mesh: AbstractMesh): void;
  80155. /**
  80156. * Attaches the controllers mesh to a camera
  80157. * @param camera the camera the mesh should be attached to
  80158. */
  80159. attachToPoseControlledCamera(camera: TargetCamera): void;
  80160. /**
  80161. * Disposes of the controller
  80162. */
  80163. dispose(): void;
  80164. /**
  80165. * The mesh that is attached to the controller
  80166. */
  80167. readonly mesh: Nullable<AbstractMesh>;
  80168. /**
  80169. * Gets the ray of the controller in the direction the controller is pointing
  80170. * @param length the length the resulting ray should be
  80171. * @returns a ray in the direction the controller is pointing
  80172. */
  80173. getForwardRay(length?: number): Ray;
  80174. }
  80175. }
  80176. declare module BABYLON {
  80177. /**
  80178. * Defines the WebVRController object that represents controllers tracked in 3D space
  80179. */
  80180. export abstract class WebVRController extends PoseEnabledController {
  80181. /**
  80182. * Internal, the default controller model for the controller
  80183. */
  80184. protected _defaultModel: AbstractMesh;
  80185. /**
  80186. * Fired when the trigger state has changed
  80187. */
  80188. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80189. /**
  80190. * Fired when the main button state has changed
  80191. */
  80192. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80193. /**
  80194. * Fired when the secondary button state has changed
  80195. */
  80196. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80197. /**
  80198. * Fired when the pad state has changed
  80199. */
  80200. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80201. /**
  80202. * Fired when controllers stick values have changed
  80203. */
  80204. onPadValuesChangedObservable: Observable<StickValues>;
  80205. /**
  80206. * Array of button availible on the controller
  80207. */
  80208. protected _buttons: Array<MutableGamepadButton>;
  80209. private _onButtonStateChange;
  80210. /**
  80211. * Fired when a controller button's state has changed
  80212. * @param callback the callback containing the button that was modified
  80213. */
  80214. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80215. /**
  80216. * X and Y axis corresponding to the controllers joystick
  80217. */
  80218. pad: StickValues;
  80219. /**
  80220. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80221. */
  80222. hand: string;
  80223. /**
  80224. * The default controller model for the controller
  80225. */
  80226. readonly defaultModel: AbstractMesh;
  80227. /**
  80228. * Creates a new WebVRController from a gamepad
  80229. * @param vrGamepad the gamepad that the WebVRController should be created from
  80230. */
  80231. constructor(vrGamepad: any);
  80232. /**
  80233. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80234. */
  80235. update(): void;
  80236. /**
  80237. * Function to be called when a button is modified
  80238. */
  80239. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80240. /**
  80241. * Loads a mesh and attaches it to the controller
  80242. * @param scene the scene the mesh should be added to
  80243. * @param meshLoaded callback for when the mesh has been loaded
  80244. */
  80245. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80246. private _setButtonValue;
  80247. private _changes;
  80248. private _checkChanges;
  80249. /**
  80250. * Disposes of th webVRCOntroller
  80251. */
  80252. dispose(): void;
  80253. }
  80254. }
  80255. declare module BABYLON {
  80256. /**
  80257. * The HemisphericLight simulates the ambient environment light,
  80258. * so the passed direction is the light reflection direction, not the incoming direction.
  80259. */
  80260. export class HemisphericLight extends Light {
  80261. /**
  80262. * The groundColor is the light in the opposite direction to the one specified during creation.
  80263. * 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.
  80264. */
  80265. groundColor: Color3;
  80266. /**
  80267. * The light reflection direction, not the incoming direction.
  80268. */
  80269. direction: Vector3;
  80270. /**
  80271. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80272. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80273. * The HemisphericLight can't cast shadows.
  80274. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80275. * @param name The friendly name of the light
  80276. * @param direction The direction of the light reflection
  80277. * @param scene The scene the light belongs to
  80278. */
  80279. constructor(name: string, direction: Vector3, scene: Scene);
  80280. protected _buildUniformLayout(): void;
  80281. /**
  80282. * Returns the string "HemisphericLight".
  80283. * @return The class name
  80284. */
  80285. getClassName(): string;
  80286. /**
  80287. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80288. * Returns the updated direction.
  80289. * @param target The target the direction should point to
  80290. * @return The computed direction
  80291. */
  80292. setDirectionToTarget(target: Vector3): Vector3;
  80293. /**
  80294. * Returns the shadow generator associated to the light.
  80295. * @returns Always null for hemispheric lights because it does not support shadows.
  80296. */
  80297. getShadowGenerator(): Nullable<IShadowGenerator>;
  80298. /**
  80299. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80300. * @param effect The effect to update
  80301. * @param lightIndex The index of the light in the effect to update
  80302. * @returns The hemispheric light
  80303. */
  80304. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80305. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80306. /**
  80307. * Computes the world matrix of the node
  80308. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80309. * @param useWasUpdatedFlag defines a reserved property
  80310. * @returns the world matrix
  80311. */
  80312. computeWorldMatrix(): Matrix;
  80313. /**
  80314. * Returns the integer 3.
  80315. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80316. */
  80317. getTypeID(): number;
  80318. /**
  80319. * Prepares the list of defines specific to the light type.
  80320. * @param defines the list of defines
  80321. * @param lightIndex defines the index of the light for the effect
  80322. */
  80323. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80324. }
  80325. }
  80326. declare module BABYLON {
  80327. /** @hidden */
  80328. export var vrMultiviewToSingleviewPixelShader: {
  80329. name: string;
  80330. shader: string;
  80331. };
  80332. }
  80333. declare module BABYLON {
  80334. /**
  80335. * Renders to multiple views with a single draw call
  80336. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80337. */
  80338. export class MultiviewRenderTarget extends RenderTargetTexture {
  80339. /**
  80340. * Creates a multiview render target
  80341. * @param scene scene used with the render target
  80342. * @param size the size of the render target (used for each view)
  80343. */
  80344. constructor(scene: Scene, size?: number | {
  80345. width: number;
  80346. height: number;
  80347. } | {
  80348. ratio: number;
  80349. });
  80350. /**
  80351. * @hidden
  80352. * @param faceIndex the face index, if its a cube texture
  80353. */
  80354. _bindFrameBuffer(faceIndex?: number): void;
  80355. /**
  80356. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80357. * @returns the view count
  80358. */
  80359. getViewCount(): number;
  80360. }
  80361. }
  80362. declare module BABYLON {
  80363. /**
  80364. * Represents a camera frustum
  80365. */
  80366. export class Frustum {
  80367. /**
  80368. * Gets the planes representing the frustum
  80369. * @param transform matrix to be applied to the returned planes
  80370. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80371. */
  80372. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80373. /**
  80374. * Gets the near frustum plane transformed by the transform matrix
  80375. * @param transform transformation matrix to be applied to the resulting frustum plane
  80376. * @param frustumPlane the resuling frustum plane
  80377. */
  80378. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80379. /**
  80380. * Gets the far frustum plane transformed by the transform matrix
  80381. * @param transform transformation matrix to be applied to the resulting frustum plane
  80382. * @param frustumPlane the resuling frustum plane
  80383. */
  80384. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80385. /**
  80386. * Gets the left frustum plane transformed by the transform matrix
  80387. * @param transform transformation matrix to be applied to the resulting frustum plane
  80388. * @param frustumPlane the resuling frustum plane
  80389. */
  80390. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80391. /**
  80392. * Gets the right frustum plane transformed by the transform matrix
  80393. * @param transform transformation matrix to be applied to the resulting frustum plane
  80394. * @param frustumPlane the resuling frustum plane
  80395. */
  80396. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80397. /**
  80398. * Gets the top frustum plane transformed by the transform matrix
  80399. * @param transform transformation matrix to be applied to the resulting frustum plane
  80400. * @param frustumPlane the resuling frustum plane
  80401. */
  80402. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80403. /**
  80404. * Gets the bottom frustum plane transformed by the transform matrix
  80405. * @param transform transformation matrix to be applied to the resulting frustum plane
  80406. * @param frustumPlane the resuling frustum plane
  80407. */
  80408. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80409. /**
  80410. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80411. * @param transform transformation matrix to be applied to the resulting frustum planes
  80412. * @param frustumPlanes the resuling frustum planes
  80413. */
  80414. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80415. }
  80416. }
  80417. declare module BABYLON {
  80418. interface Engine {
  80419. /**
  80420. * Creates a new multiview render target
  80421. * @param width defines the width of the texture
  80422. * @param height defines the height of the texture
  80423. * @returns the created multiview texture
  80424. */
  80425. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80426. /**
  80427. * Binds a multiview framebuffer to be drawn to
  80428. * @param multiviewTexture texture to bind
  80429. */
  80430. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80431. }
  80432. interface Camera {
  80433. /**
  80434. * @hidden
  80435. * 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)
  80436. */
  80437. _useMultiviewToSingleView: boolean;
  80438. /**
  80439. * @hidden
  80440. * 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)
  80441. */
  80442. _multiviewTexture: Nullable<RenderTargetTexture>;
  80443. /**
  80444. * @hidden
  80445. * ensures the multiview texture of the camera exists and has the specified width/height
  80446. * @param width height to set on the multiview texture
  80447. * @param height width to set on the multiview texture
  80448. */
  80449. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80450. }
  80451. interface Scene {
  80452. /** @hidden */
  80453. _transformMatrixR: Matrix;
  80454. /** @hidden */
  80455. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80456. /** @hidden */
  80457. _createMultiviewUbo(): void;
  80458. /** @hidden */
  80459. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80460. /** @hidden */
  80461. _renderMultiviewToSingleView(camera: Camera): void;
  80462. }
  80463. }
  80464. declare module BABYLON {
  80465. /**
  80466. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80467. * This will not be used for webXR as it supports displaying texture arrays directly
  80468. */
  80469. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80470. /**
  80471. * Initializes a VRMultiviewToSingleview
  80472. * @param name name of the post process
  80473. * @param camera camera to be applied to
  80474. * @param scaleFactor scaling factor to the size of the output texture
  80475. */
  80476. constructor(name: string, camera: Camera, scaleFactor: number);
  80477. }
  80478. }
  80479. declare module BABYLON {
  80480. interface Engine {
  80481. /** @hidden */
  80482. _vrDisplay: any;
  80483. /** @hidden */
  80484. _vrSupported: boolean;
  80485. /** @hidden */
  80486. _oldSize: Size;
  80487. /** @hidden */
  80488. _oldHardwareScaleFactor: number;
  80489. /** @hidden */
  80490. _vrExclusivePointerMode: boolean;
  80491. /** @hidden */
  80492. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80493. /** @hidden */
  80494. _onVRDisplayPointerRestricted: () => void;
  80495. /** @hidden */
  80496. _onVRDisplayPointerUnrestricted: () => void;
  80497. /** @hidden */
  80498. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80499. /** @hidden */
  80500. _onVrDisplayDisconnect: Nullable<() => void>;
  80501. /** @hidden */
  80502. _onVrDisplayPresentChange: Nullable<() => void>;
  80503. /**
  80504. * Observable signaled when VR display mode changes
  80505. */
  80506. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80507. /**
  80508. * Observable signaled when VR request present is complete
  80509. */
  80510. onVRRequestPresentComplete: Observable<boolean>;
  80511. /**
  80512. * Observable signaled when VR request present starts
  80513. */
  80514. onVRRequestPresentStart: Observable<Engine>;
  80515. /**
  80516. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80517. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80518. */
  80519. isInVRExclusivePointerMode: boolean;
  80520. /**
  80521. * Gets a boolean indicating if a webVR device was detected
  80522. * @returns true if a webVR device was detected
  80523. */
  80524. isVRDevicePresent(): boolean;
  80525. /**
  80526. * Gets the current webVR device
  80527. * @returns the current webVR device (or null)
  80528. */
  80529. getVRDevice(): any;
  80530. /**
  80531. * Initializes a webVR display and starts listening to display change events
  80532. * The onVRDisplayChangedObservable will be notified upon these changes
  80533. * @returns A promise containing a VRDisplay and if vr is supported
  80534. */
  80535. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80536. /** @hidden */
  80537. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80538. /**
  80539. * Call this function to switch to webVR mode
  80540. * Will do nothing if webVR is not supported or if there is no webVR device
  80541. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80542. */
  80543. enableVR(): void;
  80544. /** @hidden */
  80545. _onVRFullScreenTriggered(): void;
  80546. }
  80547. }
  80548. declare module BABYLON {
  80549. /**
  80550. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80551. * IMPORTANT!! The data is right-hand data.
  80552. * @export
  80553. * @interface DevicePose
  80554. */
  80555. export interface DevicePose {
  80556. /**
  80557. * The position of the device, values in array are [x,y,z].
  80558. */
  80559. readonly position: Nullable<Float32Array>;
  80560. /**
  80561. * The linearVelocity of the device, values in array are [x,y,z].
  80562. */
  80563. readonly linearVelocity: Nullable<Float32Array>;
  80564. /**
  80565. * The linearAcceleration of the device, values in array are [x,y,z].
  80566. */
  80567. readonly linearAcceleration: Nullable<Float32Array>;
  80568. /**
  80569. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80570. */
  80571. readonly orientation: Nullable<Float32Array>;
  80572. /**
  80573. * The angularVelocity of the device, values in array are [x,y,z].
  80574. */
  80575. readonly angularVelocity: Nullable<Float32Array>;
  80576. /**
  80577. * The angularAcceleration of the device, values in array are [x,y,z].
  80578. */
  80579. readonly angularAcceleration: Nullable<Float32Array>;
  80580. }
  80581. /**
  80582. * Interface representing a pose controlled object in Babylon.
  80583. * A pose controlled object has both regular pose values as well as pose values
  80584. * from an external device such as a VR head mounted display
  80585. */
  80586. export interface PoseControlled {
  80587. /**
  80588. * The position of the object in babylon space.
  80589. */
  80590. position: Vector3;
  80591. /**
  80592. * The rotation quaternion of the object in babylon space.
  80593. */
  80594. rotationQuaternion: Quaternion;
  80595. /**
  80596. * The position of the device in babylon space.
  80597. */
  80598. devicePosition?: Vector3;
  80599. /**
  80600. * The rotation quaternion of the device in babylon space.
  80601. */
  80602. deviceRotationQuaternion: Quaternion;
  80603. /**
  80604. * The raw pose coming from the device.
  80605. */
  80606. rawPose: Nullable<DevicePose>;
  80607. /**
  80608. * The scale of the device to be used when translating from device space to babylon space.
  80609. */
  80610. deviceScaleFactor: number;
  80611. /**
  80612. * Updates the poseControlled values based on the input device pose.
  80613. * @param poseData the pose data to update the object with
  80614. */
  80615. updateFromDevice(poseData: DevicePose): void;
  80616. }
  80617. /**
  80618. * Set of options to customize the webVRCamera
  80619. */
  80620. export interface WebVROptions {
  80621. /**
  80622. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80623. */
  80624. trackPosition?: boolean;
  80625. /**
  80626. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80627. */
  80628. positionScale?: number;
  80629. /**
  80630. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80631. */
  80632. displayName?: string;
  80633. /**
  80634. * Should the native controller meshes be initialized. (default: true)
  80635. */
  80636. controllerMeshes?: boolean;
  80637. /**
  80638. * Creating a default HemiLight only on controllers. (default: true)
  80639. */
  80640. defaultLightingOnControllers?: boolean;
  80641. /**
  80642. * If you don't want to use the default VR button of the helper. (default: false)
  80643. */
  80644. useCustomVRButton?: boolean;
  80645. /**
  80646. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80647. */
  80648. customVRButton?: HTMLButtonElement;
  80649. /**
  80650. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80651. */
  80652. rayLength?: number;
  80653. /**
  80654. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80655. */
  80656. defaultHeight?: number;
  80657. /**
  80658. * If multiview should be used if availible (default: false)
  80659. */
  80660. useMultiview?: boolean;
  80661. }
  80662. /**
  80663. * This represents a WebVR camera.
  80664. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80665. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80666. */
  80667. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80668. private webVROptions;
  80669. /**
  80670. * @hidden
  80671. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80672. */
  80673. _vrDevice: any;
  80674. /**
  80675. * The rawPose of the vrDevice.
  80676. */
  80677. rawPose: Nullable<DevicePose>;
  80678. private _onVREnabled;
  80679. private _specsVersion;
  80680. private _attached;
  80681. private _frameData;
  80682. protected _descendants: Array<Node>;
  80683. private _deviceRoomPosition;
  80684. /** @hidden */
  80685. _deviceRoomRotationQuaternion: Quaternion;
  80686. private _standingMatrix;
  80687. /**
  80688. * Represents device position in babylon space.
  80689. */
  80690. devicePosition: Vector3;
  80691. /**
  80692. * Represents device rotation in babylon space.
  80693. */
  80694. deviceRotationQuaternion: Quaternion;
  80695. /**
  80696. * The scale of the device to be used when translating from device space to babylon space.
  80697. */
  80698. deviceScaleFactor: number;
  80699. private _deviceToWorld;
  80700. private _worldToDevice;
  80701. /**
  80702. * References to the webVR controllers for the vrDevice.
  80703. */
  80704. controllers: Array<WebVRController>;
  80705. /**
  80706. * Emits an event when a controller is attached.
  80707. */
  80708. onControllersAttachedObservable: Observable<WebVRController[]>;
  80709. /**
  80710. * Emits an event when a controller's mesh has been loaded;
  80711. */
  80712. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80713. /**
  80714. * Emits an event when the HMD's pose has been updated.
  80715. */
  80716. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80717. private _poseSet;
  80718. /**
  80719. * If the rig cameras be used as parent instead of this camera.
  80720. */
  80721. rigParenting: boolean;
  80722. private _lightOnControllers;
  80723. private _defaultHeight?;
  80724. /**
  80725. * Instantiates a WebVRFreeCamera.
  80726. * @param name The name of the WebVRFreeCamera
  80727. * @param position The starting anchor position for the camera
  80728. * @param scene The scene the camera belongs to
  80729. * @param webVROptions a set of customizable options for the webVRCamera
  80730. */
  80731. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80732. /**
  80733. * Gets the device distance from the ground in meters.
  80734. * @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.
  80735. */
  80736. deviceDistanceToRoomGround(): number;
  80737. /**
  80738. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80739. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80740. */
  80741. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80742. /**
  80743. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80744. * @returns A promise with a boolean set to if the standing matrix is supported.
  80745. */
  80746. useStandingMatrixAsync(): Promise<boolean>;
  80747. /**
  80748. * Disposes the camera
  80749. */
  80750. dispose(): void;
  80751. /**
  80752. * Gets a vrController by name.
  80753. * @param name The name of the controller to retreive
  80754. * @returns the controller matching the name specified or null if not found
  80755. */
  80756. getControllerByName(name: string): Nullable<WebVRController>;
  80757. private _leftController;
  80758. /**
  80759. * The controller corresponding to the users left hand.
  80760. */
  80761. readonly leftController: Nullable<WebVRController>;
  80762. private _rightController;
  80763. /**
  80764. * The controller corresponding to the users right hand.
  80765. */
  80766. readonly rightController: Nullable<WebVRController>;
  80767. /**
  80768. * Casts a ray forward from the vrCamera's gaze.
  80769. * @param length Length of the ray (default: 100)
  80770. * @returns the ray corresponding to the gaze
  80771. */
  80772. getForwardRay(length?: number): Ray;
  80773. /**
  80774. * @hidden
  80775. * Updates the camera based on device's frame data
  80776. */
  80777. _checkInputs(): void;
  80778. /**
  80779. * Updates the poseControlled values based on the input device pose.
  80780. * @param poseData Pose coming from the device
  80781. */
  80782. updateFromDevice(poseData: DevicePose): void;
  80783. private _htmlElementAttached;
  80784. private _detachIfAttached;
  80785. /**
  80786. * WebVR's attach control will start broadcasting frames to the device.
  80787. * Note that in certain browsers (chrome for example) this function must be called
  80788. * within a user-interaction callback. Example:
  80789. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80790. *
  80791. * @param element html element to attach the vrDevice to
  80792. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80793. */
  80794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80795. /**
  80796. * Detaches the camera from the html element and disables VR
  80797. *
  80798. * @param element html element to detach from
  80799. */
  80800. detachControl(element: HTMLElement): void;
  80801. /**
  80802. * @returns the name of this class
  80803. */
  80804. getClassName(): string;
  80805. /**
  80806. * Calls resetPose on the vrDisplay
  80807. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80808. */
  80809. resetToCurrentRotation(): void;
  80810. /**
  80811. * @hidden
  80812. * Updates the rig cameras (left and right eye)
  80813. */
  80814. _updateRigCameras(): void;
  80815. private _workingVector;
  80816. private _oneVector;
  80817. private _workingMatrix;
  80818. private updateCacheCalled;
  80819. private _correctPositionIfNotTrackPosition;
  80820. /**
  80821. * @hidden
  80822. * Updates the cached values of the camera
  80823. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80824. */
  80825. _updateCache(ignoreParentClass?: boolean): void;
  80826. /**
  80827. * @hidden
  80828. * Get current device position in babylon world
  80829. */
  80830. _computeDevicePosition(): void;
  80831. /**
  80832. * Updates the current device position and rotation in the babylon world
  80833. */
  80834. update(): void;
  80835. /**
  80836. * @hidden
  80837. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80838. * @returns an identity matrix
  80839. */
  80840. _getViewMatrix(): Matrix;
  80841. private _tmpMatrix;
  80842. /**
  80843. * This function is called by the two RIG cameras.
  80844. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80845. * @hidden
  80846. */
  80847. _getWebVRViewMatrix(): Matrix;
  80848. /** @hidden */
  80849. _getWebVRProjectionMatrix(): Matrix;
  80850. private _onGamepadConnectedObserver;
  80851. private _onGamepadDisconnectedObserver;
  80852. private _updateCacheWhenTrackingDisabledObserver;
  80853. /**
  80854. * Initializes the controllers and their meshes
  80855. */
  80856. initControllers(): void;
  80857. }
  80858. }
  80859. declare module BABYLON {
  80860. /**
  80861. * Size options for a post process
  80862. */
  80863. export type PostProcessOptions = {
  80864. width: number;
  80865. height: number;
  80866. };
  80867. /**
  80868. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80869. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80870. */
  80871. export class PostProcess {
  80872. /** Name of the PostProcess. */
  80873. name: string;
  80874. /**
  80875. * Gets or sets the unique id of the post process
  80876. */
  80877. uniqueId: number;
  80878. /**
  80879. * Width of the texture to apply the post process on
  80880. */
  80881. width: number;
  80882. /**
  80883. * Height of the texture to apply the post process on
  80884. */
  80885. height: number;
  80886. /**
  80887. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80888. * @hidden
  80889. */
  80890. _outputTexture: Nullable<InternalTexture>;
  80891. /**
  80892. * Sampling mode used by the shader
  80893. * See https://doc.babylonjs.com/classes/3.1/texture
  80894. */
  80895. renderTargetSamplingMode: number;
  80896. /**
  80897. * Clear color to use when screen clearing
  80898. */
  80899. clearColor: Color4;
  80900. /**
  80901. * If the buffer needs to be cleared before applying the post process. (default: true)
  80902. * Should be set to false if shader will overwrite all previous pixels.
  80903. */
  80904. autoClear: boolean;
  80905. /**
  80906. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80907. */
  80908. alphaMode: number;
  80909. /**
  80910. * Sets the setAlphaBlendConstants of the babylon engine
  80911. */
  80912. alphaConstants: Color4;
  80913. /**
  80914. * Animations to be used for the post processing
  80915. */
  80916. animations: Animation[];
  80917. /**
  80918. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80919. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80920. */
  80921. enablePixelPerfectMode: boolean;
  80922. /**
  80923. * Force the postprocess to be applied without taking in account viewport
  80924. */
  80925. forceFullscreenViewport: boolean;
  80926. /**
  80927. * List of inspectable custom properties (used by the Inspector)
  80928. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80929. */
  80930. inspectableCustomProperties: IInspectable[];
  80931. /**
  80932. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80933. *
  80934. * | Value | Type | Description |
  80935. * | ----- | ----------------------------------- | ----------- |
  80936. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80937. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80938. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80939. *
  80940. */
  80941. scaleMode: number;
  80942. /**
  80943. * Force textures to be a power of two (default: false)
  80944. */
  80945. alwaysForcePOT: boolean;
  80946. private _samples;
  80947. /**
  80948. * Number of sample textures (default: 1)
  80949. */
  80950. samples: number;
  80951. /**
  80952. * Modify the scale of the post process to be the same as the viewport (default: false)
  80953. */
  80954. adaptScaleToCurrentViewport: boolean;
  80955. private _camera;
  80956. private _scene;
  80957. private _engine;
  80958. private _options;
  80959. private _reusable;
  80960. private _textureType;
  80961. /**
  80962. * Smart array of input and output textures for the post process.
  80963. * @hidden
  80964. */
  80965. _textures: SmartArray<InternalTexture>;
  80966. /**
  80967. * The index in _textures that corresponds to the output texture.
  80968. * @hidden
  80969. */
  80970. _currentRenderTextureInd: number;
  80971. private _effect;
  80972. private _samplers;
  80973. private _fragmentUrl;
  80974. private _vertexUrl;
  80975. private _parameters;
  80976. private _scaleRatio;
  80977. protected _indexParameters: any;
  80978. private _shareOutputWithPostProcess;
  80979. private _texelSize;
  80980. private _forcedOutputTexture;
  80981. /**
  80982. * Returns the fragment url or shader name used in the post process.
  80983. * @returns the fragment url or name in the shader store.
  80984. */
  80985. getEffectName(): string;
  80986. /**
  80987. * An event triggered when the postprocess is activated.
  80988. */
  80989. onActivateObservable: Observable<Camera>;
  80990. private _onActivateObserver;
  80991. /**
  80992. * A function that is added to the onActivateObservable
  80993. */
  80994. onActivate: Nullable<(camera: Camera) => void>;
  80995. /**
  80996. * An event triggered when the postprocess changes its size.
  80997. */
  80998. onSizeChangedObservable: Observable<PostProcess>;
  80999. private _onSizeChangedObserver;
  81000. /**
  81001. * A function that is added to the onSizeChangedObservable
  81002. */
  81003. onSizeChanged: (postProcess: PostProcess) => void;
  81004. /**
  81005. * An event triggered when the postprocess applies its effect.
  81006. */
  81007. onApplyObservable: Observable<Effect>;
  81008. private _onApplyObserver;
  81009. /**
  81010. * A function that is added to the onApplyObservable
  81011. */
  81012. onApply: (effect: Effect) => void;
  81013. /**
  81014. * An event triggered before rendering the postprocess
  81015. */
  81016. onBeforeRenderObservable: Observable<Effect>;
  81017. private _onBeforeRenderObserver;
  81018. /**
  81019. * A function that is added to the onBeforeRenderObservable
  81020. */
  81021. onBeforeRender: (effect: Effect) => void;
  81022. /**
  81023. * An event triggered after rendering the postprocess
  81024. */
  81025. onAfterRenderObservable: Observable<Effect>;
  81026. private _onAfterRenderObserver;
  81027. /**
  81028. * A function that is added to the onAfterRenderObservable
  81029. */
  81030. onAfterRender: (efect: Effect) => void;
  81031. /**
  81032. * 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
  81033. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81034. */
  81035. inputTexture: InternalTexture;
  81036. /**
  81037. * Gets the camera which post process is applied to.
  81038. * @returns The camera the post process is applied to.
  81039. */
  81040. getCamera(): Camera;
  81041. /**
  81042. * Gets the texel size of the postprocess.
  81043. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81044. */
  81045. readonly texelSize: Vector2;
  81046. /**
  81047. * Creates a new instance PostProcess
  81048. * @param name The name of the PostProcess.
  81049. * @param fragmentUrl The url of the fragment shader to be used.
  81050. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81051. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81052. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81053. * @param camera The camera to apply the render pass to.
  81054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81055. * @param engine The engine which the post process will be applied. (default: current engine)
  81056. * @param reusable If the post process can be reused on the same frame. (default: false)
  81057. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81058. * @param textureType Type of textures used when performing the post process. (default: 0)
  81059. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81060. * @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
  81061. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81062. */
  81063. constructor(
  81064. /** Name of the PostProcess. */
  81065. 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);
  81066. /**
  81067. * Gets a string idenfifying the name of the class
  81068. * @returns "PostProcess" string
  81069. */
  81070. getClassName(): string;
  81071. /**
  81072. * Gets the engine which this post process belongs to.
  81073. * @returns The engine the post process was enabled with.
  81074. */
  81075. getEngine(): Engine;
  81076. /**
  81077. * The effect that is created when initializing the post process.
  81078. * @returns The created effect corresponding the the postprocess.
  81079. */
  81080. getEffect(): Effect;
  81081. /**
  81082. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81083. * @param postProcess The post process to share the output with.
  81084. * @returns This post process.
  81085. */
  81086. shareOutputWith(postProcess: PostProcess): PostProcess;
  81087. /**
  81088. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81089. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81090. */
  81091. useOwnOutput(): void;
  81092. /**
  81093. * Updates the effect with the current post process compile time values and recompiles the shader.
  81094. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81095. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81096. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81097. * @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
  81098. * @param onCompiled Called when the shader has been compiled.
  81099. * @param onError Called if there is an error when compiling a shader.
  81100. */
  81101. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81102. /**
  81103. * The post process is reusable if it can be used multiple times within one frame.
  81104. * @returns If the post process is reusable
  81105. */
  81106. isReusable(): boolean;
  81107. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81108. markTextureDirty(): void;
  81109. /**
  81110. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81111. * 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.
  81112. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81113. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81114. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81115. * @returns The target texture that was bound to be written to.
  81116. */
  81117. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81118. /**
  81119. * If the post process is supported.
  81120. */
  81121. readonly isSupported: boolean;
  81122. /**
  81123. * The aspect ratio of the output texture.
  81124. */
  81125. readonly aspectRatio: number;
  81126. /**
  81127. * Get a value indicating if the post-process is ready to be used
  81128. * @returns true if the post-process is ready (shader is compiled)
  81129. */
  81130. isReady(): boolean;
  81131. /**
  81132. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81133. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81134. */
  81135. apply(): Nullable<Effect>;
  81136. private _disposeTextures;
  81137. /**
  81138. * Disposes the post process.
  81139. * @param camera The camera to dispose the post process on.
  81140. */
  81141. dispose(camera?: Camera): void;
  81142. }
  81143. }
  81144. declare module BABYLON {
  81145. /** @hidden */
  81146. export var kernelBlurVaryingDeclaration: {
  81147. name: string;
  81148. shader: string;
  81149. };
  81150. }
  81151. declare module BABYLON {
  81152. /** @hidden */
  81153. export var kernelBlurFragment: {
  81154. name: string;
  81155. shader: string;
  81156. };
  81157. }
  81158. declare module BABYLON {
  81159. /** @hidden */
  81160. export var kernelBlurFragment2: {
  81161. name: string;
  81162. shader: string;
  81163. };
  81164. }
  81165. declare module BABYLON {
  81166. /** @hidden */
  81167. export var kernelBlurPixelShader: {
  81168. name: string;
  81169. shader: string;
  81170. };
  81171. }
  81172. declare module BABYLON {
  81173. /** @hidden */
  81174. export var kernelBlurVertex: {
  81175. name: string;
  81176. shader: string;
  81177. };
  81178. }
  81179. declare module BABYLON {
  81180. /** @hidden */
  81181. export var kernelBlurVertexShader: {
  81182. name: string;
  81183. shader: string;
  81184. };
  81185. }
  81186. declare module BABYLON {
  81187. /**
  81188. * The Blur Post Process which blurs an image based on a kernel and direction.
  81189. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81190. */
  81191. export class BlurPostProcess extends PostProcess {
  81192. /** The direction in which to blur the image. */
  81193. direction: Vector2;
  81194. private blockCompilation;
  81195. protected _kernel: number;
  81196. protected _idealKernel: number;
  81197. protected _packedFloat: boolean;
  81198. private _staticDefines;
  81199. /**
  81200. * Sets the length in pixels of the blur sample region
  81201. */
  81202. /**
  81203. * Gets the length in pixels of the blur sample region
  81204. */
  81205. kernel: number;
  81206. /**
  81207. * Sets wether or not the blur needs to unpack/repack floats
  81208. */
  81209. /**
  81210. * Gets wether or not the blur is unpacking/repacking floats
  81211. */
  81212. packedFloat: boolean;
  81213. /**
  81214. * Creates a new instance BlurPostProcess
  81215. * @param name The name of the effect.
  81216. * @param direction The direction in which to blur the image.
  81217. * @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.
  81218. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81219. * @param camera The camera to apply the render pass to.
  81220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81221. * @param engine The engine which the post process will be applied. (default: current engine)
  81222. * @param reusable If the post process can be reused on the same frame. (default: false)
  81223. * @param textureType Type of textures used when performing the post process. (default: 0)
  81224. * @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)
  81225. */
  81226. constructor(name: string,
  81227. /** The direction in which to blur the image. */
  81228. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81229. /**
  81230. * Updates the effect with the current post process compile time values and recompiles the shader.
  81231. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81232. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81233. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81234. * @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
  81235. * @param onCompiled Called when the shader has been compiled.
  81236. * @param onError Called if there is an error when compiling a shader.
  81237. */
  81238. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81239. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81240. /**
  81241. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81242. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81243. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81244. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81245. * The gaps between physical kernels are compensated for in the weighting of the samples
  81246. * @param idealKernel Ideal blur kernel.
  81247. * @return Nearest best kernel.
  81248. */
  81249. protected _nearestBestKernel(idealKernel: number): number;
  81250. /**
  81251. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81252. * @param x The point on the Gaussian distribution to sample.
  81253. * @return the value of the Gaussian function at x.
  81254. */
  81255. protected _gaussianWeight(x: number): number;
  81256. /**
  81257. * Generates a string that can be used as a floating point number in GLSL.
  81258. * @param x Value to print.
  81259. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81260. * @return GLSL float string.
  81261. */
  81262. protected _glslFloat(x: number, decimalFigures?: number): string;
  81263. }
  81264. }
  81265. declare module BABYLON {
  81266. /**
  81267. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81268. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81269. * You can then easily use it as a reflectionTexture on a flat surface.
  81270. * In case the surface is not a plane, please consider relying on reflection probes.
  81271. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81272. */
  81273. export class MirrorTexture extends RenderTargetTexture {
  81274. private scene;
  81275. /**
  81276. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81277. * 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.
  81278. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81279. */
  81280. mirrorPlane: Plane;
  81281. /**
  81282. * Define the blur ratio used to blur the reflection if needed.
  81283. */
  81284. blurRatio: number;
  81285. /**
  81286. * Define the adaptive blur kernel used to blur the reflection if needed.
  81287. * This will autocompute the closest best match for the `blurKernel`
  81288. */
  81289. adaptiveBlurKernel: number;
  81290. /**
  81291. * Define the blur kernel used to blur the reflection if needed.
  81292. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81293. */
  81294. blurKernel: number;
  81295. /**
  81296. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81298. */
  81299. blurKernelX: number;
  81300. /**
  81301. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81302. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81303. */
  81304. blurKernelY: number;
  81305. private _autoComputeBlurKernel;
  81306. protected _onRatioRescale(): void;
  81307. private _updateGammaSpace;
  81308. private _imageProcessingConfigChangeObserver;
  81309. private _transformMatrix;
  81310. private _mirrorMatrix;
  81311. private _savedViewMatrix;
  81312. private _blurX;
  81313. private _blurY;
  81314. private _adaptiveBlurKernel;
  81315. private _blurKernelX;
  81316. private _blurKernelY;
  81317. private _blurRatio;
  81318. /**
  81319. * Instantiates a Mirror Texture.
  81320. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81321. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81322. * You can then easily use it as a reflectionTexture on a flat surface.
  81323. * In case the surface is not a plane, please consider relying on reflection probes.
  81324. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81325. * @param name
  81326. * @param size
  81327. * @param scene
  81328. * @param generateMipMaps
  81329. * @param type
  81330. * @param samplingMode
  81331. * @param generateDepthBuffer
  81332. */
  81333. constructor(name: string, size: number | {
  81334. width: number;
  81335. height: number;
  81336. } | {
  81337. ratio: number;
  81338. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81339. private _preparePostProcesses;
  81340. /**
  81341. * Clone the mirror texture.
  81342. * @returns the cloned texture
  81343. */
  81344. clone(): MirrorTexture;
  81345. /**
  81346. * Serialize the texture to a JSON representation you could use in Parse later on
  81347. * @returns the serialized JSON representation
  81348. */
  81349. serialize(): any;
  81350. /**
  81351. * Dispose the texture and release its associated resources.
  81352. */
  81353. dispose(): void;
  81354. }
  81355. }
  81356. declare module BABYLON {
  81357. /**
  81358. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81359. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81360. */
  81361. export class Texture extends BaseTexture {
  81362. /**
  81363. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81364. */
  81365. static SerializeBuffers: boolean;
  81366. /** @hidden */
  81367. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81368. /** @hidden */
  81369. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81370. /** @hidden */
  81371. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81372. /** nearest is mag = nearest and min = nearest and mip = linear */
  81373. static readonly NEAREST_SAMPLINGMODE: number;
  81374. /** nearest is mag = nearest and min = nearest and mip = linear */
  81375. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81376. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81377. static readonly BILINEAR_SAMPLINGMODE: number;
  81378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81379. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81380. /** Trilinear is mag = linear and min = linear and mip = linear */
  81381. static readonly TRILINEAR_SAMPLINGMODE: number;
  81382. /** Trilinear is mag = linear and min = linear and mip = linear */
  81383. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81384. /** mag = nearest and min = nearest and mip = nearest */
  81385. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81386. /** mag = nearest and min = linear and mip = nearest */
  81387. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81388. /** mag = nearest and min = linear and mip = linear */
  81389. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81390. /** mag = nearest and min = linear and mip = none */
  81391. static readonly NEAREST_LINEAR: number;
  81392. /** mag = nearest and min = nearest and mip = none */
  81393. static readonly NEAREST_NEAREST: number;
  81394. /** mag = linear and min = nearest and mip = nearest */
  81395. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81396. /** mag = linear and min = nearest and mip = linear */
  81397. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81398. /** mag = linear and min = linear and mip = none */
  81399. static readonly LINEAR_LINEAR: number;
  81400. /** mag = linear and min = nearest and mip = none */
  81401. static readonly LINEAR_NEAREST: number;
  81402. /** Explicit coordinates mode */
  81403. static readonly EXPLICIT_MODE: number;
  81404. /** Spherical coordinates mode */
  81405. static readonly SPHERICAL_MODE: number;
  81406. /** Planar coordinates mode */
  81407. static readonly PLANAR_MODE: number;
  81408. /** Cubic coordinates mode */
  81409. static readonly CUBIC_MODE: number;
  81410. /** Projection coordinates mode */
  81411. static readonly PROJECTION_MODE: number;
  81412. /** Inverse Cubic coordinates mode */
  81413. static readonly SKYBOX_MODE: number;
  81414. /** Inverse Cubic coordinates mode */
  81415. static readonly INVCUBIC_MODE: number;
  81416. /** Equirectangular coordinates mode */
  81417. static readonly EQUIRECTANGULAR_MODE: number;
  81418. /** Equirectangular Fixed coordinates mode */
  81419. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81420. /** Equirectangular Fixed Mirrored coordinates mode */
  81421. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81422. /** Texture is not repeating outside of 0..1 UVs */
  81423. static readonly CLAMP_ADDRESSMODE: number;
  81424. /** Texture is repeating outside of 0..1 UVs */
  81425. static readonly WRAP_ADDRESSMODE: number;
  81426. /** Texture is repeating and mirrored */
  81427. static readonly MIRROR_ADDRESSMODE: number;
  81428. /**
  81429. * 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
  81430. */
  81431. static UseSerializedUrlIfAny: boolean;
  81432. /**
  81433. * Define the url of the texture.
  81434. */
  81435. url: Nullable<string>;
  81436. /**
  81437. * Define an offset on the texture to offset the u coordinates of the UVs
  81438. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81439. */
  81440. uOffset: number;
  81441. /**
  81442. * Define an offset on the texture to offset the v coordinates of the UVs
  81443. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81444. */
  81445. vOffset: number;
  81446. /**
  81447. * Define an offset on the texture to scale the u coordinates of the UVs
  81448. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81449. */
  81450. uScale: number;
  81451. /**
  81452. * Define an offset on the texture to scale the v coordinates of the UVs
  81453. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81454. */
  81455. vScale: number;
  81456. /**
  81457. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81458. * @see http://doc.babylonjs.com/how_to/more_materials
  81459. */
  81460. uAng: number;
  81461. /**
  81462. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81463. * @see http://doc.babylonjs.com/how_to/more_materials
  81464. */
  81465. vAng: number;
  81466. /**
  81467. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81468. * @see http://doc.babylonjs.com/how_to/more_materials
  81469. */
  81470. wAng: number;
  81471. /**
  81472. * Defines the center of rotation (U)
  81473. */
  81474. uRotationCenter: number;
  81475. /**
  81476. * Defines the center of rotation (V)
  81477. */
  81478. vRotationCenter: number;
  81479. /**
  81480. * Defines the center of rotation (W)
  81481. */
  81482. wRotationCenter: number;
  81483. /**
  81484. * Are mip maps generated for this texture or not.
  81485. */
  81486. readonly noMipmap: boolean;
  81487. /**
  81488. * List of inspectable custom properties (used by the Inspector)
  81489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81490. */
  81491. inspectableCustomProperties: Nullable<IInspectable[]>;
  81492. private _noMipmap;
  81493. /** @hidden */
  81494. _invertY: boolean;
  81495. private _rowGenerationMatrix;
  81496. private _cachedTextureMatrix;
  81497. private _projectionModeMatrix;
  81498. private _t0;
  81499. private _t1;
  81500. private _t2;
  81501. private _cachedUOffset;
  81502. private _cachedVOffset;
  81503. private _cachedUScale;
  81504. private _cachedVScale;
  81505. private _cachedUAng;
  81506. private _cachedVAng;
  81507. private _cachedWAng;
  81508. private _cachedProjectionMatrixId;
  81509. private _cachedCoordinatesMode;
  81510. /** @hidden */
  81511. protected _initialSamplingMode: number;
  81512. /** @hidden */
  81513. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81514. private _deleteBuffer;
  81515. protected _format: Nullable<number>;
  81516. private _delayedOnLoad;
  81517. private _delayedOnError;
  81518. /**
  81519. * Observable triggered once the texture has been loaded.
  81520. */
  81521. onLoadObservable: Observable<Texture>;
  81522. protected _isBlocking: boolean;
  81523. /**
  81524. * Is the texture preventing material to render while loading.
  81525. * If false, a default texture will be used instead of the loading one during the preparation step.
  81526. */
  81527. isBlocking: boolean;
  81528. /**
  81529. * Get the current sampling mode associated with the texture.
  81530. */
  81531. readonly samplingMode: number;
  81532. /**
  81533. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81534. */
  81535. readonly invertY: boolean;
  81536. /**
  81537. * Instantiates a new texture.
  81538. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81539. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81540. * @param url define the url of the picture to load as a texture
  81541. * @param scene define the scene or engine the texture will belong to
  81542. * @param noMipmap define if the texture will require mip maps or not
  81543. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81544. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81545. * @param onLoad define a callback triggered when the texture has been loaded
  81546. * @param onError define a callback triggered when an error occurred during the loading session
  81547. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81548. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81549. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81550. */
  81551. 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);
  81552. /**
  81553. * Update the url (and optional buffer) of this texture if url was null during construction.
  81554. * @param url the url of the texture
  81555. * @param buffer the buffer of the texture (defaults to null)
  81556. * @param onLoad callback called when the texture is loaded (defaults to null)
  81557. */
  81558. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81559. /**
  81560. * Finish the loading sequence of a texture flagged as delayed load.
  81561. * @hidden
  81562. */
  81563. delayLoad(): void;
  81564. private _prepareRowForTextureGeneration;
  81565. /**
  81566. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81567. * @returns the transform matrix of the texture.
  81568. */
  81569. getTextureMatrix(): Matrix;
  81570. /**
  81571. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81572. * @returns The reflection texture transform
  81573. */
  81574. getReflectionTextureMatrix(): Matrix;
  81575. /**
  81576. * Clones the texture.
  81577. * @returns the cloned texture
  81578. */
  81579. clone(): Texture;
  81580. /**
  81581. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81582. * @returns The JSON representation of the texture
  81583. */
  81584. serialize(): any;
  81585. /**
  81586. * Get the current class name of the texture useful for serialization or dynamic coding.
  81587. * @returns "Texture"
  81588. */
  81589. getClassName(): string;
  81590. /**
  81591. * Dispose the texture and release its associated resources.
  81592. */
  81593. dispose(): void;
  81594. /**
  81595. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81596. * @param parsedTexture Define the JSON representation of the texture
  81597. * @param scene Define the scene the parsed texture should be instantiated in
  81598. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81599. * @returns The parsed texture if successful
  81600. */
  81601. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81602. /**
  81603. * Creates a texture from its base 64 representation.
  81604. * @param data Define the base64 payload without the data: prefix
  81605. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81606. * @param scene Define the scene the texture should belong to
  81607. * @param noMipmap Forces the texture to not create mip map information if true
  81608. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81609. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81610. * @param onLoad define a callback triggered when the texture has been loaded
  81611. * @param onError define a callback triggered when an error occurred during the loading session
  81612. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81613. * @returns the created texture
  81614. */
  81615. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81616. /**
  81617. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81618. * @param data Define the base64 payload without the data: prefix
  81619. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81620. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81621. * @param scene Define the scene the texture should belong to
  81622. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81623. * @param noMipmap Forces the texture to not create mip map information if true
  81624. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81625. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81626. * @param onLoad define a callback triggered when the texture has been loaded
  81627. * @param onError define a callback triggered when an error occurred during the loading session
  81628. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81629. * @returns the created texture
  81630. */
  81631. 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;
  81632. }
  81633. }
  81634. declare module BABYLON {
  81635. /**
  81636. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81637. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81638. */
  81639. export class PostProcessManager {
  81640. private _scene;
  81641. private _indexBuffer;
  81642. private _vertexBuffers;
  81643. /**
  81644. * Creates a new instance PostProcess
  81645. * @param scene The scene that the post process is associated with.
  81646. */
  81647. constructor(scene: Scene);
  81648. private _prepareBuffers;
  81649. private _buildIndexBuffer;
  81650. /**
  81651. * Rebuilds the vertex buffers of the manager.
  81652. * @hidden
  81653. */
  81654. _rebuild(): void;
  81655. /**
  81656. * Prepares a frame to be run through a post process.
  81657. * @param sourceTexture The input texture to the post procesess. (default: null)
  81658. * @param postProcesses An array of post processes to be run. (default: null)
  81659. * @returns True if the post processes were able to be run.
  81660. * @hidden
  81661. */
  81662. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81663. /**
  81664. * Manually render a set of post processes to a texture.
  81665. * @param postProcesses An array of post processes to be run.
  81666. * @param targetTexture The target texture to render to.
  81667. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81668. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81669. * @param lodLevel defines which lod of the texture to render to
  81670. */
  81671. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81672. /**
  81673. * Finalize the result of the output of the postprocesses.
  81674. * @param doNotPresent If true the result will not be displayed to the screen.
  81675. * @param targetTexture The target texture to render to.
  81676. * @param faceIndex The index of the face to bind the target texture to.
  81677. * @param postProcesses The array of post processes to render.
  81678. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81679. * @hidden
  81680. */
  81681. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81682. /**
  81683. * Disposes of the post process manager.
  81684. */
  81685. dispose(): void;
  81686. }
  81687. }
  81688. declare module BABYLON {
  81689. /** Interface used by value gradients (color, factor, ...) */
  81690. export interface IValueGradient {
  81691. /**
  81692. * Gets or sets the gradient value (between 0 and 1)
  81693. */
  81694. gradient: number;
  81695. }
  81696. /** Class used to store color4 gradient */
  81697. export class ColorGradient implements IValueGradient {
  81698. /**
  81699. * Gets or sets the gradient value (between 0 and 1)
  81700. */
  81701. gradient: number;
  81702. /**
  81703. * Gets or sets first associated color
  81704. */
  81705. color1: Color4;
  81706. /**
  81707. * Gets or sets second associated color
  81708. */
  81709. color2?: Color4;
  81710. /**
  81711. * Will get a color picked randomly between color1 and color2.
  81712. * If color2 is undefined then color1 will be used
  81713. * @param result defines the target Color4 to store the result in
  81714. */
  81715. getColorToRef(result: Color4): void;
  81716. }
  81717. /** Class used to store color 3 gradient */
  81718. export class Color3Gradient implements IValueGradient {
  81719. /**
  81720. * Gets or sets the gradient value (between 0 and 1)
  81721. */
  81722. gradient: number;
  81723. /**
  81724. * Gets or sets the associated color
  81725. */
  81726. color: Color3;
  81727. }
  81728. /** Class used to store factor gradient */
  81729. export class FactorGradient implements IValueGradient {
  81730. /**
  81731. * Gets or sets the gradient value (between 0 and 1)
  81732. */
  81733. gradient: number;
  81734. /**
  81735. * Gets or sets first associated factor
  81736. */
  81737. factor1: number;
  81738. /**
  81739. * Gets or sets second associated factor
  81740. */
  81741. factor2?: number;
  81742. /**
  81743. * Will get a number picked randomly between factor1 and factor2.
  81744. * If factor2 is undefined then factor1 will be used
  81745. * @returns the picked number
  81746. */
  81747. getFactor(): number;
  81748. }
  81749. /**
  81750. * Helper used to simplify some generic gradient tasks
  81751. */
  81752. export class GradientHelper {
  81753. /**
  81754. * Gets the current gradient from an array of IValueGradient
  81755. * @param ratio defines the current ratio to get
  81756. * @param gradients defines the array of IValueGradient
  81757. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81758. */
  81759. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81760. }
  81761. }
  81762. declare module BABYLON {
  81763. /**
  81764. * A class extending Texture allowing drawing on a texture
  81765. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81766. */
  81767. export class DynamicTexture extends Texture {
  81768. private _generateMipMaps;
  81769. private _canvas;
  81770. private _context;
  81771. private _engine;
  81772. /**
  81773. * Creates a DynamicTexture
  81774. * @param name defines the name of the texture
  81775. * @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
  81776. * @param scene defines the scene where you want the texture
  81777. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81778. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81779. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81780. */
  81781. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81782. /**
  81783. * Get the current class name of the texture useful for serialization or dynamic coding.
  81784. * @returns "DynamicTexture"
  81785. */
  81786. getClassName(): string;
  81787. /**
  81788. * Gets the current state of canRescale
  81789. */
  81790. readonly canRescale: boolean;
  81791. private _recreate;
  81792. /**
  81793. * Scales the texture
  81794. * @param ratio the scale factor to apply to both width and height
  81795. */
  81796. scale(ratio: number): void;
  81797. /**
  81798. * Resizes the texture
  81799. * @param width the new width
  81800. * @param height the new height
  81801. */
  81802. scaleTo(width: number, height: number): void;
  81803. /**
  81804. * Gets the context of the canvas used by the texture
  81805. * @returns the canvas context of the dynamic texture
  81806. */
  81807. getContext(): CanvasRenderingContext2D;
  81808. /**
  81809. * Clears the texture
  81810. */
  81811. clear(): void;
  81812. /**
  81813. * Updates the texture
  81814. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81815. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81816. */
  81817. update(invertY?: boolean, premulAlpha?: boolean): void;
  81818. /**
  81819. * Draws text onto the texture
  81820. * @param text defines the text to be drawn
  81821. * @param x defines the placement of the text from the left
  81822. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81823. * @param font defines the font to be used with font-style, font-size, font-name
  81824. * @param color defines the color used for the text
  81825. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81826. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81827. * @param update defines whether texture is immediately update (default is true)
  81828. */
  81829. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81830. /**
  81831. * Clones the texture
  81832. * @returns the clone of the texture.
  81833. */
  81834. clone(): DynamicTexture;
  81835. /**
  81836. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81837. * @returns a serialized dynamic texture object
  81838. */
  81839. serialize(): any;
  81840. /** @hidden */
  81841. _rebuild(): void;
  81842. }
  81843. }
  81844. declare module BABYLON {
  81845. interface AbstractScene {
  81846. /**
  81847. * The list of procedural textures added to the scene
  81848. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81849. */
  81850. proceduralTextures: Array<ProceduralTexture>;
  81851. }
  81852. /**
  81853. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81854. * in a given scene.
  81855. */
  81856. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81857. /**
  81858. * The component name helpfull to identify the component in the list of scene components.
  81859. */
  81860. readonly name: string;
  81861. /**
  81862. * The scene the component belongs to.
  81863. */
  81864. scene: Scene;
  81865. /**
  81866. * Creates a new instance of the component for the given scene
  81867. * @param scene Defines the scene to register the component in
  81868. */
  81869. constructor(scene: Scene);
  81870. /**
  81871. * Registers the component in a given scene
  81872. */
  81873. register(): void;
  81874. /**
  81875. * Rebuilds the elements related to this component in case of
  81876. * context lost for instance.
  81877. */
  81878. rebuild(): void;
  81879. /**
  81880. * Disposes the component and the associated ressources.
  81881. */
  81882. dispose(): void;
  81883. private _beforeClear;
  81884. }
  81885. }
  81886. declare module BABYLON {
  81887. interface Engine {
  81888. /**
  81889. * Creates a new render target cube texture
  81890. * @param size defines the size of the texture
  81891. * @param options defines the options used to create the texture
  81892. * @returns a new render target cube texture stored in an InternalTexture
  81893. */
  81894. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81895. }
  81896. }
  81897. declare module BABYLON {
  81898. /** @hidden */
  81899. export var proceduralVertexShader: {
  81900. name: string;
  81901. shader: string;
  81902. };
  81903. }
  81904. declare module BABYLON {
  81905. /**
  81906. * 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.
  81907. * This is the base class of any Procedural texture and contains most of the shareable code.
  81908. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81909. */
  81910. export class ProceduralTexture extends Texture {
  81911. isCube: boolean;
  81912. /**
  81913. * Define if the texture is enabled or not (disabled texture will not render)
  81914. */
  81915. isEnabled: boolean;
  81916. /**
  81917. * Define if the texture must be cleared before rendering (default is true)
  81918. */
  81919. autoClear: boolean;
  81920. /**
  81921. * Callback called when the texture is generated
  81922. */
  81923. onGenerated: () => void;
  81924. /**
  81925. * Event raised when the texture is generated
  81926. */
  81927. onGeneratedObservable: Observable<ProceduralTexture>;
  81928. /** @hidden */
  81929. _generateMipMaps: boolean;
  81930. /** @hidden **/
  81931. _effect: Effect;
  81932. /** @hidden */
  81933. _textures: {
  81934. [key: string]: Texture;
  81935. };
  81936. private _size;
  81937. private _currentRefreshId;
  81938. private _refreshRate;
  81939. private _vertexBuffers;
  81940. private _indexBuffer;
  81941. private _uniforms;
  81942. private _samplers;
  81943. private _fragment;
  81944. private _floats;
  81945. private _ints;
  81946. private _floatsArrays;
  81947. private _colors3;
  81948. private _colors4;
  81949. private _vectors2;
  81950. private _vectors3;
  81951. private _matrices;
  81952. private _fallbackTexture;
  81953. private _fallbackTextureUsed;
  81954. private _engine;
  81955. private _cachedDefines;
  81956. private _contentUpdateId;
  81957. private _contentData;
  81958. /**
  81959. * Instantiates a new procedural texture.
  81960. * 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.
  81961. * This is the base class of any Procedural texture and contains most of the shareable code.
  81962. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81963. * @param name Define the name of the texture
  81964. * @param size Define the size of the texture to create
  81965. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81966. * @param scene Define the scene the texture belongs to
  81967. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81968. * @param generateMipMaps Define if the texture should creates mip maps or not
  81969. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81970. */
  81971. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81972. /**
  81973. * The effect that is created when initializing the post process.
  81974. * @returns The created effect corresponding the the postprocess.
  81975. */
  81976. getEffect(): Effect;
  81977. /**
  81978. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81979. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81980. */
  81981. getContent(): Nullable<ArrayBufferView>;
  81982. private _createIndexBuffer;
  81983. /** @hidden */
  81984. _rebuild(): void;
  81985. /**
  81986. * Resets the texture in order to recreate its associated resources.
  81987. * This can be called in case of context loss
  81988. */
  81989. reset(): void;
  81990. protected _getDefines(): string;
  81991. /**
  81992. * Is the texture ready to be used ? (rendered at least once)
  81993. * @returns true if ready, otherwise, false.
  81994. */
  81995. isReady(): boolean;
  81996. /**
  81997. * Resets the refresh counter of the texture and start bak from scratch.
  81998. * Could be useful to regenerate the texture if it is setup to render only once.
  81999. */
  82000. resetRefreshCounter(): void;
  82001. /**
  82002. * Set the fragment shader to use in order to render the texture.
  82003. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82004. */
  82005. setFragment(fragment: any): void;
  82006. /**
  82007. * Define the refresh rate of the texture or the rendering frequency.
  82008. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82009. */
  82010. refreshRate: number;
  82011. /** @hidden */
  82012. _shouldRender(): boolean;
  82013. /**
  82014. * Get the size the texture is rendering at.
  82015. * @returns the size (texture is always squared)
  82016. */
  82017. getRenderSize(): number;
  82018. /**
  82019. * Resize the texture to new value.
  82020. * @param size Define the new size the texture should have
  82021. * @param generateMipMaps Define whether the new texture should create mip maps
  82022. */
  82023. resize(size: number, generateMipMaps: boolean): void;
  82024. private _checkUniform;
  82025. /**
  82026. * Set a texture in the shader program used to render.
  82027. * @param name Define the name of the uniform samplers as defined in the shader
  82028. * @param texture Define the texture to bind to this sampler
  82029. * @return the texture itself allowing "fluent" like uniform updates
  82030. */
  82031. setTexture(name: string, texture: Texture): ProceduralTexture;
  82032. /**
  82033. * Set a float in the shader.
  82034. * @param name Define the name of the uniform as defined in the shader
  82035. * @param value Define the value to give to the uniform
  82036. * @return the texture itself allowing "fluent" like uniform updates
  82037. */
  82038. setFloat(name: string, value: number): ProceduralTexture;
  82039. /**
  82040. * Set a int in the shader.
  82041. * @param name Define the name of the uniform as defined in the shader
  82042. * @param value Define the value to give to the uniform
  82043. * @return the texture itself allowing "fluent" like uniform updates
  82044. */
  82045. setInt(name: string, value: number): ProceduralTexture;
  82046. /**
  82047. * Set an array of floats in the shader.
  82048. * @param name Define the name of the uniform as defined in the shader
  82049. * @param value Define the value to give to the uniform
  82050. * @return the texture itself allowing "fluent" like uniform updates
  82051. */
  82052. setFloats(name: string, value: number[]): ProceduralTexture;
  82053. /**
  82054. * Set a vec3 in the shader from a Color3.
  82055. * @param name Define the name of the uniform as defined in the shader
  82056. * @param value Define the value to give to the uniform
  82057. * @return the texture itself allowing "fluent" like uniform updates
  82058. */
  82059. setColor3(name: string, value: Color3): ProceduralTexture;
  82060. /**
  82061. * Set a vec4 in the shader from a Color4.
  82062. * @param name Define the name of the uniform as defined in the shader
  82063. * @param value Define the value to give to the uniform
  82064. * @return the texture itself allowing "fluent" like uniform updates
  82065. */
  82066. setColor4(name: string, value: Color4): ProceduralTexture;
  82067. /**
  82068. * Set a vec2 in the shader from a Vector2.
  82069. * @param name Define the name of the uniform as defined in the shader
  82070. * @param value Define the value to give to the uniform
  82071. * @return the texture itself allowing "fluent" like uniform updates
  82072. */
  82073. setVector2(name: string, value: Vector2): ProceduralTexture;
  82074. /**
  82075. * Set a vec3 in the shader from a Vector3.
  82076. * @param name Define the name of the uniform as defined in the shader
  82077. * @param value Define the value to give to the uniform
  82078. * @return the texture itself allowing "fluent" like uniform updates
  82079. */
  82080. setVector3(name: string, value: Vector3): ProceduralTexture;
  82081. /**
  82082. * Set a mat4 in the shader from a MAtrix.
  82083. * @param name Define the name of the uniform as defined in the shader
  82084. * @param value Define the value to give to the uniform
  82085. * @return the texture itself allowing "fluent" like uniform updates
  82086. */
  82087. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82088. /**
  82089. * Render the texture to its associated render target.
  82090. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82091. */
  82092. render(useCameraPostProcess?: boolean): void;
  82093. /**
  82094. * Clone the texture.
  82095. * @returns the cloned texture
  82096. */
  82097. clone(): ProceduralTexture;
  82098. /**
  82099. * Dispose the texture and release its asoociated resources.
  82100. */
  82101. dispose(): void;
  82102. }
  82103. }
  82104. declare module BABYLON {
  82105. /**
  82106. * This represents the base class for particle system in Babylon.
  82107. * 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.
  82108. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82109. * @example https://doc.babylonjs.com/babylon101/particles
  82110. */
  82111. export class BaseParticleSystem {
  82112. /**
  82113. * Source color is added to the destination color without alpha affecting the result
  82114. */
  82115. static BLENDMODE_ONEONE: number;
  82116. /**
  82117. * Blend current color and particle color using particle’s alpha
  82118. */
  82119. static BLENDMODE_STANDARD: number;
  82120. /**
  82121. * Add current color and particle color multiplied by particle’s alpha
  82122. */
  82123. static BLENDMODE_ADD: number;
  82124. /**
  82125. * Multiply current color with particle color
  82126. */
  82127. static BLENDMODE_MULTIPLY: number;
  82128. /**
  82129. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82130. */
  82131. static BLENDMODE_MULTIPLYADD: number;
  82132. /**
  82133. * List of animations used by the particle system.
  82134. */
  82135. animations: Animation[];
  82136. /**
  82137. * The id of the Particle system.
  82138. */
  82139. id: string;
  82140. /**
  82141. * The friendly name of the Particle system.
  82142. */
  82143. name: string;
  82144. /**
  82145. * The rendering group used by the Particle system to chose when to render.
  82146. */
  82147. renderingGroupId: number;
  82148. /**
  82149. * The emitter represents the Mesh or position we are attaching the particle system to.
  82150. */
  82151. emitter: Nullable<AbstractMesh | Vector3>;
  82152. /**
  82153. * The maximum number of particles to emit per frame
  82154. */
  82155. emitRate: number;
  82156. /**
  82157. * If you want to launch only a few particles at once, that can be done, as well.
  82158. */
  82159. manualEmitCount: number;
  82160. /**
  82161. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82162. */
  82163. updateSpeed: number;
  82164. /**
  82165. * The amount of time the particle system is running (depends of the overall update speed).
  82166. */
  82167. targetStopDuration: number;
  82168. /**
  82169. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82170. */
  82171. disposeOnStop: boolean;
  82172. /**
  82173. * Minimum power of emitting particles.
  82174. */
  82175. minEmitPower: number;
  82176. /**
  82177. * Maximum power of emitting particles.
  82178. */
  82179. maxEmitPower: number;
  82180. /**
  82181. * Minimum life time of emitting particles.
  82182. */
  82183. minLifeTime: number;
  82184. /**
  82185. * Maximum life time of emitting particles.
  82186. */
  82187. maxLifeTime: number;
  82188. /**
  82189. * Minimum Size of emitting particles.
  82190. */
  82191. minSize: number;
  82192. /**
  82193. * Maximum Size of emitting particles.
  82194. */
  82195. maxSize: number;
  82196. /**
  82197. * Minimum scale of emitting particles on X axis.
  82198. */
  82199. minScaleX: number;
  82200. /**
  82201. * Maximum scale of emitting particles on X axis.
  82202. */
  82203. maxScaleX: number;
  82204. /**
  82205. * Minimum scale of emitting particles on Y axis.
  82206. */
  82207. minScaleY: number;
  82208. /**
  82209. * Maximum scale of emitting particles on Y axis.
  82210. */
  82211. maxScaleY: number;
  82212. /**
  82213. * Gets or sets the minimal initial rotation in radians.
  82214. */
  82215. minInitialRotation: number;
  82216. /**
  82217. * Gets or sets the maximal initial rotation in radians.
  82218. */
  82219. maxInitialRotation: number;
  82220. /**
  82221. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82222. */
  82223. minAngularSpeed: number;
  82224. /**
  82225. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82226. */
  82227. maxAngularSpeed: number;
  82228. /**
  82229. * The texture used to render each particle. (this can be a spritesheet)
  82230. */
  82231. particleTexture: Nullable<Texture>;
  82232. /**
  82233. * The layer mask we are rendering the particles through.
  82234. */
  82235. layerMask: number;
  82236. /**
  82237. * This can help using your own shader to render the particle system.
  82238. * The according effect will be created
  82239. */
  82240. customShader: any;
  82241. /**
  82242. * By default particle system starts as soon as they are created. This prevents the
  82243. * automatic start to happen and let you decide when to start emitting particles.
  82244. */
  82245. preventAutoStart: boolean;
  82246. private _noiseTexture;
  82247. /**
  82248. * Gets or sets a texture used to add random noise to particle positions
  82249. */
  82250. noiseTexture: Nullable<ProceduralTexture>;
  82251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82252. noiseStrength: Vector3;
  82253. /**
  82254. * Callback triggered when the particle animation is ending.
  82255. */
  82256. onAnimationEnd: Nullable<() => void>;
  82257. /**
  82258. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82259. */
  82260. blendMode: number;
  82261. /**
  82262. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82263. * to override the particles.
  82264. */
  82265. forceDepthWrite: boolean;
  82266. /** 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 */
  82267. preWarmCycles: number;
  82268. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82269. preWarmStepOffset: number;
  82270. /**
  82271. * 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)
  82272. */
  82273. spriteCellChangeSpeed: number;
  82274. /**
  82275. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82276. */
  82277. startSpriteCellID: number;
  82278. /**
  82279. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82280. */
  82281. endSpriteCellID: number;
  82282. /**
  82283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82284. */
  82285. spriteCellWidth: number;
  82286. /**
  82287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82288. */
  82289. spriteCellHeight: number;
  82290. /**
  82291. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82292. */
  82293. spriteRandomStartCell: boolean;
  82294. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82295. translationPivot: Vector2;
  82296. /** @hidden */
  82297. protected _isAnimationSheetEnabled: boolean;
  82298. /**
  82299. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82300. */
  82301. beginAnimationOnStart: boolean;
  82302. /**
  82303. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82304. */
  82305. beginAnimationFrom: number;
  82306. /**
  82307. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82308. */
  82309. beginAnimationTo: number;
  82310. /**
  82311. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82312. */
  82313. beginAnimationLoop: boolean;
  82314. /**
  82315. * Gets or sets a world offset applied to all particles
  82316. */
  82317. worldOffset: Vector3;
  82318. /**
  82319. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82320. */
  82321. isAnimationSheetEnabled: boolean;
  82322. /**
  82323. * Get hosting scene
  82324. * @returns the scene
  82325. */
  82326. getScene(): Scene;
  82327. /**
  82328. * You can use gravity if you want to give an orientation to your particles.
  82329. */
  82330. gravity: Vector3;
  82331. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82332. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82333. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82334. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82335. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82336. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82337. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82338. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82339. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82340. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82341. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82342. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82343. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82344. /**
  82345. * Defines the delay in milliseconds before starting the system (0 by default)
  82346. */
  82347. startDelay: number;
  82348. /**
  82349. * Gets the current list of drag gradients.
  82350. * You must use addDragGradient and removeDragGradient to udpate this list
  82351. * @returns the list of drag gradients
  82352. */
  82353. getDragGradients(): Nullable<Array<FactorGradient>>;
  82354. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82355. limitVelocityDamping: number;
  82356. /**
  82357. * Gets the current list of limit velocity gradients.
  82358. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82359. * @returns the list of limit velocity gradients
  82360. */
  82361. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82362. /**
  82363. * Gets the current list of color gradients.
  82364. * You must use addColorGradient and removeColorGradient to udpate this list
  82365. * @returns the list of color gradients
  82366. */
  82367. getColorGradients(): Nullable<Array<ColorGradient>>;
  82368. /**
  82369. * Gets the current list of size gradients.
  82370. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82371. * @returns the list of size gradients
  82372. */
  82373. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82374. /**
  82375. * Gets the current list of color remap gradients.
  82376. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82377. * @returns the list of color remap gradients
  82378. */
  82379. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82380. /**
  82381. * Gets the current list of alpha remap gradients.
  82382. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82383. * @returns the list of alpha remap gradients
  82384. */
  82385. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82386. /**
  82387. * Gets the current list of life time gradients.
  82388. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82389. * @returns the list of life time gradients
  82390. */
  82391. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82392. /**
  82393. * Gets the current list of angular speed gradients.
  82394. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82395. * @returns the list of angular speed gradients
  82396. */
  82397. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82398. /**
  82399. * Gets the current list of velocity gradients.
  82400. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82401. * @returns the list of velocity gradients
  82402. */
  82403. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82404. /**
  82405. * Gets the current list of start size gradients.
  82406. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82407. * @returns the list of start size gradients
  82408. */
  82409. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82410. /**
  82411. * Gets the current list of emit rate gradients.
  82412. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82413. * @returns the list of emit rate gradients
  82414. */
  82415. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82416. /**
  82417. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82418. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82419. */
  82420. direction1: Vector3;
  82421. /**
  82422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82423. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82424. */
  82425. direction2: Vector3;
  82426. /**
  82427. * 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.
  82428. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82429. */
  82430. minEmitBox: Vector3;
  82431. /**
  82432. * 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.
  82433. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82434. */
  82435. maxEmitBox: Vector3;
  82436. /**
  82437. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82438. */
  82439. color1: Color4;
  82440. /**
  82441. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82442. */
  82443. color2: Color4;
  82444. /**
  82445. * Color the particle will have at the end of its lifetime
  82446. */
  82447. colorDead: Color4;
  82448. /**
  82449. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82450. */
  82451. textureMask: Color4;
  82452. /**
  82453. * The particle emitter type defines the emitter used by the particle system.
  82454. * It can be for example box, sphere, or cone...
  82455. */
  82456. particleEmitterType: IParticleEmitterType;
  82457. /** @hidden */
  82458. _isSubEmitter: boolean;
  82459. /**
  82460. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82461. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82462. */
  82463. billboardMode: number;
  82464. protected _isBillboardBased: boolean;
  82465. /**
  82466. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82467. */
  82468. isBillboardBased: boolean;
  82469. /**
  82470. * The scene the particle system belongs to.
  82471. */
  82472. protected _scene: Scene;
  82473. /**
  82474. * Local cache of defines for image processing.
  82475. */
  82476. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82477. /**
  82478. * Default configuration related to image processing available in the standard Material.
  82479. */
  82480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82481. /**
  82482. * Gets the image processing configuration used either in this material.
  82483. */
  82484. /**
  82485. * Sets the Default image processing configuration used either in the this material.
  82486. *
  82487. * If sets to null, the scene one is in use.
  82488. */
  82489. imageProcessingConfiguration: ImageProcessingConfiguration;
  82490. /**
  82491. * Attaches a new image processing configuration to the Standard Material.
  82492. * @param configuration
  82493. */
  82494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82495. /** @hidden */
  82496. protected _reset(): void;
  82497. /** @hidden */
  82498. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82499. /**
  82500. * Instantiates a particle system.
  82501. * 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.
  82502. * @param name The name of the particle system
  82503. */
  82504. constructor(name: string);
  82505. /**
  82506. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82509. * @returns the emitter
  82510. */
  82511. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82512. /**
  82513. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82514. * @param radius The radius of the hemisphere to emit from
  82515. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82516. * @returns the emitter
  82517. */
  82518. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82519. /**
  82520. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82521. * @param radius The radius of the sphere to emit from
  82522. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82523. * @returns the emitter
  82524. */
  82525. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82526. /**
  82527. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82528. * @param radius The radius of the sphere to emit from
  82529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82531. * @returns the emitter
  82532. */
  82533. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82534. /**
  82535. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82536. * @param radius The radius of the emission cylinder
  82537. * @param height The height of the emission cylinder
  82538. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82539. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82540. * @returns the emitter
  82541. */
  82542. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82543. /**
  82544. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82545. * @param radius The radius of the cylinder to emit from
  82546. * @param height The height of the emission cylinder
  82547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82550. * @returns the emitter
  82551. */
  82552. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82553. /**
  82554. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82555. * @param radius The radius of the cone to emit from
  82556. * @param angle The base angle of the cone
  82557. * @returns the emitter
  82558. */
  82559. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82560. /**
  82561. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82564. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82565. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82566. * @returns the emitter
  82567. */
  82568. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82569. }
  82570. }
  82571. declare module BABYLON {
  82572. /**
  82573. * Type of sub emitter
  82574. */
  82575. export enum SubEmitterType {
  82576. /**
  82577. * Attached to the particle over it's lifetime
  82578. */
  82579. ATTACHED = 0,
  82580. /**
  82581. * Created when the particle dies
  82582. */
  82583. END = 1
  82584. }
  82585. /**
  82586. * Sub emitter class used to emit particles from an existing particle
  82587. */
  82588. export class SubEmitter {
  82589. /**
  82590. * the particle system to be used by the sub emitter
  82591. */
  82592. particleSystem: ParticleSystem;
  82593. /**
  82594. * Type of the submitter (Default: END)
  82595. */
  82596. type: SubEmitterType;
  82597. /**
  82598. * 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)
  82599. * Note: This only is supported when using an emitter of type Mesh
  82600. */
  82601. inheritDirection: boolean;
  82602. /**
  82603. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82604. */
  82605. inheritedVelocityAmount: number;
  82606. /**
  82607. * Creates a sub emitter
  82608. * @param particleSystem the particle system to be used by the sub emitter
  82609. */
  82610. constructor(
  82611. /**
  82612. * the particle system to be used by the sub emitter
  82613. */
  82614. particleSystem: ParticleSystem);
  82615. /**
  82616. * Clones the sub emitter
  82617. * @returns the cloned sub emitter
  82618. */
  82619. clone(): SubEmitter;
  82620. /**
  82621. * Serialize current object to a JSON object
  82622. * @returns the serialized object
  82623. */
  82624. serialize(): any;
  82625. /** @hidden */
  82626. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82627. /**
  82628. * Creates a new SubEmitter from a serialized JSON version
  82629. * @param serializationObject defines the JSON object to read from
  82630. * @param scene defines the hosting scene
  82631. * @param rootUrl defines the rootUrl for data loading
  82632. * @returns a new SubEmitter
  82633. */
  82634. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82635. /** Release associated resources */
  82636. dispose(): void;
  82637. }
  82638. }
  82639. declare module BABYLON {
  82640. /** @hidden */
  82641. export var clipPlaneFragmentDeclaration: {
  82642. name: string;
  82643. shader: string;
  82644. };
  82645. }
  82646. declare module BABYLON {
  82647. /** @hidden */
  82648. export var imageProcessingDeclaration: {
  82649. name: string;
  82650. shader: string;
  82651. };
  82652. }
  82653. declare module BABYLON {
  82654. /** @hidden */
  82655. export var imageProcessingFunctions: {
  82656. name: string;
  82657. shader: string;
  82658. };
  82659. }
  82660. declare module BABYLON {
  82661. /** @hidden */
  82662. export var clipPlaneFragment: {
  82663. name: string;
  82664. shader: string;
  82665. };
  82666. }
  82667. declare module BABYLON {
  82668. /** @hidden */
  82669. export var particlesPixelShader: {
  82670. name: string;
  82671. shader: string;
  82672. };
  82673. }
  82674. declare module BABYLON {
  82675. /** @hidden */
  82676. export var clipPlaneVertexDeclaration: {
  82677. name: string;
  82678. shader: string;
  82679. };
  82680. }
  82681. declare module BABYLON {
  82682. /** @hidden */
  82683. export var clipPlaneVertex: {
  82684. name: string;
  82685. shader: string;
  82686. };
  82687. }
  82688. declare module BABYLON {
  82689. /** @hidden */
  82690. export var particlesVertexShader: {
  82691. name: string;
  82692. shader: string;
  82693. };
  82694. }
  82695. declare module BABYLON {
  82696. /**
  82697. * This represents a particle system in Babylon.
  82698. * 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.
  82699. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82700. * @example https://doc.babylonjs.com/babylon101/particles
  82701. */
  82702. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82703. /**
  82704. * Billboard mode will only apply to Y axis
  82705. */
  82706. static readonly BILLBOARDMODE_Y: number;
  82707. /**
  82708. * Billboard mode will apply to all axes
  82709. */
  82710. static readonly BILLBOARDMODE_ALL: number;
  82711. /**
  82712. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82713. */
  82714. static readonly BILLBOARDMODE_STRETCHED: number;
  82715. /**
  82716. * This function can be defined to provide custom update for active particles.
  82717. * This function will be called instead of regular update (age, position, color, etc.).
  82718. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82719. */
  82720. updateFunction: (particles: Particle[]) => void;
  82721. private _emitterWorldMatrix;
  82722. /**
  82723. * This function can be defined to specify initial direction for every new particle.
  82724. * It by default use the emitterType defined function
  82725. */
  82726. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82727. /**
  82728. * This function can be defined to specify initial position for every new particle.
  82729. * It by default use the emitterType defined function
  82730. */
  82731. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82732. /**
  82733. * @hidden
  82734. */
  82735. _inheritedVelocityOffset: Vector3;
  82736. /**
  82737. * An event triggered when the system is disposed
  82738. */
  82739. onDisposeObservable: Observable<ParticleSystem>;
  82740. private _onDisposeObserver;
  82741. /**
  82742. * Sets a callback that will be triggered when the system is disposed
  82743. */
  82744. onDispose: () => void;
  82745. private _particles;
  82746. private _epsilon;
  82747. private _capacity;
  82748. private _stockParticles;
  82749. private _newPartsExcess;
  82750. private _vertexData;
  82751. private _vertexBuffer;
  82752. private _vertexBuffers;
  82753. private _spriteBuffer;
  82754. private _indexBuffer;
  82755. private _effect;
  82756. private _customEffect;
  82757. private _cachedDefines;
  82758. private _scaledColorStep;
  82759. private _colorDiff;
  82760. private _scaledDirection;
  82761. private _scaledGravity;
  82762. private _currentRenderId;
  82763. private _alive;
  82764. private _useInstancing;
  82765. private _started;
  82766. private _stopped;
  82767. private _actualFrame;
  82768. private _scaledUpdateSpeed;
  82769. private _vertexBufferSize;
  82770. /** @hidden */
  82771. _currentEmitRateGradient: Nullable<FactorGradient>;
  82772. /** @hidden */
  82773. _currentEmitRate1: number;
  82774. /** @hidden */
  82775. _currentEmitRate2: number;
  82776. /** @hidden */
  82777. _currentStartSizeGradient: Nullable<FactorGradient>;
  82778. /** @hidden */
  82779. _currentStartSize1: number;
  82780. /** @hidden */
  82781. _currentStartSize2: number;
  82782. private readonly _rawTextureWidth;
  82783. private _rampGradientsTexture;
  82784. private _useRampGradients;
  82785. /** Gets or sets a boolean indicating that ramp gradients must be used
  82786. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82787. */
  82788. useRampGradients: boolean;
  82789. /**
  82790. * 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.
  82791. * 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: [])
  82792. */
  82793. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82794. private _subEmitters;
  82795. /**
  82796. * @hidden
  82797. * If the particle systems emitter should be disposed when the particle system is disposed
  82798. */
  82799. _disposeEmitterOnDispose: boolean;
  82800. /**
  82801. * The current active Sub-systems, this property is used by the root particle system only.
  82802. */
  82803. activeSubSystems: Array<ParticleSystem>;
  82804. private _rootParticleSystem;
  82805. /**
  82806. * Gets the current list of active particles
  82807. */
  82808. readonly particles: Particle[];
  82809. /**
  82810. * Returns the string "ParticleSystem"
  82811. * @returns a string containing the class name
  82812. */
  82813. getClassName(): string;
  82814. /**
  82815. * Instantiates a particle system.
  82816. * 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.
  82817. * @param name The name of the particle system
  82818. * @param capacity The max number of particles alive at the same time
  82819. * @param scene The scene the particle system belongs to
  82820. * @param customEffect a custom effect used to change the way particles are rendered by default
  82821. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82822. * @param epsilon Offset used to render the particles
  82823. */
  82824. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82825. private _addFactorGradient;
  82826. private _removeFactorGradient;
  82827. /**
  82828. * Adds a new life time gradient
  82829. * @param gradient defines the gradient to use (between 0 and 1)
  82830. * @param factor defines the life time factor to affect to the specified gradient
  82831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82832. * @returns the current particle system
  82833. */
  82834. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82835. /**
  82836. * Remove a specific life time gradient
  82837. * @param gradient defines the gradient to remove
  82838. * @returns the current particle system
  82839. */
  82840. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82841. /**
  82842. * Adds a new size gradient
  82843. * @param gradient defines the gradient to use (between 0 and 1)
  82844. * @param factor defines the size factor to affect to the specified gradient
  82845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82846. * @returns the current particle system
  82847. */
  82848. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82849. /**
  82850. * Remove a specific size gradient
  82851. * @param gradient defines the gradient to remove
  82852. * @returns the current particle system
  82853. */
  82854. removeSizeGradient(gradient: number): IParticleSystem;
  82855. /**
  82856. * Adds a new color remap gradient
  82857. * @param gradient defines the gradient to use (between 0 and 1)
  82858. * @param min defines the color remap minimal range
  82859. * @param max defines the color remap maximal range
  82860. * @returns the current particle system
  82861. */
  82862. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82863. /**
  82864. * Remove a specific color remap gradient
  82865. * @param gradient defines the gradient to remove
  82866. * @returns the current particle system
  82867. */
  82868. removeColorRemapGradient(gradient: number): IParticleSystem;
  82869. /**
  82870. * Adds a new alpha remap gradient
  82871. * @param gradient defines the gradient to use (between 0 and 1)
  82872. * @param min defines the alpha remap minimal range
  82873. * @param max defines the alpha remap maximal range
  82874. * @returns the current particle system
  82875. */
  82876. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82877. /**
  82878. * Remove a specific alpha remap gradient
  82879. * @param gradient defines the gradient to remove
  82880. * @returns the current particle system
  82881. */
  82882. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82883. /**
  82884. * Adds a new angular speed gradient
  82885. * @param gradient defines the gradient to use (between 0 and 1)
  82886. * @param factor defines the angular speed to affect to the specified gradient
  82887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82888. * @returns the current particle system
  82889. */
  82890. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82891. /**
  82892. * Remove a specific angular speed gradient
  82893. * @param gradient defines the gradient to remove
  82894. * @returns the current particle system
  82895. */
  82896. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82897. /**
  82898. * Adds a new velocity gradient
  82899. * @param gradient defines the gradient to use (between 0 and 1)
  82900. * @param factor defines the velocity to affect to the specified gradient
  82901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82902. * @returns the current particle system
  82903. */
  82904. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82905. /**
  82906. * Remove a specific velocity gradient
  82907. * @param gradient defines the gradient to remove
  82908. * @returns the current particle system
  82909. */
  82910. removeVelocityGradient(gradient: number): IParticleSystem;
  82911. /**
  82912. * Adds a new limit velocity gradient
  82913. * @param gradient defines the gradient to use (between 0 and 1)
  82914. * @param factor defines the limit velocity value to affect to the specified gradient
  82915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82916. * @returns the current particle system
  82917. */
  82918. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82919. /**
  82920. * Remove a specific limit velocity gradient
  82921. * @param gradient defines the gradient to remove
  82922. * @returns the current particle system
  82923. */
  82924. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82925. /**
  82926. * Adds a new drag gradient
  82927. * @param gradient defines the gradient to use (between 0 and 1)
  82928. * @param factor defines the drag value to affect to the specified gradient
  82929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82930. * @returns the current particle system
  82931. */
  82932. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82933. /**
  82934. * Remove a specific drag gradient
  82935. * @param gradient defines the gradient to remove
  82936. * @returns the current particle system
  82937. */
  82938. removeDragGradient(gradient: number): IParticleSystem;
  82939. /**
  82940. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82941. * @param gradient defines the gradient to use (between 0 and 1)
  82942. * @param factor defines the emit rate value to affect to the specified gradient
  82943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82944. * @returns the current particle system
  82945. */
  82946. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82947. /**
  82948. * Remove a specific emit rate gradient
  82949. * @param gradient defines the gradient to remove
  82950. * @returns the current particle system
  82951. */
  82952. removeEmitRateGradient(gradient: number): IParticleSystem;
  82953. /**
  82954. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82955. * @param gradient defines the gradient to use (between 0 and 1)
  82956. * @param factor defines the start size value to affect to the specified gradient
  82957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82958. * @returns the current particle system
  82959. */
  82960. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82961. /**
  82962. * Remove a specific start size gradient
  82963. * @param gradient defines the gradient to remove
  82964. * @returns the current particle system
  82965. */
  82966. removeStartSizeGradient(gradient: number): IParticleSystem;
  82967. private _createRampGradientTexture;
  82968. /**
  82969. * Gets the current list of ramp gradients.
  82970. * You must use addRampGradient and removeRampGradient to udpate this list
  82971. * @returns the list of ramp gradients
  82972. */
  82973. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82974. /**
  82975. * Adds a new ramp gradient used to remap particle colors
  82976. * @param gradient defines the gradient to use (between 0 and 1)
  82977. * @param color defines the color to affect to the specified gradient
  82978. * @returns the current particle system
  82979. */
  82980. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82981. /**
  82982. * Remove a specific ramp gradient
  82983. * @param gradient defines the gradient to remove
  82984. * @returns the current particle system
  82985. */
  82986. removeRampGradient(gradient: number): ParticleSystem;
  82987. /**
  82988. * Adds a new color gradient
  82989. * @param gradient defines the gradient to use (between 0 and 1)
  82990. * @param color1 defines the color to affect to the specified gradient
  82991. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82992. * @returns this particle system
  82993. */
  82994. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82995. /**
  82996. * Remove a specific color gradient
  82997. * @param gradient defines the gradient to remove
  82998. * @returns this particle system
  82999. */
  83000. removeColorGradient(gradient: number): IParticleSystem;
  83001. private _fetchR;
  83002. protected _reset(): void;
  83003. private _resetEffect;
  83004. private _createVertexBuffers;
  83005. private _createIndexBuffer;
  83006. /**
  83007. * Gets the maximum number of particles active at the same time.
  83008. * @returns The max number of active particles.
  83009. */
  83010. getCapacity(): number;
  83011. /**
  83012. * Gets whether there are still active particles in the system.
  83013. * @returns True if it is alive, otherwise false.
  83014. */
  83015. isAlive(): boolean;
  83016. /**
  83017. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83018. * @returns True if it has been started, otherwise false.
  83019. */
  83020. isStarted(): boolean;
  83021. private _prepareSubEmitterInternalArray;
  83022. /**
  83023. * Starts the particle system and begins to emit
  83024. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83025. */
  83026. start(delay?: number): void;
  83027. /**
  83028. * Stops the particle system.
  83029. * @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.
  83030. */
  83031. stop(stopSubEmitters?: boolean): void;
  83032. /**
  83033. * Remove all active particles
  83034. */
  83035. reset(): void;
  83036. /**
  83037. * @hidden (for internal use only)
  83038. */
  83039. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83040. /**
  83041. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83042. * Its lifetime will start back at 0.
  83043. */
  83044. recycleParticle: (particle: Particle) => void;
  83045. private _stopSubEmitters;
  83046. private _createParticle;
  83047. private _removeFromRoot;
  83048. private _emitFromParticle;
  83049. private _update;
  83050. /** @hidden */
  83051. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83052. /** @hidden */
  83053. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83054. /** @hidden */
  83055. private _getEffect;
  83056. /**
  83057. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83058. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83059. */
  83060. animate(preWarmOnly?: boolean): void;
  83061. private _appendParticleVertices;
  83062. /**
  83063. * Rebuilds the particle system.
  83064. */
  83065. rebuild(): void;
  83066. /**
  83067. * Is this system ready to be used/rendered
  83068. * @return true if the system is ready
  83069. */
  83070. isReady(): boolean;
  83071. private _render;
  83072. /**
  83073. * Renders the particle system in its current state.
  83074. * @returns the current number of particles
  83075. */
  83076. render(): number;
  83077. /**
  83078. * Disposes the particle system and free the associated resources
  83079. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83080. */
  83081. dispose(disposeTexture?: boolean): void;
  83082. /**
  83083. * Clones the particle system.
  83084. * @param name The name of the cloned object
  83085. * @param newEmitter The new emitter to use
  83086. * @returns the cloned particle system
  83087. */
  83088. clone(name: string, newEmitter: any): ParticleSystem;
  83089. /**
  83090. * Serializes the particle system to a JSON object.
  83091. * @returns the JSON object
  83092. */
  83093. serialize(): any;
  83094. /** @hidden */
  83095. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83096. /** @hidden */
  83097. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83098. /**
  83099. * Parses a JSON object to create a particle system.
  83100. * @param parsedParticleSystem The JSON object to parse
  83101. * @param scene The scene to create the particle system in
  83102. * @param rootUrl The root url to use to load external dependencies like texture
  83103. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83104. * @returns the Parsed particle system
  83105. */
  83106. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83107. }
  83108. }
  83109. declare module BABYLON {
  83110. /**
  83111. * A particle represents one of the element emitted by a particle system.
  83112. * This is mainly define by its coordinates, direction, velocity and age.
  83113. */
  83114. export class Particle {
  83115. /**
  83116. * The particle system the particle belongs to.
  83117. */
  83118. particleSystem: ParticleSystem;
  83119. private static _Count;
  83120. /**
  83121. * Unique ID of the particle
  83122. */
  83123. id: number;
  83124. /**
  83125. * The world position of the particle in the scene.
  83126. */
  83127. position: Vector3;
  83128. /**
  83129. * The world direction of the particle in the scene.
  83130. */
  83131. direction: Vector3;
  83132. /**
  83133. * The color of the particle.
  83134. */
  83135. color: Color4;
  83136. /**
  83137. * The color change of the particle per step.
  83138. */
  83139. colorStep: Color4;
  83140. /**
  83141. * Defines how long will the life of the particle be.
  83142. */
  83143. lifeTime: number;
  83144. /**
  83145. * The current age of the particle.
  83146. */
  83147. age: number;
  83148. /**
  83149. * The current size of the particle.
  83150. */
  83151. size: number;
  83152. /**
  83153. * The current scale of the particle.
  83154. */
  83155. scale: Vector2;
  83156. /**
  83157. * The current angle of the particle.
  83158. */
  83159. angle: number;
  83160. /**
  83161. * Defines how fast is the angle changing.
  83162. */
  83163. angularSpeed: number;
  83164. /**
  83165. * Defines the cell index used by the particle to be rendered from a sprite.
  83166. */
  83167. cellIndex: number;
  83168. /**
  83169. * The information required to support color remapping
  83170. */
  83171. remapData: Vector4;
  83172. /** @hidden */
  83173. _randomCellOffset?: number;
  83174. /** @hidden */
  83175. _initialDirection: Nullable<Vector3>;
  83176. /** @hidden */
  83177. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83178. /** @hidden */
  83179. _initialStartSpriteCellID: number;
  83180. /** @hidden */
  83181. _initialEndSpriteCellID: number;
  83182. /** @hidden */
  83183. _currentColorGradient: Nullable<ColorGradient>;
  83184. /** @hidden */
  83185. _currentColor1: Color4;
  83186. /** @hidden */
  83187. _currentColor2: Color4;
  83188. /** @hidden */
  83189. _currentSizeGradient: Nullable<FactorGradient>;
  83190. /** @hidden */
  83191. _currentSize1: number;
  83192. /** @hidden */
  83193. _currentSize2: number;
  83194. /** @hidden */
  83195. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83196. /** @hidden */
  83197. _currentAngularSpeed1: number;
  83198. /** @hidden */
  83199. _currentAngularSpeed2: number;
  83200. /** @hidden */
  83201. _currentVelocityGradient: Nullable<FactorGradient>;
  83202. /** @hidden */
  83203. _currentVelocity1: number;
  83204. /** @hidden */
  83205. _currentVelocity2: number;
  83206. /** @hidden */
  83207. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83208. /** @hidden */
  83209. _currentLimitVelocity1: number;
  83210. /** @hidden */
  83211. _currentLimitVelocity2: number;
  83212. /** @hidden */
  83213. _currentDragGradient: Nullable<FactorGradient>;
  83214. /** @hidden */
  83215. _currentDrag1: number;
  83216. /** @hidden */
  83217. _currentDrag2: number;
  83218. /** @hidden */
  83219. _randomNoiseCoordinates1: Vector3;
  83220. /** @hidden */
  83221. _randomNoiseCoordinates2: Vector3;
  83222. /**
  83223. * Creates a new instance Particle
  83224. * @param particleSystem the particle system the particle belongs to
  83225. */
  83226. constructor(
  83227. /**
  83228. * The particle system the particle belongs to.
  83229. */
  83230. particleSystem: ParticleSystem);
  83231. private updateCellInfoFromSystem;
  83232. /**
  83233. * Defines how the sprite cell index is updated for the particle
  83234. */
  83235. updateCellIndex(): void;
  83236. /** @hidden */
  83237. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83238. /** @hidden */
  83239. _inheritParticleInfoToSubEmitters(): void;
  83240. /** @hidden */
  83241. _reset(): void;
  83242. /**
  83243. * Copy the properties of particle to another one.
  83244. * @param other the particle to copy the information to.
  83245. */
  83246. copyTo(other: Particle): void;
  83247. }
  83248. }
  83249. declare module BABYLON {
  83250. /**
  83251. * Particle emitter represents a volume emitting particles.
  83252. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83253. */
  83254. export interface IParticleEmitterType {
  83255. /**
  83256. * Called by the particle System when the direction is computed for the created particle.
  83257. * @param worldMatrix is the world matrix of the particle system
  83258. * @param directionToUpdate is the direction vector to update with the result
  83259. * @param particle is the particle we are computed the direction for
  83260. */
  83261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83262. /**
  83263. * Called by the particle System when the position is computed for the created particle.
  83264. * @param worldMatrix is the world matrix of the particle system
  83265. * @param positionToUpdate is the position vector to update with the result
  83266. * @param particle is the particle we are computed the position for
  83267. */
  83268. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83269. /**
  83270. * Clones the current emitter and returns a copy of it
  83271. * @returns the new emitter
  83272. */
  83273. clone(): IParticleEmitterType;
  83274. /**
  83275. * Called by the GPUParticleSystem to setup the update shader
  83276. * @param effect defines the update shader
  83277. */
  83278. applyToShader(effect: Effect): void;
  83279. /**
  83280. * Returns a string to use to update the GPU particles update shader
  83281. * @returns the effect defines string
  83282. */
  83283. getEffectDefines(): string;
  83284. /**
  83285. * Returns a string representing the class name
  83286. * @returns a string containing the class name
  83287. */
  83288. getClassName(): string;
  83289. /**
  83290. * Serializes the particle system to a JSON object.
  83291. * @returns the JSON object
  83292. */
  83293. serialize(): any;
  83294. /**
  83295. * Parse properties from a JSON object
  83296. * @param serializationObject defines the JSON object
  83297. */
  83298. parse(serializationObject: any): void;
  83299. }
  83300. }
  83301. declare module BABYLON {
  83302. /**
  83303. * Particle emitter emitting particles from the inside of a box.
  83304. * It emits the particles randomly between 2 given directions.
  83305. */
  83306. export class BoxParticleEmitter implements IParticleEmitterType {
  83307. /**
  83308. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83309. */
  83310. direction1: Vector3;
  83311. /**
  83312. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83313. */
  83314. direction2: Vector3;
  83315. /**
  83316. * 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.
  83317. */
  83318. minEmitBox: Vector3;
  83319. /**
  83320. * 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.
  83321. */
  83322. maxEmitBox: Vector3;
  83323. /**
  83324. * Creates a new instance BoxParticleEmitter
  83325. */
  83326. constructor();
  83327. /**
  83328. * Called by the particle System when the direction is computed for the created particle.
  83329. * @param worldMatrix is the world matrix of the particle system
  83330. * @param directionToUpdate is the direction vector to update with the result
  83331. * @param particle is the particle we are computed the direction for
  83332. */
  83333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83334. /**
  83335. * Called by the particle System when the position is computed for the created particle.
  83336. * @param worldMatrix is the world matrix of the particle system
  83337. * @param positionToUpdate is the position vector to update with the result
  83338. * @param particle is the particle we are computed the position for
  83339. */
  83340. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83341. /**
  83342. * Clones the current emitter and returns a copy of it
  83343. * @returns the new emitter
  83344. */
  83345. clone(): BoxParticleEmitter;
  83346. /**
  83347. * Called by the GPUParticleSystem to setup the update shader
  83348. * @param effect defines the update shader
  83349. */
  83350. applyToShader(effect: Effect): void;
  83351. /**
  83352. * Returns a string to use to update the GPU particles update shader
  83353. * @returns a string containng the defines string
  83354. */
  83355. getEffectDefines(): string;
  83356. /**
  83357. * Returns the string "BoxParticleEmitter"
  83358. * @returns a string containing the class name
  83359. */
  83360. getClassName(): string;
  83361. /**
  83362. * Serializes the particle system to a JSON object.
  83363. * @returns the JSON object
  83364. */
  83365. serialize(): any;
  83366. /**
  83367. * Parse properties from a JSON object
  83368. * @param serializationObject defines the JSON object
  83369. */
  83370. parse(serializationObject: any): void;
  83371. }
  83372. }
  83373. declare module BABYLON {
  83374. /**
  83375. * Particle emitter emitting particles from the inside of a cone.
  83376. * It emits the particles alongside the cone volume from the base to the particle.
  83377. * The emission direction might be randomized.
  83378. */
  83379. export class ConeParticleEmitter implements IParticleEmitterType {
  83380. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83381. directionRandomizer: number;
  83382. private _radius;
  83383. private _angle;
  83384. private _height;
  83385. /**
  83386. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83387. */
  83388. radiusRange: number;
  83389. /**
  83390. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83391. */
  83392. heightRange: number;
  83393. /**
  83394. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83395. */
  83396. emitFromSpawnPointOnly: boolean;
  83397. /**
  83398. * Gets or sets the radius of the emission cone
  83399. */
  83400. radius: number;
  83401. /**
  83402. * Gets or sets the angle of the emission cone
  83403. */
  83404. angle: number;
  83405. private _buildHeight;
  83406. /**
  83407. * Creates a new instance ConeParticleEmitter
  83408. * @param radius the radius of the emission cone (1 by default)
  83409. * @param angle the cone base angle (PI by default)
  83410. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83411. */
  83412. constructor(radius?: number, angle?: number,
  83413. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83414. directionRandomizer?: number);
  83415. /**
  83416. * Called by the particle System when the direction is computed for the created particle.
  83417. * @param worldMatrix is the world matrix of the particle system
  83418. * @param directionToUpdate is the direction vector to update with the result
  83419. * @param particle is the particle we are computed the direction for
  83420. */
  83421. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83422. /**
  83423. * Called by the particle System when the position is computed for the created particle.
  83424. * @param worldMatrix is the world matrix of the particle system
  83425. * @param positionToUpdate is the position vector to update with the result
  83426. * @param particle is the particle we are computed the position for
  83427. */
  83428. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83429. /**
  83430. * Clones the current emitter and returns a copy of it
  83431. * @returns the new emitter
  83432. */
  83433. clone(): ConeParticleEmitter;
  83434. /**
  83435. * Called by the GPUParticleSystem to setup the update shader
  83436. * @param effect defines the update shader
  83437. */
  83438. applyToShader(effect: Effect): void;
  83439. /**
  83440. * Returns a string to use to update the GPU particles update shader
  83441. * @returns a string containng the defines string
  83442. */
  83443. getEffectDefines(): string;
  83444. /**
  83445. * Returns the string "ConeParticleEmitter"
  83446. * @returns a string containing the class name
  83447. */
  83448. getClassName(): string;
  83449. /**
  83450. * Serializes the particle system to a JSON object.
  83451. * @returns the JSON object
  83452. */
  83453. serialize(): any;
  83454. /**
  83455. * Parse properties from a JSON object
  83456. * @param serializationObject defines the JSON object
  83457. */
  83458. parse(serializationObject: any): void;
  83459. }
  83460. }
  83461. declare module BABYLON {
  83462. /**
  83463. * Particle emitter emitting particles from the inside of a cylinder.
  83464. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83465. */
  83466. export class CylinderParticleEmitter implements IParticleEmitterType {
  83467. /**
  83468. * The radius of the emission cylinder.
  83469. */
  83470. radius: number;
  83471. /**
  83472. * The height of the emission cylinder.
  83473. */
  83474. height: number;
  83475. /**
  83476. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83477. */
  83478. radiusRange: number;
  83479. /**
  83480. * How much to randomize the particle direction [0-1].
  83481. */
  83482. directionRandomizer: number;
  83483. /**
  83484. * Creates a new instance CylinderParticleEmitter
  83485. * @param radius the radius of the emission cylinder (1 by default)
  83486. * @param height the height of the emission cylinder (1 by default)
  83487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83488. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83489. */
  83490. constructor(
  83491. /**
  83492. * The radius of the emission cylinder.
  83493. */
  83494. radius?: number,
  83495. /**
  83496. * The height of the emission cylinder.
  83497. */
  83498. height?: number,
  83499. /**
  83500. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83501. */
  83502. radiusRange?: number,
  83503. /**
  83504. * How much to randomize the particle direction [0-1].
  83505. */
  83506. directionRandomizer?: number);
  83507. /**
  83508. * Called by the particle System when the direction is computed for the created particle.
  83509. * @param worldMatrix is the world matrix of the particle system
  83510. * @param directionToUpdate is the direction vector to update with the result
  83511. * @param particle is the particle we are computed the direction for
  83512. */
  83513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83514. /**
  83515. * Called by the particle System when the position is computed for the created particle.
  83516. * @param worldMatrix is the world matrix of the particle system
  83517. * @param positionToUpdate is the position vector to update with the result
  83518. * @param particle is the particle we are computed the position for
  83519. */
  83520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83521. /**
  83522. * Clones the current emitter and returns a copy of it
  83523. * @returns the new emitter
  83524. */
  83525. clone(): CylinderParticleEmitter;
  83526. /**
  83527. * Called by the GPUParticleSystem to setup the update shader
  83528. * @param effect defines the update shader
  83529. */
  83530. applyToShader(effect: Effect): void;
  83531. /**
  83532. * Returns a string to use to update the GPU particles update shader
  83533. * @returns a string containng the defines string
  83534. */
  83535. getEffectDefines(): string;
  83536. /**
  83537. * Returns the string "CylinderParticleEmitter"
  83538. * @returns a string containing the class name
  83539. */
  83540. getClassName(): string;
  83541. /**
  83542. * Serializes the particle system to a JSON object.
  83543. * @returns the JSON object
  83544. */
  83545. serialize(): any;
  83546. /**
  83547. * Parse properties from a JSON object
  83548. * @param serializationObject defines the JSON object
  83549. */
  83550. parse(serializationObject: any): void;
  83551. }
  83552. /**
  83553. * Particle emitter emitting particles from the inside of a cylinder.
  83554. * It emits the particles randomly between two vectors.
  83555. */
  83556. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83557. /**
  83558. * The min limit of the emission direction.
  83559. */
  83560. direction1: Vector3;
  83561. /**
  83562. * The max limit of the emission direction.
  83563. */
  83564. direction2: Vector3;
  83565. /**
  83566. * Creates a new instance CylinderDirectedParticleEmitter
  83567. * @param radius the radius of the emission cylinder (1 by default)
  83568. * @param height the height of the emission cylinder (1 by default)
  83569. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83570. * @param direction1 the min limit of the emission direction (up vector by default)
  83571. * @param direction2 the max limit of the emission direction (up vector by default)
  83572. */
  83573. constructor(radius?: number, height?: number, radiusRange?: number,
  83574. /**
  83575. * The min limit of the emission direction.
  83576. */
  83577. direction1?: Vector3,
  83578. /**
  83579. * The max limit of the emission direction.
  83580. */
  83581. direction2?: Vector3);
  83582. /**
  83583. * Called by the particle System when the direction is computed for the created particle.
  83584. * @param worldMatrix is the world matrix of the particle system
  83585. * @param directionToUpdate is the direction vector to update with the result
  83586. * @param particle is the particle we are computed the direction for
  83587. */
  83588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83589. /**
  83590. * Clones the current emitter and returns a copy of it
  83591. * @returns the new emitter
  83592. */
  83593. clone(): CylinderDirectedParticleEmitter;
  83594. /**
  83595. * Called by the GPUParticleSystem to setup the update shader
  83596. * @param effect defines the update shader
  83597. */
  83598. applyToShader(effect: Effect): void;
  83599. /**
  83600. * Returns a string to use to update the GPU particles update shader
  83601. * @returns a string containng the defines string
  83602. */
  83603. getEffectDefines(): string;
  83604. /**
  83605. * Returns the string "CylinderDirectedParticleEmitter"
  83606. * @returns a string containing the class name
  83607. */
  83608. getClassName(): string;
  83609. /**
  83610. * Serializes the particle system to a JSON object.
  83611. * @returns the JSON object
  83612. */
  83613. serialize(): any;
  83614. /**
  83615. * Parse properties from a JSON object
  83616. * @param serializationObject defines the JSON object
  83617. */
  83618. parse(serializationObject: any): void;
  83619. }
  83620. }
  83621. declare module BABYLON {
  83622. /**
  83623. * Particle emitter emitting particles from the inside of a hemisphere.
  83624. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83625. */
  83626. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83627. /**
  83628. * The radius of the emission hemisphere.
  83629. */
  83630. radius: number;
  83631. /**
  83632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83633. */
  83634. radiusRange: number;
  83635. /**
  83636. * How much to randomize the particle direction [0-1].
  83637. */
  83638. directionRandomizer: number;
  83639. /**
  83640. * Creates a new instance HemisphericParticleEmitter
  83641. * @param radius the radius of the emission hemisphere (1 by default)
  83642. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83643. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83644. */
  83645. constructor(
  83646. /**
  83647. * The radius of the emission hemisphere.
  83648. */
  83649. radius?: number,
  83650. /**
  83651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83652. */
  83653. radiusRange?: number,
  83654. /**
  83655. * How much to randomize the particle direction [0-1].
  83656. */
  83657. directionRandomizer?: number);
  83658. /**
  83659. * Called by the particle System when the direction is computed for the created particle.
  83660. * @param worldMatrix is the world matrix of the particle system
  83661. * @param directionToUpdate is the direction vector to update with the result
  83662. * @param particle is the particle we are computed the direction for
  83663. */
  83664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83665. /**
  83666. * Called by the particle System when the position is computed for the created particle.
  83667. * @param worldMatrix is the world matrix of the particle system
  83668. * @param positionToUpdate is the position vector to update with the result
  83669. * @param particle is the particle we are computed the position for
  83670. */
  83671. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83672. /**
  83673. * Clones the current emitter and returns a copy of it
  83674. * @returns the new emitter
  83675. */
  83676. clone(): HemisphericParticleEmitter;
  83677. /**
  83678. * Called by the GPUParticleSystem to setup the update shader
  83679. * @param effect defines the update shader
  83680. */
  83681. applyToShader(effect: Effect): void;
  83682. /**
  83683. * Returns a string to use to update the GPU particles update shader
  83684. * @returns a string containng the defines string
  83685. */
  83686. getEffectDefines(): string;
  83687. /**
  83688. * Returns the string "HemisphericParticleEmitter"
  83689. * @returns a string containing the class name
  83690. */
  83691. getClassName(): string;
  83692. /**
  83693. * Serializes the particle system to a JSON object.
  83694. * @returns the JSON object
  83695. */
  83696. serialize(): any;
  83697. /**
  83698. * Parse properties from a JSON object
  83699. * @param serializationObject defines the JSON object
  83700. */
  83701. parse(serializationObject: any): void;
  83702. }
  83703. }
  83704. declare module BABYLON {
  83705. /**
  83706. * Particle emitter emitting particles from a point.
  83707. * It emits the particles randomly between 2 given directions.
  83708. */
  83709. export class PointParticleEmitter implements IParticleEmitterType {
  83710. /**
  83711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83712. */
  83713. direction1: Vector3;
  83714. /**
  83715. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83716. */
  83717. direction2: Vector3;
  83718. /**
  83719. * Creates a new instance PointParticleEmitter
  83720. */
  83721. constructor();
  83722. /**
  83723. * Called by the particle System when the direction is computed for the created particle.
  83724. * @param worldMatrix is the world matrix of the particle system
  83725. * @param directionToUpdate is the direction vector to update with the result
  83726. * @param particle is the particle we are computed the direction for
  83727. */
  83728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83729. /**
  83730. * Called by the particle System when the position is computed for the created particle.
  83731. * @param worldMatrix is the world matrix of the particle system
  83732. * @param positionToUpdate is the position vector to update with the result
  83733. * @param particle is the particle we are computed the position for
  83734. */
  83735. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83736. /**
  83737. * Clones the current emitter and returns a copy of it
  83738. * @returns the new emitter
  83739. */
  83740. clone(): PointParticleEmitter;
  83741. /**
  83742. * Called by the GPUParticleSystem to setup the update shader
  83743. * @param effect defines the update shader
  83744. */
  83745. applyToShader(effect: Effect): void;
  83746. /**
  83747. * Returns a string to use to update the GPU particles update shader
  83748. * @returns a string containng the defines string
  83749. */
  83750. getEffectDefines(): string;
  83751. /**
  83752. * Returns the string "PointParticleEmitter"
  83753. * @returns a string containing the class name
  83754. */
  83755. getClassName(): string;
  83756. /**
  83757. * Serializes the particle system to a JSON object.
  83758. * @returns the JSON object
  83759. */
  83760. serialize(): any;
  83761. /**
  83762. * Parse properties from a JSON object
  83763. * @param serializationObject defines the JSON object
  83764. */
  83765. parse(serializationObject: any): void;
  83766. }
  83767. }
  83768. declare module BABYLON {
  83769. /**
  83770. * Particle emitter emitting particles from the inside of a sphere.
  83771. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83772. */
  83773. export class SphereParticleEmitter implements IParticleEmitterType {
  83774. /**
  83775. * The radius of the emission sphere.
  83776. */
  83777. radius: number;
  83778. /**
  83779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83780. */
  83781. radiusRange: number;
  83782. /**
  83783. * How much to randomize the particle direction [0-1].
  83784. */
  83785. directionRandomizer: number;
  83786. /**
  83787. * Creates a new instance SphereParticleEmitter
  83788. * @param radius the radius of the emission sphere (1 by default)
  83789. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83790. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83791. */
  83792. constructor(
  83793. /**
  83794. * The radius of the emission sphere.
  83795. */
  83796. radius?: number,
  83797. /**
  83798. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83799. */
  83800. radiusRange?: number,
  83801. /**
  83802. * How much to randomize the particle direction [0-1].
  83803. */
  83804. directionRandomizer?: number);
  83805. /**
  83806. * Called by the particle System when the direction is computed for the created particle.
  83807. * @param worldMatrix is the world matrix of the particle system
  83808. * @param directionToUpdate is the direction vector to update with the result
  83809. * @param particle is the particle we are computed the direction for
  83810. */
  83811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83812. /**
  83813. * Called by the particle System when the position is computed for the created particle.
  83814. * @param worldMatrix is the world matrix of the particle system
  83815. * @param positionToUpdate is the position vector to update with the result
  83816. * @param particle is the particle we are computed the position for
  83817. */
  83818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83819. /**
  83820. * Clones the current emitter and returns a copy of it
  83821. * @returns the new emitter
  83822. */
  83823. clone(): SphereParticleEmitter;
  83824. /**
  83825. * Called by the GPUParticleSystem to setup the update shader
  83826. * @param effect defines the update shader
  83827. */
  83828. applyToShader(effect: Effect): void;
  83829. /**
  83830. * Returns a string to use to update the GPU particles update shader
  83831. * @returns a string containng the defines string
  83832. */
  83833. getEffectDefines(): string;
  83834. /**
  83835. * Returns the string "SphereParticleEmitter"
  83836. * @returns a string containing the class name
  83837. */
  83838. getClassName(): string;
  83839. /**
  83840. * Serializes the particle system to a JSON object.
  83841. * @returns the JSON object
  83842. */
  83843. serialize(): any;
  83844. /**
  83845. * Parse properties from a JSON object
  83846. * @param serializationObject defines the JSON object
  83847. */
  83848. parse(serializationObject: any): void;
  83849. }
  83850. /**
  83851. * Particle emitter emitting particles from the inside of a sphere.
  83852. * It emits the particles randomly between two vectors.
  83853. */
  83854. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83855. /**
  83856. * The min limit of the emission direction.
  83857. */
  83858. direction1: Vector3;
  83859. /**
  83860. * The max limit of the emission direction.
  83861. */
  83862. direction2: Vector3;
  83863. /**
  83864. * Creates a new instance SphereDirectedParticleEmitter
  83865. * @param radius the radius of the emission sphere (1 by default)
  83866. * @param direction1 the min limit of the emission direction (up vector by default)
  83867. * @param direction2 the max limit of the emission direction (up vector by default)
  83868. */
  83869. constructor(radius?: number,
  83870. /**
  83871. * The min limit of the emission direction.
  83872. */
  83873. direction1?: Vector3,
  83874. /**
  83875. * The max limit of the emission direction.
  83876. */
  83877. direction2?: Vector3);
  83878. /**
  83879. * Called by the particle System when the direction is computed for the created particle.
  83880. * @param worldMatrix is the world matrix of the particle system
  83881. * @param directionToUpdate is the direction vector to update with the result
  83882. * @param particle is the particle we are computed the direction for
  83883. */
  83884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83885. /**
  83886. * Clones the current emitter and returns a copy of it
  83887. * @returns the new emitter
  83888. */
  83889. clone(): SphereDirectedParticleEmitter;
  83890. /**
  83891. * Called by the GPUParticleSystem to setup the update shader
  83892. * @param effect defines the update shader
  83893. */
  83894. applyToShader(effect: Effect): void;
  83895. /**
  83896. * Returns a string to use to update the GPU particles update shader
  83897. * @returns a string containng the defines string
  83898. */
  83899. getEffectDefines(): string;
  83900. /**
  83901. * Returns the string "SphereDirectedParticleEmitter"
  83902. * @returns a string containing the class name
  83903. */
  83904. getClassName(): string;
  83905. /**
  83906. * Serializes the particle system to a JSON object.
  83907. * @returns the JSON object
  83908. */
  83909. serialize(): any;
  83910. /**
  83911. * Parse properties from a JSON object
  83912. * @param serializationObject defines the JSON object
  83913. */
  83914. parse(serializationObject: any): void;
  83915. }
  83916. }
  83917. declare module BABYLON {
  83918. /**
  83919. * Interface representing a particle system in Babylon.js.
  83920. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83921. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83922. */
  83923. export interface IParticleSystem {
  83924. /**
  83925. * List of animations used by the particle system.
  83926. */
  83927. animations: Animation[];
  83928. /**
  83929. * The id of the Particle system.
  83930. */
  83931. id: string;
  83932. /**
  83933. * The name of the Particle system.
  83934. */
  83935. name: string;
  83936. /**
  83937. * The emitter represents the Mesh or position we are attaching the particle system to.
  83938. */
  83939. emitter: Nullable<AbstractMesh | Vector3>;
  83940. /**
  83941. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83942. */
  83943. isBillboardBased: boolean;
  83944. /**
  83945. * The rendering group used by the Particle system to chose when to render.
  83946. */
  83947. renderingGroupId: number;
  83948. /**
  83949. * The layer mask we are rendering the particles through.
  83950. */
  83951. layerMask: number;
  83952. /**
  83953. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83954. */
  83955. updateSpeed: number;
  83956. /**
  83957. * The amount of time the particle system is running (depends of the overall update speed).
  83958. */
  83959. targetStopDuration: number;
  83960. /**
  83961. * The texture used to render each particle. (this can be a spritesheet)
  83962. */
  83963. particleTexture: Nullable<Texture>;
  83964. /**
  83965. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83966. */
  83967. blendMode: number;
  83968. /**
  83969. * Minimum life time of emitting particles.
  83970. */
  83971. minLifeTime: number;
  83972. /**
  83973. * Maximum life time of emitting particles.
  83974. */
  83975. maxLifeTime: number;
  83976. /**
  83977. * Minimum Size of emitting particles.
  83978. */
  83979. minSize: number;
  83980. /**
  83981. * Maximum Size of emitting particles.
  83982. */
  83983. maxSize: number;
  83984. /**
  83985. * Minimum scale of emitting particles on X axis.
  83986. */
  83987. minScaleX: number;
  83988. /**
  83989. * Maximum scale of emitting particles on X axis.
  83990. */
  83991. maxScaleX: number;
  83992. /**
  83993. * Minimum scale of emitting particles on Y axis.
  83994. */
  83995. minScaleY: number;
  83996. /**
  83997. * Maximum scale of emitting particles on Y axis.
  83998. */
  83999. maxScaleY: number;
  84000. /**
  84001. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84002. */
  84003. color1: Color4;
  84004. /**
  84005. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84006. */
  84007. color2: Color4;
  84008. /**
  84009. * Color the particle will have at the end of its lifetime.
  84010. */
  84011. colorDead: Color4;
  84012. /**
  84013. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84014. */
  84015. emitRate: number;
  84016. /**
  84017. * You can use gravity if you want to give an orientation to your particles.
  84018. */
  84019. gravity: Vector3;
  84020. /**
  84021. * Minimum power of emitting particles.
  84022. */
  84023. minEmitPower: number;
  84024. /**
  84025. * Maximum power of emitting particles.
  84026. */
  84027. maxEmitPower: number;
  84028. /**
  84029. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84030. */
  84031. minAngularSpeed: number;
  84032. /**
  84033. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84034. */
  84035. maxAngularSpeed: number;
  84036. /**
  84037. * Gets or sets the minimal initial rotation in radians.
  84038. */
  84039. minInitialRotation: number;
  84040. /**
  84041. * Gets or sets the maximal initial rotation in radians.
  84042. */
  84043. maxInitialRotation: number;
  84044. /**
  84045. * The particle emitter type defines the emitter used by the particle system.
  84046. * It can be for example box, sphere, or cone...
  84047. */
  84048. particleEmitterType: Nullable<IParticleEmitterType>;
  84049. /**
  84050. * Defines the delay in milliseconds before starting the system (0 by default)
  84051. */
  84052. startDelay: number;
  84053. /**
  84054. * 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
  84055. */
  84056. preWarmCycles: number;
  84057. /**
  84058. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84059. */
  84060. preWarmStepOffset: number;
  84061. /**
  84062. * 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)
  84063. */
  84064. spriteCellChangeSpeed: number;
  84065. /**
  84066. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84067. */
  84068. startSpriteCellID: number;
  84069. /**
  84070. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84071. */
  84072. endSpriteCellID: number;
  84073. /**
  84074. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84075. */
  84076. spriteCellWidth: number;
  84077. /**
  84078. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84079. */
  84080. spriteCellHeight: number;
  84081. /**
  84082. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84083. */
  84084. spriteRandomStartCell: boolean;
  84085. /**
  84086. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84087. */
  84088. isAnimationSheetEnabled: boolean;
  84089. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84090. translationPivot: Vector2;
  84091. /**
  84092. * Gets or sets a texture used to add random noise to particle positions
  84093. */
  84094. noiseTexture: Nullable<BaseTexture>;
  84095. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84096. noiseStrength: Vector3;
  84097. /**
  84098. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84099. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84100. */
  84101. billboardMode: number;
  84102. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84103. limitVelocityDamping: number;
  84104. /**
  84105. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84106. */
  84107. beginAnimationOnStart: boolean;
  84108. /**
  84109. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84110. */
  84111. beginAnimationFrom: number;
  84112. /**
  84113. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84114. */
  84115. beginAnimationTo: number;
  84116. /**
  84117. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84118. */
  84119. beginAnimationLoop: boolean;
  84120. /**
  84121. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84122. */
  84123. disposeOnStop: boolean;
  84124. /**
  84125. * Gets the maximum number of particles active at the same time.
  84126. * @returns The max number of active particles.
  84127. */
  84128. getCapacity(): number;
  84129. /**
  84130. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84131. * @returns True if it has been started, otherwise false.
  84132. */
  84133. isStarted(): boolean;
  84134. /**
  84135. * Animates the particle system for this frame.
  84136. */
  84137. animate(): void;
  84138. /**
  84139. * Renders the particle system in its current state.
  84140. * @returns the current number of particles
  84141. */
  84142. render(): number;
  84143. /**
  84144. * Dispose the particle system and frees its associated resources.
  84145. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84146. */
  84147. dispose(disposeTexture?: boolean): void;
  84148. /**
  84149. * Clones the particle system.
  84150. * @param name The name of the cloned object
  84151. * @param newEmitter The new emitter to use
  84152. * @returns the cloned particle system
  84153. */
  84154. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84155. /**
  84156. * Serializes the particle system to a JSON object.
  84157. * @returns the JSON object
  84158. */
  84159. serialize(): any;
  84160. /**
  84161. * Rebuild the particle system
  84162. */
  84163. rebuild(): void;
  84164. /**
  84165. * Starts the particle system and begins to emit
  84166. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84167. */
  84168. start(delay?: number): void;
  84169. /**
  84170. * Stops the particle system.
  84171. */
  84172. stop(): void;
  84173. /**
  84174. * Remove all active particles
  84175. */
  84176. reset(): void;
  84177. /**
  84178. * Is this system ready to be used/rendered
  84179. * @return true if the system is ready
  84180. */
  84181. isReady(): boolean;
  84182. /**
  84183. * Adds a new color gradient
  84184. * @param gradient defines the gradient to use (between 0 and 1)
  84185. * @param color1 defines the color to affect to the specified gradient
  84186. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84187. * @returns the current particle system
  84188. */
  84189. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84190. /**
  84191. * Remove a specific color gradient
  84192. * @param gradient defines the gradient to remove
  84193. * @returns the current particle system
  84194. */
  84195. removeColorGradient(gradient: number): IParticleSystem;
  84196. /**
  84197. * Adds a new size gradient
  84198. * @param gradient defines the gradient to use (between 0 and 1)
  84199. * @param factor defines the size factor to affect to the specified gradient
  84200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84201. * @returns the current particle system
  84202. */
  84203. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84204. /**
  84205. * Remove a specific size gradient
  84206. * @param gradient defines the gradient to remove
  84207. * @returns the current particle system
  84208. */
  84209. removeSizeGradient(gradient: number): IParticleSystem;
  84210. /**
  84211. * Gets the current list of color gradients.
  84212. * You must use addColorGradient and removeColorGradient to udpate this list
  84213. * @returns the list of color gradients
  84214. */
  84215. getColorGradients(): Nullable<Array<ColorGradient>>;
  84216. /**
  84217. * Gets the current list of size gradients.
  84218. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84219. * @returns the list of size gradients
  84220. */
  84221. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84222. /**
  84223. * Gets the current list of angular speed gradients.
  84224. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84225. * @returns the list of angular speed gradients
  84226. */
  84227. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84228. /**
  84229. * Adds a new angular speed gradient
  84230. * @param gradient defines the gradient to use (between 0 and 1)
  84231. * @param factor defines the angular speed to affect to the specified gradient
  84232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84233. * @returns the current particle system
  84234. */
  84235. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84236. /**
  84237. * Remove a specific angular speed gradient
  84238. * @param gradient defines the gradient to remove
  84239. * @returns the current particle system
  84240. */
  84241. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84242. /**
  84243. * Gets the current list of velocity gradients.
  84244. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84245. * @returns the list of velocity gradients
  84246. */
  84247. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84248. /**
  84249. * Adds a new velocity gradient
  84250. * @param gradient defines the gradient to use (between 0 and 1)
  84251. * @param factor defines the velocity to affect to the specified gradient
  84252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84253. * @returns the current particle system
  84254. */
  84255. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84256. /**
  84257. * Remove a specific velocity gradient
  84258. * @param gradient defines the gradient to remove
  84259. * @returns the current particle system
  84260. */
  84261. removeVelocityGradient(gradient: number): IParticleSystem;
  84262. /**
  84263. * Gets the current list of limit velocity gradients.
  84264. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84265. * @returns the list of limit velocity gradients
  84266. */
  84267. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84268. /**
  84269. * Adds a new limit velocity gradient
  84270. * @param gradient defines the gradient to use (between 0 and 1)
  84271. * @param factor defines the limit velocity to affect to the specified gradient
  84272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84273. * @returns the current particle system
  84274. */
  84275. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84276. /**
  84277. * Remove a specific limit velocity gradient
  84278. * @param gradient defines the gradient to remove
  84279. * @returns the current particle system
  84280. */
  84281. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84282. /**
  84283. * Adds a new drag gradient
  84284. * @param gradient defines the gradient to use (between 0 and 1)
  84285. * @param factor defines the drag to affect to the specified gradient
  84286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84287. * @returns the current particle system
  84288. */
  84289. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84290. /**
  84291. * Remove a specific drag gradient
  84292. * @param gradient defines the gradient to remove
  84293. * @returns the current particle system
  84294. */
  84295. removeDragGradient(gradient: number): IParticleSystem;
  84296. /**
  84297. * Gets the current list of drag gradients.
  84298. * You must use addDragGradient and removeDragGradient to udpate this list
  84299. * @returns the list of drag gradients
  84300. */
  84301. getDragGradients(): Nullable<Array<FactorGradient>>;
  84302. /**
  84303. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84304. * @param gradient defines the gradient to use (between 0 and 1)
  84305. * @param factor defines the emit rate to affect to the specified gradient
  84306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84307. * @returns the current particle system
  84308. */
  84309. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84310. /**
  84311. * Remove a specific emit rate gradient
  84312. * @param gradient defines the gradient to remove
  84313. * @returns the current particle system
  84314. */
  84315. removeEmitRateGradient(gradient: number): IParticleSystem;
  84316. /**
  84317. * Gets the current list of emit rate gradients.
  84318. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84319. * @returns the list of emit rate gradients
  84320. */
  84321. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84322. /**
  84323. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84324. * @param gradient defines the gradient to use (between 0 and 1)
  84325. * @param factor defines the start size to affect to the specified gradient
  84326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84327. * @returns the current particle system
  84328. */
  84329. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84330. /**
  84331. * Remove a specific start size gradient
  84332. * @param gradient defines the gradient to remove
  84333. * @returns the current particle system
  84334. */
  84335. removeStartSizeGradient(gradient: number): IParticleSystem;
  84336. /**
  84337. * Gets the current list of start size gradients.
  84338. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84339. * @returns the list of start size gradients
  84340. */
  84341. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84342. /**
  84343. * Adds a new life time gradient
  84344. * @param gradient defines the gradient to use (between 0 and 1)
  84345. * @param factor defines the life time factor to affect to the specified gradient
  84346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84347. * @returns the current particle system
  84348. */
  84349. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84350. /**
  84351. * Remove a specific life time gradient
  84352. * @param gradient defines the gradient to remove
  84353. * @returns the current particle system
  84354. */
  84355. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84356. /**
  84357. * Gets the current list of life time gradients.
  84358. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84359. * @returns the list of life time gradients
  84360. */
  84361. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84362. /**
  84363. * Gets the current list of color gradients.
  84364. * You must use addColorGradient and removeColorGradient to udpate this list
  84365. * @returns the list of color gradients
  84366. */
  84367. getColorGradients(): Nullable<Array<ColorGradient>>;
  84368. /**
  84369. * Adds a new ramp gradient used to remap particle colors
  84370. * @param gradient defines the gradient to use (between 0 and 1)
  84371. * @param color defines the color to affect to the specified gradient
  84372. * @returns the current particle system
  84373. */
  84374. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84375. /**
  84376. * Gets the current list of ramp gradients.
  84377. * You must use addRampGradient and removeRampGradient to udpate this list
  84378. * @returns the list of ramp gradients
  84379. */
  84380. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84381. /** Gets or sets a boolean indicating that ramp gradients must be used
  84382. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84383. */
  84384. useRampGradients: boolean;
  84385. /**
  84386. * Adds a new color remap gradient
  84387. * @param gradient defines the gradient to use (between 0 and 1)
  84388. * @param min defines the color remap minimal range
  84389. * @param max defines the color remap maximal range
  84390. * @returns the current particle system
  84391. */
  84392. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84393. /**
  84394. * Gets the current list of color remap gradients.
  84395. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84396. * @returns the list of color remap gradients
  84397. */
  84398. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84399. /**
  84400. * Adds a new alpha remap gradient
  84401. * @param gradient defines the gradient to use (between 0 and 1)
  84402. * @param min defines the alpha remap minimal range
  84403. * @param max defines the alpha remap maximal range
  84404. * @returns the current particle system
  84405. */
  84406. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84407. /**
  84408. * Gets the current list of alpha remap gradients.
  84409. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84410. * @returns the list of alpha remap gradients
  84411. */
  84412. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84413. /**
  84414. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84415. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84416. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84417. * @returns the emitter
  84418. */
  84419. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84420. /**
  84421. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84422. * @param radius The radius of the hemisphere to emit from
  84423. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84424. * @returns the emitter
  84425. */
  84426. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84427. /**
  84428. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84429. * @param radius The radius of the sphere to emit from
  84430. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84431. * @returns the emitter
  84432. */
  84433. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84434. /**
  84435. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84436. * @param radius The radius of the sphere to emit from
  84437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84439. * @returns the emitter
  84440. */
  84441. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84442. /**
  84443. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84444. * @param radius The radius of the emission cylinder
  84445. * @param height The height of the emission cylinder
  84446. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84447. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84448. * @returns the emitter
  84449. */
  84450. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84451. /**
  84452. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84453. * @param radius The radius of the cylinder to emit from
  84454. * @param height The height of the emission cylinder
  84455. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84458. * @returns the emitter
  84459. */
  84460. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84461. /**
  84462. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84463. * @param radius The radius of the cone to emit from
  84464. * @param angle The base angle of the cone
  84465. * @returns the emitter
  84466. */
  84467. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84468. /**
  84469. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84470. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84471. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84472. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84473. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84474. * @returns the emitter
  84475. */
  84476. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84477. /**
  84478. * Get hosting scene
  84479. * @returns the scene
  84480. */
  84481. getScene(): Scene;
  84482. }
  84483. }
  84484. declare module BABYLON {
  84485. /**
  84486. * Creates an instance based on a source mesh.
  84487. */
  84488. export class InstancedMesh extends AbstractMesh {
  84489. private _sourceMesh;
  84490. private _currentLOD;
  84491. /** @hidden */
  84492. _indexInSourceMeshInstanceArray: number;
  84493. constructor(name: string, source: Mesh);
  84494. /**
  84495. * Returns the string "InstancedMesh".
  84496. */
  84497. getClassName(): string;
  84498. /** Gets the list of lights affecting that mesh */
  84499. readonly lightSources: Light[];
  84500. _resyncLightSources(): void;
  84501. _resyncLighSource(light: Light): void;
  84502. _removeLightSource(light: Light, dispose: boolean): void;
  84503. /**
  84504. * If the source mesh receives shadows
  84505. */
  84506. readonly receiveShadows: boolean;
  84507. /**
  84508. * The material of the source mesh
  84509. */
  84510. readonly material: Nullable<Material>;
  84511. /**
  84512. * Visibility of the source mesh
  84513. */
  84514. readonly visibility: number;
  84515. /**
  84516. * Skeleton of the source mesh
  84517. */
  84518. readonly skeleton: Nullable<Skeleton>;
  84519. /**
  84520. * Rendering ground id of the source mesh
  84521. */
  84522. renderingGroupId: number;
  84523. /**
  84524. * Returns the total number of vertices (integer).
  84525. */
  84526. getTotalVertices(): number;
  84527. /**
  84528. * Returns a positive integer : the total number of indices in this mesh geometry.
  84529. * @returns the numner of indices or zero if the mesh has no geometry.
  84530. */
  84531. getTotalIndices(): number;
  84532. /**
  84533. * The source mesh of the instance
  84534. */
  84535. readonly sourceMesh: Mesh;
  84536. /**
  84537. * Is this node ready to be used/rendered
  84538. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84539. * @return {boolean} is it ready
  84540. */
  84541. isReady(completeCheck?: boolean): boolean;
  84542. /**
  84543. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84544. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84545. * @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.
  84546. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84547. */
  84548. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84549. /**
  84550. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84551. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84552. * The `data` are either a numeric array either a Float32Array.
  84553. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84554. * 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).
  84555. * Note that a new underlying VertexBuffer object is created each call.
  84556. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84557. *
  84558. * Possible `kind` values :
  84559. * - VertexBuffer.PositionKind
  84560. * - VertexBuffer.UVKind
  84561. * - VertexBuffer.UV2Kind
  84562. * - VertexBuffer.UV3Kind
  84563. * - VertexBuffer.UV4Kind
  84564. * - VertexBuffer.UV5Kind
  84565. * - VertexBuffer.UV6Kind
  84566. * - VertexBuffer.ColorKind
  84567. * - VertexBuffer.MatricesIndicesKind
  84568. * - VertexBuffer.MatricesIndicesExtraKind
  84569. * - VertexBuffer.MatricesWeightsKind
  84570. * - VertexBuffer.MatricesWeightsExtraKind
  84571. *
  84572. * Returns the Mesh.
  84573. */
  84574. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84575. /**
  84576. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84577. * If the mesh has no geometry, it is simply returned as it is.
  84578. * The `data` are either a numeric array either a Float32Array.
  84579. * No new underlying VertexBuffer object is created.
  84580. * 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.
  84581. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84582. *
  84583. * Possible `kind` values :
  84584. * - VertexBuffer.PositionKind
  84585. * - VertexBuffer.UVKind
  84586. * - VertexBuffer.UV2Kind
  84587. * - VertexBuffer.UV3Kind
  84588. * - VertexBuffer.UV4Kind
  84589. * - VertexBuffer.UV5Kind
  84590. * - VertexBuffer.UV6Kind
  84591. * - VertexBuffer.ColorKind
  84592. * - VertexBuffer.MatricesIndicesKind
  84593. * - VertexBuffer.MatricesIndicesExtraKind
  84594. * - VertexBuffer.MatricesWeightsKind
  84595. * - VertexBuffer.MatricesWeightsExtraKind
  84596. *
  84597. * Returns the Mesh.
  84598. */
  84599. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84600. /**
  84601. * Sets the mesh indices.
  84602. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84603. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84604. * This method creates a new index buffer each call.
  84605. * Returns the Mesh.
  84606. */
  84607. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84608. /**
  84609. * Boolean : True if the mesh owns the requested kind of data.
  84610. */
  84611. isVerticesDataPresent(kind: string): boolean;
  84612. /**
  84613. * Returns an array of indices (IndicesArray).
  84614. */
  84615. getIndices(): Nullable<IndicesArray>;
  84616. readonly _positions: Nullable<Vector3[]>;
  84617. /**
  84618. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84619. * This means the mesh underlying bounding box and sphere are recomputed.
  84620. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84621. * @returns the current mesh
  84622. */
  84623. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84624. /** @hidden */
  84625. _preActivate(): InstancedMesh;
  84626. /** @hidden */
  84627. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84628. /** @hidden */
  84629. _postActivate(): void;
  84630. getWorldMatrix(): Matrix;
  84631. readonly isAnInstance: boolean;
  84632. /**
  84633. * Returns the current associated LOD AbstractMesh.
  84634. */
  84635. getLOD(camera: Camera): AbstractMesh;
  84636. /** @hidden */
  84637. _syncSubMeshes(): InstancedMesh;
  84638. /** @hidden */
  84639. _generatePointsArray(): boolean;
  84640. /**
  84641. * Creates a new InstancedMesh from the current mesh.
  84642. * - name (string) : the cloned mesh name
  84643. * - newParent (optional Node) : the optional Node to parent the clone to.
  84644. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84645. *
  84646. * Returns the clone.
  84647. */
  84648. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84649. /**
  84650. * Disposes the InstancedMesh.
  84651. * Returns nothing.
  84652. */
  84653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84654. }
  84655. }
  84656. declare module BABYLON {
  84657. /**
  84658. * Defines the options associated with the creation of a shader material.
  84659. */
  84660. export interface IShaderMaterialOptions {
  84661. /**
  84662. * Does the material work in alpha blend mode
  84663. */
  84664. needAlphaBlending: boolean;
  84665. /**
  84666. * Does the material work in alpha test mode
  84667. */
  84668. needAlphaTesting: boolean;
  84669. /**
  84670. * The list of attribute names used in the shader
  84671. */
  84672. attributes: string[];
  84673. /**
  84674. * The list of unifrom names used in the shader
  84675. */
  84676. uniforms: string[];
  84677. /**
  84678. * The list of UBO names used in the shader
  84679. */
  84680. uniformBuffers: string[];
  84681. /**
  84682. * The list of sampler names used in the shader
  84683. */
  84684. samplers: string[];
  84685. /**
  84686. * The list of defines used in the shader
  84687. */
  84688. defines: string[];
  84689. }
  84690. /**
  84691. * 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.
  84692. *
  84693. * This returned material effects how the mesh will look based on the code in the shaders.
  84694. *
  84695. * @see http://doc.babylonjs.com/how_to/shader_material
  84696. */
  84697. export class ShaderMaterial extends Material {
  84698. private _shaderPath;
  84699. private _options;
  84700. private _textures;
  84701. private _textureArrays;
  84702. private _floats;
  84703. private _ints;
  84704. private _floatsArrays;
  84705. private _colors3;
  84706. private _colors3Arrays;
  84707. private _colors4;
  84708. private _colors4Arrays;
  84709. private _vectors2;
  84710. private _vectors3;
  84711. private _vectors4;
  84712. private _matrices;
  84713. private _matrices3x3;
  84714. private _matrices2x2;
  84715. private _vectors2Arrays;
  84716. private _vectors3Arrays;
  84717. private _vectors4Arrays;
  84718. private _cachedWorldViewMatrix;
  84719. private _cachedWorldViewProjectionMatrix;
  84720. private _renderId;
  84721. /**
  84722. * Instantiate a new shader material.
  84723. * 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.
  84724. * This returned material effects how the mesh will look based on the code in the shaders.
  84725. * @see http://doc.babylonjs.com/how_to/shader_material
  84726. * @param name Define the name of the material in the scene
  84727. * @param scene Define the scene the material belongs to
  84728. * @param shaderPath Defines the route to the shader code in one of three ways:
  84729. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84730. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84731. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84732. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84733. * @param options Define the options used to create the shader
  84734. */
  84735. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84736. /**
  84737. * Gets the options used to compile the shader.
  84738. * They can be modified to trigger a new compilation
  84739. */
  84740. readonly options: IShaderMaterialOptions;
  84741. /**
  84742. * Gets the current class name of the material e.g. "ShaderMaterial"
  84743. * Mainly use in serialization.
  84744. * @returns the class name
  84745. */
  84746. getClassName(): string;
  84747. /**
  84748. * Specifies if the material will require alpha blending
  84749. * @returns a boolean specifying if alpha blending is needed
  84750. */
  84751. needAlphaBlending(): boolean;
  84752. /**
  84753. * Specifies if this material should be rendered in alpha test mode
  84754. * @returns a boolean specifying if an alpha test is needed.
  84755. */
  84756. needAlphaTesting(): boolean;
  84757. private _checkUniform;
  84758. /**
  84759. * Set a texture in the shader.
  84760. * @param name Define the name of the uniform samplers as defined in the shader
  84761. * @param texture Define the texture to bind to this sampler
  84762. * @return the material itself allowing "fluent" like uniform updates
  84763. */
  84764. setTexture(name: string, texture: Texture): ShaderMaterial;
  84765. /**
  84766. * Set a texture array in the shader.
  84767. * @param name Define the name of the uniform sampler array as defined in the shader
  84768. * @param textures Define the list of textures to bind to this sampler
  84769. * @return the material itself allowing "fluent" like uniform updates
  84770. */
  84771. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84772. /**
  84773. * Set a float in the shader.
  84774. * @param name Define the name of the uniform as defined in the shader
  84775. * @param value Define the value to give to the uniform
  84776. * @return the material itself allowing "fluent" like uniform updates
  84777. */
  84778. setFloat(name: string, value: number): ShaderMaterial;
  84779. /**
  84780. * Set a int in the shader.
  84781. * @param name Define the name of the uniform as defined in the shader
  84782. * @param value Define the value to give to the uniform
  84783. * @return the material itself allowing "fluent" like uniform updates
  84784. */
  84785. setInt(name: string, value: number): ShaderMaterial;
  84786. /**
  84787. * Set an array of floats in the shader.
  84788. * @param name Define the name of the uniform as defined in the shader
  84789. * @param value Define the value to give to the uniform
  84790. * @return the material itself allowing "fluent" like uniform updates
  84791. */
  84792. setFloats(name: string, value: number[]): ShaderMaterial;
  84793. /**
  84794. * Set a vec3 in the shader from a Color3.
  84795. * @param name Define the name of the uniform as defined in the shader
  84796. * @param value Define the value to give to the uniform
  84797. * @return the material itself allowing "fluent" like uniform updates
  84798. */
  84799. setColor3(name: string, value: Color3): ShaderMaterial;
  84800. /**
  84801. * Set a vec3 array in the shader from a Color3 array.
  84802. * @param name Define the name of the uniform as defined in the shader
  84803. * @param value Define the value to give to the uniform
  84804. * @return the material itself allowing "fluent" like uniform updates
  84805. */
  84806. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84807. /**
  84808. * Set a vec4 in the shader from a Color4.
  84809. * @param name Define the name of the uniform as defined in the shader
  84810. * @param value Define the value to give to the uniform
  84811. * @return the material itself allowing "fluent" like uniform updates
  84812. */
  84813. setColor4(name: string, value: Color4): ShaderMaterial;
  84814. /**
  84815. * Set a vec4 array in the shader from a Color4 array.
  84816. * @param name Define the name of the uniform as defined in the shader
  84817. * @param value Define the value to give to the uniform
  84818. * @return the material itself allowing "fluent" like uniform updates
  84819. */
  84820. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84821. /**
  84822. * Set a vec2 in the shader from a Vector2.
  84823. * @param name Define the name of the uniform as defined in the shader
  84824. * @param value Define the value to give to the uniform
  84825. * @return the material itself allowing "fluent" like uniform updates
  84826. */
  84827. setVector2(name: string, value: Vector2): ShaderMaterial;
  84828. /**
  84829. * Set a vec3 in the shader from a Vector3.
  84830. * @param name Define the name of the uniform as defined in the shader
  84831. * @param value Define the value to give to the uniform
  84832. * @return the material itself allowing "fluent" like uniform updates
  84833. */
  84834. setVector3(name: string, value: Vector3): ShaderMaterial;
  84835. /**
  84836. * Set a vec4 in the shader from a Vector4.
  84837. * @param name Define the name of the uniform as defined in the shader
  84838. * @param value Define the value to give to the uniform
  84839. * @return the material itself allowing "fluent" like uniform updates
  84840. */
  84841. setVector4(name: string, value: Vector4): ShaderMaterial;
  84842. /**
  84843. * Set a mat4 in the shader from a Matrix.
  84844. * @param name Define the name of the uniform as defined in the shader
  84845. * @param value Define the value to give to the uniform
  84846. * @return the material itself allowing "fluent" like uniform updates
  84847. */
  84848. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84849. /**
  84850. * Set a mat3 in the shader from a Float32Array.
  84851. * @param name Define the name of the uniform as defined in the shader
  84852. * @param value Define the value to give to the uniform
  84853. * @return the material itself allowing "fluent" like uniform updates
  84854. */
  84855. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84856. /**
  84857. * Set a mat2 in the shader from a Float32Array.
  84858. * @param name Define the name of the uniform as defined in the shader
  84859. * @param value Define the value to give to the uniform
  84860. * @return the material itself allowing "fluent" like uniform updates
  84861. */
  84862. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84863. /**
  84864. * Set a vec2 array in the shader from a number array.
  84865. * @param name Define the name of the uniform as defined in the shader
  84866. * @param value Define the value to give to the uniform
  84867. * @return the material itself allowing "fluent" like uniform updates
  84868. */
  84869. setArray2(name: string, value: number[]): ShaderMaterial;
  84870. /**
  84871. * Set a vec3 array in the shader from a number array.
  84872. * @param name Define the name of the uniform as defined in the shader
  84873. * @param value Define the value to give to the uniform
  84874. * @return the material itself allowing "fluent" like uniform updates
  84875. */
  84876. setArray3(name: string, value: number[]): ShaderMaterial;
  84877. /**
  84878. * Set a vec4 array in the shader from a number array.
  84879. * @param name Define the name of the uniform as defined in the shader
  84880. * @param value Define the value to give to the uniform
  84881. * @return the material itself allowing "fluent" like uniform updates
  84882. */
  84883. setArray4(name: string, value: number[]): ShaderMaterial;
  84884. private _checkCache;
  84885. /**
  84886. * Specifies that the submesh is ready to be used
  84887. * @param mesh defines the mesh to check
  84888. * @param subMesh defines which submesh to check
  84889. * @param useInstances specifies that instances should be used
  84890. * @returns a boolean indicating that the submesh is ready or not
  84891. */
  84892. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84893. /**
  84894. * Checks if the material is ready to render the requested mesh
  84895. * @param mesh Define the mesh to render
  84896. * @param useInstances Define whether or not the material is used with instances
  84897. * @returns true if ready, otherwise false
  84898. */
  84899. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84900. /**
  84901. * Binds the world matrix to the material
  84902. * @param world defines the world transformation matrix
  84903. */
  84904. bindOnlyWorldMatrix(world: Matrix): void;
  84905. /**
  84906. * Binds the material to the mesh
  84907. * @param world defines the world transformation matrix
  84908. * @param mesh defines the mesh to bind the material to
  84909. */
  84910. bind(world: Matrix, mesh?: Mesh): void;
  84911. /**
  84912. * Gets the active textures from the material
  84913. * @returns an array of textures
  84914. */
  84915. getActiveTextures(): BaseTexture[];
  84916. /**
  84917. * Specifies if the material uses a texture
  84918. * @param texture defines the texture to check against the material
  84919. * @returns a boolean specifying if the material uses the texture
  84920. */
  84921. hasTexture(texture: BaseTexture): boolean;
  84922. /**
  84923. * Makes a duplicate of the material, and gives it a new name
  84924. * @param name defines the new name for the duplicated material
  84925. * @returns the cloned material
  84926. */
  84927. clone(name: string): ShaderMaterial;
  84928. /**
  84929. * Disposes the material
  84930. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84931. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84932. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84933. */
  84934. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84935. /**
  84936. * Serializes this material in a JSON representation
  84937. * @returns the serialized material object
  84938. */
  84939. serialize(): any;
  84940. /**
  84941. * Creates a shader material from parsed shader material data
  84942. * @param source defines the JSON represnetation of the material
  84943. * @param scene defines the hosting scene
  84944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84945. * @returns a new material
  84946. */
  84947. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84948. }
  84949. }
  84950. declare module BABYLON {
  84951. /** @hidden */
  84952. export var colorPixelShader: {
  84953. name: string;
  84954. shader: string;
  84955. };
  84956. }
  84957. declare module BABYLON {
  84958. /** @hidden */
  84959. export var colorVertexShader: {
  84960. name: string;
  84961. shader: string;
  84962. };
  84963. }
  84964. declare module BABYLON {
  84965. /**
  84966. * Line mesh
  84967. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84968. */
  84969. export class LinesMesh extends Mesh {
  84970. /**
  84971. * If vertex color should be applied to the mesh
  84972. */
  84973. readonly useVertexColor?: boolean | undefined;
  84974. /**
  84975. * If vertex alpha should be applied to the mesh
  84976. */
  84977. readonly useVertexAlpha?: boolean | undefined;
  84978. /**
  84979. * Color of the line (Default: White)
  84980. */
  84981. color: Color3;
  84982. /**
  84983. * Alpha of the line (Default: 1)
  84984. */
  84985. alpha: number;
  84986. /**
  84987. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84988. * This margin is expressed in world space coordinates, so its value may vary.
  84989. * Default value is 0.1
  84990. */
  84991. intersectionThreshold: number;
  84992. private _colorShader;
  84993. private color4;
  84994. /**
  84995. * Creates a new LinesMesh
  84996. * @param name defines the name
  84997. * @param scene defines the hosting scene
  84998. * @param parent defines the parent mesh if any
  84999. * @param source defines the optional source LinesMesh used to clone data from
  85000. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85001. * When false, achieved by calling a clone(), also passing False.
  85002. * This will make creation of children, recursive.
  85003. * @param useVertexColor defines if this LinesMesh supports vertex color
  85004. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85005. */
  85006. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85007. /**
  85008. * If vertex color should be applied to the mesh
  85009. */
  85010. useVertexColor?: boolean | undefined,
  85011. /**
  85012. * If vertex alpha should be applied to the mesh
  85013. */
  85014. useVertexAlpha?: boolean | undefined);
  85015. private _addClipPlaneDefine;
  85016. private _removeClipPlaneDefine;
  85017. isReady(): boolean;
  85018. /**
  85019. * Returns the string "LineMesh"
  85020. */
  85021. getClassName(): string;
  85022. /**
  85023. * @hidden
  85024. */
  85025. /**
  85026. * @hidden
  85027. */
  85028. material: Material;
  85029. /**
  85030. * @hidden
  85031. */
  85032. readonly checkCollisions: boolean;
  85033. /** @hidden */
  85034. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85035. /** @hidden */
  85036. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85037. /**
  85038. * Disposes of the line mesh
  85039. * @param doNotRecurse If children should be disposed
  85040. */
  85041. dispose(doNotRecurse?: boolean): void;
  85042. /**
  85043. * Returns a new LineMesh object cloned from the current one.
  85044. */
  85045. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85046. /**
  85047. * Creates a new InstancedLinesMesh object from the mesh model.
  85048. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85049. * @param name defines the name of the new instance
  85050. * @returns a new InstancedLinesMesh
  85051. */
  85052. createInstance(name: string): InstancedLinesMesh;
  85053. }
  85054. /**
  85055. * Creates an instance based on a source LinesMesh
  85056. */
  85057. export class InstancedLinesMesh extends InstancedMesh {
  85058. /**
  85059. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85060. * This margin is expressed in world space coordinates, so its value may vary.
  85061. * Initilized with the intersectionThreshold value of the source LinesMesh
  85062. */
  85063. intersectionThreshold: number;
  85064. constructor(name: string, source: LinesMesh);
  85065. /**
  85066. * Returns the string "InstancedLinesMesh".
  85067. */
  85068. getClassName(): string;
  85069. }
  85070. }
  85071. declare module BABYLON {
  85072. /** @hidden */
  85073. export var linePixelShader: {
  85074. name: string;
  85075. shader: string;
  85076. };
  85077. }
  85078. declare module BABYLON {
  85079. /** @hidden */
  85080. export var lineVertexShader: {
  85081. name: string;
  85082. shader: string;
  85083. };
  85084. }
  85085. declare module BABYLON {
  85086. interface AbstractMesh {
  85087. /**
  85088. * Gets the edgesRenderer associated with the mesh
  85089. */
  85090. edgesRenderer: Nullable<EdgesRenderer>;
  85091. }
  85092. interface LinesMesh {
  85093. /**
  85094. * Enables the edge rendering mode on the mesh.
  85095. * This mode makes the mesh edges visible
  85096. * @param epsilon defines the maximal distance between two angles to detect a face
  85097. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85098. * @returns the currentAbstractMesh
  85099. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85100. */
  85101. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85102. }
  85103. interface InstancedLinesMesh {
  85104. /**
  85105. * Enables the edge rendering mode on the mesh.
  85106. * This mode makes the mesh edges visible
  85107. * @param epsilon defines the maximal distance between two angles to detect a face
  85108. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85109. * @returns the current InstancedLinesMesh
  85110. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85111. */
  85112. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85113. }
  85114. /**
  85115. * Defines the minimum contract an Edges renderer should follow.
  85116. */
  85117. export interface IEdgesRenderer extends IDisposable {
  85118. /**
  85119. * Gets or sets a boolean indicating if the edgesRenderer is active
  85120. */
  85121. isEnabled: boolean;
  85122. /**
  85123. * Renders the edges of the attached mesh,
  85124. */
  85125. render(): void;
  85126. /**
  85127. * Checks wether or not the edges renderer is ready to render.
  85128. * @return true if ready, otherwise false.
  85129. */
  85130. isReady(): boolean;
  85131. }
  85132. /**
  85133. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85134. */
  85135. export class EdgesRenderer implements IEdgesRenderer {
  85136. /**
  85137. * Define the size of the edges with an orthographic camera
  85138. */
  85139. edgesWidthScalerForOrthographic: number;
  85140. /**
  85141. * Define the size of the edges with a perspective camera
  85142. */
  85143. edgesWidthScalerForPerspective: number;
  85144. protected _source: AbstractMesh;
  85145. protected _linesPositions: number[];
  85146. protected _linesNormals: number[];
  85147. protected _linesIndices: number[];
  85148. protected _epsilon: number;
  85149. protected _indicesCount: number;
  85150. protected _lineShader: ShaderMaterial;
  85151. protected _ib: DataBuffer;
  85152. protected _buffers: {
  85153. [key: string]: Nullable<VertexBuffer>;
  85154. };
  85155. protected _checkVerticesInsteadOfIndices: boolean;
  85156. private _meshRebuildObserver;
  85157. private _meshDisposeObserver;
  85158. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85159. isEnabled: boolean;
  85160. /**
  85161. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85162. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85163. * @param source Mesh used to create edges
  85164. * @param epsilon sum of angles in adjacency to check for edge
  85165. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85166. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85167. */
  85168. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85169. protected _prepareRessources(): void;
  85170. /** @hidden */
  85171. _rebuild(): void;
  85172. /**
  85173. * Releases the required resources for the edges renderer
  85174. */
  85175. dispose(): void;
  85176. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85177. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85178. /**
  85179. * Checks if the pair of p0 and p1 is en edge
  85180. * @param faceIndex
  85181. * @param edge
  85182. * @param faceNormals
  85183. * @param p0
  85184. * @param p1
  85185. * @private
  85186. */
  85187. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85188. /**
  85189. * push line into the position, normal and index buffer
  85190. * @protected
  85191. */
  85192. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85193. /**
  85194. * Generates lines edges from adjacencjes
  85195. * @private
  85196. */
  85197. _generateEdgesLines(): void;
  85198. /**
  85199. * Checks wether or not the edges renderer is ready to render.
  85200. * @return true if ready, otherwise false.
  85201. */
  85202. isReady(): boolean;
  85203. /**
  85204. * Renders the edges of the attached mesh,
  85205. */
  85206. render(): void;
  85207. }
  85208. /**
  85209. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85210. */
  85211. export class LineEdgesRenderer extends EdgesRenderer {
  85212. /**
  85213. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85214. * @param source LineMesh used to generate edges
  85215. * @param epsilon not important (specified angle for edge detection)
  85216. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85217. */
  85218. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85219. /**
  85220. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85221. */
  85222. _generateEdgesLines(): void;
  85223. }
  85224. }
  85225. declare module BABYLON {
  85226. /**
  85227. * This represents the object necessary to create a rendering group.
  85228. * This is exclusively used and created by the rendering manager.
  85229. * To modify the behavior, you use the available helpers in your scene or meshes.
  85230. * @hidden
  85231. */
  85232. export class RenderingGroup {
  85233. index: number;
  85234. private static _zeroVector;
  85235. private _scene;
  85236. private _opaqueSubMeshes;
  85237. private _transparentSubMeshes;
  85238. private _alphaTestSubMeshes;
  85239. private _depthOnlySubMeshes;
  85240. private _particleSystems;
  85241. private _spriteManagers;
  85242. private _opaqueSortCompareFn;
  85243. private _alphaTestSortCompareFn;
  85244. private _transparentSortCompareFn;
  85245. private _renderOpaque;
  85246. private _renderAlphaTest;
  85247. private _renderTransparent;
  85248. /** @hidden */
  85249. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85250. onBeforeTransparentRendering: () => void;
  85251. /**
  85252. * Set the opaque sort comparison function.
  85253. * If null the sub meshes will be render in the order they were created
  85254. */
  85255. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85256. /**
  85257. * Set the alpha test sort comparison function.
  85258. * If null the sub meshes will be render in the order they were created
  85259. */
  85260. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85261. /**
  85262. * Set the transparent sort comparison function.
  85263. * If null the sub meshes will be render in the order they were created
  85264. */
  85265. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85266. /**
  85267. * Creates a new rendering group.
  85268. * @param index The rendering group index
  85269. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85270. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85271. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85272. */
  85273. 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>);
  85274. /**
  85275. * Render all the sub meshes contained in the group.
  85276. * @param customRenderFunction Used to override the default render behaviour of the group.
  85277. * @returns true if rendered some submeshes.
  85278. */
  85279. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85280. /**
  85281. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85282. * @param subMeshes The submeshes to render
  85283. */
  85284. private renderOpaqueSorted;
  85285. /**
  85286. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85287. * @param subMeshes The submeshes to render
  85288. */
  85289. private renderAlphaTestSorted;
  85290. /**
  85291. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85292. * @param subMeshes The submeshes to render
  85293. */
  85294. private renderTransparentSorted;
  85295. /**
  85296. * Renders the submeshes in a specified order.
  85297. * @param subMeshes The submeshes to sort before render
  85298. * @param sortCompareFn The comparison function use to sort
  85299. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85300. * @param transparent Specifies to activate blending if true
  85301. */
  85302. private static renderSorted;
  85303. /**
  85304. * Renders the submeshes in the order they were dispatched (no sort applied).
  85305. * @param subMeshes The submeshes to render
  85306. */
  85307. private static renderUnsorted;
  85308. /**
  85309. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85310. * are rendered back to front if in the same alpha index.
  85311. *
  85312. * @param a The first submesh
  85313. * @param b The second submesh
  85314. * @returns The result of the comparison
  85315. */
  85316. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85317. /**
  85318. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85319. * are rendered back to front.
  85320. *
  85321. * @param a The first submesh
  85322. * @param b The second submesh
  85323. * @returns The result of the comparison
  85324. */
  85325. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85326. /**
  85327. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85328. * are rendered front to back (prevent overdraw).
  85329. *
  85330. * @param a The first submesh
  85331. * @param b The second submesh
  85332. * @returns The result of the comparison
  85333. */
  85334. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85335. /**
  85336. * Resets the different lists of submeshes to prepare a new frame.
  85337. */
  85338. prepare(): void;
  85339. dispose(): void;
  85340. /**
  85341. * Inserts the submesh in its correct queue depending on its material.
  85342. * @param subMesh The submesh to dispatch
  85343. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85344. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85345. */
  85346. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85347. dispatchSprites(spriteManager: ISpriteManager): void;
  85348. dispatchParticles(particleSystem: IParticleSystem): void;
  85349. private _renderParticles;
  85350. private _renderSprites;
  85351. }
  85352. }
  85353. declare module BABYLON {
  85354. /**
  85355. * Interface describing the different options available in the rendering manager
  85356. * regarding Auto Clear between groups.
  85357. */
  85358. export interface IRenderingManagerAutoClearSetup {
  85359. /**
  85360. * Defines whether or not autoclear is enable.
  85361. */
  85362. autoClear: boolean;
  85363. /**
  85364. * Defines whether or not to autoclear the depth buffer.
  85365. */
  85366. depth: boolean;
  85367. /**
  85368. * Defines whether or not to autoclear the stencil buffer.
  85369. */
  85370. stencil: boolean;
  85371. }
  85372. /**
  85373. * This class is used by the onRenderingGroupObservable
  85374. */
  85375. export class RenderingGroupInfo {
  85376. /**
  85377. * The Scene that being rendered
  85378. */
  85379. scene: Scene;
  85380. /**
  85381. * The camera currently used for the rendering pass
  85382. */
  85383. camera: Nullable<Camera>;
  85384. /**
  85385. * The ID of the renderingGroup being processed
  85386. */
  85387. renderingGroupId: number;
  85388. }
  85389. /**
  85390. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85391. * It is enable to manage the different groups as well as the different necessary sort functions.
  85392. * This should not be used directly aside of the few static configurations
  85393. */
  85394. export class RenderingManager {
  85395. /**
  85396. * The max id used for rendering groups (not included)
  85397. */
  85398. static MAX_RENDERINGGROUPS: number;
  85399. /**
  85400. * The min id used for rendering groups (included)
  85401. */
  85402. static MIN_RENDERINGGROUPS: number;
  85403. /**
  85404. * Used to globally prevent autoclearing scenes.
  85405. */
  85406. static AUTOCLEAR: boolean;
  85407. /**
  85408. * @hidden
  85409. */
  85410. _useSceneAutoClearSetup: boolean;
  85411. private _scene;
  85412. private _renderingGroups;
  85413. private _depthStencilBufferAlreadyCleaned;
  85414. private _autoClearDepthStencil;
  85415. private _customOpaqueSortCompareFn;
  85416. private _customAlphaTestSortCompareFn;
  85417. private _customTransparentSortCompareFn;
  85418. private _renderingGroupInfo;
  85419. /**
  85420. * Instantiates a new rendering group for a particular scene
  85421. * @param scene Defines the scene the groups belongs to
  85422. */
  85423. constructor(scene: Scene);
  85424. private _clearDepthStencilBuffer;
  85425. /**
  85426. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85427. * @hidden
  85428. */
  85429. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85430. /**
  85431. * Resets the different information of the group to prepare a new frame
  85432. * @hidden
  85433. */
  85434. reset(): void;
  85435. /**
  85436. * Dispose and release the group and its associated resources.
  85437. * @hidden
  85438. */
  85439. dispose(): void;
  85440. /**
  85441. * Clear the info related to rendering groups preventing retention points during dispose.
  85442. */
  85443. freeRenderingGroups(): void;
  85444. private _prepareRenderingGroup;
  85445. /**
  85446. * Add a sprite manager to the rendering manager in order to render it this frame.
  85447. * @param spriteManager Define the sprite manager to render
  85448. */
  85449. dispatchSprites(spriteManager: ISpriteManager): void;
  85450. /**
  85451. * Add a particle system to the rendering manager in order to render it this frame.
  85452. * @param particleSystem Define the particle system to render
  85453. */
  85454. dispatchParticles(particleSystem: IParticleSystem): void;
  85455. /**
  85456. * Add a submesh to the manager in order to render it this frame
  85457. * @param subMesh The submesh to dispatch
  85458. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85459. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85460. */
  85461. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85462. /**
  85463. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85464. * This allowed control for front to back rendering or reversly depending of the special needs.
  85465. *
  85466. * @param renderingGroupId The rendering group id corresponding to its index
  85467. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85468. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85469. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85470. */
  85471. 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;
  85472. /**
  85473. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85474. *
  85475. * @param renderingGroupId The rendering group id corresponding to its index
  85476. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85477. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85478. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85479. */
  85480. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85481. /**
  85482. * Gets the current auto clear configuration for one rendering group of the rendering
  85483. * manager.
  85484. * @param index the rendering group index to get the information for
  85485. * @returns The auto clear setup for the requested rendering group
  85486. */
  85487. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85488. }
  85489. }
  85490. declare module BABYLON {
  85491. /**
  85492. * This Helps creating a texture that will be created from a camera in your scene.
  85493. * It is basically a dynamic texture that could be used to create special effects for instance.
  85494. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85495. */
  85496. export class RenderTargetTexture extends Texture {
  85497. isCube: boolean;
  85498. /**
  85499. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85500. */
  85501. static readonly REFRESHRATE_RENDER_ONCE: number;
  85502. /**
  85503. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85504. */
  85505. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85506. /**
  85507. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85508. * the central point of your effect and can save a lot of performances.
  85509. */
  85510. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85511. /**
  85512. * Use this predicate to dynamically define the list of mesh you want to render.
  85513. * If set, the renderList property will be overwritten.
  85514. */
  85515. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85516. private _renderList;
  85517. /**
  85518. * Use this list to define the list of mesh you want to render.
  85519. */
  85520. renderList: Nullable<Array<AbstractMesh>>;
  85521. private _hookArray;
  85522. /**
  85523. * Define if particles should be rendered in your texture.
  85524. */
  85525. renderParticles: boolean;
  85526. /**
  85527. * Define if sprites should be rendered in your texture.
  85528. */
  85529. renderSprites: boolean;
  85530. /**
  85531. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85532. */
  85533. coordinatesMode: number;
  85534. /**
  85535. * Define the camera used to render the texture.
  85536. */
  85537. activeCamera: Nullable<Camera>;
  85538. /**
  85539. * Override the render function of the texture with your own one.
  85540. */
  85541. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85542. /**
  85543. * Define if camera post processes should be use while rendering the texture.
  85544. */
  85545. useCameraPostProcesses: boolean;
  85546. /**
  85547. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85548. */
  85549. ignoreCameraViewport: boolean;
  85550. private _postProcessManager;
  85551. private _postProcesses;
  85552. private _resizeObserver;
  85553. /**
  85554. * An event triggered when the texture is unbind.
  85555. */
  85556. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85557. /**
  85558. * An event triggered when the texture is unbind.
  85559. */
  85560. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85561. private _onAfterUnbindObserver;
  85562. /**
  85563. * Set a after unbind callback in the texture.
  85564. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85565. */
  85566. onAfterUnbind: () => void;
  85567. /**
  85568. * An event triggered before rendering the texture
  85569. */
  85570. onBeforeRenderObservable: Observable<number>;
  85571. private _onBeforeRenderObserver;
  85572. /**
  85573. * Set a before render callback in the texture.
  85574. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85575. */
  85576. onBeforeRender: (faceIndex: number) => void;
  85577. /**
  85578. * An event triggered after rendering the texture
  85579. */
  85580. onAfterRenderObservable: Observable<number>;
  85581. private _onAfterRenderObserver;
  85582. /**
  85583. * Set a after render callback in the texture.
  85584. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85585. */
  85586. onAfterRender: (faceIndex: number) => void;
  85587. /**
  85588. * An event triggered after the texture clear
  85589. */
  85590. onClearObservable: Observable<Engine>;
  85591. private _onClearObserver;
  85592. /**
  85593. * Set a clear callback in the texture.
  85594. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85595. */
  85596. onClear: (Engine: Engine) => void;
  85597. /**
  85598. * An event triggered when the texture is resized.
  85599. */
  85600. onResizeObservable: Observable<RenderTargetTexture>;
  85601. /**
  85602. * Define the clear color of the Render Target if it should be different from the scene.
  85603. */
  85604. clearColor: Color4;
  85605. protected _size: number | {
  85606. width: number;
  85607. height: number;
  85608. };
  85609. protected _initialSizeParameter: number | {
  85610. width: number;
  85611. height: number;
  85612. } | {
  85613. ratio: number;
  85614. };
  85615. protected _sizeRatio: Nullable<number>;
  85616. /** @hidden */
  85617. _generateMipMaps: boolean;
  85618. protected _renderingManager: RenderingManager;
  85619. /** @hidden */
  85620. _waitingRenderList: string[];
  85621. protected _doNotChangeAspectRatio: boolean;
  85622. protected _currentRefreshId: number;
  85623. protected _refreshRate: number;
  85624. protected _textureMatrix: Matrix;
  85625. protected _samples: number;
  85626. protected _renderTargetOptions: RenderTargetCreationOptions;
  85627. /**
  85628. * Gets render target creation options that were used.
  85629. */
  85630. readonly renderTargetOptions: RenderTargetCreationOptions;
  85631. protected _engine: Engine;
  85632. protected _onRatioRescale(): void;
  85633. /**
  85634. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85635. * It must define where the camera used to render the texture is set
  85636. */
  85637. boundingBoxPosition: Vector3;
  85638. private _boundingBoxSize;
  85639. /**
  85640. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85641. * When defined, the cubemap will switch to local mode
  85642. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85643. * @example https://www.babylonjs-playground.com/#RNASML
  85644. */
  85645. boundingBoxSize: Vector3;
  85646. /**
  85647. * In case the RTT has been created with a depth texture, get the associated
  85648. * depth texture.
  85649. * Otherwise, return null.
  85650. */
  85651. depthStencilTexture: Nullable<InternalTexture>;
  85652. /**
  85653. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85654. * or used a shadow, depth texture...
  85655. * @param name The friendly name of the texture
  85656. * @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)
  85657. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85658. * @param generateMipMaps True if mip maps need to be generated after render.
  85659. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85660. * @param type The type of the buffer in the RTT (int, half float, float...)
  85661. * @param isCube True if a cube texture needs to be created
  85662. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85663. * @param generateDepthBuffer True to generate a depth buffer
  85664. * @param generateStencilBuffer True to generate a stencil buffer
  85665. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85666. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85667. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85668. */
  85669. constructor(name: string, size: number | {
  85670. width: number;
  85671. height: number;
  85672. } | {
  85673. ratio: number;
  85674. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85675. /**
  85676. * Creates a depth stencil texture.
  85677. * This is only available in WebGL 2 or with the depth texture extension available.
  85678. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85679. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85680. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85681. */
  85682. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85683. private _processSizeParameter;
  85684. /**
  85685. * Define the number of samples to use in case of MSAA.
  85686. * It defaults to one meaning no MSAA has been enabled.
  85687. */
  85688. samples: number;
  85689. /**
  85690. * Resets the refresh counter of the texture and start bak from scratch.
  85691. * Could be useful to regenerate the texture if it is setup to render only once.
  85692. */
  85693. resetRefreshCounter(): void;
  85694. /**
  85695. * Define the refresh rate of the texture or the rendering frequency.
  85696. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85697. */
  85698. refreshRate: number;
  85699. /**
  85700. * Adds a post process to the render target rendering passes.
  85701. * @param postProcess define the post process to add
  85702. */
  85703. addPostProcess(postProcess: PostProcess): void;
  85704. /**
  85705. * Clear all the post processes attached to the render target
  85706. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85707. */
  85708. clearPostProcesses(dispose?: boolean): void;
  85709. /**
  85710. * Remove one of the post process from the list of attached post processes to the texture
  85711. * @param postProcess define the post process to remove from the list
  85712. */
  85713. removePostProcess(postProcess: PostProcess): void;
  85714. /** @hidden */
  85715. _shouldRender(): boolean;
  85716. /**
  85717. * Gets the actual render size of the texture.
  85718. * @returns the width of the render size
  85719. */
  85720. getRenderSize(): number;
  85721. /**
  85722. * Gets the actual render width of the texture.
  85723. * @returns the width of the render size
  85724. */
  85725. getRenderWidth(): number;
  85726. /**
  85727. * Gets the actual render height of the texture.
  85728. * @returns the height of the render size
  85729. */
  85730. getRenderHeight(): number;
  85731. /**
  85732. * Get if the texture can be rescaled or not.
  85733. */
  85734. readonly canRescale: boolean;
  85735. /**
  85736. * Resize the texture using a ratio.
  85737. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85738. */
  85739. scale(ratio: number): void;
  85740. /**
  85741. * Get the texture reflection matrix used to rotate/transform the reflection.
  85742. * @returns the reflection matrix
  85743. */
  85744. getReflectionTextureMatrix(): Matrix;
  85745. /**
  85746. * Resize the texture to a new desired size.
  85747. * Be carrefull as it will recreate all the data in the new texture.
  85748. * @param size Define the new size. It can be:
  85749. * - a number for squared texture,
  85750. * - an object containing { width: number, height: number }
  85751. * - or an object containing a ratio { ratio: number }
  85752. */
  85753. resize(size: number | {
  85754. width: number;
  85755. height: number;
  85756. } | {
  85757. ratio: number;
  85758. }): void;
  85759. /**
  85760. * Renders all the objects from the render list into the texture.
  85761. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85762. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85763. */
  85764. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85765. private _bestReflectionRenderTargetDimension;
  85766. /**
  85767. * @hidden
  85768. * @param faceIndex face index to bind to if this is a cubetexture
  85769. */
  85770. _bindFrameBuffer(faceIndex?: number): void;
  85771. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85772. private renderToTarget;
  85773. /**
  85774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85775. * This allowed control for front to back rendering or reversly depending of the special needs.
  85776. *
  85777. * @param renderingGroupId The rendering group id corresponding to its index
  85778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85781. */
  85782. 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;
  85783. /**
  85784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85785. *
  85786. * @param renderingGroupId The rendering group id corresponding to its index
  85787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85788. */
  85789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85790. /**
  85791. * Clones the texture.
  85792. * @returns the cloned texture
  85793. */
  85794. clone(): RenderTargetTexture;
  85795. /**
  85796. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85797. * @returns The JSON representation of the texture
  85798. */
  85799. serialize(): any;
  85800. /**
  85801. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85802. */
  85803. disposeFramebufferObjects(): void;
  85804. /**
  85805. * Dispose the texture and release its associated resources.
  85806. */
  85807. dispose(): void;
  85808. /** @hidden */
  85809. _rebuild(): void;
  85810. /**
  85811. * Clear the info related to rendering groups preventing retention point in material dispose.
  85812. */
  85813. freeRenderingGroups(): void;
  85814. /**
  85815. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85816. * @returns the view count
  85817. */
  85818. getViewCount(): number;
  85819. }
  85820. }
  85821. declare module BABYLON {
  85822. /**
  85823. * Base class for the main features of a material in Babylon.js
  85824. */
  85825. export class Material implements IAnimatable {
  85826. /**
  85827. * Returns the triangle fill mode
  85828. */
  85829. static readonly TriangleFillMode: number;
  85830. /**
  85831. * Returns the wireframe mode
  85832. */
  85833. static readonly WireFrameFillMode: number;
  85834. /**
  85835. * Returns the point fill mode
  85836. */
  85837. static readonly PointFillMode: number;
  85838. /**
  85839. * Returns the point list draw mode
  85840. */
  85841. static readonly PointListDrawMode: number;
  85842. /**
  85843. * Returns the line list draw mode
  85844. */
  85845. static readonly LineListDrawMode: number;
  85846. /**
  85847. * Returns the line loop draw mode
  85848. */
  85849. static readonly LineLoopDrawMode: number;
  85850. /**
  85851. * Returns the line strip draw mode
  85852. */
  85853. static readonly LineStripDrawMode: number;
  85854. /**
  85855. * Returns the triangle strip draw mode
  85856. */
  85857. static readonly TriangleStripDrawMode: number;
  85858. /**
  85859. * Returns the triangle fan draw mode
  85860. */
  85861. static readonly TriangleFanDrawMode: number;
  85862. /**
  85863. * Stores the clock-wise side orientation
  85864. */
  85865. static readonly ClockWiseSideOrientation: number;
  85866. /**
  85867. * Stores the counter clock-wise side orientation
  85868. */
  85869. static readonly CounterClockWiseSideOrientation: number;
  85870. /**
  85871. * The dirty texture flag value
  85872. */
  85873. static readonly TextureDirtyFlag: number;
  85874. /**
  85875. * The dirty light flag value
  85876. */
  85877. static readonly LightDirtyFlag: number;
  85878. /**
  85879. * The dirty fresnel flag value
  85880. */
  85881. static readonly FresnelDirtyFlag: number;
  85882. /**
  85883. * The dirty attribute flag value
  85884. */
  85885. static readonly AttributesDirtyFlag: number;
  85886. /**
  85887. * The dirty misc flag value
  85888. */
  85889. static readonly MiscDirtyFlag: number;
  85890. /**
  85891. * The all dirty flag value
  85892. */
  85893. static readonly AllDirtyFlag: number;
  85894. /**
  85895. * The ID of the material
  85896. */
  85897. id: string;
  85898. /**
  85899. * Gets or sets the unique id of the material
  85900. */
  85901. uniqueId: number;
  85902. /**
  85903. * The name of the material
  85904. */
  85905. name: string;
  85906. /**
  85907. * Gets or sets user defined metadata
  85908. */
  85909. metadata: any;
  85910. /**
  85911. * For internal use only. Please do not use.
  85912. */
  85913. reservedDataStore: any;
  85914. /**
  85915. * Specifies if the ready state should be checked on each call
  85916. */
  85917. checkReadyOnEveryCall: boolean;
  85918. /**
  85919. * Specifies if the ready state should be checked once
  85920. */
  85921. checkReadyOnlyOnce: boolean;
  85922. /**
  85923. * The state of the material
  85924. */
  85925. state: string;
  85926. /**
  85927. * The alpha value of the material
  85928. */
  85929. protected _alpha: number;
  85930. /**
  85931. * List of inspectable custom properties (used by the Inspector)
  85932. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85933. */
  85934. inspectableCustomProperties: IInspectable[];
  85935. /**
  85936. * Sets the alpha value of the material
  85937. */
  85938. /**
  85939. * Gets the alpha value of the material
  85940. */
  85941. alpha: number;
  85942. /**
  85943. * Specifies if back face culling is enabled
  85944. */
  85945. protected _backFaceCulling: boolean;
  85946. /**
  85947. * Sets the back-face culling state
  85948. */
  85949. /**
  85950. * Gets the back-face culling state
  85951. */
  85952. backFaceCulling: boolean;
  85953. /**
  85954. * Stores the value for side orientation
  85955. */
  85956. sideOrientation: number;
  85957. /**
  85958. * Callback triggered when the material is compiled
  85959. */
  85960. onCompiled: Nullable<(effect: Effect) => void>;
  85961. /**
  85962. * Callback triggered when an error occurs
  85963. */
  85964. onError: Nullable<(effect: Effect, errors: string) => void>;
  85965. /**
  85966. * Callback triggered to get the render target textures
  85967. */
  85968. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85969. /**
  85970. * Gets a boolean indicating that current material needs to register RTT
  85971. */
  85972. readonly hasRenderTargetTextures: boolean;
  85973. /**
  85974. * Specifies if the material should be serialized
  85975. */
  85976. doNotSerialize: boolean;
  85977. /**
  85978. * @hidden
  85979. */
  85980. _storeEffectOnSubMeshes: boolean;
  85981. /**
  85982. * Stores the animations for the material
  85983. */
  85984. animations: Nullable<Array<Animation>>;
  85985. /**
  85986. * An event triggered when the material is disposed
  85987. */
  85988. onDisposeObservable: Observable<Material>;
  85989. /**
  85990. * An observer which watches for dispose events
  85991. */
  85992. private _onDisposeObserver;
  85993. private _onUnBindObservable;
  85994. /**
  85995. * Called during a dispose event
  85996. */
  85997. onDispose: () => void;
  85998. private _onBindObservable;
  85999. /**
  86000. * An event triggered when the material is bound
  86001. */
  86002. readonly onBindObservable: Observable<AbstractMesh>;
  86003. /**
  86004. * An observer which watches for bind events
  86005. */
  86006. private _onBindObserver;
  86007. /**
  86008. * Called during a bind event
  86009. */
  86010. onBind: (Mesh: AbstractMesh) => void;
  86011. /**
  86012. * An event triggered when the material is unbound
  86013. */
  86014. readonly onUnBindObservable: Observable<Material>;
  86015. /**
  86016. * Stores the value of the alpha mode
  86017. */
  86018. private _alphaMode;
  86019. /**
  86020. * Sets the value of the alpha mode.
  86021. *
  86022. * | Value | Type | Description |
  86023. * | --- | --- | --- |
  86024. * | 0 | ALPHA_DISABLE | |
  86025. * | 1 | ALPHA_ADD | |
  86026. * | 2 | ALPHA_COMBINE | |
  86027. * | 3 | ALPHA_SUBTRACT | |
  86028. * | 4 | ALPHA_MULTIPLY | |
  86029. * | 5 | ALPHA_MAXIMIZED | |
  86030. * | 6 | ALPHA_ONEONE | |
  86031. * | 7 | ALPHA_PREMULTIPLIED | |
  86032. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86033. * | 9 | ALPHA_INTERPOLATE | |
  86034. * | 10 | ALPHA_SCREENMODE | |
  86035. *
  86036. */
  86037. /**
  86038. * Gets the value of the alpha mode
  86039. */
  86040. alphaMode: number;
  86041. /**
  86042. * Stores the state of the need depth pre-pass value
  86043. */
  86044. private _needDepthPrePass;
  86045. /**
  86046. * Sets the need depth pre-pass value
  86047. */
  86048. /**
  86049. * Gets the depth pre-pass value
  86050. */
  86051. needDepthPrePass: boolean;
  86052. /**
  86053. * Specifies if depth writing should be disabled
  86054. */
  86055. disableDepthWrite: boolean;
  86056. /**
  86057. * Specifies if depth writing should be forced
  86058. */
  86059. forceDepthWrite: boolean;
  86060. /**
  86061. * Specifies if there should be a separate pass for culling
  86062. */
  86063. separateCullingPass: boolean;
  86064. /**
  86065. * Stores the state specifing if fog should be enabled
  86066. */
  86067. private _fogEnabled;
  86068. /**
  86069. * Sets the state for enabling fog
  86070. */
  86071. /**
  86072. * Gets the value of the fog enabled state
  86073. */
  86074. fogEnabled: boolean;
  86075. /**
  86076. * Stores the size of points
  86077. */
  86078. pointSize: number;
  86079. /**
  86080. * Stores the z offset value
  86081. */
  86082. zOffset: number;
  86083. /**
  86084. * Gets a value specifying if wireframe mode is enabled
  86085. */
  86086. /**
  86087. * Sets the state of wireframe mode
  86088. */
  86089. wireframe: boolean;
  86090. /**
  86091. * Gets the value specifying if point clouds are enabled
  86092. */
  86093. /**
  86094. * Sets the state of point cloud mode
  86095. */
  86096. pointsCloud: boolean;
  86097. /**
  86098. * Gets the material fill mode
  86099. */
  86100. /**
  86101. * Sets the material fill mode
  86102. */
  86103. fillMode: number;
  86104. /**
  86105. * @hidden
  86106. * Stores the effects for the material
  86107. */
  86108. _effect: Nullable<Effect>;
  86109. /**
  86110. * @hidden
  86111. * Specifies if the material was previously ready
  86112. */
  86113. _wasPreviouslyReady: boolean;
  86114. /**
  86115. * Specifies if uniform buffers should be used
  86116. */
  86117. private _useUBO;
  86118. /**
  86119. * Stores a reference to the scene
  86120. */
  86121. private _scene;
  86122. /**
  86123. * Stores the fill mode state
  86124. */
  86125. private _fillMode;
  86126. /**
  86127. * Specifies if the depth write state should be cached
  86128. */
  86129. private _cachedDepthWriteState;
  86130. /**
  86131. * Stores the uniform buffer
  86132. */
  86133. protected _uniformBuffer: UniformBuffer;
  86134. /** @hidden */
  86135. _indexInSceneMaterialArray: number;
  86136. /** @hidden */
  86137. meshMap: Nullable<{
  86138. [id: string]: AbstractMesh | undefined;
  86139. }>;
  86140. /**
  86141. * Creates a material instance
  86142. * @param name defines the name of the material
  86143. * @param scene defines the scene to reference
  86144. * @param doNotAdd specifies if the material should be added to the scene
  86145. */
  86146. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86147. /**
  86148. * Returns a string representation of the current material
  86149. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86150. * @returns a string with material information
  86151. */
  86152. toString(fullDetails?: boolean): string;
  86153. /**
  86154. * Gets the class name of the material
  86155. * @returns a string with the class name of the material
  86156. */
  86157. getClassName(): string;
  86158. /**
  86159. * Specifies if updates for the material been locked
  86160. */
  86161. readonly isFrozen: boolean;
  86162. /**
  86163. * Locks updates for the material
  86164. */
  86165. freeze(): void;
  86166. /**
  86167. * Unlocks updates for the material
  86168. */
  86169. unfreeze(): void;
  86170. /**
  86171. * Specifies if the material is ready to be used
  86172. * @param mesh defines the mesh to check
  86173. * @param useInstances specifies if instances should be used
  86174. * @returns a boolean indicating if the material is ready to be used
  86175. */
  86176. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86177. /**
  86178. * Specifies that the submesh is ready to be used
  86179. * @param mesh defines the mesh to check
  86180. * @param subMesh defines which submesh to check
  86181. * @param useInstances specifies that instances should be used
  86182. * @returns a boolean indicating that the submesh is ready or not
  86183. */
  86184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86185. /**
  86186. * Returns the material effect
  86187. * @returns the effect associated with the material
  86188. */
  86189. getEffect(): Nullable<Effect>;
  86190. /**
  86191. * Returns the current scene
  86192. * @returns a Scene
  86193. */
  86194. getScene(): Scene;
  86195. /**
  86196. * Specifies if the material will require alpha blending
  86197. * @returns a boolean specifying if alpha blending is needed
  86198. */
  86199. needAlphaBlending(): boolean;
  86200. /**
  86201. * Specifies if the mesh will require alpha blending
  86202. * @param mesh defines the mesh to check
  86203. * @returns a boolean specifying if alpha blending is needed for the mesh
  86204. */
  86205. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86206. /**
  86207. * Specifies if this material should be rendered in alpha test mode
  86208. * @returns a boolean specifying if an alpha test is needed.
  86209. */
  86210. needAlphaTesting(): boolean;
  86211. /**
  86212. * Gets the texture used for the alpha test
  86213. * @returns the texture to use for alpha testing
  86214. */
  86215. getAlphaTestTexture(): Nullable<BaseTexture>;
  86216. /**
  86217. * Marks the material to indicate that it needs to be re-calculated
  86218. */
  86219. markDirty(): void;
  86220. /** @hidden */
  86221. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86222. /**
  86223. * Binds the material to the mesh
  86224. * @param world defines the world transformation matrix
  86225. * @param mesh defines the mesh to bind the material to
  86226. */
  86227. bind(world: Matrix, mesh?: Mesh): void;
  86228. /**
  86229. * Binds the submesh to the material
  86230. * @param world defines the world transformation matrix
  86231. * @param mesh defines the mesh containing the submesh
  86232. * @param subMesh defines the submesh to bind the material to
  86233. */
  86234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86235. /**
  86236. * Binds the world matrix to the material
  86237. * @param world defines the world transformation matrix
  86238. */
  86239. bindOnlyWorldMatrix(world: Matrix): void;
  86240. /**
  86241. * Binds the scene's uniform buffer to the effect.
  86242. * @param effect defines the effect to bind to the scene uniform buffer
  86243. * @param sceneUbo defines the uniform buffer storing scene data
  86244. */
  86245. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86246. /**
  86247. * Binds the view matrix to the effect
  86248. * @param effect defines the effect to bind the view matrix to
  86249. */
  86250. bindView(effect: Effect): void;
  86251. /**
  86252. * Binds the view projection matrix to the effect
  86253. * @param effect defines the effect to bind the view projection matrix to
  86254. */
  86255. bindViewProjection(effect: Effect): void;
  86256. /**
  86257. * Specifies if material alpha testing should be turned on for the mesh
  86258. * @param mesh defines the mesh to check
  86259. */
  86260. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86261. /**
  86262. * Processes to execute after binding the material to a mesh
  86263. * @param mesh defines the rendered mesh
  86264. */
  86265. protected _afterBind(mesh?: Mesh): void;
  86266. /**
  86267. * Unbinds the material from the mesh
  86268. */
  86269. unbind(): void;
  86270. /**
  86271. * Gets the active textures from the material
  86272. * @returns an array of textures
  86273. */
  86274. getActiveTextures(): BaseTexture[];
  86275. /**
  86276. * Specifies if the material uses a texture
  86277. * @param texture defines the texture to check against the material
  86278. * @returns a boolean specifying if the material uses the texture
  86279. */
  86280. hasTexture(texture: BaseTexture): boolean;
  86281. /**
  86282. * Makes a duplicate of the material, and gives it a new name
  86283. * @param name defines the new name for the duplicated material
  86284. * @returns the cloned material
  86285. */
  86286. clone(name: string): Nullable<Material>;
  86287. /**
  86288. * Gets the meshes bound to the material
  86289. * @returns an array of meshes bound to the material
  86290. */
  86291. getBindedMeshes(): AbstractMesh[];
  86292. /**
  86293. * Force shader compilation
  86294. * @param mesh defines the mesh associated with this material
  86295. * @param onCompiled defines a function to execute once the material is compiled
  86296. * @param options defines the options to configure the compilation
  86297. */
  86298. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86299. clipPlane: boolean;
  86300. }>): void;
  86301. /**
  86302. * Force shader compilation
  86303. * @param mesh defines the mesh that will use this material
  86304. * @param options defines additional options for compiling the shaders
  86305. * @returns a promise that resolves when the compilation completes
  86306. */
  86307. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86308. clipPlane: boolean;
  86309. }>): Promise<void>;
  86310. private static readonly _AllDirtyCallBack;
  86311. private static readonly _ImageProcessingDirtyCallBack;
  86312. private static readonly _TextureDirtyCallBack;
  86313. private static readonly _FresnelDirtyCallBack;
  86314. private static readonly _MiscDirtyCallBack;
  86315. private static readonly _LightsDirtyCallBack;
  86316. private static readonly _AttributeDirtyCallBack;
  86317. private static _FresnelAndMiscDirtyCallBack;
  86318. private static _TextureAndMiscDirtyCallBack;
  86319. private static readonly _DirtyCallbackArray;
  86320. private static readonly _RunDirtyCallBacks;
  86321. /**
  86322. * Marks a define in the material to indicate that it needs to be re-computed
  86323. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86324. */
  86325. markAsDirty(flag: number): void;
  86326. /**
  86327. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86328. * @param func defines a function which checks material defines against the submeshes
  86329. */
  86330. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86331. /**
  86332. * Indicates that we need to re-calculated for all submeshes
  86333. */
  86334. protected _markAllSubMeshesAsAllDirty(): void;
  86335. /**
  86336. * Indicates that image processing needs to be re-calculated for all submeshes
  86337. */
  86338. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86339. /**
  86340. * Indicates that textures need to be re-calculated for all submeshes
  86341. */
  86342. protected _markAllSubMeshesAsTexturesDirty(): void;
  86343. /**
  86344. * Indicates that fresnel needs to be re-calculated for all submeshes
  86345. */
  86346. protected _markAllSubMeshesAsFresnelDirty(): void;
  86347. /**
  86348. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86349. */
  86350. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86351. /**
  86352. * Indicates that lights need to be re-calculated for all submeshes
  86353. */
  86354. protected _markAllSubMeshesAsLightsDirty(): void;
  86355. /**
  86356. * Indicates that attributes need to be re-calculated for all submeshes
  86357. */
  86358. protected _markAllSubMeshesAsAttributesDirty(): void;
  86359. /**
  86360. * Indicates that misc needs to be re-calculated for all submeshes
  86361. */
  86362. protected _markAllSubMeshesAsMiscDirty(): void;
  86363. /**
  86364. * Indicates that textures and misc need to be re-calculated for all submeshes
  86365. */
  86366. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86367. /**
  86368. * Disposes the material
  86369. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86370. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86371. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86372. */
  86373. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86374. /** @hidden */
  86375. private releaseVertexArrayObject;
  86376. /**
  86377. * Serializes this material
  86378. * @returns the serialized material object
  86379. */
  86380. serialize(): any;
  86381. /**
  86382. * Creates a material from parsed material data
  86383. * @param parsedMaterial defines parsed material data
  86384. * @param scene defines the hosting scene
  86385. * @param rootUrl defines the root URL to use to load textures
  86386. * @returns a new material
  86387. */
  86388. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86389. }
  86390. }
  86391. declare module BABYLON {
  86392. /**
  86393. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86394. * separate meshes. This can be use to improve performances.
  86395. * @see http://doc.babylonjs.com/how_to/multi_materials
  86396. */
  86397. export class MultiMaterial extends Material {
  86398. private _subMaterials;
  86399. /**
  86400. * Gets or Sets the list of Materials used within the multi material.
  86401. * They need to be ordered according to the submeshes order in the associated mesh
  86402. */
  86403. subMaterials: Nullable<Material>[];
  86404. /**
  86405. * Function used to align with Node.getChildren()
  86406. * @returns the list of Materials used within the multi material
  86407. */
  86408. getChildren(): Nullable<Material>[];
  86409. /**
  86410. * Instantiates a new Multi Material
  86411. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86412. * separate meshes. This can be use to improve performances.
  86413. * @see http://doc.babylonjs.com/how_to/multi_materials
  86414. * @param name Define the name in the scene
  86415. * @param scene Define the scene the material belongs to
  86416. */
  86417. constructor(name: string, scene: Scene);
  86418. private _hookArray;
  86419. /**
  86420. * Get one of the submaterial by its index in the submaterials array
  86421. * @param index The index to look the sub material at
  86422. * @returns The Material if the index has been defined
  86423. */
  86424. getSubMaterial(index: number): Nullable<Material>;
  86425. /**
  86426. * Get the list of active textures for the whole sub materials list.
  86427. * @returns All the textures that will be used during the rendering
  86428. */
  86429. getActiveTextures(): BaseTexture[];
  86430. /**
  86431. * Gets the current class name of the material e.g. "MultiMaterial"
  86432. * Mainly use in serialization.
  86433. * @returns the class name
  86434. */
  86435. getClassName(): string;
  86436. /**
  86437. * Checks if the material is ready to render the requested sub mesh
  86438. * @param mesh Define the mesh the submesh belongs to
  86439. * @param subMesh Define the sub mesh to look readyness for
  86440. * @param useInstances Define whether or not the material is used with instances
  86441. * @returns true if ready, otherwise false
  86442. */
  86443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86444. /**
  86445. * Clones the current material and its related sub materials
  86446. * @param name Define the name of the newly cloned material
  86447. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86448. * @returns the cloned material
  86449. */
  86450. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86451. /**
  86452. * Serializes the materials into a JSON representation.
  86453. * @returns the JSON representation
  86454. */
  86455. serialize(): any;
  86456. /**
  86457. * Dispose the material and release its associated resources
  86458. * @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)
  86459. * @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)
  86460. * @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)
  86461. */
  86462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86463. /**
  86464. * Creates a MultiMaterial from parsed MultiMaterial data.
  86465. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86466. * @param scene defines the hosting scene
  86467. * @returns a new MultiMaterial
  86468. */
  86469. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86470. }
  86471. }
  86472. declare module BABYLON {
  86473. /**
  86474. * Base class for submeshes
  86475. */
  86476. export class BaseSubMesh {
  86477. /** @hidden */
  86478. _materialDefines: Nullable<MaterialDefines>;
  86479. /** @hidden */
  86480. _materialEffect: Nullable<Effect>;
  86481. /**
  86482. * Gets associated effect
  86483. */
  86484. readonly effect: Nullable<Effect>;
  86485. /**
  86486. * Sets associated effect (effect used to render this submesh)
  86487. * @param effect defines the effect to associate with
  86488. * @param defines defines the set of defines used to compile this effect
  86489. */
  86490. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86491. }
  86492. /**
  86493. * Defines a subdivision inside a mesh
  86494. */
  86495. export class SubMesh extends BaseSubMesh implements ICullable {
  86496. /** the material index to use */
  86497. materialIndex: number;
  86498. /** vertex index start */
  86499. verticesStart: number;
  86500. /** vertices count */
  86501. verticesCount: number;
  86502. /** index start */
  86503. indexStart: number;
  86504. /** indices count */
  86505. indexCount: number;
  86506. /** @hidden */
  86507. _linesIndexCount: number;
  86508. private _mesh;
  86509. private _renderingMesh;
  86510. private _boundingInfo;
  86511. private _linesIndexBuffer;
  86512. /** @hidden */
  86513. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86514. /** @hidden */
  86515. _trianglePlanes: Plane[];
  86516. /** @hidden */
  86517. _lastColliderTransformMatrix: Nullable<Matrix>;
  86518. /** @hidden */
  86519. _renderId: number;
  86520. /** @hidden */
  86521. _alphaIndex: number;
  86522. /** @hidden */
  86523. _distanceToCamera: number;
  86524. /** @hidden */
  86525. _id: number;
  86526. private _currentMaterial;
  86527. /**
  86528. * Add a new submesh to a mesh
  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. * @returns the new submesh
  86538. */
  86539. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86540. /**
  86541. * Creates a new submesh
  86542. * @param materialIndex defines the material index to use
  86543. * @param verticesStart defines vertex index start
  86544. * @param verticesCount defines vertices count
  86545. * @param indexStart defines index start
  86546. * @param indexCount defines indices count
  86547. * @param mesh defines the parent mesh
  86548. * @param renderingMesh defines an optional rendering mesh
  86549. * @param createBoundingBox defines if bounding box should be created for this submesh
  86550. */
  86551. constructor(
  86552. /** the material index to use */
  86553. materialIndex: number,
  86554. /** vertex index start */
  86555. verticesStart: number,
  86556. /** vertices count */
  86557. verticesCount: number,
  86558. /** index start */
  86559. indexStart: number,
  86560. /** indices count */
  86561. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86562. /**
  86563. * Returns true if this submesh covers the entire parent mesh
  86564. * @ignorenaming
  86565. */
  86566. readonly IsGlobal: boolean;
  86567. /**
  86568. * Returns the submesh BoudingInfo object
  86569. * @returns current bounding info (or mesh's one if the submesh is global)
  86570. */
  86571. getBoundingInfo(): BoundingInfo;
  86572. /**
  86573. * Sets the submesh BoundingInfo
  86574. * @param boundingInfo defines the new bounding info to use
  86575. * @returns the SubMesh
  86576. */
  86577. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86578. /**
  86579. * Returns the mesh of the current submesh
  86580. * @return the parent mesh
  86581. */
  86582. getMesh(): AbstractMesh;
  86583. /**
  86584. * Returns the rendering mesh of the submesh
  86585. * @returns the rendering mesh (could be different from parent mesh)
  86586. */
  86587. getRenderingMesh(): Mesh;
  86588. /**
  86589. * Returns the submesh material
  86590. * @returns null or the current material
  86591. */
  86592. getMaterial(): Nullable<Material>;
  86593. /**
  86594. * Sets a new updated BoundingInfo object to the submesh
  86595. * @param data defines an optional position array to use to determine the bounding info
  86596. * @returns the SubMesh
  86597. */
  86598. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86599. /** @hidden */
  86600. _checkCollision(collider: Collider): boolean;
  86601. /**
  86602. * Updates the submesh BoundingInfo
  86603. * @param world defines the world matrix to use to update the bounding info
  86604. * @returns the submesh
  86605. */
  86606. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86607. /**
  86608. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86609. * @param frustumPlanes defines the frustum planes
  86610. * @returns true if the submesh is intersecting with the frustum
  86611. */
  86612. isInFrustum(frustumPlanes: Plane[]): boolean;
  86613. /**
  86614. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86615. * @param frustumPlanes defines the frustum planes
  86616. * @returns true if the submesh is inside the frustum
  86617. */
  86618. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86619. /**
  86620. * Renders the submesh
  86621. * @param enableAlphaMode defines if alpha needs to be used
  86622. * @returns the submesh
  86623. */
  86624. render(enableAlphaMode: boolean): SubMesh;
  86625. /**
  86626. * @hidden
  86627. */
  86628. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86629. /**
  86630. * Checks if the submesh intersects with a ray
  86631. * @param ray defines the ray to test
  86632. * @returns true is the passed ray intersects the submesh bounding box
  86633. */
  86634. canIntersects(ray: Ray): boolean;
  86635. /**
  86636. * Intersects current submesh with a ray
  86637. * @param ray defines the ray to test
  86638. * @param positions defines mesh's positions array
  86639. * @param indices defines mesh's indices array
  86640. * @param fastCheck defines if only bounding info should be used
  86641. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86642. * @returns intersection info or null if no intersection
  86643. */
  86644. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86645. /** @hidden */
  86646. private _intersectLines;
  86647. /** @hidden */
  86648. private _intersectUnIndexedLines;
  86649. /** @hidden */
  86650. private _intersectTriangles;
  86651. /** @hidden */
  86652. private _intersectUnIndexedTriangles;
  86653. /** @hidden */
  86654. _rebuild(): void;
  86655. /**
  86656. * Creates a new submesh from the passed mesh
  86657. * @param newMesh defines the new hosting mesh
  86658. * @param newRenderingMesh defines an optional rendering mesh
  86659. * @returns the new submesh
  86660. */
  86661. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86662. /**
  86663. * Release associated resources
  86664. */
  86665. dispose(): void;
  86666. /**
  86667. * Gets the class name
  86668. * @returns the string "SubMesh".
  86669. */
  86670. getClassName(): string;
  86671. /**
  86672. * Creates a new submesh from indices data
  86673. * @param materialIndex the index of the main mesh material
  86674. * @param startIndex the index where to start the copy in the mesh indices array
  86675. * @param indexCount the number of indices to copy then from the startIndex
  86676. * @param mesh the main mesh to create the submesh from
  86677. * @param renderingMesh the optional rendering mesh
  86678. * @returns a new submesh
  86679. */
  86680. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86681. }
  86682. }
  86683. declare module BABYLON {
  86684. /**
  86685. * Class used to represent data loading progression
  86686. */
  86687. export class SceneLoaderFlags {
  86688. private static _ForceFullSceneLoadingForIncremental;
  86689. private static _ShowLoadingScreen;
  86690. private static _CleanBoneMatrixWeights;
  86691. private static _loggingLevel;
  86692. /**
  86693. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86694. */
  86695. static ForceFullSceneLoadingForIncremental: boolean;
  86696. /**
  86697. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86698. */
  86699. static ShowLoadingScreen: boolean;
  86700. /**
  86701. * Defines the current logging level (while loading the scene)
  86702. * @ignorenaming
  86703. */
  86704. static loggingLevel: number;
  86705. /**
  86706. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86707. */
  86708. static CleanBoneMatrixWeights: boolean;
  86709. }
  86710. }
  86711. declare module BABYLON {
  86712. /**
  86713. * Class used to store geometry data (vertex buffers + index buffer)
  86714. */
  86715. export class Geometry implements IGetSetVerticesData {
  86716. /**
  86717. * Gets or sets the ID of the geometry
  86718. */
  86719. id: string;
  86720. /**
  86721. * Gets or sets the unique ID of the geometry
  86722. */
  86723. uniqueId: number;
  86724. /**
  86725. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86726. */
  86727. delayLoadState: number;
  86728. /**
  86729. * Gets the file containing the data to load when running in delay load state
  86730. */
  86731. delayLoadingFile: Nullable<string>;
  86732. /**
  86733. * Callback called when the geometry is updated
  86734. */
  86735. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86736. private _scene;
  86737. private _engine;
  86738. private _meshes;
  86739. private _totalVertices;
  86740. /** @hidden */
  86741. _indices: IndicesArray;
  86742. /** @hidden */
  86743. _vertexBuffers: {
  86744. [key: string]: VertexBuffer;
  86745. };
  86746. private _isDisposed;
  86747. private _extend;
  86748. private _boundingBias;
  86749. /** @hidden */
  86750. _delayInfo: Array<string>;
  86751. private _indexBuffer;
  86752. private _indexBufferIsUpdatable;
  86753. /** @hidden */
  86754. _boundingInfo: Nullable<BoundingInfo>;
  86755. /** @hidden */
  86756. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86757. /** @hidden */
  86758. _softwareSkinningFrameId: number;
  86759. private _vertexArrayObjects;
  86760. private _updatable;
  86761. /** @hidden */
  86762. _positions: Nullable<Vector3[]>;
  86763. /**
  86764. * 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
  86765. */
  86766. /**
  86767. * 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
  86768. */
  86769. boundingBias: Vector2;
  86770. /**
  86771. * Static function used to attach a new empty geometry to a mesh
  86772. * @param mesh defines the mesh to attach the geometry to
  86773. * @returns the new Geometry
  86774. */
  86775. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86776. /**
  86777. * Creates a new geometry
  86778. * @param id defines the unique ID
  86779. * @param scene defines the hosting scene
  86780. * @param vertexData defines the VertexData used to get geometry data
  86781. * @param updatable defines if geometry must be updatable (false by default)
  86782. * @param mesh defines the mesh that will be associated with the geometry
  86783. */
  86784. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86785. /**
  86786. * Gets the current extend of the geometry
  86787. */
  86788. readonly extend: {
  86789. minimum: Vector3;
  86790. maximum: Vector3;
  86791. };
  86792. /**
  86793. * Gets the hosting scene
  86794. * @returns the hosting Scene
  86795. */
  86796. getScene(): Scene;
  86797. /**
  86798. * Gets the hosting engine
  86799. * @returns the hosting Engine
  86800. */
  86801. getEngine(): Engine;
  86802. /**
  86803. * Defines if the geometry is ready to use
  86804. * @returns true if the geometry is ready to be used
  86805. */
  86806. isReady(): boolean;
  86807. /**
  86808. * Gets a value indicating that the geometry should not be serialized
  86809. */
  86810. readonly doNotSerialize: boolean;
  86811. /** @hidden */
  86812. _rebuild(): void;
  86813. /**
  86814. * Affects all geometry data in one call
  86815. * @param vertexData defines the geometry data
  86816. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86817. */
  86818. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86819. /**
  86820. * Set specific vertex data
  86821. * @param kind defines the data kind (Position, normal, etc...)
  86822. * @param data defines the vertex data to use
  86823. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86824. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86825. */
  86826. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86827. /**
  86828. * Removes a specific vertex data
  86829. * @param kind defines the data kind (Position, normal, etc...)
  86830. */
  86831. removeVerticesData(kind: string): void;
  86832. /**
  86833. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86834. * @param buffer defines the vertex buffer to use
  86835. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86836. */
  86837. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86838. /**
  86839. * Update a specific vertex buffer
  86840. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86841. * It will do nothing if the buffer is not updatable
  86842. * @param kind defines the data kind (Position, normal, etc...)
  86843. * @param data defines the data to use
  86844. * @param offset defines the offset in the target buffer where to store the data
  86845. * @param useBytes set to true if the offset is in bytes
  86846. */
  86847. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86848. /**
  86849. * Update a specific vertex buffer
  86850. * This function will create a new buffer if the current one is not updatable
  86851. * @param kind defines the data kind (Position, normal, etc...)
  86852. * @param data defines the data to use
  86853. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86854. */
  86855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86856. private _updateBoundingInfo;
  86857. /** @hidden */
  86858. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86859. /**
  86860. * Gets total number of vertices
  86861. * @returns the total number of vertices
  86862. */
  86863. getTotalVertices(): number;
  86864. /**
  86865. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86866. * @param kind defines the data kind (Position, normal, etc...)
  86867. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86868. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86869. * @returns a float array containing vertex data
  86870. */
  86871. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86872. /**
  86873. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86874. * @param kind defines the data kind (Position, normal, etc...)
  86875. * @returns true if the vertex buffer with the specified kind is updatable
  86876. */
  86877. isVertexBufferUpdatable(kind: string): boolean;
  86878. /**
  86879. * Gets a specific vertex buffer
  86880. * @param kind defines the data kind (Position, normal, etc...)
  86881. * @returns a VertexBuffer
  86882. */
  86883. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86884. /**
  86885. * Returns all vertex buffers
  86886. * @return an object holding all vertex buffers indexed by kind
  86887. */
  86888. getVertexBuffers(): Nullable<{
  86889. [key: string]: VertexBuffer;
  86890. }>;
  86891. /**
  86892. * Gets a boolean indicating if specific vertex buffer is present
  86893. * @param kind defines the data kind (Position, normal, etc...)
  86894. * @returns true if data is present
  86895. */
  86896. isVerticesDataPresent(kind: string): boolean;
  86897. /**
  86898. * Gets a list of all attached data kinds (Position, normal, etc...)
  86899. * @returns a list of string containing all kinds
  86900. */
  86901. getVerticesDataKinds(): string[];
  86902. /**
  86903. * Update index buffer
  86904. * @param indices defines the indices to store in the index buffer
  86905. * @param offset defines the offset in the target buffer where to store the data
  86906. * @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)
  86907. */
  86908. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86909. /**
  86910. * Creates a new index buffer
  86911. * @param indices defines the indices to store in the index buffer
  86912. * @param totalVertices defines the total number of vertices (could be null)
  86913. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86914. */
  86915. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86916. /**
  86917. * Return the total number of indices
  86918. * @returns the total number of indices
  86919. */
  86920. getTotalIndices(): number;
  86921. /**
  86922. * Gets the index buffer array
  86923. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86924. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86925. * @returns the index buffer array
  86926. */
  86927. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86928. /**
  86929. * Gets the index buffer
  86930. * @return the index buffer
  86931. */
  86932. getIndexBuffer(): Nullable<DataBuffer>;
  86933. /** @hidden */
  86934. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86935. /**
  86936. * Release the associated resources for a specific mesh
  86937. * @param mesh defines the source mesh
  86938. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86939. */
  86940. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86941. /**
  86942. * Apply current geometry to a given mesh
  86943. * @param mesh defines the mesh to apply geometry to
  86944. */
  86945. applyToMesh(mesh: Mesh): void;
  86946. private _updateExtend;
  86947. private _applyToMesh;
  86948. private notifyUpdate;
  86949. /**
  86950. * Load the geometry if it was flagged as delay loaded
  86951. * @param scene defines the hosting scene
  86952. * @param onLoaded defines a callback called when the geometry is loaded
  86953. */
  86954. load(scene: Scene, onLoaded?: () => void): void;
  86955. private _queueLoad;
  86956. /**
  86957. * Invert the geometry to move from a right handed system to a left handed one.
  86958. */
  86959. toLeftHanded(): void;
  86960. /** @hidden */
  86961. _resetPointsArrayCache(): void;
  86962. /** @hidden */
  86963. _generatePointsArray(): boolean;
  86964. /**
  86965. * Gets a value indicating if the geometry is disposed
  86966. * @returns true if the geometry was disposed
  86967. */
  86968. isDisposed(): boolean;
  86969. private _disposeVertexArrayObjects;
  86970. /**
  86971. * Free all associated resources
  86972. */
  86973. dispose(): void;
  86974. /**
  86975. * Clone the current geometry into a new geometry
  86976. * @param id defines the unique ID of the new geometry
  86977. * @returns a new geometry object
  86978. */
  86979. copy(id: string): Geometry;
  86980. /**
  86981. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86982. * @return a JSON representation of the current geometry data (without the vertices data)
  86983. */
  86984. serialize(): any;
  86985. private toNumberArray;
  86986. /**
  86987. * Serialize all vertices data into a JSON oject
  86988. * @returns a JSON representation of the current geometry data
  86989. */
  86990. serializeVerticeData(): any;
  86991. /**
  86992. * Extracts a clone of a mesh geometry
  86993. * @param mesh defines the source mesh
  86994. * @param id defines the unique ID of the new geometry object
  86995. * @returns the new geometry object
  86996. */
  86997. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86998. /**
  86999. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87000. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87001. * Be aware Math.random() could cause collisions, but:
  87002. * "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"
  87003. * @returns a string containing a new GUID
  87004. */
  87005. static RandomId(): string;
  87006. /** @hidden */
  87007. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87008. private static _CleanMatricesWeights;
  87009. /**
  87010. * Create a new geometry from persisted data (Using .babylon file format)
  87011. * @param parsedVertexData defines the persisted data
  87012. * @param scene defines the hosting scene
  87013. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87014. * @returns the new geometry object
  87015. */
  87016. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87017. }
  87018. }
  87019. declare module BABYLON {
  87020. /**
  87021. * Define an interface for all classes that will get and set the data on vertices
  87022. */
  87023. export interface IGetSetVerticesData {
  87024. /**
  87025. * Gets a boolean indicating if specific vertex data is present
  87026. * @param kind defines the vertex data kind to use
  87027. * @returns true is data kind is present
  87028. */
  87029. isVerticesDataPresent(kind: string): boolean;
  87030. /**
  87031. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87032. * @param kind defines the data kind (Position, normal, etc...)
  87033. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87034. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87035. * @returns a float array containing vertex data
  87036. */
  87037. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87038. /**
  87039. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87040. * @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.
  87041. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87042. * @returns the indices array or an empty array if the mesh has no geometry
  87043. */
  87044. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87045. /**
  87046. * Set specific vertex data
  87047. * @param kind defines the data kind (Position, normal, etc...)
  87048. * @param data defines the vertex data to use
  87049. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87050. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87051. */
  87052. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87053. /**
  87054. * Update a specific associated vertex buffer
  87055. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87056. * - VertexBuffer.PositionKind
  87057. * - VertexBuffer.UVKind
  87058. * - VertexBuffer.UV2Kind
  87059. * - VertexBuffer.UV3Kind
  87060. * - VertexBuffer.UV4Kind
  87061. * - VertexBuffer.UV5Kind
  87062. * - VertexBuffer.UV6Kind
  87063. * - VertexBuffer.ColorKind
  87064. * - VertexBuffer.MatricesIndicesKind
  87065. * - VertexBuffer.MatricesIndicesExtraKind
  87066. * - VertexBuffer.MatricesWeightsKind
  87067. * - VertexBuffer.MatricesWeightsExtraKind
  87068. * @param data defines the data source
  87069. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87070. * @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)
  87071. */
  87072. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87073. /**
  87074. * Creates a new index buffer
  87075. * @param indices defines the indices to store in the index buffer
  87076. * @param totalVertices defines the total number of vertices (could be null)
  87077. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87078. */
  87079. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87080. }
  87081. /**
  87082. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87083. */
  87084. export class VertexData {
  87085. /**
  87086. * Mesh side orientation : usually the external or front surface
  87087. */
  87088. static readonly FRONTSIDE: number;
  87089. /**
  87090. * Mesh side orientation : usually the internal or back surface
  87091. */
  87092. static readonly BACKSIDE: number;
  87093. /**
  87094. * Mesh side orientation : both internal and external or front and back surfaces
  87095. */
  87096. static readonly DOUBLESIDE: number;
  87097. /**
  87098. * Mesh side orientation : by default, `FRONTSIDE`
  87099. */
  87100. static readonly DEFAULTSIDE: number;
  87101. /**
  87102. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87103. */
  87104. positions: Nullable<FloatArray>;
  87105. /**
  87106. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87107. */
  87108. normals: Nullable<FloatArray>;
  87109. /**
  87110. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87111. */
  87112. tangents: Nullable<FloatArray>;
  87113. /**
  87114. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87115. */
  87116. uvs: Nullable<FloatArray>;
  87117. /**
  87118. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87119. */
  87120. uvs2: Nullable<FloatArray>;
  87121. /**
  87122. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87123. */
  87124. uvs3: Nullable<FloatArray>;
  87125. /**
  87126. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87127. */
  87128. uvs4: Nullable<FloatArray>;
  87129. /**
  87130. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87131. */
  87132. uvs5: Nullable<FloatArray>;
  87133. /**
  87134. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87135. */
  87136. uvs6: Nullable<FloatArray>;
  87137. /**
  87138. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87139. */
  87140. colors: Nullable<FloatArray>;
  87141. /**
  87142. * 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).
  87143. */
  87144. matricesIndices: Nullable<FloatArray>;
  87145. /**
  87146. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87147. */
  87148. matricesWeights: Nullable<FloatArray>;
  87149. /**
  87150. * An array extending the number of possible indices
  87151. */
  87152. matricesIndicesExtra: Nullable<FloatArray>;
  87153. /**
  87154. * An array extending the number of possible weights when the number of indices is extended
  87155. */
  87156. matricesWeightsExtra: Nullable<FloatArray>;
  87157. /**
  87158. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87159. */
  87160. indices: Nullable<IndicesArray>;
  87161. /**
  87162. * Uses the passed data array to set the set the values for the specified kind of data
  87163. * @param data a linear array of floating numbers
  87164. * @param kind the type of data that is being set, eg positions, colors etc
  87165. */
  87166. set(data: FloatArray, kind: string): void;
  87167. /**
  87168. * Associates the vertexData to the passed Mesh.
  87169. * Sets it as updatable or not (default `false`)
  87170. * @param mesh the mesh the vertexData is applied to
  87171. * @param updatable when used and having the value true allows new data to update the vertexData
  87172. * @returns the VertexData
  87173. */
  87174. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87175. /**
  87176. * Associates the vertexData to the passed Geometry.
  87177. * Sets it as updatable or not (default `false`)
  87178. * @param geometry the geometry the vertexData is applied to
  87179. * @param updatable when used and having the value true allows new data to update the vertexData
  87180. * @returns VertexData
  87181. */
  87182. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87183. /**
  87184. * Updates the associated mesh
  87185. * @param mesh the mesh to be updated
  87186. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87187. * @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
  87188. * @returns VertexData
  87189. */
  87190. updateMesh(mesh: Mesh): VertexData;
  87191. /**
  87192. * Updates the associated geometry
  87193. * @param geometry the geometry to be updated
  87194. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87195. * @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
  87196. * @returns VertexData.
  87197. */
  87198. updateGeometry(geometry: Geometry): VertexData;
  87199. private _applyTo;
  87200. private _update;
  87201. /**
  87202. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87203. * @param matrix the transforming matrix
  87204. * @returns the VertexData
  87205. */
  87206. transform(matrix: Matrix): VertexData;
  87207. /**
  87208. * Merges the passed VertexData into the current one
  87209. * @param other the VertexData to be merged into the current one
  87210. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87211. * @returns the modified VertexData
  87212. */
  87213. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87214. private _mergeElement;
  87215. private _validate;
  87216. /**
  87217. * Serializes the VertexData
  87218. * @returns a serialized object
  87219. */
  87220. serialize(): any;
  87221. /**
  87222. * Extracts the vertexData from a mesh
  87223. * @param mesh the mesh from which to extract the VertexData
  87224. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87225. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87226. * @returns the object VertexData associated to the passed mesh
  87227. */
  87228. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87229. /**
  87230. * Extracts the vertexData from the geometry
  87231. * @param geometry the geometry from which to extract the VertexData
  87232. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87233. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87234. * @returns the object VertexData associated to the passed mesh
  87235. */
  87236. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87237. private static _ExtractFrom;
  87238. /**
  87239. * Creates the VertexData for a Ribbon
  87240. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87241. * * pathArray array of paths, each of which an array of successive Vector3
  87242. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87243. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87244. * * 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
  87245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87246. * * 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)
  87247. * * 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)
  87248. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87249. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87250. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87251. * @returns the VertexData of the ribbon
  87252. */
  87253. static CreateRibbon(options: {
  87254. pathArray: Vector3[][];
  87255. closeArray?: boolean;
  87256. closePath?: boolean;
  87257. offset?: number;
  87258. sideOrientation?: number;
  87259. frontUVs?: Vector4;
  87260. backUVs?: Vector4;
  87261. invertUV?: boolean;
  87262. uvs?: Vector2[];
  87263. colors?: Color4[];
  87264. }): VertexData;
  87265. /**
  87266. * Creates the VertexData for a box
  87267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87268. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87269. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87270. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87271. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87272. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87273. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87275. * * 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)
  87276. * * 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)
  87277. * @returns the VertexData of the box
  87278. */
  87279. static CreateBox(options: {
  87280. size?: number;
  87281. width?: number;
  87282. height?: number;
  87283. depth?: number;
  87284. faceUV?: Vector4[];
  87285. faceColors?: Color4[];
  87286. sideOrientation?: number;
  87287. frontUVs?: Vector4;
  87288. backUVs?: Vector4;
  87289. }): VertexData;
  87290. /**
  87291. * Creates the VertexData for a tiled box
  87292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87293. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87294. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87295. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87297. * @returns the VertexData of the box
  87298. */
  87299. static CreateTiledBox(options: {
  87300. pattern?: number;
  87301. width?: number;
  87302. height?: number;
  87303. depth?: number;
  87304. tileSize?: number;
  87305. tileWidth?: number;
  87306. tileHeight?: number;
  87307. alignHorizontal?: number;
  87308. alignVertical?: number;
  87309. faceUV?: Vector4[];
  87310. faceColors?: Color4[];
  87311. sideOrientation?: number;
  87312. }): VertexData;
  87313. /**
  87314. * Creates the VertexData for a tiled plane
  87315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87316. * * pattern a limited pattern arrangement depending on the number
  87317. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87318. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87319. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87321. * * 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)
  87322. * * 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)
  87323. * @returns the VertexData of the tiled plane
  87324. */
  87325. static CreateTiledPlane(options: {
  87326. pattern?: number;
  87327. tileSize?: number;
  87328. tileWidth?: number;
  87329. tileHeight?: number;
  87330. size?: number;
  87331. width?: number;
  87332. height?: number;
  87333. alignHorizontal?: number;
  87334. alignVertical?: number;
  87335. sideOrientation?: number;
  87336. frontUVs?: Vector4;
  87337. backUVs?: Vector4;
  87338. }): VertexData;
  87339. /**
  87340. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87341. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87342. * * segments sets the number of horizontal strips optional, default 32
  87343. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87344. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87345. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87346. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87347. * * 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
  87348. * * 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
  87349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87350. * * 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)
  87351. * * 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)
  87352. * @returns the VertexData of the ellipsoid
  87353. */
  87354. static CreateSphere(options: {
  87355. segments?: number;
  87356. diameter?: number;
  87357. diameterX?: number;
  87358. diameterY?: number;
  87359. diameterZ?: number;
  87360. arc?: number;
  87361. slice?: number;
  87362. sideOrientation?: number;
  87363. frontUVs?: Vector4;
  87364. backUVs?: Vector4;
  87365. }): VertexData;
  87366. /**
  87367. * Creates the VertexData for a cylinder, cone or prism
  87368. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87369. * * height sets the height (y direction) of the cylinder, optional, default 2
  87370. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87371. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87372. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87373. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87374. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87375. * * 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
  87376. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87377. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87378. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87379. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87381. * * 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)
  87382. * * 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)
  87383. * @returns the VertexData of the cylinder, cone or prism
  87384. */
  87385. static CreateCylinder(options: {
  87386. height?: number;
  87387. diameterTop?: number;
  87388. diameterBottom?: number;
  87389. diameter?: number;
  87390. tessellation?: number;
  87391. subdivisions?: number;
  87392. arc?: number;
  87393. faceColors?: Color4[];
  87394. faceUV?: Vector4[];
  87395. hasRings?: boolean;
  87396. enclose?: boolean;
  87397. sideOrientation?: number;
  87398. frontUVs?: Vector4;
  87399. backUVs?: Vector4;
  87400. }): VertexData;
  87401. /**
  87402. * Creates the VertexData for a torus
  87403. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87404. * * diameter the diameter of the torus, optional default 1
  87405. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87406. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87408. * * 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)
  87409. * * 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)
  87410. * @returns the VertexData of the torus
  87411. */
  87412. static CreateTorus(options: {
  87413. diameter?: number;
  87414. thickness?: number;
  87415. tessellation?: number;
  87416. sideOrientation?: number;
  87417. frontUVs?: Vector4;
  87418. backUVs?: Vector4;
  87419. }): VertexData;
  87420. /**
  87421. * Creates the VertexData of the LineSystem
  87422. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87423. * - lines an array of lines, each line being an array of successive Vector3
  87424. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87425. * @returns the VertexData of the LineSystem
  87426. */
  87427. static CreateLineSystem(options: {
  87428. lines: Vector3[][];
  87429. colors?: Nullable<Color4[][]>;
  87430. }): VertexData;
  87431. /**
  87432. * Create the VertexData for a DashedLines
  87433. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87434. * - points an array successive Vector3
  87435. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87436. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87437. * - dashNb the intended total number of dashes, optional, default 200
  87438. * @returns the VertexData for the DashedLines
  87439. */
  87440. static CreateDashedLines(options: {
  87441. points: Vector3[];
  87442. dashSize?: number;
  87443. gapSize?: number;
  87444. dashNb?: number;
  87445. }): VertexData;
  87446. /**
  87447. * Creates the VertexData for a Ground
  87448. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87449. * - width the width (x direction) of the ground, optional, default 1
  87450. * - height the height (z direction) of the ground, optional, default 1
  87451. * - subdivisions the number of subdivisions per side, optional, default 1
  87452. * @returns the VertexData of the Ground
  87453. */
  87454. static CreateGround(options: {
  87455. width?: number;
  87456. height?: number;
  87457. subdivisions?: number;
  87458. subdivisionsX?: number;
  87459. subdivisionsY?: number;
  87460. }): VertexData;
  87461. /**
  87462. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87463. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87464. * * xmin the ground minimum X coordinate, optional, default -1
  87465. * * zmin the ground minimum Z coordinate, optional, default -1
  87466. * * xmax the ground maximum X coordinate, optional, default 1
  87467. * * zmax the ground maximum Z coordinate, optional, default 1
  87468. * * 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}
  87469. * * 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}
  87470. * @returns the VertexData of the TiledGround
  87471. */
  87472. static CreateTiledGround(options: {
  87473. xmin: number;
  87474. zmin: number;
  87475. xmax: number;
  87476. zmax: number;
  87477. subdivisions?: {
  87478. w: number;
  87479. h: number;
  87480. };
  87481. precision?: {
  87482. w: number;
  87483. h: number;
  87484. };
  87485. }): VertexData;
  87486. /**
  87487. * Creates the VertexData of the Ground designed from a heightmap
  87488. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87489. * * width the width (x direction) of the ground
  87490. * * height the height (z direction) of the ground
  87491. * * subdivisions the number of subdivisions per side
  87492. * * minHeight the minimum altitude on the ground, optional, default 0
  87493. * * maxHeight the maximum altitude on the ground, optional default 1
  87494. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87495. * * buffer the array holding the image color data
  87496. * * bufferWidth the width of image
  87497. * * bufferHeight the height of image
  87498. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87499. * @returns the VertexData of the Ground designed from a heightmap
  87500. */
  87501. static CreateGroundFromHeightMap(options: {
  87502. width: number;
  87503. height: number;
  87504. subdivisions: number;
  87505. minHeight: number;
  87506. maxHeight: number;
  87507. colorFilter: Color3;
  87508. buffer: Uint8Array;
  87509. bufferWidth: number;
  87510. bufferHeight: number;
  87511. alphaFilter: number;
  87512. }): VertexData;
  87513. /**
  87514. * Creates the VertexData for a Plane
  87515. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87516. * * size sets the width and height of the plane to the value of size, optional default 1
  87517. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87518. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87520. * * 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)
  87521. * * 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)
  87522. * @returns the VertexData of the box
  87523. */
  87524. static CreatePlane(options: {
  87525. size?: number;
  87526. width?: number;
  87527. height?: number;
  87528. sideOrientation?: number;
  87529. frontUVs?: Vector4;
  87530. backUVs?: Vector4;
  87531. }): VertexData;
  87532. /**
  87533. * Creates the VertexData of the Disc or regular Polygon
  87534. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87535. * * radius the radius of the disc, optional default 0.5
  87536. * * tessellation the number of polygon sides, optional, default 64
  87537. * * 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
  87538. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87539. * * 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)
  87540. * * 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)
  87541. * @returns the VertexData of the box
  87542. */
  87543. static CreateDisc(options: {
  87544. radius?: number;
  87545. tessellation?: number;
  87546. arc?: number;
  87547. sideOrientation?: number;
  87548. frontUVs?: Vector4;
  87549. backUVs?: Vector4;
  87550. }): VertexData;
  87551. /**
  87552. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87553. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87554. * @param polygon a mesh built from polygonTriangulation.build()
  87555. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87556. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87557. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87558. * @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)
  87559. * @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)
  87560. * @returns the VertexData of the Polygon
  87561. */
  87562. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87563. /**
  87564. * Creates the VertexData of the IcoSphere
  87565. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87566. * * radius the radius of the IcoSphere, optional default 1
  87567. * * radiusX allows stretching in the x direction, optional, default radius
  87568. * * radiusY allows stretching in the y direction, optional, default radius
  87569. * * radiusZ allows stretching in the z direction, optional, default radius
  87570. * * flat when true creates a flat shaded mesh, optional, default true
  87571. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87573. * * 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)
  87574. * * 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)
  87575. * @returns the VertexData of the IcoSphere
  87576. */
  87577. static CreateIcoSphere(options: {
  87578. radius?: number;
  87579. radiusX?: number;
  87580. radiusY?: number;
  87581. radiusZ?: number;
  87582. flat?: boolean;
  87583. subdivisions?: number;
  87584. sideOrientation?: number;
  87585. frontUVs?: Vector4;
  87586. backUVs?: Vector4;
  87587. }): VertexData;
  87588. /**
  87589. * Creates the VertexData for a Polyhedron
  87590. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87591. * * type provided types are:
  87592. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87593. * * 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)
  87594. * * size the size of the IcoSphere, optional default 1
  87595. * * sizeX allows stretching in the x direction, optional, default size
  87596. * * sizeY allows stretching in the y direction, optional, default size
  87597. * * sizeZ allows stretching in the z direction, optional, default size
  87598. * * 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
  87599. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87600. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87601. * * flat when true creates a flat shaded mesh, optional, default true
  87602. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87604. * * 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)
  87605. * * 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)
  87606. * @returns the VertexData of the Polyhedron
  87607. */
  87608. static CreatePolyhedron(options: {
  87609. type?: number;
  87610. size?: number;
  87611. sizeX?: number;
  87612. sizeY?: number;
  87613. sizeZ?: number;
  87614. custom?: any;
  87615. faceUV?: Vector4[];
  87616. faceColors?: Color4[];
  87617. flat?: boolean;
  87618. sideOrientation?: number;
  87619. frontUVs?: Vector4;
  87620. backUVs?: Vector4;
  87621. }): VertexData;
  87622. /**
  87623. * Creates the VertexData for a TorusKnot
  87624. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87625. * * radius the radius of the torus knot, optional, default 2
  87626. * * tube the thickness of the tube, optional, default 0.5
  87627. * * radialSegments the number of sides on each tube segments, optional, default 32
  87628. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87629. * * p the number of windings around the z axis, optional, default 2
  87630. * * q the number of windings around the x axis, optional, default 3
  87631. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87632. * * 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)
  87633. * * 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)
  87634. * @returns the VertexData of the Torus Knot
  87635. */
  87636. static CreateTorusKnot(options: {
  87637. radius?: number;
  87638. tube?: number;
  87639. radialSegments?: number;
  87640. tubularSegments?: number;
  87641. p?: number;
  87642. q?: number;
  87643. sideOrientation?: number;
  87644. frontUVs?: Vector4;
  87645. backUVs?: Vector4;
  87646. }): VertexData;
  87647. /**
  87648. * Compute normals for given positions and indices
  87649. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87650. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87651. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87652. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87653. * * facetNormals : optional array of facet normals (vector3)
  87654. * * facetPositions : optional array of facet positions (vector3)
  87655. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87656. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87657. * * bInfo : optional bounding info, required for facetPartitioning computation
  87658. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87659. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87660. * * useRightHandedSystem: optional boolean to for right handed system computation
  87661. * * depthSort : optional boolean to enable the facet depth sort computation
  87662. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87663. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87664. */
  87665. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87666. facetNormals?: any;
  87667. facetPositions?: any;
  87668. facetPartitioning?: any;
  87669. ratio?: number;
  87670. bInfo?: any;
  87671. bbSize?: Vector3;
  87672. subDiv?: any;
  87673. useRightHandedSystem?: boolean;
  87674. depthSort?: boolean;
  87675. distanceTo?: Vector3;
  87676. depthSortedFacets?: any;
  87677. }): void;
  87678. /** @hidden */
  87679. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87680. /**
  87681. * Applies VertexData created from the imported parameters to the geometry
  87682. * @param parsedVertexData the parsed data from an imported file
  87683. * @param geometry the geometry to apply the VertexData to
  87684. */
  87685. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87686. }
  87687. }
  87688. declare module BABYLON {
  87689. /**
  87690. * Defines a target to use with MorphTargetManager
  87691. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87692. */
  87693. export class MorphTarget implements IAnimatable {
  87694. /** defines the name of the target */
  87695. name: string;
  87696. /**
  87697. * Gets or sets the list of animations
  87698. */
  87699. animations: Animation[];
  87700. private _scene;
  87701. private _positions;
  87702. private _normals;
  87703. private _tangents;
  87704. private _uvs;
  87705. private _influence;
  87706. /**
  87707. * Observable raised when the influence changes
  87708. */
  87709. onInfluenceChanged: Observable<boolean>;
  87710. /** @hidden */
  87711. _onDataLayoutChanged: Observable<void>;
  87712. /**
  87713. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87714. */
  87715. influence: number;
  87716. /**
  87717. * Gets or sets the id of the morph Target
  87718. */
  87719. id: string;
  87720. private _animationPropertiesOverride;
  87721. /**
  87722. * Gets or sets the animation properties override
  87723. */
  87724. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87725. /**
  87726. * Creates a new MorphTarget
  87727. * @param name defines the name of the target
  87728. * @param influence defines the influence to use
  87729. * @param scene defines the scene the morphtarget belongs to
  87730. */
  87731. constructor(
  87732. /** defines the name of the target */
  87733. name: string, influence?: number, scene?: Nullable<Scene>);
  87734. /**
  87735. * Gets a boolean defining if the target contains position data
  87736. */
  87737. readonly hasPositions: boolean;
  87738. /**
  87739. * Gets a boolean defining if the target contains normal data
  87740. */
  87741. readonly hasNormals: boolean;
  87742. /**
  87743. * Gets a boolean defining if the target contains tangent data
  87744. */
  87745. readonly hasTangents: boolean;
  87746. /**
  87747. * Gets a boolean defining if the target contains texture coordinates data
  87748. */
  87749. readonly hasUVs: boolean;
  87750. /**
  87751. * Affects position data to this target
  87752. * @param data defines the position data to use
  87753. */
  87754. setPositions(data: Nullable<FloatArray>): void;
  87755. /**
  87756. * Gets the position data stored in this target
  87757. * @returns a FloatArray containing the position data (or null if not present)
  87758. */
  87759. getPositions(): Nullable<FloatArray>;
  87760. /**
  87761. * Affects normal data to this target
  87762. * @param data defines the normal data to use
  87763. */
  87764. setNormals(data: Nullable<FloatArray>): void;
  87765. /**
  87766. * Gets the normal data stored in this target
  87767. * @returns a FloatArray containing the normal data (or null if not present)
  87768. */
  87769. getNormals(): Nullable<FloatArray>;
  87770. /**
  87771. * Affects tangent data to this target
  87772. * @param data defines the tangent data to use
  87773. */
  87774. setTangents(data: Nullable<FloatArray>): void;
  87775. /**
  87776. * Gets the tangent data stored in this target
  87777. * @returns a FloatArray containing the tangent data (or null if not present)
  87778. */
  87779. getTangents(): Nullable<FloatArray>;
  87780. /**
  87781. * Affects texture coordinates data to this target
  87782. * @param data defines the texture coordinates data to use
  87783. */
  87784. setUVs(data: Nullable<FloatArray>): void;
  87785. /**
  87786. * Gets the texture coordinates data stored in this target
  87787. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87788. */
  87789. getUVs(): Nullable<FloatArray>;
  87790. /**
  87791. * Serializes the current target into a Serialization object
  87792. * @returns the serialized object
  87793. */
  87794. serialize(): any;
  87795. /**
  87796. * Returns the string "MorphTarget"
  87797. * @returns "MorphTarget"
  87798. */
  87799. getClassName(): string;
  87800. /**
  87801. * Creates a new target from serialized data
  87802. * @param serializationObject defines the serialized data to use
  87803. * @returns a new MorphTarget
  87804. */
  87805. static Parse(serializationObject: any): MorphTarget;
  87806. /**
  87807. * Creates a MorphTarget from mesh data
  87808. * @param mesh defines the source mesh
  87809. * @param name defines the name to use for the new target
  87810. * @param influence defines the influence to attach to the target
  87811. * @returns a new MorphTarget
  87812. */
  87813. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87814. }
  87815. }
  87816. declare module BABYLON {
  87817. /**
  87818. * This class is used to deform meshes using morphing between different targets
  87819. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87820. */
  87821. export class MorphTargetManager {
  87822. private _targets;
  87823. private _targetInfluenceChangedObservers;
  87824. private _targetDataLayoutChangedObservers;
  87825. private _activeTargets;
  87826. private _scene;
  87827. private _influences;
  87828. private _supportsNormals;
  87829. private _supportsTangents;
  87830. private _supportsUVs;
  87831. private _vertexCount;
  87832. private _uniqueId;
  87833. private _tempInfluences;
  87834. /**
  87835. * Gets or sets a boolean indicating if normals must be morphed
  87836. */
  87837. enableNormalMorphing: boolean;
  87838. /**
  87839. * Gets or sets a boolean indicating if tangents must be morphed
  87840. */
  87841. enableTangentMorphing: boolean;
  87842. /**
  87843. * Gets or sets a boolean indicating if UV must be morphed
  87844. */
  87845. enableUVMorphing: boolean;
  87846. /**
  87847. * Creates a new MorphTargetManager
  87848. * @param scene defines the current scene
  87849. */
  87850. constructor(scene?: Nullable<Scene>);
  87851. /**
  87852. * Gets the unique ID of this manager
  87853. */
  87854. readonly uniqueId: number;
  87855. /**
  87856. * Gets the number of vertices handled by this manager
  87857. */
  87858. readonly vertexCount: number;
  87859. /**
  87860. * Gets a boolean indicating if this manager supports morphing of normals
  87861. */
  87862. readonly supportsNormals: boolean;
  87863. /**
  87864. * Gets a boolean indicating if this manager supports morphing of tangents
  87865. */
  87866. readonly supportsTangents: boolean;
  87867. /**
  87868. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87869. */
  87870. readonly supportsUVs: boolean;
  87871. /**
  87872. * Gets the number of targets stored in this manager
  87873. */
  87874. readonly numTargets: number;
  87875. /**
  87876. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87877. */
  87878. readonly numInfluencers: number;
  87879. /**
  87880. * Gets the list of influences (one per target)
  87881. */
  87882. readonly influences: Float32Array;
  87883. /**
  87884. * Gets the active target at specified index. An active target is a target with an influence > 0
  87885. * @param index defines the index to check
  87886. * @returns the requested target
  87887. */
  87888. getActiveTarget(index: number): MorphTarget;
  87889. /**
  87890. * Gets the target at specified index
  87891. * @param index defines the index to check
  87892. * @returns the requested target
  87893. */
  87894. getTarget(index: number): MorphTarget;
  87895. /**
  87896. * Add a new target to this manager
  87897. * @param target defines the target to add
  87898. */
  87899. addTarget(target: MorphTarget): void;
  87900. /**
  87901. * Removes a target from the manager
  87902. * @param target defines the target to remove
  87903. */
  87904. removeTarget(target: MorphTarget): void;
  87905. /**
  87906. * Serializes the current manager into a Serialization object
  87907. * @returns the serialized object
  87908. */
  87909. serialize(): any;
  87910. private _syncActiveTargets;
  87911. /**
  87912. * Syncrhonize the targets with all the meshes using this morph target manager
  87913. */
  87914. synchronize(): void;
  87915. /**
  87916. * Creates a new MorphTargetManager from serialized data
  87917. * @param serializationObject defines the serialized data
  87918. * @param scene defines the hosting scene
  87919. * @returns the new MorphTargetManager
  87920. */
  87921. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87922. }
  87923. }
  87924. declare module BABYLON {
  87925. /**
  87926. * Class used to represent a specific level of detail of a mesh
  87927. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87928. */
  87929. export class MeshLODLevel {
  87930. /** Defines the distance where this level should start being displayed */
  87931. distance: number;
  87932. /** Defines the mesh to use to render this level */
  87933. mesh: Nullable<Mesh>;
  87934. /**
  87935. * Creates a new LOD level
  87936. * @param distance defines the distance where this level should star being displayed
  87937. * @param mesh defines the mesh to use to render this level
  87938. */
  87939. constructor(
  87940. /** Defines the distance where this level should start being displayed */
  87941. distance: number,
  87942. /** Defines the mesh to use to render this level */
  87943. mesh: Nullable<Mesh>);
  87944. }
  87945. }
  87946. declare module BABYLON {
  87947. /**
  87948. * Mesh representing the gorund
  87949. */
  87950. export class GroundMesh extends Mesh {
  87951. /** If octree should be generated */
  87952. generateOctree: boolean;
  87953. private _heightQuads;
  87954. /** @hidden */
  87955. _subdivisionsX: number;
  87956. /** @hidden */
  87957. _subdivisionsY: number;
  87958. /** @hidden */
  87959. _width: number;
  87960. /** @hidden */
  87961. _height: number;
  87962. /** @hidden */
  87963. _minX: number;
  87964. /** @hidden */
  87965. _maxX: number;
  87966. /** @hidden */
  87967. _minZ: number;
  87968. /** @hidden */
  87969. _maxZ: number;
  87970. constructor(name: string, scene: Scene);
  87971. /**
  87972. * "GroundMesh"
  87973. * @returns "GroundMesh"
  87974. */
  87975. getClassName(): string;
  87976. /**
  87977. * The minimum of x and y subdivisions
  87978. */
  87979. readonly subdivisions: number;
  87980. /**
  87981. * X subdivisions
  87982. */
  87983. readonly subdivisionsX: number;
  87984. /**
  87985. * Y subdivisions
  87986. */
  87987. readonly subdivisionsY: number;
  87988. /**
  87989. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87990. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87991. * @param chunksCount the number of subdivisions for x and y
  87992. * @param octreeBlocksSize (Default: 32)
  87993. */
  87994. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87995. /**
  87996. * Returns a height (y) value in the Worl system :
  87997. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87998. * @param x x coordinate
  87999. * @param z z coordinate
  88000. * @returns the ground y position if (x, z) are outside the ground surface.
  88001. */
  88002. getHeightAtCoordinates(x: number, z: number): number;
  88003. /**
  88004. * Returns a normalized vector (Vector3) orthogonal to the ground
  88005. * at the ground coordinates (x, z) expressed in the World system.
  88006. * @param x x coordinate
  88007. * @param z z coordinate
  88008. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88009. */
  88010. getNormalAtCoordinates(x: number, z: number): Vector3;
  88011. /**
  88012. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88013. * at the ground coordinates (x, z) expressed in the World system.
  88014. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88015. * @param x x coordinate
  88016. * @param z z coordinate
  88017. * @param ref vector to store the result
  88018. * @returns the GroundMesh.
  88019. */
  88020. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88021. /**
  88022. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88023. * if the ground has been updated.
  88024. * This can be used in the render loop.
  88025. * @returns the GroundMesh.
  88026. */
  88027. updateCoordinateHeights(): GroundMesh;
  88028. private _getFacetAt;
  88029. private _initHeightQuads;
  88030. private _computeHeightQuads;
  88031. /**
  88032. * Serializes this ground mesh
  88033. * @param serializationObject object to write serialization to
  88034. */
  88035. serialize(serializationObject: any): void;
  88036. /**
  88037. * Parses a serialized ground mesh
  88038. * @param parsedMesh the serialized mesh
  88039. * @param scene the scene to create the ground mesh in
  88040. * @returns the created ground mesh
  88041. */
  88042. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88043. }
  88044. }
  88045. declare module BABYLON {
  88046. /**
  88047. * Interface for Physics-Joint data
  88048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88049. */
  88050. export interface PhysicsJointData {
  88051. /**
  88052. * The main pivot of the joint
  88053. */
  88054. mainPivot?: Vector3;
  88055. /**
  88056. * The connected pivot of the joint
  88057. */
  88058. connectedPivot?: Vector3;
  88059. /**
  88060. * The main axis of the joint
  88061. */
  88062. mainAxis?: Vector3;
  88063. /**
  88064. * The connected axis of the joint
  88065. */
  88066. connectedAxis?: Vector3;
  88067. /**
  88068. * The collision of the joint
  88069. */
  88070. collision?: boolean;
  88071. /**
  88072. * Native Oimo/Cannon/Energy data
  88073. */
  88074. nativeParams?: any;
  88075. }
  88076. /**
  88077. * This is a holder class for the physics joint created by the physics plugin
  88078. * It holds a set of functions to control the underlying joint
  88079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88080. */
  88081. export class PhysicsJoint {
  88082. /**
  88083. * The type of the physics joint
  88084. */
  88085. type: number;
  88086. /**
  88087. * The data for the physics joint
  88088. */
  88089. jointData: PhysicsJointData;
  88090. private _physicsJoint;
  88091. protected _physicsPlugin: IPhysicsEnginePlugin;
  88092. /**
  88093. * Initializes the physics joint
  88094. * @param type The type of the physics joint
  88095. * @param jointData The data for the physics joint
  88096. */
  88097. constructor(
  88098. /**
  88099. * The type of the physics joint
  88100. */
  88101. type: number,
  88102. /**
  88103. * The data for the physics joint
  88104. */
  88105. jointData: PhysicsJointData);
  88106. /**
  88107. * Gets the physics joint
  88108. */
  88109. /**
  88110. * Sets the physics joint
  88111. */
  88112. physicsJoint: any;
  88113. /**
  88114. * Sets the physics plugin
  88115. */
  88116. physicsPlugin: IPhysicsEnginePlugin;
  88117. /**
  88118. * Execute a function that is physics-plugin specific.
  88119. * @param {Function} func the function that will be executed.
  88120. * It accepts two parameters: the physics world and the physics joint
  88121. */
  88122. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88123. /**
  88124. * Distance-Joint type
  88125. */
  88126. static DistanceJoint: number;
  88127. /**
  88128. * Hinge-Joint type
  88129. */
  88130. static HingeJoint: number;
  88131. /**
  88132. * Ball-and-Socket joint type
  88133. */
  88134. static BallAndSocketJoint: number;
  88135. /**
  88136. * Wheel-Joint type
  88137. */
  88138. static WheelJoint: number;
  88139. /**
  88140. * Slider-Joint type
  88141. */
  88142. static SliderJoint: number;
  88143. /**
  88144. * Prismatic-Joint type
  88145. */
  88146. static PrismaticJoint: number;
  88147. /**
  88148. * Universal-Joint type
  88149. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88150. */
  88151. static UniversalJoint: number;
  88152. /**
  88153. * Hinge-Joint 2 type
  88154. */
  88155. static Hinge2Joint: number;
  88156. /**
  88157. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88158. */
  88159. static PointToPointJoint: number;
  88160. /**
  88161. * Spring-Joint type
  88162. */
  88163. static SpringJoint: number;
  88164. /**
  88165. * Lock-Joint type
  88166. */
  88167. static LockJoint: number;
  88168. }
  88169. /**
  88170. * A class representing a physics distance joint
  88171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88172. */
  88173. export class DistanceJoint extends PhysicsJoint {
  88174. /**
  88175. *
  88176. * @param jointData The data for the Distance-Joint
  88177. */
  88178. constructor(jointData: DistanceJointData);
  88179. /**
  88180. * Update the predefined distance.
  88181. * @param maxDistance The maximum preferred distance
  88182. * @param minDistance The minimum preferred distance
  88183. */
  88184. updateDistance(maxDistance: number, minDistance?: number): void;
  88185. }
  88186. /**
  88187. * Represents a Motor-Enabled Joint
  88188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88189. */
  88190. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88191. /**
  88192. * Initializes the Motor-Enabled Joint
  88193. * @param type The type of the joint
  88194. * @param jointData The physica joint data for the joint
  88195. */
  88196. constructor(type: number, jointData: PhysicsJointData);
  88197. /**
  88198. * Set the motor values.
  88199. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88200. * @param force the force to apply
  88201. * @param maxForce max force for this motor.
  88202. */
  88203. setMotor(force?: number, maxForce?: number): void;
  88204. /**
  88205. * Set the motor's limits.
  88206. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88207. * @param upperLimit The upper limit of the motor
  88208. * @param lowerLimit The lower limit of the motor
  88209. */
  88210. setLimit(upperLimit: number, lowerLimit?: number): void;
  88211. }
  88212. /**
  88213. * This class represents a single physics Hinge-Joint
  88214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88215. */
  88216. export class HingeJoint extends MotorEnabledJoint {
  88217. /**
  88218. * Initializes the Hinge-Joint
  88219. * @param jointData The joint data for the Hinge-Joint
  88220. */
  88221. constructor(jointData: PhysicsJointData);
  88222. /**
  88223. * Set the motor values.
  88224. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88225. * @param {number} force the force to apply
  88226. * @param {number} maxForce max force for this motor.
  88227. */
  88228. setMotor(force?: number, maxForce?: number): void;
  88229. /**
  88230. * Set the motor's limits.
  88231. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88232. * @param upperLimit The upper limit of the motor
  88233. * @param lowerLimit The lower limit of the motor
  88234. */
  88235. setLimit(upperLimit: number, lowerLimit?: number): void;
  88236. }
  88237. /**
  88238. * This class represents a dual hinge physics joint (same as wheel joint)
  88239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88240. */
  88241. export class Hinge2Joint extends MotorEnabledJoint {
  88242. /**
  88243. * Initializes the Hinge2-Joint
  88244. * @param jointData The joint data for the Hinge2-Joint
  88245. */
  88246. constructor(jointData: PhysicsJointData);
  88247. /**
  88248. * Set the motor values.
  88249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88250. * @param {number} targetSpeed the speed the motor is to reach
  88251. * @param {number} maxForce max force for this motor.
  88252. * @param {motorIndex} the motor's index, 0 or 1.
  88253. */
  88254. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88255. /**
  88256. * Set the motor limits.
  88257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88258. * @param {number} upperLimit the upper limit
  88259. * @param {number} lowerLimit lower limit
  88260. * @param {motorIndex} the motor's index, 0 or 1.
  88261. */
  88262. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88263. }
  88264. /**
  88265. * Interface for a motor enabled joint
  88266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88267. */
  88268. export interface IMotorEnabledJoint {
  88269. /**
  88270. * Physics joint
  88271. */
  88272. physicsJoint: any;
  88273. /**
  88274. * Sets the motor of the motor-enabled joint
  88275. * @param force The force of the motor
  88276. * @param maxForce The maximum force of the motor
  88277. * @param motorIndex The index of the motor
  88278. */
  88279. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88280. /**
  88281. * Sets the limit of the motor
  88282. * @param upperLimit The upper limit of the motor
  88283. * @param lowerLimit The lower limit of the motor
  88284. * @param motorIndex The index of the motor
  88285. */
  88286. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88287. }
  88288. /**
  88289. * Joint data for a Distance-Joint
  88290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88291. */
  88292. export interface DistanceJointData extends PhysicsJointData {
  88293. /**
  88294. * Max distance the 2 joint objects can be apart
  88295. */
  88296. maxDistance: number;
  88297. }
  88298. /**
  88299. * Joint data from a spring joint
  88300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88301. */
  88302. export interface SpringJointData extends PhysicsJointData {
  88303. /**
  88304. * Length of the spring
  88305. */
  88306. length: number;
  88307. /**
  88308. * Stiffness of the spring
  88309. */
  88310. stiffness: number;
  88311. /**
  88312. * Damping of the spring
  88313. */
  88314. damping: number;
  88315. /** this callback will be called when applying the force to the impostors. */
  88316. forceApplicationCallback: () => void;
  88317. }
  88318. }
  88319. declare module BABYLON {
  88320. /**
  88321. * Holds the data for the raycast result
  88322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88323. */
  88324. export class PhysicsRaycastResult {
  88325. private _hasHit;
  88326. private _hitDistance;
  88327. private _hitNormalWorld;
  88328. private _hitPointWorld;
  88329. private _rayFromWorld;
  88330. private _rayToWorld;
  88331. /**
  88332. * Gets if there was a hit
  88333. */
  88334. readonly hasHit: boolean;
  88335. /**
  88336. * Gets the distance from the hit
  88337. */
  88338. readonly hitDistance: number;
  88339. /**
  88340. * Gets the hit normal/direction in the world
  88341. */
  88342. readonly hitNormalWorld: Vector3;
  88343. /**
  88344. * Gets the hit point in the world
  88345. */
  88346. readonly hitPointWorld: Vector3;
  88347. /**
  88348. * Gets the ray "start point" of the ray in the world
  88349. */
  88350. readonly rayFromWorld: Vector3;
  88351. /**
  88352. * Gets the ray "end point" of the ray in the world
  88353. */
  88354. readonly rayToWorld: Vector3;
  88355. /**
  88356. * Sets the hit data (normal & point in world space)
  88357. * @param hitNormalWorld defines the normal in world space
  88358. * @param hitPointWorld defines the point in world space
  88359. */
  88360. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88361. /**
  88362. * Sets the distance from the start point to the hit point
  88363. * @param distance
  88364. */
  88365. setHitDistance(distance: number): void;
  88366. /**
  88367. * Calculates the distance manually
  88368. */
  88369. calculateHitDistance(): void;
  88370. /**
  88371. * Resets all the values to default
  88372. * @param from The from point on world space
  88373. * @param to The to point on world space
  88374. */
  88375. reset(from?: Vector3, to?: Vector3): void;
  88376. }
  88377. /**
  88378. * Interface for the size containing width and height
  88379. */
  88380. interface IXYZ {
  88381. /**
  88382. * X
  88383. */
  88384. x: number;
  88385. /**
  88386. * Y
  88387. */
  88388. y: number;
  88389. /**
  88390. * Z
  88391. */
  88392. z: number;
  88393. }
  88394. }
  88395. declare module BABYLON {
  88396. /**
  88397. * Interface used to describe a physics joint
  88398. */
  88399. export interface PhysicsImpostorJoint {
  88400. /** Defines the main impostor to which the joint is linked */
  88401. mainImpostor: PhysicsImpostor;
  88402. /** Defines the impostor that is connected to the main impostor using this joint */
  88403. connectedImpostor: PhysicsImpostor;
  88404. /** Defines the joint itself */
  88405. joint: PhysicsJoint;
  88406. }
  88407. /** @hidden */
  88408. export interface IPhysicsEnginePlugin {
  88409. world: any;
  88410. name: string;
  88411. setGravity(gravity: Vector3): void;
  88412. setTimeStep(timeStep: number): void;
  88413. getTimeStep(): number;
  88414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88415. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88416. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88417. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88418. removePhysicsBody(impostor: PhysicsImpostor): void;
  88419. generateJoint(joint: PhysicsImpostorJoint): void;
  88420. removeJoint(joint: PhysicsImpostorJoint): void;
  88421. isSupported(): boolean;
  88422. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88423. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88424. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88425. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88426. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88427. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88428. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88429. getBodyMass(impostor: PhysicsImpostor): number;
  88430. getBodyFriction(impostor: PhysicsImpostor): number;
  88431. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88432. getBodyRestitution(impostor: PhysicsImpostor): number;
  88433. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88434. getBodyPressure?(impostor: PhysicsImpostor): number;
  88435. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88436. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88437. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88438. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88439. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88440. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88441. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88442. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88443. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88444. sleepBody(impostor: PhysicsImpostor): void;
  88445. wakeUpBody(impostor: PhysicsImpostor): void;
  88446. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88447. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88448. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88449. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88450. getRadius(impostor: PhysicsImpostor): number;
  88451. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88452. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88453. dispose(): void;
  88454. }
  88455. /**
  88456. * Interface used to define a physics engine
  88457. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88458. */
  88459. export interface IPhysicsEngine {
  88460. /**
  88461. * Gets the gravity vector used by the simulation
  88462. */
  88463. gravity: Vector3;
  88464. /**
  88465. * Sets the gravity vector used by the simulation
  88466. * @param gravity defines the gravity vector to use
  88467. */
  88468. setGravity(gravity: Vector3): void;
  88469. /**
  88470. * Set the time step of the physics engine.
  88471. * Default is 1/60.
  88472. * To slow it down, enter 1/600 for example.
  88473. * To speed it up, 1/30
  88474. * @param newTimeStep the new timestep to apply to this world.
  88475. */
  88476. setTimeStep(newTimeStep: number): void;
  88477. /**
  88478. * Get the time step of the physics engine.
  88479. * @returns the current time step
  88480. */
  88481. getTimeStep(): number;
  88482. /**
  88483. * Release all resources
  88484. */
  88485. dispose(): void;
  88486. /**
  88487. * Gets the name of the current physics plugin
  88488. * @returns the name of the plugin
  88489. */
  88490. getPhysicsPluginName(): string;
  88491. /**
  88492. * Adding a new impostor for the impostor tracking.
  88493. * This will be done by the impostor itself.
  88494. * @param impostor the impostor to add
  88495. */
  88496. addImpostor(impostor: PhysicsImpostor): void;
  88497. /**
  88498. * Remove an impostor from the engine.
  88499. * This impostor and its mesh will not longer be updated by the physics engine.
  88500. * @param impostor the impostor to remove
  88501. */
  88502. removeImpostor(impostor: PhysicsImpostor): void;
  88503. /**
  88504. * Add a joint to the physics engine
  88505. * @param mainImpostor defines the main impostor to which the joint is added.
  88506. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88507. * @param joint defines the joint that will connect both impostors.
  88508. */
  88509. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88510. /**
  88511. * Removes a joint from the simulation
  88512. * @param mainImpostor defines the impostor used with the joint
  88513. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88514. * @param joint defines the joint to remove
  88515. */
  88516. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88517. /**
  88518. * Gets the current plugin used to run the simulation
  88519. * @returns current plugin
  88520. */
  88521. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88522. /**
  88523. * Gets the list of physic impostors
  88524. * @returns an array of PhysicsImpostor
  88525. */
  88526. getImpostors(): Array<PhysicsImpostor>;
  88527. /**
  88528. * Gets the impostor for a physics enabled object
  88529. * @param object defines the object impersonated by the impostor
  88530. * @returns the PhysicsImpostor or null if not found
  88531. */
  88532. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88533. /**
  88534. * Gets the impostor for a physics body object
  88535. * @param body defines physics body used by the impostor
  88536. * @returns the PhysicsImpostor or null if not found
  88537. */
  88538. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88539. /**
  88540. * Does a raycast in the physics world
  88541. * @param from when should the ray start?
  88542. * @param to when should the ray end?
  88543. * @returns PhysicsRaycastResult
  88544. */
  88545. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88546. /**
  88547. * Called by the scene. No need to call it.
  88548. * @param delta defines the timespam between frames
  88549. */
  88550. _step(delta: number): void;
  88551. }
  88552. }
  88553. declare module BABYLON {
  88554. /**
  88555. * The interface for the physics imposter parameters
  88556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88557. */
  88558. export interface PhysicsImpostorParameters {
  88559. /**
  88560. * The mass of the physics imposter
  88561. */
  88562. mass: number;
  88563. /**
  88564. * The friction of the physics imposter
  88565. */
  88566. friction?: number;
  88567. /**
  88568. * The coefficient of restitution of the physics imposter
  88569. */
  88570. restitution?: number;
  88571. /**
  88572. * The native options of the physics imposter
  88573. */
  88574. nativeOptions?: any;
  88575. /**
  88576. * Specifies if the parent should be ignored
  88577. */
  88578. ignoreParent?: boolean;
  88579. /**
  88580. * Specifies if bi-directional transformations should be disabled
  88581. */
  88582. disableBidirectionalTransformation?: boolean;
  88583. /**
  88584. * The pressure inside the physics imposter, soft object only
  88585. */
  88586. pressure?: number;
  88587. /**
  88588. * The stiffness the physics imposter, soft object only
  88589. */
  88590. stiffness?: number;
  88591. /**
  88592. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88593. */
  88594. velocityIterations?: number;
  88595. /**
  88596. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88597. */
  88598. positionIterations?: number;
  88599. /**
  88600. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88601. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88602. * Add to fix multiple points
  88603. */
  88604. fixedPoints?: number;
  88605. /**
  88606. * The collision margin around a soft object
  88607. */
  88608. margin?: number;
  88609. /**
  88610. * The collision margin around a soft object
  88611. */
  88612. damping?: number;
  88613. /**
  88614. * The path for a rope based on an extrusion
  88615. */
  88616. path?: any;
  88617. /**
  88618. * The shape of an extrusion used for a rope based on an extrusion
  88619. */
  88620. shape?: any;
  88621. }
  88622. /**
  88623. * Interface for a physics-enabled object
  88624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88625. */
  88626. export interface IPhysicsEnabledObject {
  88627. /**
  88628. * The position of the physics-enabled object
  88629. */
  88630. position: Vector3;
  88631. /**
  88632. * The rotation of the physics-enabled object
  88633. */
  88634. rotationQuaternion: Nullable<Quaternion>;
  88635. /**
  88636. * The scale of the physics-enabled object
  88637. */
  88638. scaling: Vector3;
  88639. /**
  88640. * The rotation of the physics-enabled object
  88641. */
  88642. rotation?: Vector3;
  88643. /**
  88644. * The parent of the physics-enabled object
  88645. */
  88646. parent?: any;
  88647. /**
  88648. * The bounding info of the physics-enabled object
  88649. * @returns The bounding info of the physics-enabled object
  88650. */
  88651. getBoundingInfo(): BoundingInfo;
  88652. /**
  88653. * Computes the world matrix
  88654. * @param force Specifies if the world matrix should be computed by force
  88655. * @returns A world matrix
  88656. */
  88657. computeWorldMatrix(force: boolean): Matrix;
  88658. /**
  88659. * Gets the world matrix
  88660. * @returns A world matrix
  88661. */
  88662. getWorldMatrix?(): Matrix;
  88663. /**
  88664. * Gets the child meshes
  88665. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88666. * @returns An array of abstract meshes
  88667. */
  88668. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88669. /**
  88670. * Gets the vertex data
  88671. * @param kind The type of vertex data
  88672. * @returns A nullable array of numbers, or a float32 array
  88673. */
  88674. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88675. /**
  88676. * Gets the indices from the mesh
  88677. * @returns A nullable array of index arrays
  88678. */
  88679. getIndices?(): Nullable<IndicesArray>;
  88680. /**
  88681. * Gets the scene from the mesh
  88682. * @returns the indices array or null
  88683. */
  88684. getScene?(): Scene;
  88685. /**
  88686. * Gets the absolute position from the mesh
  88687. * @returns the absolute position
  88688. */
  88689. getAbsolutePosition(): Vector3;
  88690. /**
  88691. * Gets the absolute pivot point from the mesh
  88692. * @returns the absolute pivot point
  88693. */
  88694. getAbsolutePivotPoint(): Vector3;
  88695. /**
  88696. * Rotates the mesh
  88697. * @param axis The axis of rotation
  88698. * @param amount The amount of rotation
  88699. * @param space The space of the rotation
  88700. * @returns The rotation transform node
  88701. */
  88702. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88703. /**
  88704. * Translates the mesh
  88705. * @param axis The axis of translation
  88706. * @param distance The distance of translation
  88707. * @param space The space of the translation
  88708. * @returns The transform node
  88709. */
  88710. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88711. /**
  88712. * Sets the absolute position of the mesh
  88713. * @param absolutePosition The absolute position of the mesh
  88714. * @returns The transform node
  88715. */
  88716. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88717. /**
  88718. * Gets the class name of the mesh
  88719. * @returns The class name
  88720. */
  88721. getClassName(): string;
  88722. }
  88723. /**
  88724. * Represents a physics imposter
  88725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88726. */
  88727. export class PhysicsImpostor {
  88728. /**
  88729. * The physics-enabled object used as the physics imposter
  88730. */
  88731. object: IPhysicsEnabledObject;
  88732. /**
  88733. * The type of the physics imposter
  88734. */
  88735. type: number;
  88736. private _options;
  88737. private _scene?;
  88738. /**
  88739. * The default object size of the imposter
  88740. */
  88741. static DEFAULT_OBJECT_SIZE: Vector3;
  88742. /**
  88743. * The identity quaternion of the imposter
  88744. */
  88745. static IDENTITY_QUATERNION: Quaternion;
  88746. /** @hidden */
  88747. _pluginData: any;
  88748. private _physicsEngine;
  88749. private _physicsBody;
  88750. private _bodyUpdateRequired;
  88751. private _onBeforePhysicsStepCallbacks;
  88752. private _onAfterPhysicsStepCallbacks;
  88753. /** @hidden */
  88754. _onPhysicsCollideCallbacks: Array<{
  88755. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88756. otherImpostors: Array<PhysicsImpostor>;
  88757. }>;
  88758. private _deltaPosition;
  88759. private _deltaRotation;
  88760. private _deltaRotationConjugated;
  88761. /** @hidden */
  88762. _isFromLine: boolean;
  88763. private _parent;
  88764. private _isDisposed;
  88765. private static _tmpVecs;
  88766. private static _tmpQuat;
  88767. /**
  88768. * Specifies if the physics imposter is disposed
  88769. */
  88770. readonly isDisposed: boolean;
  88771. /**
  88772. * Gets the mass of the physics imposter
  88773. */
  88774. mass: number;
  88775. /**
  88776. * Gets the coefficient of friction
  88777. */
  88778. /**
  88779. * Sets the coefficient of friction
  88780. */
  88781. friction: number;
  88782. /**
  88783. * Gets the coefficient of restitution
  88784. */
  88785. /**
  88786. * Sets the coefficient of restitution
  88787. */
  88788. restitution: number;
  88789. /**
  88790. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88791. */
  88792. /**
  88793. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88794. */
  88795. pressure: number;
  88796. /**
  88797. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88798. */
  88799. /**
  88800. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88801. */
  88802. stiffness: number;
  88803. /**
  88804. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88805. */
  88806. /**
  88807. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88808. */
  88809. velocityIterations: number;
  88810. /**
  88811. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88812. */
  88813. /**
  88814. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88815. */
  88816. positionIterations: number;
  88817. /**
  88818. * The unique id of the physics imposter
  88819. * set by the physics engine when adding this impostor to the array
  88820. */
  88821. uniqueId: number;
  88822. /**
  88823. * @hidden
  88824. */
  88825. soft: boolean;
  88826. /**
  88827. * @hidden
  88828. */
  88829. segments: number;
  88830. private _joints;
  88831. /**
  88832. * Initializes the physics imposter
  88833. * @param object The physics-enabled object used as the physics imposter
  88834. * @param type The type of the physics imposter
  88835. * @param _options The options for the physics imposter
  88836. * @param _scene The Babylon scene
  88837. */
  88838. constructor(
  88839. /**
  88840. * The physics-enabled object used as the physics imposter
  88841. */
  88842. object: IPhysicsEnabledObject,
  88843. /**
  88844. * The type of the physics imposter
  88845. */
  88846. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88847. /**
  88848. * This function will completly initialize this impostor.
  88849. * It will create a new body - but only if this mesh has no parent.
  88850. * If it has, this impostor will not be used other than to define the impostor
  88851. * of the child mesh.
  88852. * @hidden
  88853. */
  88854. _init(): void;
  88855. private _getPhysicsParent;
  88856. /**
  88857. * Should a new body be generated.
  88858. * @returns boolean specifying if body initialization is required
  88859. */
  88860. isBodyInitRequired(): boolean;
  88861. /**
  88862. * Sets the updated scaling
  88863. * @param updated Specifies if the scaling is updated
  88864. */
  88865. setScalingUpdated(): void;
  88866. /**
  88867. * Force a regeneration of this or the parent's impostor's body.
  88868. * Use under cautious - This will remove all joints already implemented.
  88869. */
  88870. forceUpdate(): void;
  88871. /**
  88872. * Gets the body that holds this impostor. Either its own, or its parent.
  88873. */
  88874. /**
  88875. * Set the physics body. Used mainly by the physics engine/plugin
  88876. */
  88877. physicsBody: any;
  88878. /**
  88879. * Get the parent of the physics imposter
  88880. * @returns Physics imposter or null
  88881. */
  88882. /**
  88883. * Sets the parent of the physics imposter
  88884. */
  88885. parent: Nullable<PhysicsImpostor>;
  88886. /**
  88887. * Resets the update flags
  88888. */
  88889. resetUpdateFlags(): void;
  88890. /**
  88891. * Gets the object extend size
  88892. * @returns the object extend size
  88893. */
  88894. getObjectExtendSize(): Vector3;
  88895. /**
  88896. * Gets the object center
  88897. * @returns The object center
  88898. */
  88899. getObjectCenter(): Vector3;
  88900. /**
  88901. * Get a specific parametes from the options parameter
  88902. * @param paramName The object parameter name
  88903. * @returns The object parameter
  88904. */
  88905. getParam(paramName: string): any;
  88906. /**
  88907. * Sets a specific parameter in the options given to the physics plugin
  88908. * @param paramName The parameter name
  88909. * @param value The value of the parameter
  88910. */
  88911. setParam(paramName: string, value: number): void;
  88912. /**
  88913. * Specifically change the body's mass option. Won't recreate the physics body object
  88914. * @param mass The mass of the physics imposter
  88915. */
  88916. setMass(mass: number): void;
  88917. /**
  88918. * Gets the linear velocity
  88919. * @returns linear velocity or null
  88920. */
  88921. getLinearVelocity(): Nullable<Vector3>;
  88922. /**
  88923. * Sets the linear velocity
  88924. * @param velocity linear velocity or null
  88925. */
  88926. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88927. /**
  88928. * Gets the angular velocity
  88929. * @returns angular velocity or null
  88930. */
  88931. getAngularVelocity(): Nullable<Vector3>;
  88932. /**
  88933. * Sets the angular velocity
  88934. * @param velocity The velocity or null
  88935. */
  88936. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88937. /**
  88938. * Execute a function with the physics plugin native code
  88939. * Provide a function the will have two variables - the world object and the physics body object
  88940. * @param func The function to execute with the physics plugin native code
  88941. */
  88942. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88943. /**
  88944. * Register a function that will be executed before the physics world is stepping forward
  88945. * @param func The function to execute before the physics world is stepped forward
  88946. */
  88947. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88948. /**
  88949. * Unregister a function that will be executed before the physics world is stepping forward
  88950. * @param func The function to execute before the physics world is stepped forward
  88951. */
  88952. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88953. /**
  88954. * Register a function that will be executed after the physics step
  88955. * @param func The function to execute after physics step
  88956. */
  88957. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88958. /**
  88959. * Unregisters a function that will be executed after the physics step
  88960. * @param func The function to execute after physics step
  88961. */
  88962. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88963. /**
  88964. * register a function that will be executed when this impostor collides against a different body
  88965. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88966. * @param func Callback that is executed on collision
  88967. */
  88968. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88969. /**
  88970. * Unregisters the physics imposter on contact
  88971. * @param collideAgainst The physics object to collide against
  88972. * @param func Callback to execute on collision
  88973. */
  88974. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88975. private _tmpQuat;
  88976. private _tmpQuat2;
  88977. /**
  88978. * Get the parent rotation
  88979. * @returns The parent rotation
  88980. */
  88981. getParentsRotation(): Quaternion;
  88982. /**
  88983. * this function is executed by the physics engine.
  88984. */
  88985. beforeStep: () => void;
  88986. /**
  88987. * this function is executed by the physics engine
  88988. */
  88989. afterStep: () => void;
  88990. /**
  88991. * Legacy collision detection event support
  88992. */
  88993. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88994. /**
  88995. * event and body object due to cannon's event-based architecture.
  88996. */
  88997. onCollide: (e: {
  88998. body: any;
  88999. }) => void;
  89000. /**
  89001. * Apply a force
  89002. * @param force The force to apply
  89003. * @param contactPoint The contact point for the force
  89004. * @returns The physics imposter
  89005. */
  89006. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89007. /**
  89008. * Apply an impulse
  89009. * @param force The impulse force
  89010. * @param contactPoint The contact point for the impulse force
  89011. * @returns The physics imposter
  89012. */
  89013. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89014. /**
  89015. * A help function to create a joint
  89016. * @param otherImpostor A physics imposter used to create a joint
  89017. * @param jointType The type of joint
  89018. * @param jointData The data for the joint
  89019. * @returns The physics imposter
  89020. */
  89021. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89022. /**
  89023. * Add a joint to this impostor with a different impostor
  89024. * @param otherImpostor A physics imposter used to add a joint
  89025. * @param joint The joint to add
  89026. * @returns The physics imposter
  89027. */
  89028. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89029. /**
  89030. * Add an anchor to a cloth impostor
  89031. * @param otherImpostor rigid impostor to anchor to
  89032. * @param width ratio across width from 0 to 1
  89033. * @param height ratio up height from 0 to 1
  89034. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89035. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89036. * @returns impostor the soft imposter
  89037. */
  89038. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89039. /**
  89040. * Add a hook to a rope impostor
  89041. * @param otherImpostor rigid impostor to anchor to
  89042. * @param length ratio across rope from 0 to 1
  89043. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89044. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89045. * @returns impostor the rope imposter
  89046. */
  89047. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89048. /**
  89049. * Will keep this body still, in a sleep mode.
  89050. * @returns the physics imposter
  89051. */
  89052. sleep(): PhysicsImpostor;
  89053. /**
  89054. * Wake the body up.
  89055. * @returns The physics imposter
  89056. */
  89057. wakeUp(): PhysicsImpostor;
  89058. /**
  89059. * Clones the physics imposter
  89060. * @param newObject The physics imposter clones to this physics-enabled object
  89061. * @returns A nullable physics imposter
  89062. */
  89063. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89064. /**
  89065. * Disposes the physics imposter
  89066. */
  89067. dispose(): void;
  89068. /**
  89069. * Sets the delta position
  89070. * @param position The delta position amount
  89071. */
  89072. setDeltaPosition(position: Vector3): void;
  89073. /**
  89074. * Sets the delta rotation
  89075. * @param rotation The delta rotation amount
  89076. */
  89077. setDeltaRotation(rotation: Quaternion): void;
  89078. /**
  89079. * Gets the box size of the physics imposter and stores the result in the input parameter
  89080. * @param result Stores the box size
  89081. * @returns The physics imposter
  89082. */
  89083. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89084. /**
  89085. * Gets the radius of the physics imposter
  89086. * @returns Radius of the physics imposter
  89087. */
  89088. getRadius(): number;
  89089. /**
  89090. * Sync a bone with this impostor
  89091. * @param bone The bone to sync to the impostor.
  89092. * @param boneMesh The mesh that the bone is influencing.
  89093. * @param jointPivot The pivot of the joint / bone in local space.
  89094. * @param distToJoint Optional distance from the impostor to the joint.
  89095. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89096. */
  89097. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89098. /**
  89099. * Sync impostor to a bone
  89100. * @param bone The bone that the impostor will be synced to.
  89101. * @param boneMesh The mesh that the bone is influencing.
  89102. * @param jointPivot The pivot of the joint / bone in local space.
  89103. * @param distToJoint Optional distance from the impostor to the joint.
  89104. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89105. * @param boneAxis Optional vector3 axis the bone is aligned with
  89106. */
  89107. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89108. /**
  89109. * No-Imposter type
  89110. */
  89111. static NoImpostor: number;
  89112. /**
  89113. * Sphere-Imposter type
  89114. */
  89115. static SphereImpostor: number;
  89116. /**
  89117. * Box-Imposter type
  89118. */
  89119. static BoxImpostor: number;
  89120. /**
  89121. * Plane-Imposter type
  89122. */
  89123. static PlaneImpostor: number;
  89124. /**
  89125. * Mesh-imposter type
  89126. */
  89127. static MeshImpostor: number;
  89128. /**
  89129. * Capsule-Impostor type (Ammo.js plugin only)
  89130. */
  89131. static CapsuleImpostor: number;
  89132. /**
  89133. * Cylinder-Imposter type
  89134. */
  89135. static CylinderImpostor: number;
  89136. /**
  89137. * Particle-Imposter type
  89138. */
  89139. static ParticleImpostor: number;
  89140. /**
  89141. * Heightmap-Imposter type
  89142. */
  89143. static HeightmapImpostor: number;
  89144. /**
  89145. * ConvexHull-Impostor type (Ammo.js plugin only)
  89146. */
  89147. static ConvexHullImpostor: number;
  89148. /**
  89149. * Rope-Imposter type
  89150. */
  89151. static RopeImpostor: number;
  89152. /**
  89153. * Cloth-Imposter type
  89154. */
  89155. static ClothImpostor: number;
  89156. /**
  89157. * Softbody-Imposter type
  89158. */
  89159. static SoftbodyImpostor: number;
  89160. }
  89161. }
  89162. declare module BABYLON {
  89163. /**
  89164. * @hidden
  89165. **/
  89166. export class _CreationDataStorage {
  89167. closePath?: boolean;
  89168. closeArray?: boolean;
  89169. idx: number[];
  89170. dashSize: number;
  89171. gapSize: number;
  89172. path3D: Path3D;
  89173. pathArray: Vector3[][];
  89174. arc: number;
  89175. radius: number;
  89176. cap: number;
  89177. tessellation: number;
  89178. }
  89179. /**
  89180. * @hidden
  89181. **/
  89182. class _InstanceDataStorage {
  89183. visibleInstances: any;
  89184. batchCache: _InstancesBatch;
  89185. instancesBufferSize: number;
  89186. instancesBuffer: Nullable<Buffer>;
  89187. instancesData: Float32Array;
  89188. overridenInstanceCount: number;
  89189. isFrozen: boolean;
  89190. previousBatch: Nullable<_InstancesBatch>;
  89191. hardwareInstancedRendering: boolean;
  89192. sideOrientation: number;
  89193. }
  89194. /**
  89195. * @hidden
  89196. **/
  89197. export class _InstancesBatch {
  89198. mustReturn: boolean;
  89199. visibleInstances: Nullable<InstancedMesh[]>[];
  89200. renderSelf: boolean[];
  89201. hardwareInstancedRendering: boolean[];
  89202. }
  89203. /**
  89204. * Class used to represent renderable models
  89205. */
  89206. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89207. /**
  89208. * Mesh side orientation : usually the external or front surface
  89209. */
  89210. static readonly FRONTSIDE: number;
  89211. /**
  89212. * Mesh side orientation : usually the internal or back surface
  89213. */
  89214. static readonly BACKSIDE: number;
  89215. /**
  89216. * Mesh side orientation : both internal and external or front and back surfaces
  89217. */
  89218. static readonly DOUBLESIDE: number;
  89219. /**
  89220. * Mesh side orientation : by default, `FRONTSIDE`
  89221. */
  89222. static readonly DEFAULTSIDE: number;
  89223. /**
  89224. * Mesh cap setting : no cap
  89225. */
  89226. static readonly NO_CAP: number;
  89227. /**
  89228. * Mesh cap setting : one cap at the beginning of the mesh
  89229. */
  89230. static readonly CAP_START: number;
  89231. /**
  89232. * Mesh cap setting : one cap at the end of the mesh
  89233. */
  89234. static readonly CAP_END: number;
  89235. /**
  89236. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89237. */
  89238. static readonly CAP_ALL: number;
  89239. /**
  89240. * Mesh pattern setting : no flip or rotate
  89241. */
  89242. static readonly NO_FLIP: number;
  89243. /**
  89244. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89245. */
  89246. static readonly FLIP_TILE: number;
  89247. /**
  89248. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89249. */
  89250. static readonly ROTATE_TILE: number;
  89251. /**
  89252. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89253. */
  89254. static readonly FLIP_ROW: number;
  89255. /**
  89256. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89257. */
  89258. static readonly ROTATE_ROW: number;
  89259. /**
  89260. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89261. */
  89262. static readonly FLIP_N_ROTATE_TILE: number;
  89263. /**
  89264. * Mesh pattern setting : rotate pattern and rotate
  89265. */
  89266. static readonly FLIP_N_ROTATE_ROW: number;
  89267. /**
  89268. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89269. */
  89270. static readonly CENTER: number;
  89271. /**
  89272. * Mesh tile positioning : part tiles on left
  89273. */
  89274. static readonly LEFT: number;
  89275. /**
  89276. * Mesh tile positioning : part tiles on right
  89277. */
  89278. static readonly RIGHT: number;
  89279. /**
  89280. * Mesh tile positioning : part tiles on top
  89281. */
  89282. static readonly TOP: number;
  89283. /**
  89284. * Mesh tile positioning : part tiles on bottom
  89285. */
  89286. static readonly BOTTOM: number;
  89287. /**
  89288. * Gets the default side orientation.
  89289. * @param orientation the orientation to value to attempt to get
  89290. * @returns the default orientation
  89291. * @hidden
  89292. */
  89293. static _GetDefaultSideOrientation(orientation?: number): number;
  89294. private _internalMeshDataInfo;
  89295. /**
  89296. * An event triggered before rendering the mesh
  89297. */
  89298. readonly onBeforeRenderObservable: Observable<Mesh>;
  89299. /**
  89300. * An event triggered before binding the mesh
  89301. */
  89302. readonly onBeforeBindObservable: Observable<Mesh>;
  89303. /**
  89304. * An event triggered after rendering the mesh
  89305. */
  89306. readonly onAfterRenderObservable: Observable<Mesh>;
  89307. /**
  89308. * An event triggered before drawing the mesh
  89309. */
  89310. readonly onBeforeDrawObservable: Observable<Mesh>;
  89311. private _onBeforeDrawObserver;
  89312. /**
  89313. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89314. */
  89315. onBeforeDraw: () => void;
  89316. readonly hasInstances: boolean;
  89317. /**
  89318. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89319. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89320. */
  89321. delayLoadState: number;
  89322. /**
  89323. * Gets the list of instances created from this mesh
  89324. * it is not supposed to be modified manually.
  89325. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89326. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89327. */
  89328. instances: InstancedMesh[];
  89329. /**
  89330. * Gets the file containing delay loading data for this mesh
  89331. */
  89332. delayLoadingFile: string;
  89333. /** @hidden */
  89334. _binaryInfo: any;
  89335. /**
  89336. * User defined function used to change how LOD level selection is done
  89337. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89338. */
  89339. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89340. /**
  89341. * Gets or sets the morph target manager
  89342. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89343. */
  89344. morphTargetManager: Nullable<MorphTargetManager>;
  89345. /** @hidden */
  89346. _creationDataStorage: Nullable<_CreationDataStorage>;
  89347. /** @hidden */
  89348. _geometry: Nullable<Geometry>;
  89349. /** @hidden */
  89350. _delayInfo: Array<string>;
  89351. /** @hidden */
  89352. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89353. /** @hidden */
  89354. _instanceDataStorage: _InstanceDataStorage;
  89355. private _effectiveMaterial;
  89356. /** @hidden */
  89357. _shouldGenerateFlatShading: boolean;
  89358. /** @hidden */
  89359. _originalBuilderSideOrientation: number;
  89360. /**
  89361. * Use this property to change the original side orientation defined at construction time
  89362. */
  89363. overrideMaterialSideOrientation: Nullable<number>;
  89364. /**
  89365. * Gets the source mesh (the one used to clone this one from)
  89366. */
  89367. readonly source: Nullable<Mesh>;
  89368. /**
  89369. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89370. */
  89371. isUnIndexed: boolean;
  89372. /**
  89373. * @constructor
  89374. * @param name The value used by scene.getMeshByName() to do a lookup.
  89375. * @param scene The scene to add this mesh to.
  89376. * @param parent The parent of this mesh, if it has one
  89377. * @param source An optional Mesh from which geometry is shared, cloned.
  89378. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89379. * When false, achieved by calling a clone(), also passing False.
  89380. * This will make creation of children, recursive.
  89381. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89382. */
  89383. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89384. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89385. /**
  89386. * Gets the class name
  89387. * @returns the string "Mesh".
  89388. */
  89389. getClassName(): string;
  89390. /** @hidden */
  89391. readonly _isMesh: boolean;
  89392. /**
  89393. * Returns a description of this mesh
  89394. * @param fullDetails define if full details about this mesh must be used
  89395. * @returns a descriptive string representing this mesh
  89396. */
  89397. toString(fullDetails?: boolean): string;
  89398. /** @hidden */
  89399. _unBindEffect(): void;
  89400. /**
  89401. * Gets a boolean indicating if this mesh has LOD
  89402. */
  89403. readonly hasLODLevels: boolean;
  89404. /**
  89405. * Gets the list of MeshLODLevel associated with the current mesh
  89406. * @returns an array of MeshLODLevel
  89407. */
  89408. getLODLevels(): MeshLODLevel[];
  89409. private _sortLODLevels;
  89410. /**
  89411. * Add a mesh as LOD level triggered at the given distance.
  89412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89413. * @param distance The distance from the center of the object to show this level
  89414. * @param mesh The mesh to be added as LOD level (can be null)
  89415. * @return This mesh (for chaining)
  89416. */
  89417. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89418. /**
  89419. * Returns the LOD level mesh at the passed distance or null if not found.
  89420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89421. * @param distance The distance from the center of the object to show this level
  89422. * @returns a Mesh or `null`
  89423. */
  89424. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89425. /**
  89426. * Remove a mesh from the LOD array
  89427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89428. * @param mesh defines the mesh to be removed
  89429. * @return This mesh (for chaining)
  89430. */
  89431. removeLODLevel(mesh: Mesh): Mesh;
  89432. /**
  89433. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89434. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89435. * @param camera defines the camera to use to compute distance
  89436. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89437. * @return This mesh (for chaining)
  89438. */
  89439. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89440. /**
  89441. * Gets the mesh internal Geometry object
  89442. */
  89443. readonly geometry: Nullable<Geometry>;
  89444. /**
  89445. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89446. * @returns the total number of vertices
  89447. */
  89448. getTotalVertices(): number;
  89449. /**
  89450. * Returns the content of an associated vertex buffer
  89451. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89452. * - VertexBuffer.PositionKind
  89453. * - VertexBuffer.UVKind
  89454. * - VertexBuffer.UV2Kind
  89455. * - VertexBuffer.UV3Kind
  89456. * - VertexBuffer.UV4Kind
  89457. * - VertexBuffer.UV5Kind
  89458. * - VertexBuffer.UV6Kind
  89459. * - VertexBuffer.ColorKind
  89460. * - VertexBuffer.MatricesIndicesKind
  89461. * - VertexBuffer.MatricesIndicesExtraKind
  89462. * - VertexBuffer.MatricesWeightsKind
  89463. * - VertexBuffer.MatricesWeightsExtraKind
  89464. * @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
  89465. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89466. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89467. */
  89468. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89469. /**
  89470. * Returns the mesh VertexBuffer object from the requested `kind`
  89471. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89472. * - VertexBuffer.PositionKind
  89473. * - VertexBuffer.NormalKind
  89474. * - VertexBuffer.UVKind
  89475. * - VertexBuffer.UV2Kind
  89476. * - VertexBuffer.UV3Kind
  89477. * - VertexBuffer.UV4Kind
  89478. * - VertexBuffer.UV5Kind
  89479. * - VertexBuffer.UV6Kind
  89480. * - VertexBuffer.ColorKind
  89481. * - VertexBuffer.MatricesIndicesKind
  89482. * - VertexBuffer.MatricesIndicesExtraKind
  89483. * - VertexBuffer.MatricesWeightsKind
  89484. * - VertexBuffer.MatricesWeightsExtraKind
  89485. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89486. */
  89487. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89488. /**
  89489. * Tests if a specific vertex buffer is associated with this mesh
  89490. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89491. * - VertexBuffer.PositionKind
  89492. * - VertexBuffer.NormalKind
  89493. * - VertexBuffer.UVKind
  89494. * - VertexBuffer.UV2Kind
  89495. * - VertexBuffer.UV3Kind
  89496. * - VertexBuffer.UV4Kind
  89497. * - VertexBuffer.UV5Kind
  89498. * - VertexBuffer.UV6Kind
  89499. * - VertexBuffer.ColorKind
  89500. * - VertexBuffer.MatricesIndicesKind
  89501. * - VertexBuffer.MatricesIndicesExtraKind
  89502. * - VertexBuffer.MatricesWeightsKind
  89503. * - VertexBuffer.MatricesWeightsExtraKind
  89504. * @returns a boolean
  89505. */
  89506. isVerticesDataPresent(kind: string): boolean;
  89507. /**
  89508. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89509. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89510. * - VertexBuffer.PositionKind
  89511. * - VertexBuffer.UVKind
  89512. * - VertexBuffer.UV2Kind
  89513. * - VertexBuffer.UV3Kind
  89514. * - VertexBuffer.UV4Kind
  89515. * - VertexBuffer.UV5Kind
  89516. * - VertexBuffer.UV6Kind
  89517. * - VertexBuffer.ColorKind
  89518. * - VertexBuffer.MatricesIndicesKind
  89519. * - VertexBuffer.MatricesIndicesExtraKind
  89520. * - VertexBuffer.MatricesWeightsKind
  89521. * - VertexBuffer.MatricesWeightsExtraKind
  89522. * @returns a boolean
  89523. */
  89524. isVertexBufferUpdatable(kind: string): boolean;
  89525. /**
  89526. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89527. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89528. * - VertexBuffer.PositionKind
  89529. * - VertexBuffer.NormalKind
  89530. * - VertexBuffer.UVKind
  89531. * - VertexBuffer.UV2Kind
  89532. * - VertexBuffer.UV3Kind
  89533. * - VertexBuffer.UV4Kind
  89534. * - VertexBuffer.UV5Kind
  89535. * - VertexBuffer.UV6Kind
  89536. * - VertexBuffer.ColorKind
  89537. * - VertexBuffer.MatricesIndicesKind
  89538. * - VertexBuffer.MatricesIndicesExtraKind
  89539. * - VertexBuffer.MatricesWeightsKind
  89540. * - VertexBuffer.MatricesWeightsExtraKind
  89541. * @returns an array of strings
  89542. */
  89543. getVerticesDataKinds(): string[];
  89544. /**
  89545. * Returns a positive integer : the total number of indices in this mesh geometry.
  89546. * @returns the numner of indices or zero if the mesh has no geometry.
  89547. */
  89548. getTotalIndices(): number;
  89549. /**
  89550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89551. * @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.
  89552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89553. * @returns the indices array or an empty array if the mesh has no geometry
  89554. */
  89555. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89556. readonly isBlocked: boolean;
  89557. /**
  89558. * Determine if the current mesh is ready to be rendered
  89559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89560. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89561. * @returns true if all associated assets are ready (material, textures, shaders)
  89562. */
  89563. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89564. /**
  89565. * 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.
  89566. */
  89567. readonly areNormalsFrozen: boolean;
  89568. /**
  89569. * 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.
  89570. * @returns the current mesh
  89571. */
  89572. freezeNormals(): Mesh;
  89573. /**
  89574. * 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
  89575. * @returns the current mesh
  89576. */
  89577. unfreezeNormals(): Mesh;
  89578. /**
  89579. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89580. */
  89581. overridenInstanceCount: number;
  89582. /** @hidden */
  89583. _preActivate(): Mesh;
  89584. /** @hidden */
  89585. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89586. /** @hidden */
  89587. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89588. /**
  89589. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89590. * This means the mesh underlying bounding box and sphere are recomputed.
  89591. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89592. * @returns the current mesh
  89593. */
  89594. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89595. /** @hidden */
  89596. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89597. /**
  89598. * This function will subdivide the mesh into multiple submeshes
  89599. * @param count defines the expected number of submeshes
  89600. */
  89601. subdivide(count: number): void;
  89602. /**
  89603. * Copy a FloatArray into a specific associated vertex buffer
  89604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89605. * - VertexBuffer.PositionKind
  89606. * - VertexBuffer.UVKind
  89607. * - VertexBuffer.UV2Kind
  89608. * - VertexBuffer.UV3Kind
  89609. * - VertexBuffer.UV4Kind
  89610. * - VertexBuffer.UV5Kind
  89611. * - VertexBuffer.UV6Kind
  89612. * - VertexBuffer.ColorKind
  89613. * - VertexBuffer.MatricesIndicesKind
  89614. * - VertexBuffer.MatricesIndicesExtraKind
  89615. * - VertexBuffer.MatricesWeightsKind
  89616. * - VertexBuffer.MatricesWeightsExtraKind
  89617. * @param data defines the data source
  89618. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89619. * @param stride defines the data stride size (can be null)
  89620. * @returns the current mesh
  89621. */
  89622. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89623. /**
  89624. * Flags an associated vertex buffer as updatable
  89625. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89626. * - VertexBuffer.PositionKind
  89627. * - VertexBuffer.UVKind
  89628. * - VertexBuffer.UV2Kind
  89629. * - VertexBuffer.UV3Kind
  89630. * - VertexBuffer.UV4Kind
  89631. * - VertexBuffer.UV5Kind
  89632. * - VertexBuffer.UV6Kind
  89633. * - VertexBuffer.ColorKind
  89634. * - VertexBuffer.MatricesIndicesKind
  89635. * - VertexBuffer.MatricesIndicesExtraKind
  89636. * - VertexBuffer.MatricesWeightsKind
  89637. * - VertexBuffer.MatricesWeightsExtraKind
  89638. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89639. */
  89640. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89641. /**
  89642. * Sets the mesh global Vertex Buffer
  89643. * @param buffer defines the buffer to use
  89644. * @returns the current mesh
  89645. */
  89646. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89647. /**
  89648. * Update a specific associated vertex buffer
  89649. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89650. * - VertexBuffer.PositionKind
  89651. * - VertexBuffer.UVKind
  89652. * - VertexBuffer.UV2Kind
  89653. * - VertexBuffer.UV3Kind
  89654. * - VertexBuffer.UV4Kind
  89655. * - VertexBuffer.UV5Kind
  89656. * - VertexBuffer.UV6Kind
  89657. * - VertexBuffer.ColorKind
  89658. * - VertexBuffer.MatricesIndicesKind
  89659. * - VertexBuffer.MatricesIndicesExtraKind
  89660. * - VertexBuffer.MatricesWeightsKind
  89661. * - VertexBuffer.MatricesWeightsExtraKind
  89662. * @param data defines the data source
  89663. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89664. * @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)
  89665. * @returns the current mesh
  89666. */
  89667. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89668. /**
  89669. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89670. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89671. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89672. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89673. * @returns the current mesh
  89674. */
  89675. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89676. /**
  89677. * Creates a un-shared specific occurence of the geometry for the mesh.
  89678. * @returns the current mesh
  89679. */
  89680. makeGeometryUnique(): Mesh;
  89681. /**
  89682. * Set the index buffer of this mesh
  89683. * @param indices defines the source data
  89684. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89685. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89686. * @returns the current mesh
  89687. */
  89688. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89689. /**
  89690. * Update the current index buffer
  89691. * @param indices defines the source data
  89692. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89693. * @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)
  89694. * @returns the current mesh
  89695. */
  89696. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89697. /**
  89698. * Invert the geometry to move from a right handed system to a left handed one.
  89699. * @returns the current mesh
  89700. */
  89701. toLeftHanded(): Mesh;
  89702. /** @hidden */
  89703. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89704. /** @hidden */
  89705. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89706. /**
  89707. * Registers for this mesh a javascript function called just before the rendering process
  89708. * @param func defines the function to call before rendering this mesh
  89709. * @returns the current mesh
  89710. */
  89711. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89712. /**
  89713. * Disposes a previously registered javascript function called before the rendering
  89714. * @param func defines the function to remove
  89715. * @returns the current mesh
  89716. */
  89717. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89718. /**
  89719. * Registers for this mesh a javascript function called just after the rendering is complete
  89720. * @param func defines the function to call after rendering this mesh
  89721. * @returns the current mesh
  89722. */
  89723. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89724. /**
  89725. * Disposes a previously registered javascript function called after the rendering.
  89726. * @param func defines the function to remove
  89727. * @returns the current mesh
  89728. */
  89729. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89730. /** @hidden */
  89731. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89732. /** @hidden */
  89733. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89734. /** @hidden */
  89735. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89736. /** @hidden */
  89737. _rebuild(): void;
  89738. /** @hidden */
  89739. _freeze(): void;
  89740. /** @hidden */
  89741. _unFreeze(): void;
  89742. /**
  89743. * 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
  89744. * @param subMesh defines the subMesh to render
  89745. * @param enableAlphaMode defines if alpha mode can be changed
  89746. * @returns the current mesh
  89747. */
  89748. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89749. private _onBeforeDraw;
  89750. /**
  89751. * Renormalize the mesh and patch it up if there are no weights
  89752. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89753. * However in the case of zero weights then we set just a single influence to 1.
  89754. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89755. */
  89756. cleanMatrixWeights(): void;
  89757. private normalizeSkinFourWeights;
  89758. private normalizeSkinWeightsAndExtra;
  89759. /**
  89760. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89761. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89762. * the user know there was an issue with importing the mesh
  89763. * @returns a validation object with skinned, valid and report string
  89764. */
  89765. validateSkinning(): {
  89766. skinned: boolean;
  89767. valid: boolean;
  89768. report: string;
  89769. };
  89770. /** @hidden */
  89771. _checkDelayState(): Mesh;
  89772. private _queueLoad;
  89773. /**
  89774. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89775. * A mesh is in the frustum if its bounding box intersects the frustum
  89776. * @param frustumPlanes defines the frustum to test
  89777. * @returns true if the mesh is in the frustum planes
  89778. */
  89779. isInFrustum(frustumPlanes: Plane[]): boolean;
  89780. /**
  89781. * Sets the mesh material by the material or multiMaterial `id` property
  89782. * @param id is a string identifying the material or the multiMaterial
  89783. * @returns the current mesh
  89784. */
  89785. setMaterialByID(id: string): Mesh;
  89786. /**
  89787. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89788. * @returns an array of IAnimatable
  89789. */
  89790. getAnimatables(): IAnimatable[];
  89791. /**
  89792. * Modifies the mesh geometry according to the passed transformation matrix.
  89793. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89794. * The mesh normals are modified using the same transformation.
  89795. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89796. * @param transform defines the transform matrix to use
  89797. * @see http://doc.babylonjs.com/resources/baking_transformations
  89798. * @returns the current mesh
  89799. */
  89800. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89801. /**
  89802. * Modifies the mesh geometry according to its own current World Matrix.
  89803. * The mesh World Matrix is then reset.
  89804. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89805. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89806. * @see http://doc.babylonjs.com/resources/baking_transformations
  89807. * @returns the current mesh
  89808. */
  89809. bakeCurrentTransformIntoVertices(): Mesh;
  89810. /** @hidden */
  89811. readonly _positions: Nullable<Vector3[]>;
  89812. /** @hidden */
  89813. _resetPointsArrayCache(): Mesh;
  89814. /** @hidden */
  89815. _generatePointsArray(): boolean;
  89816. /**
  89817. * Returns a new Mesh object generated from the current mesh properties.
  89818. * This method must not get confused with createInstance()
  89819. * @param name is a string, the name given to the new mesh
  89820. * @param newParent can be any Node object (default `null`)
  89821. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89822. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89823. * @returns a new mesh
  89824. */
  89825. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89826. /**
  89827. * Releases resources associated with this mesh.
  89828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89830. */
  89831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89832. /**
  89833. * Modifies the mesh geometry according to a displacement map.
  89834. * 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.
  89835. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89836. * @param url is a string, the URL from the image file is to be downloaded.
  89837. * @param minHeight is the lower limit of the displacement.
  89838. * @param maxHeight is the upper limit of the displacement.
  89839. * @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.
  89840. * @param uvOffset is an optional vector2 used to offset UV.
  89841. * @param uvScale is an optional vector2 used to scale UV.
  89842. * @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.
  89843. * @returns the Mesh.
  89844. */
  89845. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89846. /**
  89847. * Modifies the mesh geometry according to a displacementMap buffer.
  89848. * 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.
  89849. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89850. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89851. * @param heightMapWidth is the width of the buffer image.
  89852. * @param heightMapHeight is the height of the buffer image.
  89853. * @param minHeight is the lower limit of the displacement.
  89854. * @param maxHeight is the upper limit of the displacement.
  89855. * @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.
  89856. * @param uvOffset is an optional vector2 used to offset UV.
  89857. * @param uvScale is an optional vector2 used to scale UV.
  89858. * @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.
  89859. * @returns the Mesh.
  89860. */
  89861. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89862. /**
  89863. * Modify the mesh to get a flat shading rendering.
  89864. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89865. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89866. * @returns current mesh
  89867. */
  89868. convertToFlatShadedMesh(): Mesh;
  89869. /**
  89870. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89871. * In other words, more vertices, no more indices and a single bigger VBO.
  89872. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89873. * @returns current mesh
  89874. */
  89875. convertToUnIndexedMesh(): Mesh;
  89876. /**
  89877. * Inverses facet orientations.
  89878. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89879. * @param flipNormals will also inverts the normals
  89880. * @returns current mesh
  89881. */
  89882. flipFaces(flipNormals?: boolean): Mesh;
  89883. /**
  89884. * Increase the number of facets and hence vertices in a mesh
  89885. * Vertex normals are interpolated from existing vertex normals
  89886. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89887. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89888. */
  89889. increaseVertices(numberPerEdge: number): void;
  89890. /**
  89891. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89892. * This will undo any application of covertToFlatShadedMesh
  89893. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89894. */
  89895. forceSharedVertices(): void;
  89896. /** @hidden */
  89897. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89898. /** @hidden */
  89899. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89900. /**
  89901. * Creates a new InstancedMesh object from the mesh model.
  89902. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89903. * @param name defines the name of the new instance
  89904. * @returns a new InstancedMesh
  89905. */
  89906. createInstance(name: string): InstancedMesh;
  89907. /**
  89908. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89909. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89910. * @returns the current mesh
  89911. */
  89912. synchronizeInstances(): Mesh;
  89913. /**
  89914. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89915. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89916. * This should be used together with the simplification to avoid disappearing triangles.
  89917. * @param successCallback an optional success callback to be called after the optimization finished.
  89918. * @returns the current mesh
  89919. */
  89920. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89921. /**
  89922. * Serialize current mesh
  89923. * @param serializationObject defines the object which will receive the serialization data
  89924. */
  89925. serialize(serializationObject: any): void;
  89926. /** @hidden */
  89927. _syncGeometryWithMorphTargetManager(): void;
  89928. /** @hidden */
  89929. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89930. /**
  89931. * Returns a new Mesh object parsed from the source provided.
  89932. * @param parsedMesh is the source
  89933. * @param scene defines the hosting scene
  89934. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89935. * @returns a new Mesh
  89936. */
  89937. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89938. /**
  89939. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89940. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89941. * @param name defines the name of the mesh to create
  89942. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89943. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89944. * @param closePath creates a seam between the first and the last points of each path of the path array
  89945. * @param offset is taken in account only if the `pathArray` is containing a single path
  89946. * @param scene defines the hosting scene
  89947. * @param updatable defines if the mesh must be flagged as updatable
  89948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89949. * @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)
  89950. * @returns a new Mesh
  89951. */
  89952. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89953. /**
  89954. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89955. * @param name defines the name of the mesh to create
  89956. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89957. * @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
  89958. * @param scene defines the hosting scene
  89959. * @param updatable defines if the mesh must be flagged as updatable
  89960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89961. * @returns a new Mesh
  89962. */
  89963. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89964. /**
  89965. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89966. * @param name defines the name of the mesh to create
  89967. * @param size sets the size (float) of each box side (default 1)
  89968. * @param scene defines the hosting scene
  89969. * @param updatable defines if the mesh must be flagged as updatable
  89970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89971. * @returns a new Mesh
  89972. */
  89973. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89974. /**
  89975. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89976. * @param name defines the name of the mesh to create
  89977. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89978. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89979. * @param scene defines the hosting scene
  89980. * @param updatable defines if the mesh must be flagged as updatable
  89981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89982. * @returns a new Mesh
  89983. */
  89984. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89985. /**
  89986. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89987. * @param name defines the name of the mesh to create
  89988. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89989. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89990. * @param scene defines the hosting scene
  89991. * @returns a new Mesh
  89992. */
  89993. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89994. /**
  89995. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89996. * @param name defines the name of the mesh to create
  89997. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89998. * @param diameterTop set the top cap diameter (floats, default 1)
  89999. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90000. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90001. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90002. * @param scene defines the hosting scene
  90003. * @param updatable defines if the mesh must be flagged as updatable
  90004. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90005. * @returns a new Mesh
  90006. */
  90007. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90008. /**
  90009. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90010. * @param name defines the name of the mesh to create
  90011. * @param diameter sets the diameter size (float) of the torus (default 1)
  90012. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90013. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90014. * @param scene defines the hosting scene
  90015. * @param updatable defines if the mesh must be flagged as updatable
  90016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90017. * @returns a new Mesh
  90018. */
  90019. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90020. /**
  90021. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90022. * @param name defines the name of the mesh to create
  90023. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90024. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90025. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90026. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90027. * @param p the number of windings on X axis (positive integers, default 2)
  90028. * @param q the number of windings on Y axis (positive integers, default 3)
  90029. * @param scene defines the hosting scene
  90030. * @param updatable defines if the mesh must be flagged as updatable
  90031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90032. * @returns a new Mesh
  90033. */
  90034. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90035. /**
  90036. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90037. * @param name defines the name of the mesh to create
  90038. * @param points is an array successive Vector3
  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 CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90045. /**
  90046. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90047. * @param name defines the name of the mesh to create
  90048. * @param points is an array successive Vector3
  90049. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90050. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90051. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90052. * @param scene defines the hosting scene
  90053. * @param updatable defines if the mesh must be flagged as updatable
  90054. * @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)
  90055. * @returns a new Mesh
  90056. */
  90057. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90058. /**
  90059. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90060. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90061. * 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.
  90062. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90063. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90064. * Remember you can only change the shape positions, not their number when updating a polygon.
  90065. * @see http://doc.babylonjs.com/how_to/parametric_shapes#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 scene defines the hosting scene
  90069. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90070. * @param updatable defines if the mesh must be flagged as updatable
  90071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90072. * @param earcutInjection can be used to inject your own earcut reference
  90073. * @returns a new Mesh
  90074. */
  90075. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90076. /**
  90077. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90079. * @param name defines the name of the mesh to create
  90080. * @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
  90081. * @param depth defines the height of extrusion
  90082. * @param scene defines the hosting scene
  90083. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90084. * @param updatable defines if the mesh must be flagged as updatable
  90085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90086. * @param earcutInjection can be used to inject your own earcut reference
  90087. * @returns a new Mesh
  90088. */
  90089. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90090. /**
  90091. * Creates an extruded shape mesh.
  90092. * 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
  90093. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90094. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90095. * @param name defines the name of the mesh to create
  90096. * @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
  90097. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90098. * @param scale is the value to scale the shape
  90099. * @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
  90100. * @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
  90101. * @param scene defines the hosting scene
  90102. * @param updatable defines if the mesh must be flagged as updatable
  90103. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90104. * @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)
  90105. * @returns a new Mesh
  90106. */
  90107. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90108. /**
  90109. * Creates an custom extruded shape mesh.
  90110. * The custom extrusion is a parametric shape.
  90111. * It has no predefined shape. Its final shape will depend on the input parameters.
  90112. * Please consider using the same method from the MeshBuilder class instead
  90113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90114. * @param name defines the name of the mesh to create
  90115. * @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
  90116. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90117. * @param scaleFunction is a custom Javascript function called on each path point
  90118. * @param rotationFunction is a custom Javascript function called on each path point
  90119. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90120. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90121. * @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
  90122. * @param scene defines the hosting scene
  90123. * @param updatable defines if the mesh must be flagged as updatable
  90124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90125. * @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)
  90126. * @returns a new Mesh
  90127. */
  90128. 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;
  90129. /**
  90130. * Creates lathe mesh.
  90131. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90132. * Please consider using the same method from the MeshBuilder class instead
  90133. * @param name defines the name of the mesh to create
  90134. * @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
  90135. * @param radius is the radius value of the lathe
  90136. * @param tessellation is the side number of the lathe.
  90137. * @param scene defines the hosting scene
  90138. * @param updatable defines if the mesh must be flagged as updatable
  90139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90140. * @returns a new Mesh
  90141. */
  90142. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90143. /**
  90144. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90145. * @param name defines the name of the mesh to create
  90146. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90147. * @param scene defines the hosting scene
  90148. * @param updatable defines if the mesh must be flagged as updatable
  90149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90150. * @returns a new Mesh
  90151. */
  90152. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90153. /**
  90154. * Creates a ground mesh.
  90155. * Please consider using the same method from the MeshBuilder class instead
  90156. * @param name defines the name of the mesh to create
  90157. * @param width set the width of the ground
  90158. * @param height set the height of the ground
  90159. * @param subdivisions sets the number of subdivisions per side
  90160. * @param scene defines the hosting scene
  90161. * @param updatable defines if the mesh must be flagged as updatable
  90162. * @returns a new Mesh
  90163. */
  90164. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90165. /**
  90166. * Creates a tiled ground mesh.
  90167. * Please consider using the same method from the MeshBuilder class instead
  90168. * @param name defines the name of the mesh to create
  90169. * @param xmin set the ground minimum X coordinate
  90170. * @param zmin set the ground minimum Y coordinate
  90171. * @param xmax set the ground maximum X coordinate
  90172. * @param zmax set the ground maximum Z coordinate
  90173. * @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
  90174. * @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
  90175. * @param scene defines the hosting scene
  90176. * @param updatable defines if the mesh must be flagged as updatable
  90177. * @returns a new Mesh
  90178. */
  90179. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90180. w: number;
  90181. h: number;
  90182. }, precision: {
  90183. w: number;
  90184. h: number;
  90185. }, scene: Scene, updatable?: boolean): Mesh;
  90186. /**
  90187. * Creates a ground mesh from a height map.
  90188. * Please consider using the same method from the MeshBuilder class instead
  90189. * @see http://doc.babylonjs.com/babylon101/height_map
  90190. * @param name defines the name of the mesh to create
  90191. * @param url sets the URL of the height map image resource
  90192. * @param width set the ground width size
  90193. * @param height set the ground height size
  90194. * @param subdivisions sets the number of subdivision per side
  90195. * @param minHeight is the minimum altitude on the ground
  90196. * @param maxHeight is the maximum altitude on the ground
  90197. * @param scene defines the hosting scene
  90198. * @param updatable defines if the mesh must be flagged as updatable
  90199. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90200. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90201. * @returns a new Mesh
  90202. */
  90203. 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;
  90204. /**
  90205. * Creates a tube mesh.
  90206. * The tube is a parametric shape.
  90207. * It has no predefined shape. Its final shape will depend on the input parameters.
  90208. * Please consider using the same method from the MeshBuilder class instead
  90209. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90210. * @param name defines the name of the mesh to create
  90211. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90212. * @param radius sets the tube radius size
  90213. * @param tessellation is the number of sides on the tubular surface
  90214. * @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
  90215. * @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
  90216. * @param scene defines the hosting scene
  90217. * @param updatable defines if the mesh must be flagged as updatable
  90218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90219. * @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)
  90220. * @returns a new Mesh
  90221. */
  90222. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90223. (i: number, distance: number): number;
  90224. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90225. /**
  90226. * Creates a polyhedron mesh.
  90227. * Please consider using the same method from the MeshBuilder class instead.
  90228. * * 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
  90229. * * The parameter `size` (positive float, default 1) sets the polygon size
  90230. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90231. * * 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`
  90232. * * 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
  90233. * * 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)`)
  90234. * * 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
  90235. * * 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
  90236. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90237. * * If you create a double-sided mesh, you can choose what parts of 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
  90238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90239. * @param name defines the name of the mesh to create
  90240. * @param options defines the options used to create the mesh
  90241. * @param scene defines the hosting scene
  90242. * @returns a new Mesh
  90243. */
  90244. static CreatePolyhedron(name: string, options: {
  90245. type?: number;
  90246. size?: number;
  90247. sizeX?: number;
  90248. sizeY?: number;
  90249. sizeZ?: number;
  90250. custom?: any;
  90251. faceUV?: Vector4[];
  90252. faceColors?: Color4[];
  90253. updatable?: boolean;
  90254. sideOrientation?: number;
  90255. }, scene: Scene): Mesh;
  90256. /**
  90257. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90258. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90259. * * 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`)
  90260. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90261. * * 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
  90262. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90263. * * If you create a double-sided mesh, you can choose what parts of 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
  90264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90265. * @param name defines the name of the mesh
  90266. * @param options defines the options used to create the mesh
  90267. * @param scene defines the hosting scene
  90268. * @returns a new Mesh
  90269. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90270. */
  90271. static CreateIcoSphere(name: string, options: {
  90272. radius?: number;
  90273. flat?: boolean;
  90274. subdivisions?: number;
  90275. sideOrientation?: number;
  90276. updatable?: boolean;
  90277. }, scene: Scene): Mesh;
  90278. /**
  90279. * Creates a decal mesh.
  90280. * Please consider using the same method from the MeshBuilder class instead.
  90281. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90282. * @param name defines the name of the mesh
  90283. * @param sourceMesh defines the mesh receiving the decal
  90284. * @param position sets the position of the decal in world coordinates
  90285. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90286. * @param size sets the decal scaling
  90287. * @param angle sets the angle to rotate the decal
  90288. * @returns a new Mesh
  90289. */
  90290. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90291. /**
  90292. * Prepare internal position array for software CPU skinning
  90293. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90294. */
  90295. setPositionsForCPUSkinning(): Float32Array;
  90296. /**
  90297. * Prepare internal normal array for software CPU skinning
  90298. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90299. */
  90300. setNormalsForCPUSkinning(): Float32Array;
  90301. /**
  90302. * Updates the vertex buffer by applying transformation from the bones
  90303. * @param skeleton defines the skeleton to apply to current mesh
  90304. * @returns the current mesh
  90305. */
  90306. applySkeleton(skeleton: Skeleton): Mesh;
  90307. /**
  90308. * 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
  90309. * @param meshes defines the list of meshes to scan
  90310. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90311. */
  90312. static MinMax(meshes: AbstractMesh[]): {
  90313. min: Vector3;
  90314. max: Vector3;
  90315. };
  90316. /**
  90317. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90318. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90319. * @returns a vector3
  90320. */
  90321. static Center(meshesOrMinMaxVector: {
  90322. min: Vector3;
  90323. max: Vector3;
  90324. } | AbstractMesh[]): Vector3;
  90325. /**
  90326. * Merge the array of meshes into a single mesh for performance reasons.
  90327. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90328. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90329. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90330. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90331. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90332. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90333. * @returns a new mesh
  90334. */
  90335. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90336. /** @hidden */
  90337. addInstance(instance: InstancedMesh): void;
  90338. /** @hidden */
  90339. removeInstance(instance: InstancedMesh): void;
  90340. }
  90341. }
  90342. declare module BABYLON {
  90343. /**
  90344. * This is the base class of all the camera used in the application.
  90345. * @see http://doc.babylonjs.com/features/cameras
  90346. */
  90347. export class Camera extends Node {
  90348. /** @hidden */
  90349. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90350. /**
  90351. * This is the default projection mode used by the cameras.
  90352. * It helps recreating a feeling of perspective and better appreciate depth.
  90353. * This is the best way to simulate real life cameras.
  90354. */
  90355. static readonly PERSPECTIVE_CAMERA: number;
  90356. /**
  90357. * This helps creating camera with an orthographic mode.
  90358. * 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.
  90359. */
  90360. static readonly ORTHOGRAPHIC_CAMERA: number;
  90361. /**
  90362. * This is the default FOV mode for perspective cameras.
  90363. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90364. */
  90365. static readonly FOVMODE_VERTICAL_FIXED: number;
  90366. /**
  90367. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90368. */
  90369. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90370. /**
  90371. * This specifies ther is no need for a camera rig.
  90372. * Basically only one eye is rendered corresponding to the camera.
  90373. */
  90374. static readonly RIG_MODE_NONE: number;
  90375. /**
  90376. * Simulates a camera Rig with one blue eye and one red eye.
  90377. * This can be use with 3d blue and red glasses.
  90378. */
  90379. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90380. /**
  90381. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90382. */
  90383. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90384. /**
  90385. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90386. */
  90387. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90388. /**
  90389. * Defines that both eyes of the camera will be rendered over under each other.
  90390. */
  90391. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90392. /**
  90393. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90394. */
  90395. static readonly RIG_MODE_VR: number;
  90396. /**
  90397. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90398. */
  90399. static readonly RIG_MODE_WEBVR: number;
  90400. /**
  90401. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90402. */
  90403. static readonly RIG_MODE_CUSTOM: number;
  90404. /**
  90405. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90406. */
  90407. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90408. /**
  90409. * Define the input manager associated with the camera.
  90410. */
  90411. inputs: CameraInputsManager<Camera>;
  90412. /** @hidden */
  90413. _position: Vector3;
  90414. /**
  90415. * Define the current local position of the camera in the scene
  90416. */
  90417. position: Vector3;
  90418. /**
  90419. * The vector the camera should consider as up.
  90420. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90421. */
  90422. upVector: Vector3;
  90423. /**
  90424. * Define the current limit on the left side for an orthographic camera
  90425. * In scene unit
  90426. */
  90427. orthoLeft: Nullable<number>;
  90428. /**
  90429. * Define the current limit on the right side for an orthographic camera
  90430. * In scene unit
  90431. */
  90432. orthoRight: Nullable<number>;
  90433. /**
  90434. * Define the current limit on the bottom side for an orthographic camera
  90435. * In scene unit
  90436. */
  90437. orthoBottom: Nullable<number>;
  90438. /**
  90439. * Define the current limit on the top side for an orthographic camera
  90440. * In scene unit
  90441. */
  90442. orthoTop: Nullable<number>;
  90443. /**
  90444. * Field Of View is set in Radians. (default is 0.8)
  90445. */
  90446. fov: number;
  90447. /**
  90448. * Define the minimum distance the camera can see from.
  90449. * This is important to note that the depth buffer are not infinite and the closer it starts
  90450. * the more your scene might encounter depth fighting issue.
  90451. */
  90452. minZ: number;
  90453. /**
  90454. * Define the maximum distance the camera can see to.
  90455. * This is important to note that the depth buffer are not infinite and the further it end
  90456. * the more your scene might encounter depth fighting issue.
  90457. */
  90458. maxZ: number;
  90459. /**
  90460. * Define the default inertia of the camera.
  90461. * This helps giving a smooth feeling to the camera movement.
  90462. */
  90463. inertia: number;
  90464. /**
  90465. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90466. */
  90467. mode: number;
  90468. /**
  90469. * Define wether the camera is intermediate.
  90470. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90471. */
  90472. isIntermediate: boolean;
  90473. /**
  90474. * Define the viewport of the camera.
  90475. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90476. */
  90477. viewport: Viewport;
  90478. /**
  90479. * Restricts the camera to viewing objects with the same layerMask.
  90480. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90481. */
  90482. layerMask: number;
  90483. /**
  90484. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90485. */
  90486. fovMode: number;
  90487. /**
  90488. * Rig mode of the camera.
  90489. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90490. * This is normally controlled byt the camera themselves as internal use.
  90491. */
  90492. cameraRigMode: number;
  90493. /**
  90494. * Defines the distance between both "eyes" in case of a RIG
  90495. */
  90496. interaxialDistance: number;
  90497. /**
  90498. * Defines if stereoscopic rendering is done side by side or over under.
  90499. */
  90500. isStereoscopicSideBySide: boolean;
  90501. /**
  90502. * 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
  90503. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90504. * else in the scene. (Eg. security camera)
  90505. *
  90506. * 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)
  90507. */
  90508. customRenderTargets: RenderTargetTexture[];
  90509. /**
  90510. * When set, the camera will render to this render target instead of the default canvas
  90511. *
  90512. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90513. */
  90514. outputRenderTarget: Nullable<RenderTargetTexture>;
  90515. /**
  90516. * Observable triggered when the camera view matrix has changed.
  90517. */
  90518. onViewMatrixChangedObservable: Observable<Camera>;
  90519. /**
  90520. * Observable triggered when the camera Projection matrix has changed.
  90521. */
  90522. onProjectionMatrixChangedObservable: Observable<Camera>;
  90523. /**
  90524. * Observable triggered when the inputs have been processed.
  90525. */
  90526. onAfterCheckInputsObservable: Observable<Camera>;
  90527. /**
  90528. * Observable triggered when reset has been called and applied to the camera.
  90529. */
  90530. onRestoreStateObservable: Observable<Camera>;
  90531. /** @hidden */
  90532. _cameraRigParams: any;
  90533. /** @hidden */
  90534. _rigCameras: Camera[];
  90535. /** @hidden */
  90536. _rigPostProcess: Nullable<PostProcess>;
  90537. protected _webvrViewMatrix: Matrix;
  90538. /** @hidden */
  90539. _skipRendering: boolean;
  90540. /** @hidden */
  90541. _projectionMatrix: Matrix;
  90542. /** @hidden */
  90543. _postProcesses: Nullable<PostProcess>[];
  90544. /** @hidden */
  90545. _activeMeshes: SmartArray<AbstractMesh>;
  90546. protected _globalPosition: Vector3;
  90547. /** @hidden */
  90548. _computedViewMatrix: Matrix;
  90549. private _doNotComputeProjectionMatrix;
  90550. private _transformMatrix;
  90551. private _frustumPlanes;
  90552. private _refreshFrustumPlanes;
  90553. private _storedFov;
  90554. private _stateStored;
  90555. /**
  90556. * Instantiates a new camera object.
  90557. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90558. * @see http://doc.babylonjs.com/features/cameras
  90559. * @param name Defines the name of the camera in the scene
  90560. * @param position Defines the position of the camera
  90561. * @param scene Defines the scene the camera belongs too
  90562. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90563. */
  90564. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90565. /**
  90566. * Store current camera state (fov, position, etc..)
  90567. * @returns the camera
  90568. */
  90569. storeState(): Camera;
  90570. /**
  90571. * Restores the camera state values if it has been stored. You must call storeState() first
  90572. */
  90573. protected _restoreStateValues(): boolean;
  90574. /**
  90575. * Restored camera state. You must call storeState() first.
  90576. * @returns true if restored and false otherwise
  90577. */
  90578. restoreState(): boolean;
  90579. /**
  90580. * Gets the class name of the camera.
  90581. * @returns the class name
  90582. */
  90583. getClassName(): string;
  90584. /** @hidden */
  90585. readonly _isCamera: boolean;
  90586. /**
  90587. * Gets a string representation of the camera useful for debug purpose.
  90588. * @param fullDetails Defines that a more verboe level of logging is required
  90589. * @returns the string representation
  90590. */
  90591. toString(fullDetails?: boolean): string;
  90592. /**
  90593. * Gets the current world space position of the camera.
  90594. */
  90595. readonly globalPosition: Vector3;
  90596. /**
  90597. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90598. * @returns the active meshe list
  90599. */
  90600. getActiveMeshes(): SmartArray<AbstractMesh>;
  90601. /**
  90602. * Check wether a mesh is part of the current active mesh list of the camera
  90603. * @param mesh Defines the mesh to check
  90604. * @returns true if active, false otherwise
  90605. */
  90606. isActiveMesh(mesh: Mesh): boolean;
  90607. /**
  90608. * Is this camera ready to be used/rendered
  90609. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90610. * @return true if the camera is ready
  90611. */
  90612. isReady(completeCheck?: boolean): boolean;
  90613. /** @hidden */
  90614. _initCache(): void;
  90615. /** @hidden */
  90616. _updateCache(ignoreParentClass?: boolean): void;
  90617. /** @hidden */
  90618. _isSynchronized(): boolean;
  90619. /** @hidden */
  90620. _isSynchronizedViewMatrix(): boolean;
  90621. /** @hidden */
  90622. _isSynchronizedProjectionMatrix(): boolean;
  90623. /**
  90624. * Attach the input controls to a specific dom element to get the input from.
  90625. * @param element Defines the element the controls should be listened from
  90626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90627. */
  90628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90629. /**
  90630. * Detach the current controls from the specified dom element.
  90631. * @param element Defines the element to stop listening the inputs from
  90632. */
  90633. detachControl(element: HTMLElement): void;
  90634. /**
  90635. * Update the camera state according to the different inputs gathered during the frame.
  90636. */
  90637. update(): void;
  90638. /** @hidden */
  90639. _checkInputs(): void;
  90640. /** @hidden */
  90641. readonly rigCameras: Camera[];
  90642. /**
  90643. * Gets the post process used by the rig cameras
  90644. */
  90645. readonly rigPostProcess: Nullable<PostProcess>;
  90646. /**
  90647. * Internal, gets the first post proces.
  90648. * @returns the first post process to be run on this camera.
  90649. */
  90650. _getFirstPostProcess(): Nullable<PostProcess>;
  90651. private _cascadePostProcessesToRigCams;
  90652. /**
  90653. * Attach a post process to the camera.
  90654. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90655. * @param postProcess The post process to attach to the camera
  90656. * @param insertAt The position of the post process in case several of them are in use in the scene
  90657. * @returns the position the post process has been inserted at
  90658. */
  90659. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90660. /**
  90661. * Detach a post process to the camera.
  90662. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90663. * @param postProcess The post process to detach from the camera
  90664. */
  90665. detachPostProcess(postProcess: PostProcess): void;
  90666. /**
  90667. * Gets the current world matrix of the camera
  90668. */
  90669. getWorldMatrix(): Matrix;
  90670. /** @hidden */
  90671. _getViewMatrix(): Matrix;
  90672. /**
  90673. * Gets the current view matrix of the camera.
  90674. * @param force forces the camera to recompute the matrix without looking at the cached state
  90675. * @returns the view matrix
  90676. */
  90677. getViewMatrix(force?: boolean): Matrix;
  90678. /**
  90679. * Freeze the projection matrix.
  90680. * It will prevent the cache check of the camera projection compute and can speed up perf
  90681. * if no parameter of the camera are meant to change
  90682. * @param projection Defines manually a projection if necessary
  90683. */
  90684. freezeProjectionMatrix(projection?: Matrix): void;
  90685. /**
  90686. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90687. */
  90688. unfreezeProjectionMatrix(): void;
  90689. /**
  90690. * Gets the current projection matrix of the camera.
  90691. * @param force forces the camera to recompute the matrix without looking at the cached state
  90692. * @returns the projection matrix
  90693. */
  90694. getProjectionMatrix(force?: boolean): Matrix;
  90695. /**
  90696. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90697. * @returns a Matrix
  90698. */
  90699. getTransformationMatrix(): Matrix;
  90700. private _updateFrustumPlanes;
  90701. /**
  90702. * Checks if a cullable object (mesh...) is in the camera frustum
  90703. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90704. * @param target The object to check
  90705. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90706. * @returns true if the object is in frustum otherwise false
  90707. */
  90708. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90709. /**
  90710. * Checks if a cullable object (mesh...) is in the camera frustum
  90711. * Unlike isInFrustum this cheks the full bounding box
  90712. * @param target The object to check
  90713. * @returns true if the object is in frustum otherwise false
  90714. */
  90715. isCompletelyInFrustum(target: ICullable): boolean;
  90716. /**
  90717. * Gets a ray in the forward direction from the camera.
  90718. * @param length Defines the length of the ray to create
  90719. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90720. * @param origin Defines the start point of the ray which defaults to the camera position
  90721. * @returns the forward ray
  90722. */
  90723. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90724. /**
  90725. * Releases resources associated with this node.
  90726. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90727. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90728. */
  90729. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90730. /** @hidden */
  90731. _isLeftCamera: boolean;
  90732. /**
  90733. * Gets the left camera of a rig setup in case of Rigged Camera
  90734. */
  90735. readonly isLeftCamera: boolean;
  90736. /** @hidden */
  90737. _isRightCamera: boolean;
  90738. /**
  90739. * Gets the right camera of a rig setup in case of Rigged Camera
  90740. */
  90741. readonly isRightCamera: boolean;
  90742. /**
  90743. * Gets the left camera of a rig setup in case of Rigged Camera
  90744. */
  90745. readonly leftCamera: Nullable<FreeCamera>;
  90746. /**
  90747. * Gets the right camera of a rig setup in case of Rigged Camera
  90748. */
  90749. readonly rightCamera: Nullable<FreeCamera>;
  90750. /**
  90751. * Gets the left camera target of a rig setup in case of Rigged Camera
  90752. * @returns the target position
  90753. */
  90754. getLeftTarget(): Nullable<Vector3>;
  90755. /**
  90756. * Gets the right camera target of a rig setup in case of Rigged Camera
  90757. * @returns the target position
  90758. */
  90759. getRightTarget(): Nullable<Vector3>;
  90760. /**
  90761. * @hidden
  90762. */
  90763. setCameraRigMode(mode: number, rigParams: any): void;
  90764. /** @hidden */
  90765. static _setStereoscopicRigMode(camera: Camera): void;
  90766. /** @hidden */
  90767. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90768. /** @hidden */
  90769. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90770. /** @hidden */
  90771. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90772. /** @hidden */
  90773. _getVRProjectionMatrix(): Matrix;
  90774. protected _updateCameraRotationMatrix(): void;
  90775. protected _updateWebVRCameraRotationMatrix(): void;
  90776. /**
  90777. * This function MUST be overwritten by the different WebVR cameras available.
  90778. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90779. * @hidden
  90780. */
  90781. _getWebVRProjectionMatrix(): Matrix;
  90782. /**
  90783. * This function MUST be overwritten by the different WebVR cameras available.
  90784. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90785. * @hidden
  90786. */
  90787. _getWebVRViewMatrix(): Matrix;
  90788. /** @hidden */
  90789. setCameraRigParameter(name: string, value: any): void;
  90790. /**
  90791. * needs to be overridden by children so sub has required properties to be copied
  90792. * @hidden
  90793. */
  90794. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90795. /**
  90796. * May need to be overridden by children
  90797. * @hidden
  90798. */
  90799. _updateRigCameras(): void;
  90800. /** @hidden */
  90801. _setupInputs(): void;
  90802. /**
  90803. * Serialiaze the camera setup to a json represention
  90804. * @returns the JSON representation
  90805. */
  90806. serialize(): any;
  90807. /**
  90808. * Clones the current camera.
  90809. * @param name The cloned camera name
  90810. * @returns the cloned camera
  90811. */
  90812. clone(name: string): Camera;
  90813. /**
  90814. * Gets the direction of the camera relative to a given local axis.
  90815. * @param localAxis Defines the reference axis to provide a relative direction.
  90816. * @return the direction
  90817. */
  90818. getDirection(localAxis: Vector3): Vector3;
  90819. /**
  90820. * Returns the current camera absolute rotation
  90821. */
  90822. readonly absoluteRotation: Quaternion;
  90823. /**
  90824. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90825. * @param localAxis Defines the reference axis to provide a relative direction.
  90826. * @param result Defines the vector to store the result in
  90827. */
  90828. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90829. /**
  90830. * Gets a camera constructor for a given camera type
  90831. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90832. * @param name The name of the camera the result will be able to instantiate
  90833. * @param scene The scene the result will construct the camera in
  90834. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90835. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90836. * @returns a factory method to construc the camera
  90837. */
  90838. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90839. /**
  90840. * Compute the world matrix of the camera.
  90841. * @returns the camera workd matrix
  90842. */
  90843. computeWorldMatrix(): Matrix;
  90844. /**
  90845. * Parse a JSON and creates the camera from the parsed information
  90846. * @param parsedCamera The JSON to parse
  90847. * @param scene The scene to instantiate the camera in
  90848. * @returns the newly constructed camera
  90849. */
  90850. static Parse(parsedCamera: any, scene: Scene): Camera;
  90851. }
  90852. }
  90853. declare module BABYLON {
  90854. /**
  90855. * Class containing static functions to help procedurally build meshes
  90856. */
  90857. export class DiscBuilder {
  90858. /**
  90859. * Creates a plane polygonal mesh. By default, this is a disc
  90860. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90861. * * 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
  90862. * * 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
  90863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90866. * @param name defines the name of the mesh
  90867. * @param options defines the options used to create the mesh
  90868. * @param scene defines the hosting scene
  90869. * @returns the plane polygonal mesh
  90870. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90871. */
  90872. static CreateDisc(name: string, options: {
  90873. radius?: number;
  90874. tessellation?: number;
  90875. arc?: number;
  90876. updatable?: boolean;
  90877. sideOrientation?: number;
  90878. frontUVs?: Vector4;
  90879. backUVs?: Vector4;
  90880. }, scene?: Nullable<Scene>): Mesh;
  90881. }
  90882. }
  90883. declare module BABYLON {
  90884. /**
  90885. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90886. *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.
  90887. * The SPS is also a particle system. It provides some methods to manage the particles.
  90888. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90889. *
  90890. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90891. */
  90892. export class SolidParticleSystem implements IDisposable {
  90893. /**
  90894. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90895. * Example : var p = SPS.particles[i];
  90896. */
  90897. particles: SolidParticle[];
  90898. /**
  90899. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90900. */
  90901. nbParticles: number;
  90902. /**
  90903. * If the particles must ever face the camera (default false). Useful for planar particles.
  90904. */
  90905. billboard: boolean;
  90906. /**
  90907. * Recompute normals when adding a shape
  90908. */
  90909. recomputeNormals: boolean;
  90910. /**
  90911. * This a counter ofr your own usage. It's not set by any SPS functions.
  90912. */
  90913. counter: number;
  90914. /**
  90915. * The SPS name. This name is also given to the underlying mesh.
  90916. */
  90917. name: string;
  90918. /**
  90919. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90920. */
  90921. mesh: Mesh;
  90922. /**
  90923. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90924. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90925. */
  90926. vars: any;
  90927. /**
  90928. * This array is populated when the SPS is set as 'pickable'.
  90929. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90930. * Each element of this array is an object `{idx: int, faceId: int}`.
  90931. * `idx` is the picked particle index in the `SPS.particles` array
  90932. * `faceId` is the picked face index counted within this particle.
  90933. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90934. */
  90935. pickedParticles: {
  90936. idx: number;
  90937. faceId: number;
  90938. }[];
  90939. /**
  90940. * This array is populated when `enableDepthSort` is set to true.
  90941. * Each element of this array is an instance of the class DepthSortedParticle.
  90942. */
  90943. depthSortedParticles: DepthSortedParticle[];
  90944. /**
  90945. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90946. * @hidden
  90947. */
  90948. _bSphereOnly: boolean;
  90949. /**
  90950. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90951. * @hidden
  90952. */
  90953. _bSphereRadiusFactor: number;
  90954. private _scene;
  90955. private _positions;
  90956. private _indices;
  90957. private _normals;
  90958. private _colors;
  90959. private _uvs;
  90960. private _indices32;
  90961. private _positions32;
  90962. private _normals32;
  90963. private _fixedNormal32;
  90964. private _colors32;
  90965. private _uvs32;
  90966. private _index;
  90967. private _updatable;
  90968. private _pickable;
  90969. private _isVisibilityBoxLocked;
  90970. private _alwaysVisible;
  90971. private _depthSort;
  90972. private _shapeCounter;
  90973. private _copy;
  90974. private _color;
  90975. private _computeParticleColor;
  90976. private _computeParticleTexture;
  90977. private _computeParticleRotation;
  90978. private _computeParticleVertex;
  90979. private _computeBoundingBox;
  90980. private _depthSortParticles;
  90981. private _camera;
  90982. private _mustUnrotateFixedNormals;
  90983. private _particlesIntersect;
  90984. private _needs32Bits;
  90985. /**
  90986. * Creates a SPS (Solid Particle System) object.
  90987. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90988. * @param scene (Scene) is the scene in which the SPS is added.
  90989. * @param options defines the options of the sps e.g.
  90990. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90991. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90992. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90993. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90994. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90995. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90996. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90997. */
  90998. constructor(name: string, scene: Scene, options?: {
  90999. updatable?: boolean;
  91000. isPickable?: boolean;
  91001. enableDepthSort?: boolean;
  91002. particleIntersection?: boolean;
  91003. boundingSphereOnly?: boolean;
  91004. bSphereRadiusFactor?: number;
  91005. });
  91006. /**
  91007. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91008. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91009. * @returns the created mesh
  91010. */
  91011. buildMesh(): Mesh;
  91012. /**
  91013. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91014. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91015. * Thus the particles generated from `digest()` have their property `position` set yet.
  91016. * @param mesh ( Mesh ) is the mesh to be digested
  91017. * @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
  91018. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91019. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91020. * @returns the current SPS
  91021. */
  91022. digest(mesh: Mesh, options?: {
  91023. facetNb?: number;
  91024. number?: number;
  91025. delta?: number;
  91026. }): SolidParticleSystem;
  91027. private _unrotateFixedNormals;
  91028. private _resetCopy;
  91029. private _meshBuilder;
  91030. private _posToShape;
  91031. private _uvsToShapeUV;
  91032. private _addParticle;
  91033. /**
  91034. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91035. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91036. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91037. * @param nb (positive integer) the number of particles to be created from this model
  91038. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91039. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91040. * @returns the number of shapes in the system
  91041. */
  91042. addShape(mesh: Mesh, nb: number, options?: {
  91043. positionFunction?: any;
  91044. vertexFunction?: any;
  91045. }): number;
  91046. private _rebuildParticle;
  91047. /**
  91048. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91049. * @returns the SPS.
  91050. */
  91051. rebuildMesh(): SolidParticleSystem;
  91052. /**
  91053. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91054. * This method calls `updateParticle()` for each particle of the SPS.
  91055. * For an animated SPS, it is usually called within the render loop.
  91056. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91057. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91058. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91059. * @returns the SPS.
  91060. */
  91061. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91062. /**
  91063. * Disposes the SPS.
  91064. */
  91065. dispose(): void;
  91066. /**
  91067. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91069. * @returns the SPS.
  91070. */
  91071. refreshVisibleSize(): SolidParticleSystem;
  91072. /**
  91073. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91074. * @param size the size (float) of the visibility box
  91075. * note : this doesn't lock the SPS mesh bounding box.
  91076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91077. */
  91078. setVisibilityBox(size: number): void;
  91079. /**
  91080. * Gets whether the SPS as always visible or not
  91081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91082. */
  91083. /**
  91084. * Sets the SPS as always visible or not
  91085. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91086. */
  91087. isAlwaysVisible: boolean;
  91088. /**
  91089. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91090. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91091. */
  91092. /**
  91093. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91094. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91095. */
  91096. isVisibilityBoxLocked: boolean;
  91097. /**
  91098. * Tells to `setParticles()` to compute the particle rotations or not.
  91099. * Default value : true. The SPS is faster when it's set to false.
  91100. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91101. */
  91102. /**
  91103. * Gets if `setParticles()` computes the particle rotations or not.
  91104. * Default value : true. The SPS is faster when it's set to false.
  91105. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91106. */
  91107. computeParticleRotation: boolean;
  91108. /**
  91109. * Tells to `setParticles()` to compute the particle colors or not.
  91110. * Default value : true. The SPS is faster when it's set to false.
  91111. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91112. */
  91113. /**
  91114. * Gets if `setParticles()` computes the particle colors or not.
  91115. * Default value : true. The SPS is faster when it's set to false.
  91116. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91117. */
  91118. computeParticleColor: boolean;
  91119. /**
  91120. * Gets if `setParticles()` computes the particle textures or not.
  91121. * Default value : true. The SPS is faster when it's set to false.
  91122. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91123. */
  91124. computeParticleTexture: boolean;
  91125. /**
  91126. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91127. * Default value : false. The SPS is faster when it's set to false.
  91128. * Note : the particle custom vertex positions aren't stored values.
  91129. */
  91130. /**
  91131. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91132. * Default value : false. The SPS is faster when it's set to false.
  91133. * Note : the particle custom vertex positions aren't stored values.
  91134. */
  91135. computeParticleVertex: boolean;
  91136. /**
  91137. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91138. */
  91139. /**
  91140. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91141. */
  91142. computeBoundingBox: boolean;
  91143. /**
  91144. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91145. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91146. * Default : `true`
  91147. */
  91148. /**
  91149. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91150. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91151. * Default : `true`
  91152. */
  91153. depthSortParticles: boolean;
  91154. /**
  91155. * This function does nothing. It may be overwritten to set all the particle first values.
  91156. * The SPS doesn't call this function, you may have to call it by your own.
  91157. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91158. */
  91159. initParticles(): void;
  91160. /**
  91161. * This function does nothing. It may be overwritten to recycle a particle.
  91162. * The SPS doesn't call this function, you may have to call it by your own.
  91163. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91164. * @param particle The particle to recycle
  91165. * @returns the recycled particle
  91166. */
  91167. recycleParticle(particle: SolidParticle): SolidParticle;
  91168. /**
  91169. * Updates a particle : this function should be overwritten by the user.
  91170. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91171. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91172. * @example : just set a particle position or velocity and recycle conditions
  91173. * @param particle The particle to update
  91174. * @returns the updated particle
  91175. */
  91176. updateParticle(particle: SolidParticle): SolidParticle;
  91177. /**
  91178. * Updates a vertex of a particle : it can be overwritten by the user.
  91179. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91180. * @param particle the current particle
  91181. * @param vertex the current index of the current particle
  91182. * @param pt the index of the current vertex in the particle shape
  91183. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91184. * @example : just set a vertex particle position
  91185. * @returns the updated vertex
  91186. */
  91187. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91188. /**
  91189. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91190. * This does nothing and may be overwritten by the user.
  91191. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91192. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91193. * @param update the boolean update value actually passed to setParticles()
  91194. */
  91195. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91196. /**
  91197. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91198. * This will be passed three parameters.
  91199. * This does nothing and may be overwritten by the user.
  91200. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91201. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91202. * @param update the boolean update value actually passed to setParticles()
  91203. */
  91204. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91205. }
  91206. }
  91207. declare module BABYLON {
  91208. /**
  91209. * Represents one particle of a solid particle system.
  91210. */
  91211. export class SolidParticle {
  91212. /**
  91213. * particle global index
  91214. */
  91215. idx: number;
  91216. /**
  91217. * The color of the particle
  91218. */
  91219. color: Nullable<Color4>;
  91220. /**
  91221. * The world space position of the particle.
  91222. */
  91223. position: Vector3;
  91224. /**
  91225. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91226. */
  91227. rotation: Vector3;
  91228. /**
  91229. * The world space rotation quaternion of the particle.
  91230. */
  91231. rotationQuaternion: Nullable<Quaternion>;
  91232. /**
  91233. * The scaling of the particle.
  91234. */
  91235. scaling: Vector3;
  91236. /**
  91237. * The uvs of the particle.
  91238. */
  91239. uvs: Vector4;
  91240. /**
  91241. * The current speed of the particle.
  91242. */
  91243. velocity: Vector3;
  91244. /**
  91245. * The pivot point in the particle local space.
  91246. */
  91247. pivot: Vector3;
  91248. /**
  91249. * Must the particle be translated from its pivot point in its local space ?
  91250. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91251. * Default : false
  91252. */
  91253. translateFromPivot: boolean;
  91254. /**
  91255. * Is the particle active or not ?
  91256. */
  91257. alive: boolean;
  91258. /**
  91259. * Is the particle visible or not ?
  91260. */
  91261. isVisible: boolean;
  91262. /**
  91263. * Index of this particle in the global "positions" array (Internal use)
  91264. * @hidden
  91265. */
  91266. _pos: number;
  91267. /**
  91268. * @hidden Index of this particle in the global "indices" array (Internal use)
  91269. */
  91270. _ind: number;
  91271. /**
  91272. * @hidden ModelShape of this particle (Internal use)
  91273. */
  91274. _model: ModelShape;
  91275. /**
  91276. * ModelShape id of this particle
  91277. */
  91278. shapeId: number;
  91279. /**
  91280. * Index of the particle in its shape id
  91281. */
  91282. idxInShape: number;
  91283. /**
  91284. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91285. */
  91286. _modelBoundingInfo: BoundingInfo;
  91287. /**
  91288. * @hidden Particle BoundingInfo object (Internal use)
  91289. */
  91290. _boundingInfo: BoundingInfo;
  91291. /**
  91292. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91293. */
  91294. _sps: SolidParticleSystem;
  91295. /**
  91296. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91297. */
  91298. _stillInvisible: boolean;
  91299. /**
  91300. * @hidden Last computed particle rotation matrix
  91301. */
  91302. _rotationMatrix: number[];
  91303. /**
  91304. * Parent particle Id, if any.
  91305. * Default null.
  91306. */
  91307. parentId: Nullable<number>;
  91308. /**
  91309. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91310. * The possible values are :
  91311. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91312. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91313. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91314. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91315. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91316. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91317. * */
  91318. cullingStrategy: number;
  91319. /**
  91320. * @hidden Internal global position in the SPS.
  91321. */
  91322. _globalPosition: Vector3;
  91323. /**
  91324. * Creates a Solid Particle object.
  91325. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91326. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91327. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91328. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91329. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91330. * @param shapeId (integer) is the model shape identifier in the SPS.
  91331. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91332. * @param sps defines the sps it is associated to
  91333. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91334. */
  91335. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91336. /**
  91337. * Legacy support, changed scale to scaling
  91338. */
  91339. /**
  91340. * Legacy support, changed scale to scaling
  91341. */
  91342. scale: Vector3;
  91343. /**
  91344. * Legacy support, changed quaternion to rotationQuaternion
  91345. */
  91346. /**
  91347. * Legacy support, changed quaternion to rotationQuaternion
  91348. */
  91349. quaternion: Nullable<Quaternion>;
  91350. /**
  91351. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91352. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91353. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91354. * @returns true if it intersects
  91355. */
  91356. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91357. /**
  91358. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91359. * A particle is in the frustum if its bounding box intersects the frustum
  91360. * @param frustumPlanes defines the frustum to test
  91361. * @returns true if the particle is in the frustum planes
  91362. */
  91363. isInFrustum(frustumPlanes: Plane[]): boolean;
  91364. /**
  91365. * get the rotation matrix of the particle
  91366. * @hidden
  91367. */
  91368. getRotationMatrix(m: Matrix): void;
  91369. }
  91370. /**
  91371. * Represents the shape of the model used by one particle of a solid particle system.
  91372. * SPS internal tool, don't use it manually.
  91373. */
  91374. export class ModelShape {
  91375. /**
  91376. * The shape id
  91377. * @hidden
  91378. */
  91379. shapeID: number;
  91380. /**
  91381. * flat array of model positions (internal use)
  91382. * @hidden
  91383. */
  91384. _shape: Vector3[];
  91385. /**
  91386. * flat array of model UVs (internal use)
  91387. * @hidden
  91388. */
  91389. _shapeUV: number[];
  91390. /**
  91391. * length of the shape in the model indices array (internal use)
  91392. * @hidden
  91393. */
  91394. _indicesLength: number;
  91395. /**
  91396. * Custom position function (internal use)
  91397. * @hidden
  91398. */
  91399. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91400. /**
  91401. * Custom vertex function (internal use)
  91402. * @hidden
  91403. */
  91404. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91405. /**
  91406. * 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.
  91407. * SPS internal tool, don't use it manually.
  91408. * @hidden
  91409. */
  91410. 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>);
  91411. }
  91412. /**
  91413. * Represents a Depth Sorted Particle in the solid particle system.
  91414. */
  91415. export class DepthSortedParticle {
  91416. /**
  91417. * Index of the particle in the "indices" array
  91418. */
  91419. ind: number;
  91420. /**
  91421. * Length of the particle shape in the "indices" array
  91422. */
  91423. indicesLength: number;
  91424. /**
  91425. * Squared distance from the particle to the camera
  91426. */
  91427. sqDistance: number;
  91428. }
  91429. }
  91430. declare module BABYLON {
  91431. /**
  91432. * @hidden
  91433. */
  91434. export class _MeshCollisionData {
  91435. _checkCollisions: boolean;
  91436. _collisionMask: number;
  91437. _collisionGroup: number;
  91438. _collider: Nullable<Collider>;
  91439. _oldPositionForCollisions: Vector3;
  91440. _diffPositionForCollisions: Vector3;
  91441. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91442. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91443. }
  91444. }
  91445. declare module BABYLON {
  91446. /** @hidden */
  91447. class _FacetDataStorage {
  91448. facetPositions: Vector3[];
  91449. facetNormals: Vector3[];
  91450. facetPartitioning: number[][];
  91451. facetNb: number;
  91452. partitioningSubdivisions: number;
  91453. partitioningBBoxRatio: number;
  91454. facetDataEnabled: boolean;
  91455. facetParameters: any;
  91456. bbSize: Vector3;
  91457. subDiv: {
  91458. max: number;
  91459. X: number;
  91460. Y: number;
  91461. Z: number;
  91462. };
  91463. facetDepthSort: boolean;
  91464. facetDepthSortEnabled: boolean;
  91465. depthSortedIndices: IndicesArray;
  91466. depthSortedFacets: {
  91467. ind: number;
  91468. sqDistance: number;
  91469. }[];
  91470. facetDepthSortFunction: (f1: {
  91471. ind: number;
  91472. sqDistance: number;
  91473. }, f2: {
  91474. ind: number;
  91475. sqDistance: number;
  91476. }) => number;
  91477. facetDepthSortFrom: Vector3;
  91478. facetDepthSortOrigin: Vector3;
  91479. invertedMatrix: Matrix;
  91480. }
  91481. /**
  91482. * @hidden
  91483. **/
  91484. class _InternalAbstractMeshDataInfo {
  91485. _hasVertexAlpha: boolean;
  91486. _useVertexColors: boolean;
  91487. _numBoneInfluencers: number;
  91488. _applyFog: boolean;
  91489. _receiveShadows: boolean;
  91490. _facetData: _FacetDataStorage;
  91491. _visibility: number;
  91492. _skeleton: Nullable<Skeleton>;
  91493. _layerMask: number;
  91494. _computeBonesUsingShaders: boolean;
  91495. _isActive: boolean;
  91496. _onlyForInstances: boolean;
  91497. _isActiveIntermediate: boolean;
  91498. _onlyForInstancesIntermediate: boolean;
  91499. }
  91500. /**
  91501. * Class used to store all common mesh properties
  91502. */
  91503. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91504. /** No occlusion */
  91505. static OCCLUSION_TYPE_NONE: number;
  91506. /** Occlusion set to optimisitic */
  91507. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91508. /** Occlusion set to strict */
  91509. static OCCLUSION_TYPE_STRICT: number;
  91510. /** Use an accurante occlusion algorithm */
  91511. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91512. /** Use a conservative occlusion algorithm */
  91513. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91514. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91515. * Test order :
  91516. * Is the bounding sphere outside the frustum ?
  91517. * If not, are the bounding box vertices outside the frustum ?
  91518. * It not, then the cullable object is in the frustum.
  91519. */
  91520. static readonly CULLINGSTRATEGY_STANDARD: number;
  91521. /** Culling strategy : Bounding Sphere Only.
  91522. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91523. * It's also less accurate than the standard because some not visible objects can still be selected.
  91524. * Test : is the bounding sphere outside the frustum ?
  91525. * If not, then the cullable object is in the frustum.
  91526. */
  91527. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91528. /** Culling strategy : Optimistic Inclusion.
  91529. * This in an inclusion test first, then the standard exclusion test.
  91530. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91531. * 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.
  91532. * Anyway, it's as accurate as the standard strategy.
  91533. * Test :
  91534. * Is the cullable object bounding sphere center in the frustum ?
  91535. * If not, apply the default culling strategy.
  91536. */
  91537. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91538. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91539. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91540. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91541. * 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.
  91542. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91543. * Test :
  91544. * Is the cullable object bounding sphere center in the frustum ?
  91545. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91546. */
  91547. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91548. /**
  91549. * No billboard
  91550. */
  91551. static readonly BILLBOARDMODE_NONE: number;
  91552. /** Billboard on X axis */
  91553. static readonly BILLBOARDMODE_X: number;
  91554. /** Billboard on Y axis */
  91555. static readonly BILLBOARDMODE_Y: number;
  91556. /** Billboard on Z axis */
  91557. static readonly BILLBOARDMODE_Z: number;
  91558. /** Billboard on all axes */
  91559. static readonly BILLBOARDMODE_ALL: number;
  91560. /** Billboard on using position instead of orientation */
  91561. static readonly BILLBOARDMODE_USE_POSITION: number;
  91562. /** @hidden */
  91563. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91564. /**
  91565. * The culling strategy to use to check whether the mesh must be rendered or not.
  91566. * This value can be changed at any time and will be used on the next render mesh selection.
  91567. * The possible values are :
  91568. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91569. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91570. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91571. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91572. * Please read each static variable documentation to get details about the culling process.
  91573. * */
  91574. cullingStrategy: number;
  91575. /**
  91576. * Gets the number of facets in the mesh
  91577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91578. */
  91579. readonly facetNb: number;
  91580. /**
  91581. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91583. */
  91584. partitioningSubdivisions: number;
  91585. /**
  91586. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91587. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91589. */
  91590. partitioningBBoxRatio: number;
  91591. /**
  91592. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91593. * Works only for updatable meshes.
  91594. * Doesn't work with multi-materials
  91595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91596. */
  91597. mustDepthSortFacets: boolean;
  91598. /**
  91599. * The location (Vector3) where the facet depth sort must be computed from.
  91600. * By default, the active camera position.
  91601. * Used only when facet depth sort is enabled
  91602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91603. */
  91604. facetDepthSortFrom: Vector3;
  91605. /**
  91606. * gets a boolean indicating if facetData is enabled
  91607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91608. */
  91609. readonly isFacetDataEnabled: boolean;
  91610. /** @hidden */
  91611. _updateNonUniformScalingState(value: boolean): boolean;
  91612. /**
  91613. * An event triggered when this mesh collides with another one
  91614. */
  91615. onCollideObservable: Observable<AbstractMesh>;
  91616. /** Set a function to call when this mesh collides with another one */
  91617. onCollide: () => void;
  91618. /**
  91619. * An event triggered when the collision's position changes
  91620. */
  91621. onCollisionPositionChangeObservable: Observable<Vector3>;
  91622. /** Set a function to call when the collision's position changes */
  91623. onCollisionPositionChange: () => void;
  91624. /**
  91625. * An event triggered when material is changed
  91626. */
  91627. onMaterialChangedObservable: Observable<AbstractMesh>;
  91628. /**
  91629. * Gets or sets the orientation for POV movement & rotation
  91630. */
  91631. definedFacingForward: boolean;
  91632. /** @hidden */
  91633. _occlusionQuery: Nullable<WebGLQuery>;
  91634. /** @hidden */
  91635. _renderingGroup: Nullable<RenderingGroup>;
  91636. /**
  91637. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91638. */
  91639. /**
  91640. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91641. */
  91642. visibility: number;
  91643. /** Gets or sets the alpha index used to sort transparent meshes
  91644. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91645. */
  91646. alphaIndex: number;
  91647. /**
  91648. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91649. */
  91650. isVisible: boolean;
  91651. /**
  91652. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91653. */
  91654. isPickable: boolean;
  91655. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91656. showSubMeshesBoundingBox: boolean;
  91657. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91659. */
  91660. isBlocker: boolean;
  91661. /**
  91662. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91663. */
  91664. enablePointerMoveEvents: boolean;
  91665. /**
  91666. * Specifies the rendering group id for this mesh (0 by default)
  91667. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91668. */
  91669. renderingGroupId: number;
  91670. private _material;
  91671. /** Gets or sets current material */
  91672. material: Nullable<Material>;
  91673. /**
  91674. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91675. * @see http://doc.babylonjs.com/babylon101/shadows
  91676. */
  91677. receiveShadows: boolean;
  91678. /** Defines color to use when rendering outline */
  91679. outlineColor: Color3;
  91680. /** Define width to use when rendering outline */
  91681. outlineWidth: number;
  91682. /** Defines color to use when rendering overlay */
  91683. overlayColor: Color3;
  91684. /** Defines alpha to use when rendering overlay */
  91685. overlayAlpha: number;
  91686. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91687. hasVertexAlpha: boolean;
  91688. /** 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) */
  91689. useVertexColors: boolean;
  91690. /**
  91691. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91692. */
  91693. computeBonesUsingShaders: boolean;
  91694. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91695. numBoneInfluencers: number;
  91696. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91697. applyFog: boolean;
  91698. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91699. useOctreeForRenderingSelection: boolean;
  91700. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91701. useOctreeForPicking: boolean;
  91702. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91703. useOctreeForCollisions: boolean;
  91704. /**
  91705. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91706. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91707. */
  91708. layerMask: number;
  91709. /**
  91710. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91711. */
  91712. alwaysSelectAsActiveMesh: boolean;
  91713. /**
  91714. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91715. */
  91716. doNotSyncBoundingInfo: boolean;
  91717. /**
  91718. * Gets or sets the current action manager
  91719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91720. */
  91721. actionManager: Nullable<AbstractActionManager>;
  91722. private _meshCollisionData;
  91723. /**
  91724. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91725. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91726. */
  91727. ellipsoid: Vector3;
  91728. /**
  91729. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91731. */
  91732. ellipsoidOffset: Vector3;
  91733. /**
  91734. * Gets or sets a collision mask used to mask collisions (default is -1).
  91735. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91736. */
  91737. collisionMask: number;
  91738. /**
  91739. * Gets or sets the current collision group mask (-1 by default).
  91740. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91741. */
  91742. collisionGroup: number;
  91743. /**
  91744. * Defines edge width used when edgesRenderer is enabled
  91745. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91746. */
  91747. edgesWidth: number;
  91748. /**
  91749. * Defines edge color used when edgesRenderer is enabled
  91750. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91751. */
  91752. edgesColor: Color4;
  91753. /** @hidden */
  91754. _edgesRenderer: Nullable<IEdgesRenderer>;
  91755. /** @hidden */
  91756. _masterMesh: Nullable<AbstractMesh>;
  91757. /** @hidden */
  91758. _boundingInfo: Nullable<BoundingInfo>;
  91759. /** @hidden */
  91760. _renderId: number;
  91761. /**
  91762. * Gets or sets the list of subMeshes
  91763. * @see http://doc.babylonjs.com/how_to/multi_materials
  91764. */
  91765. subMeshes: SubMesh[];
  91766. /** @hidden */
  91767. _intersectionsInProgress: AbstractMesh[];
  91768. /** @hidden */
  91769. _unIndexed: boolean;
  91770. /** @hidden */
  91771. _lightSources: Light[];
  91772. /** Gets the list of lights affecting that mesh */
  91773. readonly lightSources: Light[];
  91774. /** @hidden */
  91775. readonly _positions: Nullable<Vector3[]>;
  91776. /** @hidden */
  91777. _waitingData: {
  91778. lods: Nullable<any>;
  91779. actions: Nullable<any>;
  91780. freezeWorldMatrix: Nullable<boolean>;
  91781. };
  91782. /** @hidden */
  91783. _bonesTransformMatrices: Nullable<Float32Array>;
  91784. /** @hidden */
  91785. _transformMatrixTexture: Nullable<RawTexture>;
  91786. /**
  91787. * Gets or sets a skeleton to apply skining transformations
  91788. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91789. */
  91790. skeleton: Nullable<Skeleton>;
  91791. /**
  91792. * An event triggered when the mesh is rebuilt.
  91793. */
  91794. onRebuildObservable: Observable<AbstractMesh>;
  91795. /**
  91796. * Creates a new AbstractMesh
  91797. * @param name defines the name of the mesh
  91798. * @param scene defines the hosting scene
  91799. */
  91800. constructor(name: string, scene?: Nullable<Scene>);
  91801. /**
  91802. * Returns the string "AbstractMesh"
  91803. * @returns "AbstractMesh"
  91804. */
  91805. getClassName(): string;
  91806. /**
  91807. * Gets a string representation of the current mesh
  91808. * @param fullDetails defines a boolean indicating if full details must be included
  91809. * @returns a string representation of the current mesh
  91810. */
  91811. toString(fullDetails?: boolean): string;
  91812. /**
  91813. * @hidden
  91814. */
  91815. protected _getEffectiveParent(): Nullable<Node>;
  91816. /** @hidden */
  91817. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91818. /** @hidden */
  91819. _rebuild(): void;
  91820. /** @hidden */
  91821. _resyncLightSources(): void;
  91822. /** @hidden */
  91823. _resyncLighSource(light: Light): void;
  91824. /** @hidden */
  91825. _unBindEffect(): void;
  91826. /** @hidden */
  91827. _removeLightSource(light: Light, dispose: boolean): void;
  91828. private _markSubMeshesAsDirty;
  91829. /** @hidden */
  91830. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91831. /** @hidden */
  91832. _markSubMeshesAsAttributesDirty(): void;
  91833. /** @hidden */
  91834. _markSubMeshesAsMiscDirty(): void;
  91835. /**
  91836. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91837. */
  91838. scaling: Vector3;
  91839. /**
  91840. * Returns true if the mesh is blocked. Implemented by child classes
  91841. */
  91842. readonly isBlocked: boolean;
  91843. /**
  91844. * Returns the mesh itself by default. Implemented by child classes
  91845. * @param camera defines the camera to use to pick the right LOD level
  91846. * @returns the currentAbstractMesh
  91847. */
  91848. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91849. /**
  91850. * Returns 0 by default. Implemented by child classes
  91851. * @returns an integer
  91852. */
  91853. getTotalVertices(): number;
  91854. /**
  91855. * Returns a positive integer : the total number of indices in this mesh geometry.
  91856. * @returns the numner of indices or zero if the mesh has no geometry.
  91857. */
  91858. getTotalIndices(): number;
  91859. /**
  91860. * Returns null by default. Implemented by child classes
  91861. * @returns null
  91862. */
  91863. getIndices(): Nullable<IndicesArray>;
  91864. /**
  91865. * Returns the array of the requested vertex data kind. Implemented by child classes
  91866. * @param kind defines the vertex data kind to use
  91867. * @returns null
  91868. */
  91869. getVerticesData(kind: string): Nullable<FloatArray>;
  91870. /**
  91871. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91872. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91873. * Note that a new underlying VertexBuffer object is created each call.
  91874. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91875. * @param kind defines vertex data kind:
  91876. * * VertexBuffer.PositionKind
  91877. * * VertexBuffer.UVKind
  91878. * * VertexBuffer.UV2Kind
  91879. * * VertexBuffer.UV3Kind
  91880. * * VertexBuffer.UV4Kind
  91881. * * VertexBuffer.UV5Kind
  91882. * * VertexBuffer.UV6Kind
  91883. * * VertexBuffer.ColorKind
  91884. * * VertexBuffer.MatricesIndicesKind
  91885. * * VertexBuffer.MatricesIndicesExtraKind
  91886. * * VertexBuffer.MatricesWeightsKind
  91887. * * VertexBuffer.MatricesWeightsExtraKind
  91888. * @param data defines the data source
  91889. * @param updatable defines if the data must be flagged as updatable (or static)
  91890. * @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
  91891. * @returns the current mesh
  91892. */
  91893. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91894. /**
  91895. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91896. * If the mesh has no geometry, it is simply returned as it is.
  91897. * @param kind defines vertex data kind:
  91898. * * VertexBuffer.PositionKind
  91899. * * VertexBuffer.UVKind
  91900. * * VertexBuffer.UV2Kind
  91901. * * VertexBuffer.UV3Kind
  91902. * * VertexBuffer.UV4Kind
  91903. * * VertexBuffer.UV5Kind
  91904. * * VertexBuffer.UV6Kind
  91905. * * VertexBuffer.ColorKind
  91906. * * VertexBuffer.MatricesIndicesKind
  91907. * * VertexBuffer.MatricesIndicesExtraKind
  91908. * * VertexBuffer.MatricesWeightsKind
  91909. * * VertexBuffer.MatricesWeightsExtraKind
  91910. * @param data defines the data source
  91911. * @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
  91912. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91913. * @returns the current mesh
  91914. */
  91915. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91916. /**
  91917. * Sets the mesh indices,
  91918. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91919. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91920. * @param totalVertices Defines the total number of vertices
  91921. * @returns the current mesh
  91922. */
  91923. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91924. /**
  91925. * Gets a boolean indicating if specific vertex data is present
  91926. * @param kind defines the vertex data kind to use
  91927. * @returns true is data kind is present
  91928. */
  91929. isVerticesDataPresent(kind: string): boolean;
  91930. /**
  91931. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91932. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91933. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91934. * @returns a BoundingInfo
  91935. */
  91936. getBoundingInfo(): BoundingInfo;
  91937. /**
  91938. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91939. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91940. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91941. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91942. * @returns the current mesh
  91943. */
  91944. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91945. /**
  91946. * Overwrite the current bounding info
  91947. * @param boundingInfo defines the new bounding info
  91948. * @returns the current mesh
  91949. */
  91950. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91951. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91952. readonly useBones: boolean;
  91953. /** @hidden */
  91954. _preActivate(): void;
  91955. /** @hidden */
  91956. _preActivateForIntermediateRendering(renderId: number): void;
  91957. /** @hidden */
  91958. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91959. /** @hidden */
  91960. _postActivate(): void;
  91961. /** @hidden */
  91962. _freeze(): void;
  91963. /** @hidden */
  91964. _unFreeze(): void;
  91965. /**
  91966. * Gets the current world matrix
  91967. * @returns a Matrix
  91968. */
  91969. getWorldMatrix(): Matrix;
  91970. /** @hidden */
  91971. _getWorldMatrixDeterminant(): number;
  91972. /**
  91973. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91974. */
  91975. readonly isAnInstance: boolean;
  91976. /**
  91977. * Gets a boolean indicating if this mesh has instances
  91978. */
  91979. readonly hasInstances: boolean;
  91980. /**
  91981. * Perform relative position change from the point of view of behind the front of the mesh.
  91982. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91983. * Supports definition of mesh facing forward or backward
  91984. * @param amountRight defines the distance on the right axis
  91985. * @param amountUp defines the distance on the up axis
  91986. * @param amountForward defines the distance on the forward axis
  91987. * @returns the current mesh
  91988. */
  91989. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91990. /**
  91991. * Calculate relative position change from the point of view of behind the front of the mesh.
  91992. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91993. * Supports definition of mesh facing forward or backward
  91994. * @param amountRight defines the distance on the right axis
  91995. * @param amountUp defines the distance on the up axis
  91996. * @param amountForward defines the distance on the forward axis
  91997. * @returns the new displacement vector
  91998. */
  91999. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92000. /**
  92001. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92002. * Supports definition of mesh facing forward or backward
  92003. * @param flipBack defines the flip
  92004. * @param twirlClockwise defines the twirl
  92005. * @param tiltRight defines the tilt
  92006. * @returns the current mesh
  92007. */
  92008. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92009. /**
  92010. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92011. * Supports definition of mesh facing forward or backward.
  92012. * @param flipBack defines the flip
  92013. * @param twirlClockwise defines the twirl
  92014. * @param tiltRight defines the tilt
  92015. * @returns the new rotation vector
  92016. */
  92017. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92018. /**
  92019. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92020. * This means the mesh underlying bounding box and sphere are recomputed.
  92021. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92022. * @returns the current mesh
  92023. */
  92024. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92025. /** @hidden */
  92026. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92027. /** @hidden */
  92028. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92029. /** @hidden */
  92030. _updateBoundingInfo(): AbstractMesh;
  92031. /** @hidden */
  92032. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92033. /** @hidden */
  92034. protected _afterComputeWorldMatrix(): void;
  92035. /** @hidden */
  92036. readonly _effectiveMesh: AbstractMesh;
  92037. /**
  92038. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92039. * A mesh is in the frustum if its bounding box intersects the frustum
  92040. * @param frustumPlanes defines the frustum to test
  92041. * @returns true if the mesh is in the frustum planes
  92042. */
  92043. isInFrustum(frustumPlanes: Plane[]): boolean;
  92044. /**
  92045. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92046. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92047. * @param frustumPlanes defines the frustum to test
  92048. * @returns true if the mesh is completely in the frustum planes
  92049. */
  92050. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92051. /**
  92052. * True if the mesh intersects another mesh or a SolidParticle object
  92053. * @param mesh defines a target mesh or SolidParticle to test
  92054. * @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)
  92055. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92056. * @returns true if there is an intersection
  92057. */
  92058. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92059. /**
  92060. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92061. * @param point defines the point to test
  92062. * @returns true if there is an intersection
  92063. */
  92064. intersectsPoint(point: Vector3): boolean;
  92065. /**
  92066. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92068. */
  92069. checkCollisions: boolean;
  92070. /**
  92071. * Gets Collider object used to compute collisions (not physics)
  92072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92073. */
  92074. readonly collider: Nullable<Collider>;
  92075. /**
  92076. * Move the mesh using collision engine
  92077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92078. * @param displacement defines the requested displacement vector
  92079. * @returns the current mesh
  92080. */
  92081. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92082. private _onCollisionPositionChange;
  92083. /** @hidden */
  92084. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92085. /** @hidden */
  92086. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92087. /** @hidden */
  92088. _checkCollision(collider: Collider): AbstractMesh;
  92089. /** @hidden */
  92090. _generatePointsArray(): boolean;
  92091. /**
  92092. * Checks if the passed Ray intersects with the mesh
  92093. * @param ray defines the ray to use
  92094. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92095. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92096. * @returns the picking info
  92097. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92098. */
  92099. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92100. /**
  92101. * Clones the current mesh
  92102. * @param name defines the mesh name
  92103. * @param newParent defines the new mesh parent
  92104. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92105. * @returns the new mesh
  92106. */
  92107. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92108. /**
  92109. * Disposes all the submeshes of the current meshnp
  92110. * @returns the current mesh
  92111. */
  92112. releaseSubMeshes(): AbstractMesh;
  92113. /**
  92114. * Releases resources associated with this abstract mesh.
  92115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92117. */
  92118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92119. /**
  92120. * Adds the passed mesh as a child to the current mesh
  92121. * @param mesh defines the child mesh
  92122. * @returns the current mesh
  92123. */
  92124. addChild(mesh: AbstractMesh): AbstractMesh;
  92125. /**
  92126. * Removes the passed mesh from the current mesh children list
  92127. * @param mesh defines the child mesh
  92128. * @returns the current mesh
  92129. */
  92130. removeChild(mesh: AbstractMesh): AbstractMesh;
  92131. /** @hidden */
  92132. private _initFacetData;
  92133. /**
  92134. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92135. * This method can be called within the render loop.
  92136. * 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
  92137. * @returns the current mesh
  92138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92139. */
  92140. updateFacetData(): AbstractMesh;
  92141. /**
  92142. * Returns the facetLocalNormals array.
  92143. * The normals are expressed in the mesh local spac
  92144. * @returns an array of Vector3
  92145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92146. */
  92147. getFacetLocalNormals(): Vector3[];
  92148. /**
  92149. * Returns the facetLocalPositions array.
  92150. * The facet positions are expressed in the mesh local space
  92151. * @returns an array of Vector3
  92152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92153. */
  92154. getFacetLocalPositions(): Vector3[];
  92155. /**
  92156. * Returns the facetLocalPartioning array
  92157. * @returns an array of array of numbers
  92158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92159. */
  92160. getFacetLocalPartitioning(): number[][];
  92161. /**
  92162. * Returns the i-th facet position in the world system.
  92163. * This method allocates a new Vector3 per call
  92164. * @param i defines the facet index
  92165. * @returns a new Vector3
  92166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92167. */
  92168. getFacetPosition(i: number): Vector3;
  92169. /**
  92170. * Sets the reference Vector3 with the i-th facet position in the world system
  92171. * @param i defines the facet index
  92172. * @param ref defines the target vector
  92173. * @returns the current mesh
  92174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92175. */
  92176. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92177. /**
  92178. * Returns the i-th facet normal in the world system.
  92179. * This method allocates a new Vector3 per call
  92180. * @param i defines the facet index
  92181. * @returns a new Vector3
  92182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92183. */
  92184. getFacetNormal(i: number): Vector3;
  92185. /**
  92186. * Sets the reference Vector3 with the i-th facet normal in the world system
  92187. * @param i defines the facet index
  92188. * @param ref defines the target vector
  92189. * @returns the current mesh
  92190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92191. */
  92192. getFacetNormalToRef(i: number, ref: Vector3): this;
  92193. /**
  92194. * 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)
  92195. * @param x defines x coordinate
  92196. * @param y defines y coordinate
  92197. * @param z defines z coordinate
  92198. * @returns the array of facet indexes
  92199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92200. */
  92201. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92202. /**
  92203. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92204. * @param projected sets as the (x,y,z) world projection on the facet
  92205. * @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
  92206. * @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
  92207. * @param x defines x coordinate
  92208. * @param y defines y coordinate
  92209. * @param z defines z coordinate
  92210. * @returns the face index if found (or null instead)
  92211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92212. */
  92213. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92214. /**
  92215. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92216. * @param projected sets as the (x,y,z) local projection on the facet
  92217. * @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
  92218. * @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
  92219. * @param x defines x coordinate
  92220. * @param y defines y coordinate
  92221. * @param z defines z coordinate
  92222. * @returns the face index if found (or null instead)
  92223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92224. */
  92225. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92226. /**
  92227. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92228. * @returns the parameters
  92229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92230. */
  92231. getFacetDataParameters(): any;
  92232. /**
  92233. * Disables the feature FacetData and frees the related memory
  92234. * @returns the current mesh
  92235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92236. */
  92237. disableFacetData(): AbstractMesh;
  92238. /**
  92239. * Updates the AbstractMesh indices array
  92240. * @param indices defines the data source
  92241. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92242. * @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)
  92243. * @returns the current mesh
  92244. */
  92245. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92246. /**
  92247. * Creates new normals data for the mesh
  92248. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92249. * @returns the current mesh
  92250. */
  92251. createNormals(updatable: boolean): AbstractMesh;
  92252. /**
  92253. * Align the mesh with a normal
  92254. * @param normal defines the normal to use
  92255. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92256. * @returns the current mesh
  92257. */
  92258. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92259. /** @hidden */
  92260. _checkOcclusionQuery(): boolean;
  92261. /**
  92262. * Disables the mesh edge rendering mode
  92263. * @returns the currentAbstractMesh
  92264. */
  92265. disableEdgesRendering(): AbstractMesh;
  92266. /**
  92267. * Enables the edge rendering mode on the mesh.
  92268. * This mode makes the mesh edges visible
  92269. * @param epsilon defines the maximal distance between two angles to detect a face
  92270. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92271. * @returns the currentAbstractMesh
  92272. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92273. */
  92274. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92275. }
  92276. }
  92277. declare module BABYLON {
  92278. /**
  92279. * Interface used to define ActionEvent
  92280. */
  92281. export interface IActionEvent {
  92282. /** The mesh or sprite that triggered the action */
  92283. source: any;
  92284. /** The X mouse cursor position at the time of the event */
  92285. pointerX: number;
  92286. /** The Y mouse cursor position at the time of the event */
  92287. pointerY: number;
  92288. /** The mesh that is currently pointed at (can be null) */
  92289. meshUnderPointer: Nullable<AbstractMesh>;
  92290. /** the original (browser) event that triggered the ActionEvent */
  92291. sourceEvent?: any;
  92292. /** additional data for the event */
  92293. additionalData?: any;
  92294. }
  92295. /**
  92296. * ActionEvent is the event being sent when an action is triggered.
  92297. */
  92298. export class ActionEvent implements IActionEvent {
  92299. /** The mesh or sprite that triggered the action */
  92300. source: any;
  92301. /** The X mouse cursor position at the time of the event */
  92302. pointerX: number;
  92303. /** The Y mouse cursor position at the time of the event */
  92304. pointerY: number;
  92305. /** The mesh that is currently pointed at (can be null) */
  92306. meshUnderPointer: Nullable<AbstractMesh>;
  92307. /** the original (browser) event that triggered the ActionEvent */
  92308. sourceEvent?: any;
  92309. /** additional data for the event */
  92310. additionalData?: any;
  92311. /**
  92312. * Creates a new ActionEvent
  92313. * @param source The mesh or sprite that triggered the action
  92314. * @param pointerX The X mouse cursor position at the time of the event
  92315. * @param pointerY The Y mouse cursor position at the time of the event
  92316. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92317. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92318. * @param additionalData additional data for the event
  92319. */
  92320. constructor(
  92321. /** The mesh or sprite that triggered the action */
  92322. source: any,
  92323. /** The X mouse cursor position at the time of the event */
  92324. pointerX: number,
  92325. /** The Y mouse cursor position at the time of the event */
  92326. pointerY: number,
  92327. /** The mesh that is currently pointed at (can be null) */
  92328. meshUnderPointer: Nullable<AbstractMesh>,
  92329. /** the original (browser) event that triggered the ActionEvent */
  92330. sourceEvent?: any,
  92331. /** additional data for the event */
  92332. additionalData?: any);
  92333. /**
  92334. * Helper function to auto-create an ActionEvent from a source mesh.
  92335. * @param source The source mesh that triggered the event
  92336. * @param evt The original (browser) event
  92337. * @param additionalData additional data for the event
  92338. * @returns the new ActionEvent
  92339. */
  92340. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92341. /**
  92342. * Helper function to auto-create an ActionEvent from a source sprite
  92343. * @param source The source sprite that triggered the event
  92344. * @param scene Scene associated with the sprite
  92345. * @param evt The original (browser) event
  92346. * @param additionalData additional data for the event
  92347. * @returns the new ActionEvent
  92348. */
  92349. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92350. /**
  92351. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92352. * @param scene the scene where the event occurred
  92353. * @param evt The original (browser) event
  92354. * @returns the new ActionEvent
  92355. */
  92356. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92357. /**
  92358. * Helper function to auto-create an ActionEvent from a primitive
  92359. * @param prim defines the target primitive
  92360. * @param pointerPos defines the pointer position
  92361. * @param evt The original (browser) event
  92362. * @param additionalData additional data for the event
  92363. * @returns the new ActionEvent
  92364. */
  92365. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92366. }
  92367. }
  92368. declare module BABYLON {
  92369. /**
  92370. * Abstract class used to decouple action Manager from scene and meshes.
  92371. * Do not instantiate.
  92372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92373. */
  92374. export abstract class AbstractActionManager implements IDisposable {
  92375. /** Gets the list of active triggers */
  92376. static Triggers: {
  92377. [key: string]: number;
  92378. };
  92379. /** Gets the cursor to use when hovering items */
  92380. hoverCursor: string;
  92381. /** Gets the list of actions */
  92382. actions: IAction[];
  92383. /**
  92384. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92385. */
  92386. isRecursive: boolean;
  92387. /**
  92388. * Releases all associated resources
  92389. */
  92390. abstract dispose(): void;
  92391. /**
  92392. * Does this action manager has pointer triggers
  92393. */
  92394. abstract readonly hasPointerTriggers: boolean;
  92395. /**
  92396. * Does this action manager has pick triggers
  92397. */
  92398. abstract readonly hasPickTriggers: boolean;
  92399. /**
  92400. * Process a specific trigger
  92401. * @param trigger defines the trigger to process
  92402. * @param evt defines the event details to be processed
  92403. */
  92404. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92405. /**
  92406. * Does this action manager handles actions of any of the given triggers
  92407. * @param triggers defines the triggers to be tested
  92408. * @return a boolean indicating whether one (or more) of the triggers is handled
  92409. */
  92410. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92411. /**
  92412. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92413. * speed.
  92414. * @param triggerA defines the trigger to be tested
  92415. * @param triggerB defines the trigger to be tested
  92416. * @return a boolean indicating whether one (or more) of the triggers is handled
  92417. */
  92418. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92419. /**
  92420. * Does this action manager handles actions of a given trigger
  92421. * @param trigger defines the trigger to be tested
  92422. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92423. * @return whether the trigger is handled
  92424. */
  92425. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92426. /**
  92427. * Serialize this manager to a JSON object
  92428. * @param name defines the property name to store this manager
  92429. * @returns a JSON representation of this manager
  92430. */
  92431. abstract serialize(name: string): any;
  92432. /**
  92433. * Registers an action to this action manager
  92434. * @param action defines the action to be registered
  92435. * @return the action amended (prepared) after registration
  92436. */
  92437. abstract registerAction(action: IAction): Nullable<IAction>;
  92438. /**
  92439. * Unregisters an action to this action manager
  92440. * @param action defines the action to be unregistered
  92441. * @return a boolean indicating whether the action has been unregistered
  92442. */
  92443. abstract unregisterAction(action: IAction): Boolean;
  92444. /**
  92445. * Does exist one action manager with at least one trigger
  92446. **/
  92447. static readonly HasTriggers: boolean;
  92448. /**
  92449. * Does exist one action manager with at least one pick trigger
  92450. **/
  92451. static readonly HasPickTriggers: boolean;
  92452. /**
  92453. * Does exist one action manager that handles actions of a given trigger
  92454. * @param trigger defines the trigger to be tested
  92455. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92456. **/
  92457. static HasSpecificTrigger(trigger: number): boolean;
  92458. }
  92459. }
  92460. declare module BABYLON {
  92461. /**
  92462. * Defines how a node can be built from a string name.
  92463. */
  92464. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92465. /**
  92466. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92467. */
  92468. export class Node implements IBehaviorAware<Node> {
  92469. /** @hidden */
  92470. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92471. private static _NodeConstructors;
  92472. /**
  92473. * Add a new node constructor
  92474. * @param type defines the type name of the node to construct
  92475. * @param constructorFunc defines the constructor function
  92476. */
  92477. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92478. /**
  92479. * Returns a node constructor based on type name
  92480. * @param type defines the type name
  92481. * @param name defines the new node name
  92482. * @param scene defines the hosting scene
  92483. * @param options defines optional options to transmit to constructors
  92484. * @returns the new constructor or null
  92485. */
  92486. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92487. /**
  92488. * Gets or sets the name of the node
  92489. */
  92490. name: string;
  92491. /**
  92492. * Gets or sets the id of the node
  92493. */
  92494. id: string;
  92495. /**
  92496. * Gets or sets the unique id of the node
  92497. */
  92498. uniqueId: number;
  92499. /**
  92500. * Gets or sets a string used to store user defined state for the node
  92501. */
  92502. state: string;
  92503. /**
  92504. * Gets or sets an object used to store user defined information for the node
  92505. */
  92506. metadata: any;
  92507. /**
  92508. * For internal use only. Please do not use.
  92509. */
  92510. reservedDataStore: any;
  92511. /**
  92512. * List of inspectable custom properties (used by the Inspector)
  92513. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92514. */
  92515. inspectableCustomProperties: IInspectable[];
  92516. /**
  92517. * Gets or sets a boolean used to define if the node must be serialized
  92518. */
  92519. doNotSerialize: boolean;
  92520. /** @hidden */
  92521. _isDisposed: boolean;
  92522. /**
  92523. * Gets a list of Animations associated with the node
  92524. */
  92525. animations: Animation[];
  92526. protected _ranges: {
  92527. [name: string]: Nullable<AnimationRange>;
  92528. };
  92529. /**
  92530. * Callback raised when the node is ready to be used
  92531. */
  92532. onReady: Nullable<(node: Node) => void>;
  92533. private _isEnabled;
  92534. private _isParentEnabled;
  92535. private _isReady;
  92536. /** @hidden */
  92537. _currentRenderId: number;
  92538. private _parentUpdateId;
  92539. /** @hidden */
  92540. _childUpdateId: number;
  92541. /** @hidden */
  92542. _waitingParentId: Nullable<string>;
  92543. /** @hidden */
  92544. _scene: Scene;
  92545. /** @hidden */
  92546. _cache: any;
  92547. private _parentNode;
  92548. private _children;
  92549. /** @hidden */
  92550. _worldMatrix: Matrix;
  92551. /** @hidden */
  92552. _worldMatrixDeterminant: number;
  92553. /** @hidden */
  92554. _worldMatrixDeterminantIsDirty: boolean;
  92555. /** @hidden */
  92556. private _sceneRootNodesIndex;
  92557. /**
  92558. * Gets a boolean indicating if the node has been disposed
  92559. * @returns true if the node was disposed
  92560. */
  92561. isDisposed(): boolean;
  92562. /**
  92563. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92564. * @see https://doc.babylonjs.com/how_to/parenting
  92565. */
  92566. parent: Nullable<Node>;
  92567. private addToSceneRootNodes;
  92568. private removeFromSceneRootNodes;
  92569. private _animationPropertiesOverride;
  92570. /**
  92571. * Gets or sets the animation properties override
  92572. */
  92573. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92574. /**
  92575. * Gets a string idenfifying the name of the class
  92576. * @returns "Node" string
  92577. */
  92578. getClassName(): string;
  92579. /** @hidden */
  92580. readonly _isNode: boolean;
  92581. /**
  92582. * An event triggered when the mesh is disposed
  92583. */
  92584. onDisposeObservable: Observable<Node>;
  92585. private _onDisposeObserver;
  92586. /**
  92587. * Sets a callback that will be raised when the node will be disposed
  92588. */
  92589. onDispose: () => void;
  92590. /**
  92591. * Creates a new Node
  92592. * @param name the name and id to be given to this node
  92593. * @param scene the scene this node will be added to
  92594. * @param addToRootNodes the node will be added to scene.rootNodes
  92595. */
  92596. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92597. /**
  92598. * Gets the scene of the node
  92599. * @returns a scene
  92600. */
  92601. getScene(): Scene;
  92602. /**
  92603. * Gets the engine of the node
  92604. * @returns a Engine
  92605. */
  92606. getEngine(): Engine;
  92607. private _behaviors;
  92608. /**
  92609. * Attach a behavior to the node
  92610. * @see http://doc.babylonjs.com/features/behaviour
  92611. * @param behavior defines the behavior to attach
  92612. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92613. * @returns the current Node
  92614. */
  92615. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92616. /**
  92617. * Remove an attached behavior
  92618. * @see http://doc.babylonjs.com/features/behaviour
  92619. * @param behavior defines the behavior to attach
  92620. * @returns the current Node
  92621. */
  92622. removeBehavior(behavior: Behavior<Node>): Node;
  92623. /**
  92624. * Gets the list of attached behaviors
  92625. * @see http://doc.babylonjs.com/features/behaviour
  92626. */
  92627. readonly behaviors: Behavior<Node>[];
  92628. /**
  92629. * Gets an attached behavior by name
  92630. * @param name defines the name of the behavior to look for
  92631. * @see http://doc.babylonjs.com/features/behaviour
  92632. * @returns null if behavior was not found else the requested behavior
  92633. */
  92634. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92635. /**
  92636. * Returns the latest update of the World matrix
  92637. * @returns a Matrix
  92638. */
  92639. getWorldMatrix(): Matrix;
  92640. /** @hidden */
  92641. _getWorldMatrixDeterminant(): number;
  92642. /**
  92643. * Returns directly the latest state of the mesh World matrix.
  92644. * A Matrix is returned.
  92645. */
  92646. readonly worldMatrixFromCache: Matrix;
  92647. /** @hidden */
  92648. _initCache(): void;
  92649. /** @hidden */
  92650. updateCache(force?: boolean): void;
  92651. /** @hidden */
  92652. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92653. /** @hidden */
  92654. _updateCache(ignoreParentClass?: boolean): void;
  92655. /** @hidden */
  92656. _isSynchronized(): boolean;
  92657. /** @hidden */
  92658. _markSyncedWithParent(): void;
  92659. /** @hidden */
  92660. isSynchronizedWithParent(): boolean;
  92661. /** @hidden */
  92662. isSynchronized(): boolean;
  92663. /**
  92664. * Is this node ready to be used/rendered
  92665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92666. * @return true if the node is ready
  92667. */
  92668. isReady(completeCheck?: boolean): boolean;
  92669. /**
  92670. * Is this node enabled?
  92671. * 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
  92672. * @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
  92673. * @return whether this node (and its parent) is enabled
  92674. */
  92675. isEnabled(checkAncestors?: boolean): boolean;
  92676. /** @hidden */
  92677. protected _syncParentEnabledState(): void;
  92678. /**
  92679. * Set the enabled state of this node
  92680. * @param value defines the new enabled state
  92681. */
  92682. setEnabled(value: boolean): void;
  92683. /**
  92684. * Is this node a descendant of the given node?
  92685. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92686. * @param ancestor defines the parent node to inspect
  92687. * @returns a boolean indicating if this node is a descendant of the given node
  92688. */
  92689. isDescendantOf(ancestor: Node): boolean;
  92690. /** @hidden */
  92691. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92692. /**
  92693. * Will return all nodes that have this node as ascendant
  92694. * @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
  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. * @return all children nodes of all types
  92697. */
  92698. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92699. /**
  92700. * Get all child-meshes of this node
  92701. * @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)
  92702. * @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
  92703. * @returns an array of AbstractMesh
  92704. */
  92705. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92706. /**
  92707. * Get all direct children of this node
  92708. * @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
  92709. * @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)
  92710. * @returns an array of Node
  92711. */
  92712. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92713. /** @hidden */
  92714. _setReady(state: boolean): void;
  92715. /**
  92716. * Get an animation by name
  92717. * @param name defines the name of the animation to look for
  92718. * @returns null if not found else the requested animation
  92719. */
  92720. getAnimationByName(name: string): Nullable<Animation>;
  92721. /**
  92722. * Creates an animation range for this node
  92723. * @param name defines the name of the range
  92724. * @param from defines the starting key
  92725. * @param to defines the end key
  92726. */
  92727. createAnimationRange(name: string, from: number, to: number): void;
  92728. /**
  92729. * Delete a specific animation range
  92730. * @param name defines the name of the range to delete
  92731. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92732. */
  92733. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92734. /**
  92735. * Get an animation range by name
  92736. * @param name defines the name of the animation range to look for
  92737. * @returns null if not found else the requested animation range
  92738. */
  92739. getAnimationRange(name: string): Nullable<AnimationRange>;
  92740. /**
  92741. * Gets the list of all animation ranges defined on this node
  92742. * @returns an array
  92743. */
  92744. getAnimationRanges(): Nullable<AnimationRange>[];
  92745. /**
  92746. * Will start the animation sequence
  92747. * @param name defines the range frames for animation sequence
  92748. * @param loop defines if the animation should loop (false by default)
  92749. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92750. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92751. * @returns the object created for this animation. If range does not exist, it will return null
  92752. */
  92753. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92754. /**
  92755. * Serialize animation ranges into a JSON compatible object
  92756. * @returns serialization object
  92757. */
  92758. serializeAnimationRanges(): any;
  92759. /**
  92760. * Computes the world matrix of the node
  92761. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92762. * @returns the world matrix
  92763. */
  92764. computeWorldMatrix(force?: boolean): Matrix;
  92765. /**
  92766. * Releases resources associated with this node.
  92767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92769. */
  92770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92771. /**
  92772. * Parse animation range data from a serialization object and store them into a given node
  92773. * @param node defines where to store the animation ranges
  92774. * @param parsedNode defines the serialization object to read data from
  92775. * @param scene defines the hosting scene
  92776. */
  92777. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92778. /**
  92779. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92780. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92781. * @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
  92782. * @returns the new bounding vectors
  92783. */
  92784. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92785. min: Vector3;
  92786. max: Vector3;
  92787. };
  92788. }
  92789. }
  92790. declare module BABYLON {
  92791. /**
  92792. * @hidden
  92793. */
  92794. export class _IAnimationState {
  92795. key: number;
  92796. repeatCount: number;
  92797. workValue?: any;
  92798. loopMode?: number;
  92799. offsetValue?: any;
  92800. highLimitValue?: any;
  92801. }
  92802. /**
  92803. * Class used to store any kind of animation
  92804. */
  92805. export class Animation {
  92806. /**Name of the animation */
  92807. name: string;
  92808. /**Property to animate */
  92809. targetProperty: string;
  92810. /**The frames per second of the animation */
  92811. framePerSecond: number;
  92812. /**The data type of the animation */
  92813. dataType: number;
  92814. /**The loop mode of the animation */
  92815. loopMode?: number | undefined;
  92816. /**Specifies if blending should be enabled */
  92817. enableBlending?: boolean | undefined;
  92818. /**
  92819. * Use matrix interpolation instead of using direct key value when animating matrices
  92820. */
  92821. static AllowMatricesInterpolation: boolean;
  92822. /**
  92823. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92824. */
  92825. static AllowMatrixDecomposeForInterpolation: boolean;
  92826. /**
  92827. * Stores the key frames of the animation
  92828. */
  92829. private _keys;
  92830. /**
  92831. * Stores the easing function of the animation
  92832. */
  92833. private _easingFunction;
  92834. /**
  92835. * @hidden Internal use only
  92836. */
  92837. _runtimeAnimations: RuntimeAnimation[];
  92838. /**
  92839. * The set of event that will be linked to this animation
  92840. */
  92841. private _events;
  92842. /**
  92843. * Stores an array of target property paths
  92844. */
  92845. targetPropertyPath: string[];
  92846. /**
  92847. * Stores the blending speed of the animation
  92848. */
  92849. blendingSpeed: number;
  92850. /**
  92851. * Stores the animation ranges for the animation
  92852. */
  92853. private _ranges;
  92854. /**
  92855. * @hidden Internal use
  92856. */
  92857. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92858. /**
  92859. * Sets up an animation
  92860. * @param property The property to animate
  92861. * @param animationType The animation type to apply
  92862. * @param framePerSecond The frames per second of the animation
  92863. * @param easingFunction The easing function used in the animation
  92864. * @returns The created animation
  92865. */
  92866. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92867. /**
  92868. * Create and start an animation on a node
  92869. * @param name defines the name of the global animation that will be run on all nodes
  92870. * @param node defines the root node where the animation will take place
  92871. * @param targetProperty defines property to animate
  92872. * @param framePerSecond defines the number of frame per second yo use
  92873. * @param totalFrame defines the number of frames in total
  92874. * @param from defines the initial value
  92875. * @param to defines the final value
  92876. * @param loopMode defines which loop mode you want to use (off by default)
  92877. * @param easingFunction defines the easing function to use (linear by default)
  92878. * @param onAnimationEnd defines the callback to call when animation end
  92879. * @returns the animatable created for this animation
  92880. */
  92881. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92882. /**
  92883. * Create and start an animation on a node and its descendants
  92884. * @param name defines the name of the global animation that will be run on all nodes
  92885. * @param node defines the root node where the animation will take place
  92886. * @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
  92887. * @param targetProperty defines property to animate
  92888. * @param framePerSecond defines the number of frame per second to use
  92889. * @param totalFrame defines the number of frames in total
  92890. * @param from defines the initial value
  92891. * @param to defines the final value
  92892. * @param loopMode defines which loop mode you want to use (off by default)
  92893. * @param easingFunction defines the easing function to use (linear by default)
  92894. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92895. * @returns the list of animatables created for all nodes
  92896. * @example https://www.babylonjs-playground.com/#MH0VLI
  92897. */
  92898. 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[]>;
  92899. /**
  92900. * Creates a new animation, merges it with the existing animations and starts it
  92901. * @param name Name of the animation
  92902. * @param node Node which contains the scene that begins the animations
  92903. * @param targetProperty Specifies which property to animate
  92904. * @param framePerSecond The frames per second of the animation
  92905. * @param totalFrame The total number of frames
  92906. * @param from The frame at the beginning of the animation
  92907. * @param to The frame at the end of the animation
  92908. * @param loopMode Specifies the loop mode of the animation
  92909. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92910. * @param onAnimationEnd Callback to run once the animation is complete
  92911. * @returns Nullable animation
  92912. */
  92913. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92914. /**
  92915. * Transition property of an host to the target Value
  92916. * @param property The property to transition
  92917. * @param targetValue The target Value of the property
  92918. * @param host The object where the property to animate belongs
  92919. * @param scene Scene used to run the animation
  92920. * @param frameRate Framerate (in frame/s) to use
  92921. * @param transition The transition type we want to use
  92922. * @param duration The duration of the animation, in milliseconds
  92923. * @param onAnimationEnd Callback trigger at the end of the animation
  92924. * @returns Nullable animation
  92925. */
  92926. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92927. /**
  92928. * Return the array of runtime animations currently using this animation
  92929. */
  92930. readonly runtimeAnimations: RuntimeAnimation[];
  92931. /**
  92932. * Specifies if any of the runtime animations are currently running
  92933. */
  92934. readonly hasRunningRuntimeAnimations: boolean;
  92935. /**
  92936. * Initializes the animation
  92937. * @param name Name of the animation
  92938. * @param targetProperty Property to animate
  92939. * @param framePerSecond The frames per second of the animation
  92940. * @param dataType The data type of the animation
  92941. * @param loopMode The loop mode of the animation
  92942. * @param enableBlending Specifies if blending should be enabled
  92943. */
  92944. constructor(
  92945. /**Name of the animation */
  92946. name: string,
  92947. /**Property to animate */
  92948. targetProperty: string,
  92949. /**The frames per second of the animation */
  92950. framePerSecond: number,
  92951. /**The data type of the animation */
  92952. dataType: number,
  92953. /**The loop mode of the animation */
  92954. loopMode?: number | undefined,
  92955. /**Specifies if blending should be enabled */
  92956. enableBlending?: boolean | undefined);
  92957. /**
  92958. * Converts the animation to a string
  92959. * @param fullDetails support for multiple levels of logging within scene loading
  92960. * @returns String form of the animation
  92961. */
  92962. toString(fullDetails?: boolean): string;
  92963. /**
  92964. * Add an event to this animation
  92965. * @param event Event to add
  92966. */
  92967. addEvent(event: AnimationEvent): void;
  92968. /**
  92969. * Remove all events found at the given frame
  92970. * @param frame The frame to remove events from
  92971. */
  92972. removeEvents(frame: number): void;
  92973. /**
  92974. * Retrieves all the events from the animation
  92975. * @returns Events from the animation
  92976. */
  92977. getEvents(): AnimationEvent[];
  92978. /**
  92979. * Creates an animation range
  92980. * @param name Name of the animation range
  92981. * @param from Starting frame of the animation range
  92982. * @param to Ending frame of the animation
  92983. */
  92984. createRange(name: string, from: number, to: number): void;
  92985. /**
  92986. * Deletes an animation range by name
  92987. * @param name Name of the animation range to delete
  92988. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92989. */
  92990. deleteRange(name: string, deleteFrames?: boolean): void;
  92991. /**
  92992. * Gets the animation range by name, or null if not defined
  92993. * @param name Name of the animation range
  92994. * @returns Nullable animation range
  92995. */
  92996. getRange(name: string): Nullable<AnimationRange>;
  92997. /**
  92998. * Gets the key frames from the animation
  92999. * @returns The key frames of the animation
  93000. */
  93001. getKeys(): Array<IAnimationKey>;
  93002. /**
  93003. * Gets the highest frame rate of the animation
  93004. * @returns Highest frame rate of the animation
  93005. */
  93006. getHighestFrame(): number;
  93007. /**
  93008. * Gets the easing function of the animation
  93009. * @returns Easing function of the animation
  93010. */
  93011. getEasingFunction(): IEasingFunction;
  93012. /**
  93013. * Sets the easing function of the animation
  93014. * @param easingFunction A custom mathematical formula for animation
  93015. */
  93016. setEasingFunction(easingFunction: EasingFunction): void;
  93017. /**
  93018. * Interpolates a scalar linearly
  93019. * @param startValue Start value of the animation curve
  93020. * @param endValue End value of the animation curve
  93021. * @param gradient Scalar amount to interpolate
  93022. * @returns Interpolated scalar value
  93023. */
  93024. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93025. /**
  93026. * Interpolates a scalar cubically
  93027. * @param startValue Start value of the animation curve
  93028. * @param outTangent End tangent of the animation
  93029. * @param endValue End value of the animation curve
  93030. * @param inTangent Start tangent of the animation curve
  93031. * @param gradient Scalar amount to interpolate
  93032. * @returns Interpolated scalar value
  93033. */
  93034. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93035. /**
  93036. * Interpolates a quaternion using a spherical linear interpolation
  93037. * @param startValue Start value of the animation curve
  93038. * @param endValue End value of the animation curve
  93039. * @param gradient Scalar amount to interpolate
  93040. * @returns Interpolated quaternion value
  93041. */
  93042. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93043. /**
  93044. * Interpolates a quaternion cubically
  93045. * @param startValue Start value of the animation curve
  93046. * @param outTangent End tangent of the animation curve
  93047. * @param endValue End value of the animation curve
  93048. * @param inTangent Start tangent of the animation curve
  93049. * @param gradient Scalar amount to interpolate
  93050. * @returns Interpolated quaternion value
  93051. */
  93052. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93053. /**
  93054. * Interpolates a Vector3 linearl
  93055. * @param startValue Start value of the animation curve
  93056. * @param endValue End value of the animation curve
  93057. * @param gradient Scalar amount to interpolate
  93058. * @returns Interpolated scalar value
  93059. */
  93060. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93061. /**
  93062. * Interpolates a Vector3 cubically
  93063. * @param startValue Start value of the animation curve
  93064. * @param outTangent End tangent of the animation
  93065. * @param endValue End value of the animation curve
  93066. * @param inTangent Start tangent of the animation curve
  93067. * @param gradient Scalar amount to interpolate
  93068. * @returns InterpolatedVector3 value
  93069. */
  93070. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93071. /**
  93072. * Interpolates a Vector2 linearly
  93073. * @param startValue Start value of the animation curve
  93074. * @param endValue End value of the animation curve
  93075. * @param gradient Scalar amount to interpolate
  93076. * @returns Interpolated Vector2 value
  93077. */
  93078. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93079. /**
  93080. * Interpolates a Vector2 cubically
  93081. * @param startValue Start value of the animation curve
  93082. * @param outTangent End tangent of the animation
  93083. * @param endValue End value of the animation curve
  93084. * @param inTangent Start tangent of the animation curve
  93085. * @param gradient Scalar amount to interpolate
  93086. * @returns Interpolated Vector2 value
  93087. */
  93088. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93089. /**
  93090. * Interpolates a size linearly
  93091. * @param startValue Start value of the animation curve
  93092. * @param endValue End value of the animation curve
  93093. * @param gradient Scalar amount to interpolate
  93094. * @returns Interpolated Size value
  93095. */
  93096. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93097. /**
  93098. * Interpolates a Color3 linearly
  93099. * @param startValue Start value of the animation curve
  93100. * @param endValue End value of the animation curve
  93101. * @param gradient Scalar amount to interpolate
  93102. * @returns Interpolated Color3 value
  93103. */
  93104. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93105. /**
  93106. * @hidden Internal use only
  93107. */
  93108. _getKeyValue(value: any): any;
  93109. /**
  93110. * @hidden Internal use only
  93111. */
  93112. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93113. /**
  93114. * Defines the function to use to interpolate matrices
  93115. * @param startValue defines the start matrix
  93116. * @param endValue defines the end matrix
  93117. * @param gradient defines the gradient between both matrices
  93118. * @param result defines an optional target matrix where to store the interpolation
  93119. * @returns the interpolated matrix
  93120. */
  93121. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93122. /**
  93123. * Makes a copy of the animation
  93124. * @returns Cloned animation
  93125. */
  93126. clone(): Animation;
  93127. /**
  93128. * Sets the key frames of the animation
  93129. * @param values The animation key frames to set
  93130. */
  93131. setKeys(values: Array<IAnimationKey>): void;
  93132. /**
  93133. * Serializes the animation to an object
  93134. * @returns Serialized object
  93135. */
  93136. serialize(): any;
  93137. /**
  93138. * Float animation type
  93139. */
  93140. private static _ANIMATIONTYPE_FLOAT;
  93141. /**
  93142. * Vector3 animation type
  93143. */
  93144. private static _ANIMATIONTYPE_VECTOR3;
  93145. /**
  93146. * Quaternion animation type
  93147. */
  93148. private static _ANIMATIONTYPE_QUATERNION;
  93149. /**
  93150. * Matrix animation type
  93151. */
  93152. private static _ANIMATIONTYPE_MATRIX;
  93153. /**
  93154. * Color3 animation type
  93155. */
  93156. private static _ANIMATIONTYPE_COLOR3;
  93157. /**
  93158. * Vector2 animation type
  93159. */
  93160. private static _ANIMATIONTYPE_VECTOR2;
  93161. /**
  93162. * Size animation type
  93163. */
  93164. private static _ANIMATIONTYPE_SIZE;
  93165. /**
  93166. * Relative Loop Mode
  93167. */
  93168. private static _ANIMATIONLOOPMODE_RELATIVE;
  93169. /**
  93170. * Cycle Loop Mode
  93171. */
  93172. private static _ANIMATIONLOOPMODE_CYCLE;
  93173. /**
  93174. * Constant Loop Mode
  93175. */
  93176. private static _ANIMATIONLOOPMODE_CONSTANT;
  93177. /**
  93178. * Get the float animation type
  93179. */
  93180. static readonly ANIMATIONTYPE_FLOAT: number;
  93181. /**
  93182. * Get the Vector3 animation type
  93183. */
  93184. static readonly ANIMATIONTYPE_VECTOR3: number;
  93185. /**
  93186. * Get the Vector2 animation type
  93187. */
  93188. static readonly ANIMATIONTYPE_VECTOR2: number;
  93189. /**
  93190. * Get the Size animation type
  93191. */
  93192. static readonly ANIMATIONTYPE_SIZE: number;
  93193. /**
  93194. * Get the Quaternion animation type
  93195. */
  93196. static readonly ANIMATIONTYPE_QUATERNION: number;
  93197. /**
  93198. * Get the Matrix animation type
  93199. */
  93200. static readonly ANIMATIONTYPE_MATRIX: number;
  93201. /**
  93202. * Get the Color3 animation type
  93203. */
  93204. static readonly ANIMATIONTYPE_COLOR3: number;
  93205. /**
  93206. * Get the Relative Loop Mode
  93207. */
  93208. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93209. /**
  93210. * Get the Cycle Loop Mode
  93211. */
  93212. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93213. /**
  93214. * Get the Constant Loop Mode
  93215. */
  93216. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93217. /** @hidden */
  93218. static _UniversalLerp(left: any, right: any, amount: number): any;
  93219. /**
  93220. * Parses an animation object and creates an animation
  93221. * @param parsedAnimation Parsed animation object
  93222. * @returns Animation object
  93223. */
  93224. static Parse(parsedAnimation: any): Animation;
  93225. /**
  93226. * Appends the serialized animations from the source animations
  93227. * @param source Source containing the animations
  93228. * @param destination Target to store the animations
  93229. */
  93230. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93231. }
  93232. }
  93233. declare module BABYLON {
  93234. /**
  93235. * Interface containing an array of animations
  93236. */
  93237. export interface IAnimatable {
  93238. /**
  93239. * Array of animations
  93240. */
  93241. animations: Nullable<Array<Animation>>;
  93242. }
  93243. }
  93244. declare module BABYLON {
  93245. /**
  93246. * This represents all the required information to add a fresnel effect on a material:
  93247. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93248. */
  93249. export class FresnelParameters {
  93250. private _isEnabled;
  93251. /**
  93252. * Define if the fresnel effect is enable or not.
  93253. */
  93254. isEnabled: boolean;
  93255. /**
  93256. * Define the color used on edges (grazing angle)
  93257. */
  93258. leftColor: Color3;
  93259. /**
  93260. * Define the color used on center
  93261. */
  93262. rightColor: Color3;
  93263. /**
  93264. * Define bias applied to computed fresnel term
  93265. */
  93266. bias: number;
  93267. /**
  93268. * Defined the power exponent applied to fresnel term
  93269. */
  93270. power: number;
  93271. /**
  93272. * Clones the current fresnel and its valuues
  93273. * @returns a clone fresnel configuration
  93274. */
  93275. clone(): FresnelParameters;
  93276. /**
  93277. * Serializes the current fresnel parameters to a JSON representation.
  93278. * @return the JSON serialization
  93279. */
  93280. serialize(): any;
  93281. /**
  93282. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93283. * @param parsedFresnelParameters Define the JSON representation
  93284. * @returns the parsed parameters
  93285. */
  93286. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93287. }
  93288. }
  93289. declare module BABYLON {
  93290. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93291. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93292. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93293. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93294. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93295. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93296. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93297. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93298. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93299. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93300. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93301. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93302. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93303. /**
  93304. * Decorator used to define property that can be serialized as reference to a camera
  93305. * @param sourceName defines the name of the property to decorate
  93306. */
  93307. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93308. /**
  93309. * Class used to help serialization objects
  93310. */
  93311. export class SerializationHelper {
  93312. /** @hidden */
  93313. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93314. /** @hidden */
  93315. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93316. /** @hidden */
  93317. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93318. /** @hidden */
  93319. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93320. /**
  93321. * Appends the serialized animations from the source animations
  93322. * @param source Source containing the animations
  93323. * @param destination Target to store the animations
  93324. */
  93325. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93326. /**
  93327. * Static function used to serialized a specific entity
  93328. * @param entity defines the entity to serialize
  93329. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93330. * @returns a JSON compatible object representing the serialization of the entity
  93331. */
  93332. static Serialize<T>(entity: T, serializationObject?: any): any;
  93333. /**
  93334. * Creates a new entity from a serialization data object
  93335. * @param creationFunction defines a function used to instanciated the new entity
  93336. * @param source defines the source serialization data
  93337. * @param scene defines the hosting scene
  93338. * @param rootUrl defines the root url for resources
  93339. * @returns a new entity
  93340. */
  93341. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93342. /**
  93343. * Clones an object
  93344. * @param creationFunction defines the function used to instanciate the new object
  93345. * @param source defines the source object
  93346. * @returns the cloned object
  93347. */
  93348. static Clone<T>(creationFunction: () => T, source: T): T;
  93349. /**
  93350. * Instanciates a new object based on a source one (some data will be shared between both object)
  93351. * @param creationFunction defines the function used to instanciate the new object
  93352. * @param source defines the source object
  93353. * @returns the new object
  93354. */
  93355. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93356. }
  93357. }
  93358. declare module BABYLON {
  93359. /**
  93360. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93361. */
  93362. export interface CubeMapInfo {
  93363. /**
  93364. * The pixel array for the front face.
  93365. * This is stored in format, left to right, up to down format.
  93366. */
  93367. front: Nullable<ArrayBufferView>;
  93368. /**
  93369. * The pixel array for the back face.
  93370. * This is stored in format, left to right, up to down format.
  93371. */
  93372. back: Nullable<ArrayBufferView>;
  93373. /**
  93374. * The pixel array for the left face.
  93375. * This is stored in format, left to right, up to down format.
  93376. */
  93377. left: Nullable<ArrayBufferView>;
  93378. /**
  93379. * The pixel array for the right face.
  93380. * This is stored in format, left to right, up to down format.
  93381. */
  93382. right: Nullable<ArrayBufferView>;
  93383. /**
  93384. * The pixel array for the up face.
  93385. * This is stored in format, left to right, up to down format.
  93386. */
  93387. up: Nullable<ArrayBufferView>;
  93388. /**
  93389. * The pixel array for the down face.
  93390. * This is stored in format, left to right, up to down format.
  93391. */
  93392. down: Nullable<ArrayBufferView>;
  93393. /**
  93394. * The size of the cubemap stored.
  93395. *
  93396. * Each faces will be size * size pixels.
  93397. */
  93398. size: number;
  93399. /**
  93400. * The format of the texture.
  93401. *
  93402. * RGBA, RGB.
  93403. */
  93404. format: number;
  93405. /**
  93406. * The type of the texture data.
  93407. *
  93408. * UNSIGNED_INT, FLOAT.
  93409. */
  93410. type: number;
  93411. /**
  93412. * Specifies whether the texture is in gamma space.
  93413. */
  93414. gammaSpace: boolean;
  93415. }
  93416. /**
  93417. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93418. */
  93419. export class PanoramaToCubeMapTools {
  93420. private static FACE_FRONT;
  93421. private static FACE_BACK;
  93422. private static FACE_RIGHT;
  93423. private static FACE_LEFT;
  93424. private static FACE_DOWN;
  93425. private static FACE_UP;
  93426. /**
  93427. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93428. *
  93429. * @param float32Array The source data.
  93430. * @param inputWidth The width of the input panorama.
  93431. * @param inputHeight The height of the input panorama.
  93432. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93433. * @return The cubemap data
  93434. */
  93435. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93436. private static CreateCubemapTexture;
  93437. private static CalcProjectionSpherical;
  93438. }
  93439. }
  93440. declare module BABYLON {
  93441. /**
  93442. * Helper class dealing with the extraction of spherical polynomial dataArray
  93443. * from a cube map.
  93444. */
  93445. export class CubeMapToSphericalPolynomialTools {
  93446. private static FileFaces;
  93447. /**
  93448. * Converts a texture to the according Spherical Polynomial data.
  93449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93450. *
  93451. * @param texture The texture to extract the information from.
  93452. * @return The Spherical Polynomial data.
  93453. */
  93454. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93455. /**
  93456. * Converts a cubemap to the according Spherical Polynomial data.
  93457. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93458. *
  93459. * @param cubeInfo The Cube map to extract the information from.
  93460. * @return The Spherical Polynomial data.
  93461. */
  93462. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93463. }
  93464. }
  93465. declare module BABYLON {
  93466. /**
  93467. * Class used to manipulate GUIDs
  93468. */
  93469. export class GUID {
  93470. /**
  93471. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93472. * Be aware Math.random() could cause collisions, but:
  93473. * "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"
  93474. * @returns a pseudo random id
  93475. */
  93476. static RandomId(): string;
  93477. }
  93478. }
  93479. declare module BABYLON {
  93480. /**
  93481. * Base class of all the textures in babylon.
  93482. * It groups all the common properties the materials, post process, lights... might need
  93483. * in order to make a correct use of the texture.
  93484. */
  93485. export class BaseTexture implements IAnimatable {
  93486. /**
  93487. * Default anisotropic filtering level for the application.
  93488. * It is set to 4 as a good tradeoff between perf and quality.
  93489. */
  93490. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93491. /**
  93492. * Gets or sets the unique id of the texture
  93493. */
  93494. uniqueId: number;
  93495. /**
  93496. * Define the name of the texture.
  93497. */
  93498. name: string;
  93499. /**
  93500. * Gets or sets an object used to store user defined information.
  93501. */
  93502. metadata: any;
  93503. /**
  93504. * For internal use only. Please do not use.
  93505. */
  93506. reservedDataStore: any;
  93507. private _hasAlpha;
  93508. /**
  93509. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93510. */
  93511. hasAlpha: boolean;
  93512. /**
  93513. * Defines if the alpha value should be determined via the rgb values.
  93514. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93515. */
  93516. getAlphaFromRGB: boolean;
  93517. /**
  93518. * Intensity or strength of the texture.
  93519. * It is commonly used by materials to fine tune the intensity of the texture
  93520. */
  93521. level: number;
  93522. /**
  93523. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93524. * This is part of the texture as textures usually maps to one uv set.
  93525. */
  93526. coordinatesIndex: number;
  93527. private _coordinatesMode;
  93528. /**
  93529. * How a texture is mapped.
  93530. *
  93531. * | Value | Type | Description |
  93532. * | ----- | ----------------------------------- | ----------- |
  93533. * | 0 | EXPLICIT_MODE | |
  93534. * | 1 | SPHERICAL_MODE | |
  93535. * | 2 | PLANAR_MODE | |
  93536. * | 3 | CUBIC_MODE | |
  93537. * | 4 | PROJECTION_MODE | |
  93538. * | 5 | SKYBOX_MODE | |
  93539. * | 6 | INVCUBIC_MODE | |
  93540. * | 7 | EQUIRECTANGULAR_MODE | |
  93541. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93542. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93543. */
  93544. coordinatesMode: number;
  93545. /**
  93546. * | Value | Type | Description |
  93547. * | ----- | ------------------ | ----------- |
  93548. * | 0 | CLAMP_ADDRESSMODE | |
  93549. * | 1 | WRAP_ADDRESSMODE | |
  93550. * | 2 | MIRROR_ADDRESSMODE | |
  93551. */
  93552. wrapU: number;
  93553. /**
  93554. * | Value | Type | Description |
  93555. * | ----- | ------------------ | ----------- |
  93556. * | 0 | CLAMP_ADDRESSMODE | |
  93557. * | 1 | WRAP_ADDRESSMODE | |
  93558. * | 2 | MIRROR_ADDRESSMODE | |
  93559. */
  93560. wrapV: number;
  93561. /**
  93562. * | Value | Type | Description |
  93563. * | ----- | ------------------ | ----------- |
  93564. * | 0 | CLAMP_ADDRESSMODE | |
  93565. * | 1 | WRAP_ADDRESSMODE | |
  93566. * | 2 | MIRROR_ADDRESSMODE | |
  93567. */
  93568. wrapR: number;
  93569. /**
  93570. * With compliant hardware and browser (supporting anisotropic filtering)
  93571. * this defines the level of anisotropic filtering in the texture.
  93572. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93573. */
  93574. anisotropicFilteringLevel: number;
  93575. /**
  93576. * Define if the texture is a cube texture or if false a 2d texture.
  93577. */
  93578. isCube: boolean;
  93579. /**
  93580. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93581. */
  93582. is3D: boolean;
  93583. /**
  93584. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93585. * HDR texture are usually stored in linear space.
  93586. * This only impacts the PBR and Background materials
  93587. */
  93588. gammaSpace: boolean;
  93589. /**
  93590. * Gets or sets whether or not the texture contains RGBD data.
  93591. */
  93592. isRGBD: boolean;
  93593. /**
  93594. * Is Z inverted in the texture (useful in a cube texture).
  93595. */
  93596. invertZ: boolean;
  93597. /**
  93598. * Are mip maps generated for this texture or not.
  93599. */
  93600. readonly noMipmap: boolean;
  93601. /**
  93602. * @hidden
  93603. */
  93604. lodLevelInAlpha: boolean;
  93605. /**
  93606. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93607. */
  93608. lodGenerationOffset: number;
  93609. /**
  93610. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93611. */
  93612. lodGenerationScale: number;
  93613. /**
  93614. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93615. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93616. * average roughness values.
  93617. */
  93618. linearSpecularLOD: boolean;
  93619. /**
  93620. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93621. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93622. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93623. */
  93624. irradianceTexture: Nullable<BaseTexture>;
  93625. /**
  93626. * Define if the texture is a render target.
  93627. */
  93628. isRenderTarget: boolean;
  93629. /**
  93630. * Define the unique id of the texture in the scene.
  93631. */
  93632. readonly uid: string;
  93633. /**
  93634. * Return a string representation of the texture.
  93635. * @returns the texture as a string
  93636. */
  93637. toString(): string;
  93638. /**
  93639. * Get the class name of the texture.
  93640. * @returns "BaseTexture"
  93641. */
  93642. getClassName(): string;
  93643. /**
  93644. * Define the list of animation attached to the texture.
  93645. */
  93646. animations: Animation[];
  93647. /**
  93648. * An event triggered when the texture is disposed.
  93649. */
  93650. onDisposeObservable: Observable<BaseTexture>;
  93651. private _onDisposeObserver;
  93652. /**
  93653. * Callback triggered when the texture has been disposed.
  93654. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93655. */
  93656. onDispose: () => void;
  93657. /**
  93658. * Define the current state of the loading sequence when in delayed load mode.
  93659. */
  93660. delayLoadState: number;
  93661. private _scene;
  93662. /** @hidden */
  93663. _texture: Nullable<InternalTexture>;
  93664. private _uid;
  93665. /**
  93666. * Define if the texture is preventinga material to render or not.
  93667. * If not and the texture is not ready, the engine will use a default black texture instead.
  93668. */
  93669. readonly isBlocking: boolean;
  93670. /**
  93671. * Instantiates a new BaseTexture.
  93672. * Base class of all the textures in babylon.
  93673. * It groups all the common properties the materials, post process, lights... might need
  93674. * in order to make a correct use of the texture.
  93675. * @param scene Define the scene the texture blongs to
  93676. */
  93677. constructor(scene: Nullable<Scene>);
  93678. /**
  93679. * Get the scene the texture belongs to.
  93680. * @returns the scene or null if undefined
  93681. */
  93682. getScene(): Nullable<Scene>;
  93683. /**
  93684. * Get the texture transform matrix used to offset tile the texture for istance.
  93685. * @returns the transformation matrix
  93686. */
  93687. getTextureMatrix(): Matrix;
  93688. /**
  93689. * Get the texture reflection matrix used to rotate/transform the reflection.
  93690. * @returns the reflection matrix
  93691. */
  93692. getReflectionTextureMatrix(): Matrix;
  93693. /**
  93694. * Get the underlying lower level texture from Babylon.
  93695. * @returns the insternal texture
  93696. */
  93697. getInternalTexture(): Nullable<InternalTexture>;
  93698. /**
  93699. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93700. * @returns true if ready or not blocking
  93701. */
  93702. isReadyOrNotBlocking(): boolean;
  93703. /**
  93704. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93705. * @returns true if fully ready
  93706. */
  93707. isReady(): boolean;
  93708. private _cachedSize;
  93709. /**
  93710. * Get the size of the texture.
  93711. * @returns the texture size.
  93712. */
  93713. getSize(): ISize;
  93714. /**
  93715. * Get the base size of the texture.
  93716. * It can be different from the size if the texture has been resized for POT for instance
  93717. * @returns the base size
  93718. */
  93719. getBaseSize(): ISize;
  93720. /**
  93721. * Update the sampling mode of the texture.
  93722. * Default is Trilinear mode.
  93723. *
  93724. * | Value | Type | Description |
  93725. * | ----- | ------------------ | ----------- |
  93726. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93727. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93728. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93729. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93730. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93731. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93732. * | 7 | NEAREST_LINEAR | |
  93733. * | 8 | NEAREST_NEAREST | |
  93734. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93735. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93736. * | 11 | LINEAR_LINEAR | |
  93737. * | 12 | LINEAR_NEAREST | |
  93738. *
  93739. * > _mag_: magnification filter (close to the viewer)
  93740. * > _min_: minification filter (far from the viewer)
  93741. * > _mip_: filter used between mip map levels
  93742. *@param samplingMode Define the new sampling mode of the texture
  93743. */
  93744. updateSamplingMode(samplingMode: number): void;
  93745. /**
  93746. * Scales the texture if is `canRescale()`
  93747. * @param ratio the resize factor we want to use to rescale
  93748. */
  93749. scale(ratio: number): void;
  93750. /**
  93751. * Get if the texture can rescale.
  93752. */
  93753. readonly canRescale: boolean;
  93754. /** @hidden */
  93755. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93756. /** @hidden */
  93757. _rebuild(): void;
  93758. /**
  93759. * Triggers the load sequence in delayed load mode.
  93760. */
  93761. delayLoad(): void;
  93762. /**
  93763. * Clones the texture.
  93764. * @returns the cloned texture
  93765. */
  93766. clone(): Nullable<BaseTexture>;
  93767. /**
  93768. * Get the texture underlying type (INT, FLOAT...)
  93769. */
  93770. readonly textureType: number;
  93771. /**
  93772. * Get the texture underlying format (RGB, RGBA...)
  93773. */
  93774. readonly textureFormat: number;
  93775. /**
  93776. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93777. * This will returns an RGBA array buffer containing either in values (0-255) or
  93778. * float values (0-1) depending of the underlying buffer type.
  93779. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93780. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93781. * @param buffer defines a user defined buffer to fill with data (can be null)
  93782. * @returns The Array buffer containing the pixels data.
  93783. */
  93784. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93785. /**
  93786. * Release and destroy the underlying lower level texture aka internalTexture.
  93787. */
  93788. releaseInternalTexture(): void;
  93789. /**
  93790. * Get the polynomial representation of the texture data.
  93791. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93792. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93793. */
  93794. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93795. /** @hidden */
  93796. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93797. /** @hidden */
  93798. readonly _lodTextureMid: Nullable<BaseTexture>;
  93799. /** @hidden */
  93800. readonly _lodTextureLow: Nullable<BaseTexture>;
  93801. /**
  93802. * Dispose the texture and release its associated resources.
  93803. */
  93804. dispose(): void;
  93805. /**
  93806. * Serialize the texture into a JSON representation that can be parsed later on.
  93807. * @returns the JSON representation of the texture
  93808. */
  93809. serialize(): any;
  93810. /**
  93811. * Helper function to be called back once a list of texture contains only ready textures.
  93812. * @param textures Define the list of textures to wait for
  93813. * @param callback Define the callback triggered once the entire list will be ready
  93814. */
  93815. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93816. }
  93817. }
  93818. declare module BABYLON {
  93819. /**
  93820. * Class used to store data associated with WebGL texture data for the engine
  93821. * This class should not be used directly
  93822. */
  93823. export class InternalTexture {
  93824. /** @hidden */
  93825. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93826. /**
  93827. * The source of the texture data is unknown
  93828. */
  93829. static DATASOURCE_UNKNOWN: number;
  93830. /**
  93831. * Texture data comes from an URL
  93832. */
  93833. static DATASOURCE_URL: number;
  93834. /**
  93835. * Texture data is only used for temporary storage
  93836. */
  93837. static DATASOURCE_TEMP: number;
  93838. /**
  93839. * Texture data comes from raw data (ArrayBuffer)
  93840. */
  93841. static DATASOURCE_RAW: number;
  93842. /**
  93843. * Texture content is dynamic (video or dynamic texture)
  93844. */
  93845. static DATASOURCE_DYNAMIC: number;
  93846. /**
  93847. * Texture content is generated by rendering to it
  93848. */
  93849. static DATASOURCE_RENDERTARGET: number;
  93850. /**
  93851. * Texture content is part of a multi render target process
  93852. */
  93853. static DATASOURCE_MULTIRENDERTARGET: number;
  93854. /**
  93855. * Texture data comes from a cube data file
  93856. */
  93857. static DATASOURCE_CUBE: number;
  93858. /**
  93859. * Texture data comes from a raw cube data
  93860. */
  93861. static DATASOURCE_CUBERAW: number;
  93862. /**
  93863. * Texture data come from a prefiltered cube data file
  93864. */
  93865. static DATASOURCE_CUBEPREFILTERED: number;
  93866. /**
  93867. * Texture content is raw 3D data
  93868. */
  93869. static DATASOURCE_RAW3D: number;
  93870. /**
  93871. * Texture content is a depth texture
  93872. */
  93873. static DATASOURCE_DEPTHTEXTURE: number;
  93874. /**
  93875. * Texture data comes from a raw cube data encoded with RGBD
  93876. */
  93877. static DATASOURCE_CUBERAW_RGBD: number;
  93878. /**
  93879. * Defines if the texture is ready
  93880. */
  93881. isReady: boolean;
  93882. /**
  93883. * Defines if the texture is a cube texture
  93884. */
  93885. isCube: boolean;
  93886. /**
  93887. * Defines if the texture contains 3D data
  93888. */
  93889. is3D: boolean;
  93890. /**
  93891. * Defines if the texture contains multiview data
  93892. */
  93893. isMultiview: boolean;
  93894. /**
  93895. * Gets the URL used to load this texture
  93896. */
  93897. url: string;
  93898. /**
  93899. * Gets the sampling mode of the texture
  93900. */
  93901. samplingMode: number;
  93902. /**
  93903. * Gets a boolean indicating if the texture needs mipmaps generation
  93904. */
  93905. generateMipMaps: boolean;
  93906. /**
  93907. * Gets the number of samples used by the texture (WebGL2+ only)
  93908. */
  93909. samples: number;
  93910. /**
  93911. * Gets the type of the texture (int, float...)
  93912. */
  93913. type: number;
  93914. /**
  93915. * Gets the format of the texture (RGB, RGBA...)
  93916. */
  93917. format: number;
  93918. /**
  93919. * Observable called when the texture is loaded
  93920. */
  93921. onLoadedObservable: Observable<InternalTexture>;
  93922. /**
  93923. * Gets the width of the texture
  93924. */
  93925. width: number;
  93926. /**
  93927. * Gets the height of the texture
  93928. */
  93929. height: number;
  93930. /**
  93931. * Gets the depth of the texture
  93932. */
  93933. depth: number;
  93934. /**
  93935. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93936. */
  93937. baseWidth: number;
  93938. /**
  93939. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93940. */
  93941. baseHeight: number;
  93942. /**
  93943. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93944. */
  93945. baseDepth: number;
  93946. /**
  93947. * Gets a boolean indicating if the texture is inverted on Y axis
  93948. */
  93949. invertY: boolean;
  93950. /** @hidden */
  93951. _invertVScale: boolean;
  93952. /** @hidden */
  93953. _associatedChannel: number;
  93954. /** @hidden */
  93955. _dataSource: number;
  93956. /** @hidden */
  93957. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93958. /** @hidden */
  93959. _bufferView: Nullable<ArrayBufferView>;
  93960. /** @hidden */
  93961. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93962. /** @hidden */
  93963. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93964. /** @hidden */
  93965. _size: number;
  93966. /** @hidden */
  93967. _extension: string;
  93968. /** @hidden */
  93969. _files: Nullable<string[]>;
  93970. /** @hidden */
  93971. _workingCanvas: Nullable<HTMLCanvasElement>;
  93972. /** @hidden */
  93973. _workingContext: Nullable<CanvasRenderingContext2D>;
  93974. /** @hidden */
  93975. _framebuffer: Nullable<WebGLFramebuffer>;
  93976. /** @hidden */
  93977. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93978. /** @hidden */
  93979. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93980. /** @hidden */
  93981. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93982. /** @hidden */
  93983. _attachments: Nullable<number[]>;
  93984. /** @hidden */
  93985. _cachedCoordinatesMode: Nullable<number>;
  93986. /** @hidden */
  93987. _cachedWrapU: Nullable<number>;
  93988. /** @hidden */
  93989. _cachedWrapV: Nullable<number>;
  93990. /** @hidden */
  93991. _cachedWrapR: Nullable<number>;
  93992. /** @hidden */
  93993. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93994. /** @hidden */
  93995. _isDisabled: boolean;
  93996. /** @hidden */
  93997. _compression: Nullable<string>;
  93998. /** @hidden */
  93999. _generateStencilBuffer: boolean;
  94000. /** @hidden */
  94001. _generateDepthBuffer: boolean;
  94002. /** @hidden */
  94003. _comparisonFunction: number;
  94004. /** @hidden */
  94005. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  94006. /** @hidden */
  94007. _lodGenerationScale: number;
  94008. /** @hidden */
  94009. _lodGenerationOffset: number;
  94010. /** @hidden */
  94011. _colorTextureArray: Nullable<WebGLTexture>;
  94012. /** @hidden */
  94013. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94014. /** @hidden */
  94015. _lodTextureHigh: Nullable<BaseTexture>;
  94016. /** @hidden */
  94017. _lodTextureMid: Nullable<BaseTexture>;
  94018. /** @hidden */
  94019. _lodTextureLow: Nullable<BaseTexture>;
  94020. /** @hidden */
  94021. _isRGBD: boolean;
  94022. /** @hidden */
  94023. _linearSpecularLOD: boolean;
  94024. /** @hidden */
  94025. _irradianceTexture: Nullable<BaseTexture>;
  94026. /** @hidden */
  94027. _webGLTexture: Nullable<WebGLTexture>;
  94028. /** @hidden */
  94029. _references: number;
  94030. private _engine;
  94031. /**
  94032. * Gets the Engine the texture belongs to.
  94033. * @returns The babylon engine
  94034. */
  94035. getEngine(): Engine;
  94036. /**
  94037. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94038. */
  94039. readonly dataSource: number;
  94040. /**
  94041. * Creates a new InternalTexture
  94042. * @param engine defines the engine to use
  94043. * @param dataSource defines the type of data that will be used
  94044. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94045. */
  94046. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94047. /**
  94048. * Increments the number of references (ie. the number of Texture that point to it)
  94049. */
  94050. incrementReferences(): void;
  94051. /**
  94052. * Change the size of the texture (not the size of the content)
  94053. * @param width defines the new width
  94054. * @param height defines the new height
  94055. * @param depth defines the new depth (1 by default)
  94056. */
  94057. updateSize(width: int, height: int, depth?: int): void;
  94058. /** @hidden */
  94059. _rebuild(): void;
  94060. /** @hidden */
  94061. _swapAndDie(target: InternalTexture): void;
  94062. /**
  94063. * Dispose the current allocated resources
  94064. */
  94065. dispose(): void;
  94066. }
  94067. }
  94068. declare module BABYLON {
  94069. /**
  94070. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94071. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94072. */
  94073. export class EffectFallbacks {
  94074. private _defines;
  94075. private _currentRank;
  94076. private _maxRank;
  94077. private _mesh;
  94078. /**
  94079. * Removes the fallback from the bound mesh.
  94080. */
  94081. unBindMesh(): void;
  94082. /**
  94083. * Adds a fallback on the specified property.
  94084. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94085. * @param define The name of the define in the shader
  94086. */
  94087. addFallback(rank: number, define: string): void;
  94088. /**
  94089. * Sets the mesh to use CPU skinning when needing to fallback.
  94090. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94091. * @param mesh The mesh to use the fallbacks.
  94092. */
  94093. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94094. /**
  94095. * Checks to see if more fallbacks are still availible.
  94096. */
  94097. readonly hasMoreFallbacks: boolean;
  94098. /**
  94099. * Removes the defines that should be removed when falling back.
  94100. * @param currentDefines defines the current define statements for the shader.
  94101. * @param effect defines the current effect we try to compile
  94102. * @returns The resulting defines with defines of the current rank removed.
  94103. */
  94104. reduce(currentDefines: string, effect: Effect): string;
  94105. }
  94106. /**
  94107. * Options to be used when creating an effect.
  94108. */
  94109. export class EffectCreationOptions {
  94110. /**
  94111. * Atrributes that will be used in the shader.
  94112. */
  94113. attributes: string[];
  94114. /**
  94115. * Uniform varible names that will be set in the shader.
  94116. */
  94117. uniformsNames: string[];
  94118. /**
  94119. * Uniform buffer varible names that will be set in the shader.
  94120. */
  94121. uniformBuffersNames: string[];
  94122. /**
  94123. * Sampler texture variable names that will be set in the shader.
  94124. */
  94125. samplers: string[];
  94126. /**
  94127. * Define statements that will be set in the shader.
  94128. */
  94129. defines: any;
  94130. /**
  94131. * Possible fallbacks for this effect to improve performance when needed.
  94132. */
  94133. fallbacks: Nullable<EffectFallbacks>;
  94134. /**
  94135. * Callback that will be called when the shader is compiled.
  94136. */
  94137. onCompiled: Nullable<(effect: Effect) => void>;
  94138. /**
  94139. * Callback that will be called if an error occurs during shader compilation.
  94140. */
  94141. onError: Nullable<(effect: Effect, errors: string) => void>;
  94142. /**
  94143. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94144. */
  94145. indexParameters: any;
  94146. /**
  94147. * Max number of lights that can be used in the shader.
  94148. */
  94149. maxSimultaneousLights: number;
  94150. /**
  94151. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94152. */
  94153. transformFeedbackVaryings: Nullable<string[]>;
  94154. }
  94155. /**
  94156. * Effect containing vertex and fragment shader that can be executed on an object.
  94157. */
  94158. export class Effect implements IDisposable {
  94159. /**
  94160. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94161. */
  94162. static ShadersRepository: string;
  94163. /**
  94164. * Name of the effect.
  94165. */
  94166. name: any;
  94167. /**
  94168. * String container all the define statements that should be set on the shader.
  94169. */
  94170. defines: string;
  94171. /**
  94172. * Callback that will be called when the shader is compiled.
  94173. */
  94174. onCompiled: Nullable<(effect: Effect) => void>;
  94175. /**
  94176. * Callback that will be called if an error occurs during shader compilation.
  94177. */
  94178. onError: Nullable<(effect: Effect, errors: string) => void>;
  94179. /**
  94180. * Callback that will be called when effect is bound.
  94181. */
  94182. onBind: Nullable<(effect: Effect) => void>;
  94183. /**
  94184. * Unique ID of the effect.
  94185. */
  94186. uniqueId: number;
  94187. /**
  94188. * Observable that will be called when the shader is compiled.
  94189. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94190. */
  94191. onCompileObservable: Observable<Effect>;
  94192. /**
  94193. * Observable that will be called if an error occurs during shader compilation.
  94194. */
  94195. onErrorObservable: Observable<Effect>;
  94196. /** @hidden */
  94197. _onBindObservable: Nullable<Observable<Effect>>;
  94198. /**
  94199. * Observable that will be called when effect is bound.
  94200. */
  94201. readonly onBindObservable: Observable<Effect>;
  94202. /** @hidden */
  94203. _bonesComputationForcedToCPU: boolean;
  94204. private static _uniqueIdSeed;
  94205. private _engine;
  94206. private _uniformBuffersNames;
  94207. private _uniformsNames;
  94208. private _samplerList;
  94209. private _samplers;
  94210. private _isReady;
  94211. private _compilationError;
  94212. private _attributesNames;
  94213. private _attributes;
  94214. private _uniforms;
  94215. /**
  94216. * Key for the effect.
  94217. * @hidden
  94218. */
  94219. _key: string;
  94220. private _indexParameters;
  94221. private _fallbacks;
  94222. private _vertexSourceCode;
  94223. private _fragmentSourceCode;
  94224. private _vertexSourceCodeOverride;
  94225. private _fragmentSourceCodeOverride;
  94226. private _transformFeedbackVaryings;
  94227. /**
  94228. * Compiled shader to webGL program.
  94229. * @hidden
  94230. */
  94231. _pipelineContext: Nullable<IPipelineContext>;
  94232. private _valueCache;
  94233. private static _baseCache;
  94234. /**
  94235. * Instantiates an effect.
  94236. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94237. * @param baseName Name of the effect.
  94238. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94239. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94240. * @param samplers List of sampler variables that will be passed to the shader.
  94241. * @param engine Engine to be used to render the effect
  94242. * @param defines Define statements to be added to the shader.
  94243. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94244. * @param onCompiled Callback that will be called when the shader is compiled.
  94245. * @param onError Callback that will be called if an error occurs during shader compilation.
  94246. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94247. */
  94248. 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);
  94249. private _useFinalCode;
  94250. /**
  94251. * Unique key for this effect
  94252. */
  94253. readonly key: string;
  94254. /**
  94255. * If the effect has been compiled and prepared.
  94256. * @returns if the effect is compiled and prepared.
  94257. */
  94258. isReady(): boolean;
  94259. private _isReadyInternal;
  94260. /**
  94261. * The engine the effect was initialized with.
  94262. * @returns the engine.
  94263. */
  94264. getEngine(): Engine;
  94265. /**
  94266. * The pipeline context for this effect
  94267. * @returns the associated pipeline context
  94268. */
  94269. getPipelineContext(): Nullable<IPipelineContext>;
  94270. /**
  94271. * The set of names of attribute variables for the shader.
  94272. * @returns An array of attribute names.
  94273. */
  94274. getAttributesNames(): string[];
  94275. /**
  94276. * Returns the attribute at the given index.
  94277. * @param index The index of the attribute.
  94278. * @returns The location of the attribute.
  94279. */
  94280. getAttributeLocation(index: number): number;
  94281. /**
  94282. * Returns the attribute based on the name of the variable.
  94283. * @param name of the attribute to look up.
  94284. * @returns the attribute location.
  94285. */
  94286. getAttributeLocationByName(name: string): number;
  94287. /**
  94288. * The number of attributes.
  94289. * @returns the numnber of attributes.
  94290. */
  94291. getAttributesCount(): number;
  94292. /**
  94293. * Gets the index of a uniform variable.
  94294. * @param uniformName of the uniform to look up.
  94295. * @returns the index.
  94296. */
  94297. getUniformIndex(uniformName: string): number;
  94298. /**
  94299. * Returns the attribute based on the name of the variable.
  94300. * @param uniformName of the uniform to look up.
  94301. * @returns the location of the uniform.
  94302. */
  94303. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94304. /**
  94305. * Returns an array of sampler variable names
  94306. * @returns The array of sampler variable neames.
  94307. */
  94308. getSamplers(): string[];
  94309. /**
  94310. * The error from the last compilation.
  94311. * @returns the error string.
  94312. */
  94313. getCompilationError(): string;
  94314. /**
  94315. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94316. * @param func The callback to be used.
  94317. */
  94318. executeWhenCompiled(func: (effect: Effect) => void): void;
  94319. private _checkIsReady;
  94320. /** @hidden */
  94321. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94322. /** @hidden */
  94323. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94324. /** @hidden */
  94325. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94326. /**
  94327. * Recompiles the webGL program
  94328. * @param vertexSourceCode The source code for the vertex shader.
  94329. * @param fragmentSourceCode The source code for the fragment shader.
  94330. * @param onCompiled Callback called when completed.
  94331. * @param onError Callback called on error.
  94332. * @hidden
  94333. */
  94334. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94335. /**
  94336. * Prepares the effect
  94337. * @hidden
  94338. */
  94339. _prepareEffect(): void;
  94340. private _processCompilationErrors;
  94341. /**
  94342. * Checks if the effect is supported. (Must be called after compilation)
  94343. */
  94344. readonly isSupported: boolean;
  94345. /**
  94346. * Binds a texture to the engine to be used as output of the shader.
  94347. * @param channel Name of the output variable.
  94348. * @param texture Texture to bind.
  94349. * @hidden
  94350. */
  94351. _bindTexture(channel: string, texture: InternalTexture): void;
  94352. /**
  94353. * Sets a texture on the engine to be used in the shader.
  94354. * @param channel Name of the sampler variable.
  94355. * @param texture Texture to set.
  94356. */
  94357. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94358. /**
  94359. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94360. * @param channel Name of the sampler variable.
  94361. * @param texture Texture to set.
  94362. */
  94363. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94364. /**
  94365. * Sets an array of textures on the engine to be used in the shader.
  94366. * @param channel Name of the variable.
  94367. * @param textures Textures to set.
  94368. */
  94369. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94370. /**
  94371. * 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)
  94372. * @param channel Name of the sampler variable.
  94373. * @param postProcess Post process to get the input texture from.
  94374. */
  94375. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94376. /**
  94377. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94378. * 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)
  94379. * @param channel Name of the sampler variable.
  94380. * @param postProcess Post process to get the output texture from.
  94381. */
  94382. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94383. /** @hidden */
  94384. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94385. /** @hidden */
  94386. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94387. /** @hidden */
  94388. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94389. /** @hidden */
  94390. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94391. /**
  94392. * Binds a buffer to a uniform.
  94393. * @param buffer Buffer to bind.
  94394. * @param name Name of the uniform variable to bind to.
  94395. */
  94396. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94397. /**
  94398. * Binds block to a uniform.
  94399. * @param blockName Name of the block to bind.
  94400. * @param index Index to bind.
  94401. */
  94402. bindUniformBlock(blockName: string, index: number): void;
  94403. /**
  94404. * Sets an interger value on a uniform variable.
  94405. * @param uniformName Name of the variable.
  94406. * @param value Value to be set.
  94407. * @returns this effect.
  94408. */
  94409. setInt(uniformName: string, value: number): Effect;
  94410. /**
  94411. * Sets an int array on a uniform variable.
  94412. * @param uniformName Name of the variable.
  94413. * @param array array to be set.
  94414. * @returns this effect.
  94415. */
  94416. setIntArray(uniformName: string, array: Int32Array): Effect;
  94417. /**
  94418. * 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)
  94419. * @param uniformName Name of the variable.
  94420. * @param array array to be set.
  94421. * @returns this effect.
  94422. */
  94423. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94424. /**
  94425. * 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)
  94426. * @param uniformName Name of the variable.
  94427. * @param array array to be set.
  94428. * @returns this effect.
  94429. */
  94430. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94431. /**
  94432. * 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)
  94433. * @param uniformName Name of the variable.
  94434. * @param array array to be set.
  94435. * @returns this effect.
  94436. */
  94437. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94438. /**
  94439. * Sets an float array on a uniform variable.
  94440. * @param uniformName Name of the variable.
  94441. * @param array array to be set.
  94442. * @returns this effect.
  94443. */
  94444. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94445. /**
  94446. * 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)
  94447. * @param uniformName Name of the variable.
  94448. * @param array array to be set.
  94449. * @returns this effect.
  94450. */
  94451. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94452. /**
  94453. * 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)
  94454. * @param uniformName Name of the variable.
  94455. * @param array array to be set.
  94456. * @returns this effect.
  94457. */
  94458. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94459. /**
  94460. * 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)
  94461. * @param uniformName Name of the variable.
  94462. * @param array array to be set.
  94463. * @returns this effect.
  94464. */
  94465. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94466. /**
  94467. * Sets an array on a uniform variable.
  94468. * @param uniformName Name of the variable.
  94469. * @param array array to be set.
  94470. * @returns this effect.
  94471. */
  94472. setArray(uniformName: string, array: number[]): Effect;
  94473. /**
  94474. * 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)
  94475. * @param uniformName Name of the variable.
  94476. * @param array array to be set.
  94477. * @returns this effect.
  94478. */
  94479. setArray2(uniformName: string, array: number[]): Effect;
  94480. /**
  94481. * 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)
  94482. * @param uniformName Name of the variable.
  94483. * @param array array to be set.
  94484. * @returns this effect.
  94485. */
  94486. setArray3(uniformName: string, array: number[]): Effect;
  94487. /**
  94488. * 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)
  94489. * @param uniformName Name of the variable.
  94490. * @param array array to be set.
  94491. * @returns this effect.
  94492. */
  94493. setArray4(uniformName: string, array: number[]): Effect;
  94494. /**
  94495. * Sets matrices on a uniform variable.
  94496. * @param uniformName Name of the variable.
  94497. * @param matrices matrices to be set.
  94498. * @returns this effect.
  94499. */
  94500. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94501. /**
  94502. * Sets matrix on a uniform variable.
  94503. * @param uniformName Name of the variable.
  94504. * @param matrix matrix to be set.
  94505. * @returns this effect.
  94506. */
  94507. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94508. /**
  94509. * 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)
  94510. * @param uniformName Name of the variable.
  94511. * @param matrix matrix to be set.
  94512. * @returns this effect.
  94513. */
  94514. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94515. /**
  94516. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94517. * @param uniformName Name of the variable.
  94518. * @param matrix matrix to be set.
  94519. * @returns this effect.
  94520. */
  94521. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94522. /**
  94523. * Sets a float on a uniform variable.
  94524. * @param uniformName Name of the variable.
  94525. * @param value value to be set.
  94526. * @returns this effect.
  94527. */
  94528. setFloat(uniformName: string, value: number): Effect;
  94529. /**
  94530. * Sets a boolean on a uniform variable.
  94531. * @param uniformName Name of the variable.
  94532. * @param bool value to be set.
  94533. * @returns this effect.
  94534. */
  94535. setBool(uniformName: string, bool: boolean): Effect;
  94536. /**
  94537. * Sets a Vector2 on a uniform variable.
  94538. * @param uniformName Name of the variable.
  94539. * @param vector2 vector2 to be set.
  94540. * @returns this effect.
  94541. */
  94542. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94543. /**
  94544. * Sets a float2 on a uniform variable.
  94545. * @param uniformName Name of the variable.
  94546. * @param x First float in float2.
  94547. * @param y Second float in float2.
  94548. * @returns this effect.
  94549. */
  94550. setFloat2(uniformName: string, x: number, y: number): Effect;
  94551. /**
  94552. * Sets a Vector3 on a uniform variable.
  94553. * @param uniformName Name of the variable.
  94554. * @param vector3 Value to be set.
  94555. * @returns this effect.
  94556. */
  94557. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94558. /**
  94559. * Sets a float3 on a uniform variable.
  94560. * @param uniformName Name of the variable.
  94561. * @param x First float in float3.
  94562. * @param y Second float in float3.
  94563. * @param z Third float in float3.
  94564. * @returns this effect.
  94565. */
  94566. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94567. /**
  94568. * Sets a Vector4 on a uniform variable.
  94569. * @param uniformName Name of the variable.
  94570. * @param vector4 Value to be set.
  94571. * @returns this effect.
  94572. */
  94573. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94574. /**
  94575. * Sets a float4 on a uniform variable.
  94576. * @param uniformName Name of the variable.
  94577. * @param x First float in float4.
  94578. * @param y Second float in float4.
  94579. * @param z Third float in float4.
  94580. * @param w Fourth float in float4.
  94581. * @returns this effect.
  94582. */
  94583. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94584. /**
  94585. * Sets a Color3 on a uniform variable.
  94586. * @param uniformName Name of the variable.
  94587. * @param color3 Value to be set.
  94588. * @returns this effect.
  94589. */
  94590. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94591. /**
  94592. * Sets a Color4 on a uniform variable.
  94593. * @param uniformName Name of the variable.
  94594. * @param color3 Value to be set.
  94595. * @param alpha Alpha value to be set.
  94596. * @returns this effect.
  94597. */
  94598. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94599. /**
  94600. * Sets a Color4 on a uniform variable
  94601. * @param uniformName defines the name of the variable
  94602. * @param color4 defines the value to be set
  94603. * @returns this effect.
  94604. */
  94605. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94606. /** Release all associated resources */
  94607. dispose(): void;
  94608. /**
  94609. * This function will add a new shader to the shader store
  94610. * @param name the name of the shader
  94611. * @param pixelShader optional pixel shader content
  94612. * @param vertexShader optional vertex shader content
  94613. */
  94614. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94615. /**
  94616. * Store of each shader (The can be looked up using effect.key)
  94617. */
  94618. static ShadersStore: {
  94619. [key: string]: string;
  94620. };
  94621. /**
  94622. * Store of each included file for a shader (The can be looked up using effect.key)
  94623. */
  94624. static IncludesShadersStore: {
  94625. [key: string]: string;
  94626. };
  94627. /**
  94628. * Resets the cache of effects.
  94629. */
  94630. static ResetCache(): void;
  94631. }
  94632. }
  94633. declare module BABYLON {
  94634. /**
  94635. * Uniform buffer objects.
  94636. *
  94637. * Handles blocks of uniform on the GPU.
  94638. *
  94639. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94640. *
  94641. * For more information, please refer to :
  94642. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94643. */
  94644. export class UniformBuffer {
  94645. private _engine;
  94646. private _buffer;
  94647. private _data;
  94648. private _bufferData;
  94649. private _dynamic?;
  94650. private _uniformLocations;
  94651. private _uniformSizes;
  94652. private _uniformLocationPointer;
  94653. private _needSync;
  94654. private _noUBO;
  94655. private _currentEffect;
  94656. private static _MAX_UNIFORM_SIZE;
  94657. private static _tempBuffer;
  94658. /**
  94659. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94660. * This is dynamic to allow compat with webgl 1 and 2.
  94661. * You will need to pass the name of the uniform as well as the value.
  94662. */
  94663. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94664. /**
  94665. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94666. * This is dynamic to allow compat with webgl 1 and 2.
  94667. * You will need to pass the name of the uniform as well as the value.
  94668. */
  94669. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94670. /**
  94671. * Lambda to Update a single float in a uniform buffer.
  94672. * This is dynamic to allow compat with webgl 1 and 2.
  94673. * You will need to pass the name of the uniform as well as the value.
  94674. */
  94675. updateFloat: (name: string, x: number) => void;
  94676. /**
  94677. * Lambda to Update a vec2 of float in a uniform buffer.
  94678. * This is dynamic to allow compat with webgl 1 and 2.
  94679. * You will need to pass the name of the uniform as well as the value.
  94680. */
  94681. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94682. /**
  94683. * Lambda to Update a vec3 of float in a uniform buffer.
  94684. * This is dynamic to allow compat with webgl 1 and 2.
  94685. * You will need to pass the name of the uniform as well as the value.
  94686. */
  94687. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94688. /**
  94689. * Lambda to Update a vec4 of float in a uniform buffer.
  94690. * This is dynamic to allow compat with webgl 1 and 2.
  94691. * You will need to pass the name of the uniform as well as the value.
  94692. */
  94693. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94694. /**
  94695. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94696. * This is dynamic to allow compat with webgl 1 and 2.
  94697. * You will need to pass the name of the uniform as well as the value.
  94698. */
  94699. updateMatrix: (name: string, mat: Matrix) => void;
  94700. /**
  94701. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94702. * This is dynamic to allow compat with webgl 1 and 2.
  94703. * You will need to pass the name of the uniform as well as the value.
  94704. */
  94705. updateVector3: (name: string, vector: Vector3) => void;
  94706. /**
  94707. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94708. * This is dynamic to allow compat with webgl 1 and 2.
  94709. * You will need to pass the name of the uniform as well as the value.
  94710. */
  94711. updateVector4: (name: string, vector: Vector4) => void;
  94712. /**
  94713. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94714. * This is dynamic to allow compat with webgl 1 and 2.
  94715. * You will need to pass the name of the uniform as well as the value.
  94716. */
  94717. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94718. /**
  94719. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94720. * This is dynamic to allow compat with webgl 1 and 2.
  94721. * You will need to pass the name of the uniform as well as the value.
  94722. */
  94723. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94724. /**
  94725. * Instantiates a new Uniform buffer objects.
  94726. *
  94727. * Handles blocks of uniform on the GPU.
  94728. *
  94729. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94730. *
  94731. * For more information, please refer to :
  94732. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94733. * @param engine Define the engine the buffer is associated with
  94734. * @param data Define the data contained in the buffer
  94735. * @param dynamic Define if the buffer is updatable
  94736. */
  94737. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94738. /**
  94739. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94740. * or just falling back on setUniformXXX calls.
  94741. */
  94742. readonly useUbo: boolean;
  94743. /**
  94744. * Indicates if the WebGL underlying uniform buffer is in sync
  94745. * with the javascript cache data.
  94746. */
  94747. readonly isSync: boolean;
  94748. /**
  94749. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94750. * Also, a dynamic UniformBuffer will disable cache verification and always
  94751. * update the underlying WebGL uniform buffer to the GPU.
  94752. * @returns if Dynamic, otherwise false
  94753. */
  94754. isDynamic(): boolean;
  94755. /**
  94756. * The data cache on JS side.
  94757. * @returns the underlying data as a float array
  94758. */
  94759. getData(): Float32Array;
  94760. /**
  94761. * The underlying WebGL Uniform buffer.
  94762. * @returns the webgl buffer
  94763. */
  94764. getBuffer(): Nullable<DataBuffer>;
  94765. /**
  94766. * std140 layout specifies how to align data within an UBO structure.
  94767. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94768. * for specs.
  94769. */
  94770. private _fillAlignment;
  94771. /**
  94772. * Adds an uniform in the buffer.
  94773. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94774. * for the layout to be correct !
  94775. * @param name Name of the uniform, as used in the uniform block in the shader.
  94776. * @param size Data size, or data directly.
  94777. */
  94778. addUniform(name: string, size: number | number[]): void;
  94779. /**
  94780. * Adds a Matrix 4x4 to the uniform buffer.
  94781. * @param name Name of the uniform, as used in the uniform block in the shader.
  94782. * @param mat A 4x4 matrix.
  94783. */
  94784. addMatrix(name: string, mat: Matrix): void;
  94785. /**
  94786. * Adds a vec2 to the uniform buffer.
  94787. * @param name Name of the uniform, as used in the uniform block in the shader.
  94788. * @param x Define the x component value of the vec2
  94789. * @param y Define the y component value of the vec2
  94790. */
  94791. addFloat2(name: string, x: number, y: number): void;
  94792. /**
  94793. * Adds a vec3 to the uniform buffer.
  94794. * @param name Name of the uniform, as used in the uniform block in the shader.
  94795. * @param x Define the x component value of the vec3
  94796. * @param y Define the y component value of the vec3
  94797. * @param z Define the z component value of the vec3
  94798. */
  94799. addFloat3(name: string, x: number, y: number, z: 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 color Define the vec3 from a Color
  94804. */
  94805. addColor3(name: string, color: Color3): void;
  94806. /**
  94807. * Adds a vec4 to the uniform buffer.
  94808. * @param name Name of the uniform, as used in the uniform block in the shader.
  94809. * @param color Define the rgb components from a Color
  94810. * @param alpha Define the a component of the vec4
  94811. */
  94812. addColor4(name: string, color: Color3, alpha: number): void;
  94813. /**
  94814. * Adds a vec3 to the uniform buffer.
  94815. * @param name Name of the uniform, as used in the uniform block in the shader.
  94816. * @param vector Define the vec3 components from a Vector
  94817. */
  94818. addVector3(name: string, vector: Vector3): void;
  94819. /**
  94820. * Adds a Matrix 3x3 to the uniform buffer.
  94821. * @param name Name of the uniform, as used in the uniform block in the shader.
  94822. */
  94823. addMatrix3x3(name: string): void;
  94824. /**
  94825. * Adds a Matrix 2x2 to the uniform buffer.
  94826. * @param name Name of the uniform, as used in the uniform block in the shader.
  94827. */
  94828. addMatrix2x2(name: string): void;
  94829. /**
  94830. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94831. */
  94832. create(): void;
  94833. /** @hidden */
  94834. _rebuild(): void;
  94835. /**
  94836. * Updates the WebGL Uniform Buffer on the GPU.
  94837. * If the `dynamic` flag is set to true, no cache comparison is done.
  94838. * Otherwise, the buffer will be updated only if the cache differs.
  94839. */
  94840. update(): void;
  94841. /**
  94842. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94843. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94844. * @param data Define the flattened data
  94845. * @param size Define the size of the data.
  94846. */
  94847. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94848. private _valueCache;
  94849. private _cacheMatrix;
  94850. private _updateMatrix3x3ForUniform;
  94851. private _updateMatrix3x3ForEffect;
  94852. private _updateMatrix2x2ForEffect;
  94853. private _updateMatrix2x2ForUniform;
  94854. private _updateFloatForEffect;
  94855. private _updateFloatForUniform;
  94856. private _updateFloat2ForEffect;
  94857. private _updateFloat2ForUniform;
  94858. private _updateFloat3ForEffect;
  94859. private _updateFloat3ForUniform;
  94860. private _updateFloat4ForEffect;
  94861. private _updateFloat4ForUniform;
  94862. private _updateMatrixForEffect;
  94863. private _updateMatrixForUniform;
  94864. private _updateVector3ForEffect;
  94865. private _updateVector3ForUniform;
  94866. private _updateVector4ForEffect;
  94867. private _updateVector4ForUniform;
  94868. private _updateColor3ForEffect;
  94869. private _updateColor3ForUniform;
  94870. private _updateColor4ForEffect;
  94871. private _updateColor4ForUniform;
  94872. /**
  94873. * Sets a sampler uniform on the effect.
  94874. * @param name Define the name of the sampler.
  94875. * @param texture Define the texture to set in the sampler
  94876. */
  94877. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94878. /**
  94879. * Directly updates the value of the uniform in the cache AND on the GPU.
  94880. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94881. * @param data Define the flattened data
  94882. */
  94883. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94884. /**
  94885. * Binds this uniform buffer to an effect.
  94886. * @param effect Define the effect to bind the buffer to
  94887. * @param name Name of the uniform block in the shader.
  94888. */
  94889. bindToEffect(effect: Effect, name: string): void;
  94890. /**
  94891. * Disposes the uniform buffer.
  94892. */
  94893. dispose(): void;
  94894. }
  94895. }
  94896. declare module BABYLON {
  94897. /**
  94898. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94900. */
  94901. export class Analyser {
  94902. /**
  94903. * Gets or sets the smoothing
  94904. * @ignorenaming
  94905. */
  94906. SMOOTHING: number;
  94907. /**
  94908. * Gets or sets the FFT table size
  94909. * @ignorenaming
  94910. */
  94911. FFT_SIZE: number;
  94912. /**
  94913. * Gets or sets the bar graph amplitude
  94914. * @ignorenaming
  94915. */
  94916. BARGRAPHAMPLITUDE: number;
  94917. /**
  94918. * Gets or sets the position of the debug canvas
  94919. * @ignorenaming
  94920. */
  94921. DEBUGCANVASPOS: {
  94922. x: number;
  94923. y: number;
  94924. };
  94925. /**
  94926. * Gets or sets the debug canvas size
  94927. * @ignorenaming
  94928. */
  94929. DEBUGCANVASSIZE: {
  94930. width: number;
  94931. height: number;
  94932. };
  94933. private _byteFreqs;
  94934. private _byteTime;
  94935. private _floatFreqs;
  94936. private _webAudioAnalyser;
  94937. private _debugCanvas;
  94938. private _debugCanvasContext;
  94939. private _scene;
  94940. private _registerFunc;
  94941. private _audioEngine;
  94942. /**
  94943. * Creates a new analyser
  94944. * @param scene defines hosting scene
  94945. */
  94946. constructor(scene: Scene);
  94947. /**
  94948. * Get the number of data values you will have to play with for the visualization
  94949. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94950. * @returns a number
  94951. */
  94952. getFrequencyBinCount(): number;
  94953. /**
  94954. * Gets the current frequency data as a byte array
  94955. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94956. * @returns a Uint8Array
  94957. */
  94958. getByteFrequencyData(): Uint8Array;
  94959. /**
  94960. * Gets the current waveform as a byte array
  94961. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94962. * @returns a Uint8Array
  94963. */
  94964. getByteTimeDomainData(): Uint8Array;
  94965. /**
  94966. * Gets the current frequency data as a float array
  94967. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94968. * @returns a Float32Array
  94969. */
  94970. getFloatFrequencyData(): Float32Array;
  94971. /**
  94972. * Renders the debug canvas
  94973. */
  94974. drawDebugCanvas(): void;
  94975. /**
  94976. * Stops rendering the debug canvas and removes it
  94977. */
  94978. stopDebugCanvas(): void;
  94979. /**
  94980. * Connects two audio nodes
  94981. * @param inputAudioNode defines first node to connect
  94982. * @param outputAudioNode defines second node to connect
  94983. */
  94984. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94985. /**
  94986. * Releases all associated resources
  94987. */
  94988. dispose(): void;
  94989. }
  94990. }
  94991. declare module BABYLON {
  94992. /**
  94993. * This represents an audio engine and it is responsible
  94994. * to play, synchronize and analyse sounds throughout the application.
  94995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94996. */
  94997. export interface IAudioEngine extends IDisposable {
  94998. /**
  94999. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95000. */
  95001. readonly canUseWebAudio: boolean;
  95002. /**
  95003. * Gets the current AudioContext if available.
  95004. */
  95005. readonly audioContext: Nullable<AudioContext>;
  95006. /**
  95007. * The master gain node defines the global audio volume of your audio engine.
  95008. */
  95009. readonly masterGain: GainNode;
  95010. /**
  95011. * Gets whether or not mp3 are supported by your browser.
  95012. */
  95013. readonly isMP3supported: boolean;
  95014. /**
  95015. * Gets whether or not ogg are supported by your browser.
  95016. */
  95017. readonly isOGGsupported: boolean;
  95018. /**
  95019. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95020. * @ignoreNaming
  95021. */
  95022. WarnedWebAudioUnsupported: boolean;
  95023. /**
  95024. * Defines if the audio engine relies on a custom unlocked button.
  95025. * In this case, the embedded button will not be displayed.
  95026. */
  95027. useCustomUnlockedButton: boolean;
  95028. /**
  95029. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95030. */
  95031. readonly unlocked: boolean;
  95032. /**
  95033. * Event raised when audio has been unlocked on the browser.
  95034. */
  95035. onAudioUnlockedObservable: Observable<AudioEngine>;
  95036. /**
  95037. * Event raised when audio has been locked on the browser.
  95038. */
  95039. onAudioLockedObservable: Observable<AudioEngine>;
  95040. /**
  95041. * Flags the audio engine in Locked state.
  95042. * This happens due to new browser policies preventing audio to autoplay.
  95043. */
  95044. lock(): void;
  95045. /**
  95046. * Unlocks the audio engine once a user action has been done on the dom.
  95047. * This is helpful to resume play once browser policies have been satisfied.
  95048. */
  95049. unlock(): void;
  95050. }
  95051. /**
  95052. * This represents the default audio engine used in babylon.
  95053. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95055. */
  95056. export class AudioEngine implements IAudioEngine {
  95057. private _audioContext;
  95058. private _audioContextInitialized;
  95059. private _muteButton;
  95060. private _hostElement;
  95061. /**
  95062. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95063. */
  95064. canUseWebAudio: boolean;
  95065. /**
  95066. * The master gain node defines the global audio volume of your audio engine.
  95067. */
  95068. masterGain: GainNode;
  95069. /**
  95070. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95071. * @ignoreNaming
  95072. */
  95073. WarnedWebAudioUnsupported: boolean;
  95074. /**
  95075. * Gets whether or not mp3 are supported by your browser.
  95076. */
  95077. isMP3supported: boolean;
  95078. /**
  95079. * Gets whether or not ogg are supported by your browser.
  95080. */
  95081. isOGGsupported: boolean;
  95082. /**
  95083. * Gets whether audio has been unlocked on the device.
  95084. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95085. * a user interaction has happened.
  95086. */
  95087. unlocked: boolean;
  95088. /**
  95089. * Defines if the audio engine relies on a custom unlocked button.
  95090. * In this case, the embedded button will not be displayed.
  95091. */
  95092. useCustomUnlockedButton: boolean;
  95093. /**
  95094. * Event raised when audio has been unlocked on the browser.
  95095. */
  95096. onAudioUnlockedObservable: Observable<AudioEngine>;
  95097. /**
  95098. * Event raised when audio has been locked on the browser.
  95099. */
  95100. onAudioLockedObservable: Observable<AudioEngine>;
  95101. /**
  95102. * Gets the current AudioContext if available.
  95103. */
  95104. readonly audioContext: Nullable<AudioContext>;
  95105. private _connectedAnalyser;
  95106. /**
  95107. * Instantiates a new audio engine.
  95108. *
  95109. * There should be only one per page as some browsers restrict the number
  95110. * of audio contexts you can create.
  95111. * @param hostElement defines the host element where to display the mute icon if necessary
  95112. */
  95113. constructor(hostElement?: Nullable<HTMLElement>);
  95114. /**
  95115. * Flags the audio engine in Locked state.
  95116. * This happens due to new browser policies preventing audio to autoplay.
  95117. */
  95118. lock(): void;
  95119. /**
  95120. * Unlocks the audio engine once a user action has been done on the dom.
  95121. * This is helpful to resume play once browser policies have been satisfied.
  95122. */
  95123. unlock(): void;
  95124. private _resumeAudioContext;
  95125. private _initializeAudioContext;
  95126. private _tryToRun;
  95127. private _triggerRunningState;
  95128. private _triggerSuspendedState;
  95129. private _displayMuteButton;
  95130. private _moveButtonToTopLeft;
  95131. private _onResize;
  95132. private _hideMuteButton;
  95133. /**
  95134. * Destroy and release the resources associated with the audio ccontext.
  95135. */
  95136. dispose(): void;
  95137. /**
  95138. * Gets the global volume sets on the master gain.
  95139. * @returns the global volume if set or -1 otherwise
  95140. */
  95141. getGlobalVolume(): number;
  95142. /**
  95143. * Sets the global volume of your experience (sets on the master gain).
  95144. * @param newVolume Defines the new global volume of the application
  95145. */
  95146. setGlobalVolume(newVolume: number): void;
  95147. /**
  95148. * Connect the audio engine to an audio analyser allowing some amazing
  95149. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95151. * @param analyser The analyser to connect to the engine
  95152. */
  95153. connectToAnalyser(analyser: Analyser): void;
  95154. }
  95155. }
  95156. declare module BABYLON {
  95157. /**
  95158. * Interface used to present a loading screen while loading a scene
  95159. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95160. */
  95161. export interface ILoadingScreen {
  95162. /**
  95163. * Function called to display the loading screen
  95164. */
  95165. displayLoadingUI: () => void;
  95166. /**
  95167. * Function called to hide the loading screen
  95168. */
  95169. hideLoadingUI: () => void;
  95170. /**
  95171. * Gets or sets the color to use for the background
  95172. */
  95173. loadingUIBackgroundColor: string;
  95174. /**
  95175. * Gets or sets the text to display while loading
  95176. */
  95177. loadingUIText: string;
  95178. }
  95179. /**
  95180. * Class used for the default loading screen
  95181. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95182. */
  95183. export class DefaultLoadingScreen implements ILoadingScreen {
  95184. private _renderingCanvas;
  95185. private _loadingText;
  95186. private _loadingDivBackgroundColor;
  95187. private _loadingDiv;
  95188. private _loadingTextDiv;
  95189. /** Gets or sets the logo url to use for the default loading screen */
  95190. static DefaultLogoUrl: string;
  95191. /** Gets or sets the spinner url to use for the default loading screen */
  95192. static DefaultSpinnerUrl: string;
  95193. /**
  95194. * Creates a new default loading screen
  95195. * @param _renderingCanvas defines the canvas used to render the scene
  95196. * @param _loadingText defines the default text to display
  95197. * @param _loadingDivBackgroundColor defines the default background color
  95198. */
  95199. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95200. /**
  95201. * Function called to display the loading screen
  95202. */
  95203. displayLoadingUI(): void;
  95204. /**
  95205. * Function called to hide the loading screen
  95206. */
  95207. hideLoadingUI(): void;
  95208. /**
  95209. * Gets or sets the text to display while loading
  95210. */
  95211. loadingUIText: string;
  95212. /**
  95213. * Gets or sets the color to use for the background
  95214. */
  95215. loadingUIBackgroundColor: string;
  95216. private _resizeLoadingUI;
  95217. }
  95218. }
  95219. declare module BABYLON {
  95220. /** @hidden */
  95221. export class WebGLPipelineContext implements IPipelineContext {
  95222. engine: Engine;
  95223. program: Nullable<WebGLProgram>;
  95224. context?: WebGLRenderingContext;
  95225. vertexShader?: WebGLShader;
  95226. fragmentShader?: WebGLShader;
  95227. isParallelCompiled: boolean;
  95228. onCompiled?: () => void;
  95229. transformFeedback?: WebGLTransformFeedback | null;
  95230. readonly isAsync: boolean;
  95231. readonly isReady: boolean;
  95232. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95233. }
  95234. }
  95235. declare module BABYLON {
  95236. /** @hidden */
  95237. export class WebGLDataBuffer extends DataBuffer {
  95238. private _buffer;
  95239. constructor(resource: WebGLBuffer);
  95240. readonly underlyingResource: any;
  95241. }
  95242. }
  95243. declare module BABYLON {
  95244. /** @hidden */
  95245. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95246. attributeProcessor(attribute: string): string;
  95247. varyingProcessor(varying: string, isFragment: boolean): string;
  95248. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95249. }
  95250. }
  95251. declare module BABYLON {
  95252. /**
  95253. * This class is used to track a performance counter which is number based.
  95254. * The user has access to many properties which give statistics of different nature.
  95255. *
  95256. * The implementer can track two kinds of Performance Counter: time and count.
  95257. * 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.
  95258. * 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.
  95259. */
  95260. export class PerfCounter {
  95261. /**
  95262. * Gets or sets a global boolean to turn on and off all the counters
  95263. */
  95264. static Enabled: boolean;
  95265. /**
  95266. * Returns the smallest value ever
  95267. */
  95268. readonly min: number;
  95269. /**
  95270. * Returns the biggest value ever
  95271. */
  95272. readonly max: number;
  95273. /**
  95274. * Returns the average value since the performance counter is running
  95275. */
  95276. readonly average: number;
  95277. /**
  95278. * Returns the average value of the last second the counter was monitored
  95279. */
  95280. readonly lastSecAverage: number;
  95281. /**
  95282. * Returns the current value
  95283. */
  95284. readonly current: number;
  95285. /**
  95286. * Gets the accumulated total
  95287. */
  95288. readonly total: number;
  95289. /**
  95290. * Gets the total value count
  95291. */
  95292. readonly count: number;
  95293. /**
  95294. * Creates a new counter
  95295. */
  95296. constructor();
  95297. /**
  95298. * Call this method to start monitoring a new frame.
  95299. * 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.
  95300. */
  95301. fetchNewFrame(): void;
  95302. /**
  95303. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95304. * @param newCount the count value to add to the monitored count
  95305. * @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.
  95306. */
  95307. addCount(newCount: number, fetchResult: boolean): void;
  95308. /**
  95309. * Start monitoring this performance counter
  95310. */
  95311. beginMonitoring(): void;
  95312. /**
  95313. * Compute the time lapsed since the previous beginMonitoring() call.
  95314. * @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
  95315. */
  95316. endMonitoring(newFrame?: boolean): void;
  95317. private _fetchResult;
  95318. private _startMonitoringTime;
  95319. private _min;
  95320. private _max;
  95321. private _average;
  95322. private _current;
  95323. private _totalValueCount;
  95324. private _totalAccumulated;
  95325. private _lastSecAverage;
  95326. private _lastSecAccumulated;
  95327. private _lastSecTime;
  95328. private _lastSecValueCount;
  95329. }
  95330. }
  95331. declare module BABYLON {
  95332. /**
  95333. * Interface for any object that can request an animation frame
  95334. */
  95335. export interface ICustomAnimationFrameRequester {
  95336. /**
  95337. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95338. */
  95339. renderFunction?: Function;
  95340. /**
  95341. * Called to request the next frame to render to
  95342. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95343. */
  95344. requestAnimationFrame: Function;
  95345. /**
  95346. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95347. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95348. */
  95349. requestID?: number;
  95350. }
  95351. }
  95352. declare module BABYLON {
  95353. /**
  95354. * Settings for finer control over video usage
  95355. */
  95356. export interface VideoTextureSettings {
  95357. /**
  95358. * Applies `autoplay` to video, if specified
  95359. */
  95360. autoPlay?: boolean;
  95361. /**
  95362. * Applies `loop` to video, if specified
  95363. */
  95364. loop?: boolean;
  95365. /**
  95366. * Automatically updates internal texture from video at every frame in the render loop
  95367. */
  95368. autoUpdateTexture: boolean;
  95369. /**
  95370. * Image src displayed during the video loading or until the user interacts with the video.
  95371. */
  95372. poster?: string;
  95373. }
  95374. /**
  95375. * If you want to display a video in your scene, this is the special texture for that.
  95376. * This special texture works similar to other textures, with the exception of a few parameters.
  95377. * @see https://doc.babylonjs.com/how_to/video_texture
  95378. */
  95379. export class VideoTexture extends Texture {
  95380. /**
  95381. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95382. */
  95383. readonly autoUpdateTexture: boolean;
  95384. /**
  95385. * The video instance used by the texture internally
  95386. */
  95387. readonly video: HTMLVideoElement;
  95388. private _onUserActionRequestedObservable;
  95389. /**
  95390. * Event triggerd when a dom action is required by the user to play the video.
  95391. * This happens due to recent changes in browser policies preventing video to auto start.
  95392. */
  95393. readonly onUserActionRequestedObservable: Observable<Texture>;
  95394. private _generateMipMaps;
  95395. private _engine;
  95396. private _stillImageCaptured;
  95397. private _displayingPosterTexture;
  95398. private _settings;
  95399. private _createInternalTextureOnEvent;
  95400. private _frameId;
  95401. /**
  95402. * Creates a video texture.
  95403. * If you want to display a video in your scene, this is the special texture for that.
  95404. * This special texture works similar to other textures, with the exception of a few parameters.
  95405. * @see https://doc.babylonjs.com/how_to/video_texture
  95406. * @param name optional name, will detect from video source, if not defined
  95407. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95408. * @param scene is obviously the current scene.
  95409. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95410. * @param invertY is false by default but can be used to invert video on Y axis
  95411. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95412. * @param settings allows finer control over video usage
  95413. */
  95414. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95415. private _getName;
  95416. private _getVideo;
  95417. private _createInternalTexture;
  95418. private reset;
  95419. /**
  95420. * @hidden Internal method to initiate `update`.
  95421. */
  95422. _rebuild(): void;
  95423. /**
  95424. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95425. */
  95426. update(): void;
  95427. /**
  95428. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95429. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95430. */
  95431. updateTexture(isVisible: boolean): void;
  95432. protected _updateInternalTexture: () => void;
  95433. /**
  95434. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95435. * @param url New url.
  95436. */
  95437. updateURL(url: string): void;
  95438. /**
  95439. * Dispose the texture and release its associated resources.
  95440. */
  95441. dispose(): void;
  95442. /**
  95443. * Creates a video texture straight from a stream.
  95444. * @param scene Define the scene the texture should be created in
  95445. * @param stream Define the stream the texture should be created from
  95446. * @returns The created video texture as a promise
  95447. */
  95448. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95449. /**
  95450. * Creates a video texture straight from your WebCam video feed.
  95451. * @param scene Define the scene the texture should be created in
  95452. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95453. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95454. * @returns The created video texture as a promise
  95455. */
  95456. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95457. minWidth: number;
  95458. maxWidth: number;
  95459. minHeight: number;
  95460. maxHeight: number;
  95461. deviceId: string;
  95462. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95463. /**
  95464. * Creates a video texture straight from your WebCam video feed.
  95465. * @param scene Define the scene the texture should be created in
  95466. * @param onReady Define a callback to triggered once the texture will be ready
  95467. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95468. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95469. */
  95470. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95471. minWidth: number;
  95472. maxWidth: number;
  95473. minHeight: number;
  95474. maxHeight: number;
  95475. deviceId: string;
  95476. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95477. }
  95478. }
  95479. declare module BABYLON {
  95480. /**
  95481. * Defines the interface used by objects containing a viewport (like a camera)
  95482. */
  95483. interface IViewportOwnerLike {
  95484. /**
  95485. * Gets or sets the viewport
  95486. */
  95487. viewport: IViewportLike;
  95488. }
  95489. /**
  95490. * Interface for attribute information associated with buffer instanciation
  95491. */
  95492. export class InstancingAttributeInfo {
  95493. /**
  95494. * Index/offset of the attribute in the vertex shader
  95495. */
  95496. index: number;
  95497. /**
  95498. * size of the attribute, 1, 2, 3 or 4
  95499. */
  95500. attributeSize: number;
  95501. /**
  95502. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95503. * default is FLOAT
  95504. */
  95505. attribyteType: number;
  95506. /**
  95507. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95508. */
  95509. normalized: boolean;
  95510. /**
  95511. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95512. */
  95513. offset: number;
  95514. /**
  95515. * Name of the GLSL attribute, for debugging purpose only
  95516. */
  95517. attributeName: string;
  95518. }
  95519. /**
  95520. * Define options used to create a depth texture
  95521. */
  95522. export class DepthTextureCreationOptions {
  95523. /** Specifies whether or not a stencil should be allocated in the texture */
  95524. generateStencil?: boolean;
  95525. /** Specifies whether or not bilinear filtering is enable on the texture */
  95526. bilinearFiltering?: boolean;
  95527. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95528. comparisonFunction?: number;
  95529. /** Specifies if the created texture is a cube texture */
  95530. isCube?: boolean;
  95531. }
  95532. /**
  95533. * Class used to describe the capabilities of the engine relatively to the current browser
  95534. */
  95535. export class EngineCapabilities {
  95536. /** Maximum textures units per fragment shader */
  95537. maxTexturesImageUnits: number;
  95538. /** Maximum texture units per vertex shader */
  95539. maxVertexTextureImageUnits: number;
  95540. /** Maximum textures units in the entire pipeline */
  95541. maxCombinedTexturesImageUnits: number;
  95542. /** Maximum texture size */
  95543. maxTextureSize: number;
  95544. /** Maximum cube texture size */
  95545. maxCubemapTextureSize: number;
  95546. /** Maximum render texture size */
  95547. maxRenderTextureSize: number;
  95548. /** Maximum number of vertex attributes */
  95549. maxVertexAttribs: number;
  95550. /** Maximum number of varyings */
  95551. maxVaryingVectors: number;
  95552. /** Maximum number of uniforms per vertex shader */
  95553. maxVertexUniformVectors: number;
  95554. /** Maximum number of uniforms per fragment shader */
  95555. maxFragmentUniformVectors: number;
  95556. /** Defines if standard derivates (dx/dy) are supported */
  95557. standardDerivatives: boolean;
  95558. /** Defines if s3tc texture compression is supported */
  95559. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95560. /** Defines if pvrtc texture compression is supported */
  95561. pvrtc: any;
  95562. /** Defines if etc1 texture compression is supported */
  95563. etc1: any;
  95564. /** Defines if etc2 texture compression is supported */
  95565. etc2: any;
  95566. /** Defines if astc texture compression is supported */
  95567. astc: any;
  95568. /** Defines if float textures are supported */
  95569. textureFloat: boolean;
  95570. /** Defines if vertex array objects are supported */
  95571. vertexArrayObject: boolean;
  95572. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95573. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95574. /** Gets the maximum level of anisotropy supported */
  95575. maxAnisotropy: number;
  95576. /** Defines if instancing is supported */
  95577. instancedArrays: boolean;
  95578. /** Defines if 32 bits indices are supported */
  95579. uintIndices: boolean;
  95580. /** Defines if high precision shaders are supported */
  95581. highPrecisionShaderSupported: boolean;
  95582. /** Defines if depth reading in the fragment shader is supported */
  95583. fragmentDepthSupported: boolean;
  95584. /** Defines if float texture linear filtering is supported*/
  95585. textureFloatLinearFiltering: boolean;
  95586. /** Defines if rendering to float textures is supported */
  95587. textureFloatRender: boolean;
  95588. /** Defines if half float textures are supported*/
  95589. textureHalfFloat: boolean;
  95590. /** Defines if half float texture linear filtering is supported*/
  95591. textureHalfFloatLinearFiltering: boolean;
  95592. /** Defines if rendering to half float textures is supported */
  95593. textureHalfFloatRender: boolean;
  95594. /** Defines if textureLOD shader command is supported */
  95595. textureLOD: boolean;
  95596. /** Defines if draw buffers extension is supported */
  95597. drawBuffersExtension: boolean;
  95598. /** Defines if depth textures are supported */
  95599. depthTextureExtension: boolean;
  95600. /** Defines if float color buffer are supported */
  95601. colorBufferFloat: boolean;
  95602. /** Gets disjoint timer query extension (null if not supported) */
  95603. timerQuery: EXT_disjoint_timer_query;
  95604. /** Defines if timestamp can be used with timer query */
  95605. canUseTimestampForTimerQuery: boolean;
  95606. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95607. multiview: any;
  95608. /** Function used to let the system compiles shaders in background */
  95609. parallelShaderCompile: {
  95610. COMPLETION_STATUS_KHR: number;
  95611. };
  95612. /** Max number of texture samples for MSAA */
  95613. maxMSAASamples: number;
  95614. }
  95615. /** Interface defining initialization parameters for Engine class */
  95616. export interface EngineOptions extends WebGLContextAttributes {
  95617. /**
  95618. * Defines if the engine should no exceed a specified device ratio
  95619. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95620. */
  95621. limitDeviceRatio?: number;
  95622. /**
  95623. * Defines if webvr should be enabled automatically
  95624. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95625. */
  95626. autoEnableWebVR?: boolean;
  95627. /**
  95628. * Defines if webgl2 should be turned off even if supported
  95629. * @see http://doc.babylonjs.com/features/webgl2
  95630. */
  95631. disableWebGL2Support?: boolean;
  95632. /**
  95633. * Defines if webaudio should be initialized as well
  95634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95635. */
  95636. audioEngine?: boolean;
  95637. /**
  95638. * Defines if animations should run using a deterministic lock step
  95639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95640. */
  95641. deterministicLockstep?: boolean;
  95642. /** Defines the maximum steps to use with deterministic lock step mode */
  95643. lockstepMaxSteps?: number;
  95644. /**
  95645. * Defines that engine should ignore context lost events
  95646. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95647. */
  95648. doNotHandleContextLost?: boolean;
  95649. /**
  95650. * Defines that engine should ignore modifying touch action attribute and style
  95651. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95652. */
  95653. doNotHandleTouchAction?: boolean;
  95654. /**
  95655. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95656. */
  95657. useHighPrecisionFloats?: boolean;
  95658. }
  95659. /**
  95660. * Defines the interface used by display changed events
  95661. */
  95662. export interface IDisplayChangedEventArgs {
  95663. /** Gets the vrDisplay object (if any) */
  95664. vrDisplay: Nullable<any>;
  95665. /** Gets a boolean indicating if webVR is supported */
  95666. vrSupported: boolean;
  95667. }
  95668. /**
  95669. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95670. */
  95671. export class Engine {
  95672. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95673. static ExceptionList: ({
  95674. key: string;
  95675. capture: string;
  95676. captureConstraint: number;
  95677. targets: string[];
  95678. } | {
  95679. key: string;
  95680. capture: null;
  95681. captureConstraint: null;
  95682. targets: string[];
  95683. })[];
  95684. /** Gets the list of created engines */
  95685. static readonly Instances: Engine[];
  95686. /**
  95687. * Gets the latest created engine
  95688. */
  95689. static readonly LastCreatedEngine: Nullable<Engine>;
  95690. /**
  95691. * Gets the latest created scene
  95692. */
  95693. static readonly LastCreatedScene: Nullable<Scene>;
  95694. /**
  95695. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95696. * @param flag defines which part of the materials must be marked as dirty
  95697. * @param predicate defines a predicate used to filter which materials should be affected
  95698. */
  95699. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95700. /** @hidden */
  95701. static _TextureLoaders: IInternalTextureLoader[];
  95702. /** Defines that alpha blending is disabled */
  95703. static readonly ALPHA_DISABLE: number;
  95704. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95705. static readonly ALPHA_ADD: number;
  95706. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95707. static readonly ALPHA_COMBINE: number;
  95708. /** Defines that alpha blending to DEST - SRC * DEST */
  95709. static readonly ALPHA_SUBTRACT: number;
  95710. /** Defines that alpha blending to SRC * DEST */
  95711. static readonly ALPHA_MULTIPLY: number;
  95712. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95713. static readonly ALPHA_MAXIMIZED: number;
  95714. /** Defines that alpha blending to SRC + DEST */
  95715. static readonly ALPHA_ONEONE: number;
  95716. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95717. static readonly ALPHA_PREMULTIPLIED: number;
  95718. /**
  95719. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95720. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95721. */
  95722. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95723. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95724. static readonly ALPHA_INTERPOLATE: number;
  95725. /**
  95726. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95727. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95728. */
  95729. static readonly ALPHA_SCREENMODE: number;
  95730. /** Defines that the ressource is not delayed*/
  95731. static readonly DELAYLOADSTATE_NONE: number;
  95732. /** Defines that the ressource was successfully delay loaded */
  95733. static readonly DELAYLOADSTATE_LOADED: number;
  95734. /** Defines that the ressource is currently delay loading */
  95735. static readonly DELAYLOADSTATE_LOADING: number;
  95736. /** Defines that the ressource is delayed and has not started loading */
  95737. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95738. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95739. static readonly NEVER: number;
  95740. /** 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 */
  95741. static readonly ALWAYS: number;
  95742. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95743. static readonly LESS: number;
  95744. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95745. static readonly EQUAL: number;
  95746. /** 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 */
  95747. static readonly LEQUAL: number;
  95748. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95749. static readonly GREATER: number;
  95750. /** 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 */
  95751. static readonly GEQUAL: number;
  95752. /** 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 */
  95753. static readonly NOTEQUAL: number;
  95754. /** Passed to stencilOperation to specify that stencil value must be kept */
  95755. static readonly KEEP: number;
  95756. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95757. static readonly REPLACE: number;
  95758. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95759. static readonly INCR: number;
  95760. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95761. static readonly DECR: number;
  95762. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95763. static readonly INVERT: number;
  95764. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95765. static readonly INCR_WRAP: number;
  95766. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95767. static readonly DECR_WRAP: number;
  95768. /** Texture is not repeating outside of 0..1 UVs */
  95769. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95770. /** Texture is repeating outside of 0..1 UVs */
  95771. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95772. /** Texture is repeating and mirrored */
  95773. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95774. /** ALPHA */
  95775. static readonly TEXTUREFORMAT_ALPHA: number;
  95776. /** LUMINANCE */
  95777. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95778. /** LUMINANCE_ALPHA */
  95779. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95780. /** RGB */
  95781. static readonly TEXTUREFORMAT_RGB: number;
  95782. /** RGBA */
  95783. static readonly TEXTUREFORMAT_RGBA: number;
  95784. /** RED */
  95785. static readonly TEXTUREFORMAT_RED: number;
  95786. /** RED (2nd reference) */
  95787. static readonly TEXTUREFORMAT_R: number;
  95788. /** RG */
  95789. static readonly TEXTUREFORMAT_RG: number;
  95790. /** RED_INTEGER */
  95791. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95792. /** RED_INTEGER (2nd reference) */
  95793. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95794. /** RG_INTEGER */
  95795. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95796. /** RGB_INTEGER */
  95797. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95798. /** RGBA_INTEGER */
  95799. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95800. /** UNSIGNED_BYTE */
  95801. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95802. /** UNSIGNED_BYTE (2nd reference) */
  95803. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95804. /** FLOAT */
  95805. static readonly TEXTURETYPE_FLOAT: number;
  95806. /** HALF_FLOAT */
  95807. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95808. /** BYTE */
  95809. static readonly TEXTURETYPE_BYTE: number;
  95810. /** SHORT */
  95811. static readonly TEXTURETYPE_SHORT: number;
  95812. /** UNSIGNED_SHORT */
  95813. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95814. /** INT */
  95815. static readonly TEXTURETYPE_INT: number;
  95816. /** UNSIGNED_INT */
  95817. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95818. /** UNSIGNED_SHORT_4_4_4_4 */
  95819. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95820. /** UNSIGNED_SHORT_5_5_5_1 */
  95821. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95822. /** UNSIGNED_SHORT_5_6_5 */
  95823. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95824. /** UNSIGNED_INT_2_10_10_10_REV */
  95825. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95826. /** UNSIGNED_INT_24_8 */
  95827. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95828. /** UNSIGNED_INT_10F_11F_11F_REV */
  95829. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95830. /** UNSIGNED_INT_5_9_9_9_REV */
  95831. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95832. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95833. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95834. /** nearest is mag = nearest and min = nearest and mip = linear */
  95835. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95836. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95837. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95838. /** Trilinear is mag = linear and min = linear and mip = linear */
  95839. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95840. /** nearest is mag = nearest and min = nearest and mip = linear */
  95841. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95842. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95843. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95844. /** Trilinear is mag = linear and min = linear and mip = linear */
  95845. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95846. /** mag = nearest and min = nearest and mip = nearest */
  95847. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95848. /** mag = nearest and min = linear and mip = nearest */
  95849. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95850. /** mag = nearest and min = linear and mip = linear */
  95851. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95852. /** mag = nearest and min = linear and mip = none */
  95853. static readonly TEXTURE_NEAREST_LINEAR: number;
  95854. /** mag = nearest and min = nearest and mip = none */
  95855. static readonly TEXTURE_NEAREST_NEAREST: number;
  95856. /** mag = linear and min = nearest and mip = nearest */
  95857. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95858. /** mag = linear and min = nearest and mip = linear */
  95859. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95860. /** mag = linear and min = linear and mip = none */
  95861. static readonly TEXTURE_LINEAR_LINEAR: number;
  95862. /** mag = linear and min = nearest and mip = none */
  95863. static readonly TEXTURE_LINEAR_NEAREST: number;
  95864. /** Explicit coordinates mode */
  95865. static readonly TEXTURE_EXPLICIT_MODE: number;
  95866. /** Spherical coordinates mode */
  95867. static readonly TEXTURE_SPHERICAL_MODE: number;
  95868. /** Planar coordinates mode */
  95869. static readonly TEXTURE_PLANAR_MODE: number;
  95870. /** Cubic coordinates mode */
  95871. static readonly TEXTURE_CUBIC_MODE: number;
  95872. /** Projection coordinates mode */
  95873. static readonly TEXTURE_PROJECTION_MODE: number;
  95874. /** Skybox coordinates mode */
  95875. static readonly TEXTURE_SKYBOX_MODE: number;
  95876. /** Inverse Cubic coordinates mode */
  95877. static readonly TEXTURE_INVCUBIC_MODE: number;
  95878. /** Equirectangular coordinates mode */
  95879. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95880. /** Equirectangular Fixed coordinates mode */
  95881. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95882. /** Equirectangular Fixed Mirrored coordinates mode */
  95883. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95884. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95885. static readonly SCALEMODE_FLOOR: number;
  95886. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95887. static readonly SCALEMODE_NEAREST: number;
  95888. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95889. static readonly SCALEMODE_CEILING: number;
  95890. /**
  95891. * Returns the current npm package of the sdk
  95892. */
  95893. static readonly NpmPackage: string;
  95894. /**
  95895. * Returns the current version of the framework
  95896. */
  95897. static readonly Version: string;
  95898. /**
  95899. * Returns a string describing the current engine
  95900. */
  95901. readonly description: string;
  95902. /**
  95903. * Gets or sets the epsilon value used by collision engine
  95904. */
  95905. static CollisionsEpsilon: number;
  95906. /**
  95907. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95908. */
  95909. static ShadersRepository: string;
  95910. /**
  95911. * Method called to create the default loading screen.
  95912. * This can be overriden in your own app.
  95913. * @param canvas The rendering canvas element
  95914. * @returns The loading screen
  95915. */
  95916. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95917. /**
  95918. * Method called to create the default rescale post process on each engine.
  95919. */
  95920. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95921. /** @hidden */
  95922. _shaderProcessor: IShaderProcessor;
  95923. /**
  95924. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95925. */
  95926. forcePOTTextures: boolean;
  95927. /**
  95928. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95929. */
  95930. isFullscreen: boolean;
  95931. /**
  95932. * Gets a boolean indicating if the pointer is currently locked
  95933. */
  95934. isPointerLock: boolean;
  95935. /**
  95936. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95937. */
  95938. cullBackFaces: boolean;
  95939. /**
  95940. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95941. */
  95942. renderEvenInBackground: boolean;
  95943. /**
  95944. * Gets or sets a boolean indicating that cache can be kept between frames
  95945. */
  95946. preventCacheWipeBetweenFrames: boolean;
  95947. /**
  95948. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95949. **/
  95950. enableOfflineSupport: boolean;
  95951. /**
  95952. * 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)
  95953. **/
  95954. disableManifestCheck: boolean;
  95955. /**
  95956. * Gets the list of created scenes
  95957. */
  95958. scenes: Scene[];
  95959. /**
  95960. * Event raised when a new scene is created
  95961. */
  95962. onNewSceneAddedObservable: Observable<Scene>;
  95963. /**
  95964. * Gets the list of created postprocesses
  95965. */
  95966. postProcesses: PostProcess[];
  95967. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95968. validateShaderPrograms: boolean;
  95969. /**
  95970. * Observable event triggered each time the rendering canvas is resized
  95971. */
  95972. onResizeObservable: Observable<Engine>;
  95973. /**
  95974. * Observable event triggered each time the canvas loses focus
  95975. */
  95976. onCanvasBlurObservable: Observable<Engine>;
  95977. /**
  95978. * Observable event triggered each time the canvas gains focus
  95979. */
  95980. onCanvasFocusObservable: Observable<Engine>;
  95981. /**
  95982. * Observable event triggered each time the canvas receives pointerout event
  95983. */
  95984. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95985. /**
  95986. * Observable event triggered before each texture is initialized
  95987. */
  95988. onBeforeTextureInitObservable: Observable<Texture>;
  95989. /**
  95990. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95991. */
  95992. disableUniformBuffers: boolean;
  95993. /** @hidden */
  95994. _uniformBuffers: UniformBuffer[];
  95995. /**
  95996. * Gets a boolean indicating that the engine supports uniform buffers
  95997. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95998. */
  95999. readonly supportsUniformBuffers: boolean;
  96000. /**
  96001. * Observable raised when the engine begins a new frame
  96002. */
  96003. onBeginFrameObservable: Observable<Engine>;
  96004. /**
  96005. * If set, will be used to request the next animation frame for the render loop
  96006. */
  96007. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  96008. /**
  96009. * Observable raised when the engine ends the current frame
  96010. */
  96011. onEndFrameObservable: Observable<Engine>;
  96012. /**
  96013. * Observable raised when the engine is about to compile a shader
  96014. */
  96015. onBeforeShaderCompilationObservable: Observable<Engine>;
  96016. /**
  96017. * Observable raised when the engine has jsut compiled a shader
  96018. */
  96019. onAfterShaderCompilationObservable: Observable<Engine>;
  96020. /** @hidden */
  96021. _gl: WebGLRenderingContext;
  96022. private _renderingCanvas;
  96023. private _windowIsBackground;
  96024. protected _webGLVersion: number;
  96025. protected _highPrecisionShadersAllowed: boolean;
  96026. /** @hidden */
  96027. readonly _shouldUseHighPrecisionShader: boolean;
  96028. /**
  96029. * Gets a boolean indicating that only power of 2 textures are supported
  96030. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96031. */
  96032. readonly needPOTTextures: boolean;
  96033. /** @hidden */
  96034. _badOS: boolean;
  96035. /** @hidden */
  96036. _badDesktopOS: boolean;
  96037. /**
  96038. * Gets the audio engine
  96039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96040. * @ignorenaming
  96041. */
  96042. static audioEngine: IAudioEngine;
  96043. /**
  96044. * Default AudioEngine factory responsible of creating the Audio Engine.
  96045. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96046. */
  96047. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96048. /**
  96049. * Default offline support factory responsible of creating a tool used to store data locally.
  96050. * By default, this will create a Database object if the workload has been embedded.
  96051. */
  96052. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96053. private _onFocus;
  96054. private _onBlur;
  96055. private _onCanvasPointerOut;
  96056. private _onCanvasBlur;
  96057. private _onCanvasFocus;
  96058. private _onFullscreenChange;
  96059. private _onPointerLockChange;
  96060. private _hardwareScalingLevel;
  96061. /** @hidden */
  96062. _caps: EngineCapabilities;
  96063. private _pointerLockRequested;
  96064. private _isStencilEnable;
  96065. protected _colorWrite: boolean;
  96066. private _loadingScreen;
  96067. /** @hidden */
  96068. _drawCalls: PerfCounter;
  96069. private _glVersion;
  96070. private _glRenderer;
  96071. private _glVendor;
  96072. private _videoTextureSupported;
  96073. private _renderingQueueLaunched;
  96074. private _activeRenderLoops;
  96075. private _deterministicLockstep;
  96076. private _lockstepMaxSteps;
  96077. /**
  96078. * Observable signaled when a context lost event is raised
  96079. */
  96080. onContextLostObservable: Observable<Engine>;
  96081. /**
  96082. * Observable signaled when a context restored event is raised
  96083. */
  96084. onContextRestoredObservable: Observable<Engine>;
  96085. private _onContextLost;
  96086. private _onContextRestored;
  96087. private _contextWasLost;
  96088. /** @hidden */
  96089. _doNotHandleContextLost: boolean;
  96090. /**
  96091. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96093. */
  96094. doNotHandleContextLost: boolean;
  96095. private _performanceMonitor;
  96096. private _fps;
  96097. private _deltaTime;
  96098. /**
  96099. * Turn this value on if you want to pause FPS computation when in background
  96100. */
  96101. disablePerformanceMonitorInBackground: boolean;
  96102. /**
  96103. * Gets the performance monitor attached to this engine
  96104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96105. */
  96106. readonly performanceMonitor: PerformanceMonitor;
  96107. /**
  96108. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96109. */
  96110. disableVertexArrayObjects: boolean;
  96111. /** @hidden */
  96112. protected _depthCullingState: _DepthCullingState;
  96113. /** @hidden */
  96114. protected _stencilState: _StencilState;
  96115. /** @hidden */
  96116. protected _alphaState: _AlphaState;
  96117. /** @hidden */
  96118. protected _alphaMode: number;
  96119. /** @hidden */
  96120. _internalTexturesCache: InternalTexture[];
  96121. /** @hidden */
  96122. protected _activeChannel: number;
  96123. private _currentTextureChannel;
  96124. /** @hidden */
  96125. protected _boundTexturesCache: {
  96126. [key: string]: Nullable<InternalTexture>;
  96127. };
  96128. /** @hidden */
  96129. protected _currentEffect: Nullable<Effect>;
  96130. /** @hidden */
  96131. protected _currentProgram: Nullable<WebGLProgram>;
  96132. private _compiledEffects;
  96133. private _vertexAttribArraysEnabled;
  96134. /** @hidden */
  96135. protected _cachedViewport: Nullable<IViewportLike>;
  96136. private _cachedVertexArrayObject;
  96137. /** @hidden */
  96138. protected _cachedVertexBuffers: any;
  96139. /** @hidden */
  96140. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96141. /** @hidden */
  96142. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96143. /** @hidden */
  96144. _currentRenderTarget: Nullable<InternalTexture>;
  96145. private _uintIndicesCurrentlySet;
  96146. private _currentBoundBuffer;
  96147. /** @hidden */
  96148. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96149. private _currentBufferPointers;
  96150. private _currentInstanceLocations;
  96151. private _currentInstanceBuffers;
  96152. private _textureUnits;
  96153. /** @hidden */
  96154. _workingCanvas: Nullable<HTMLCanvasElement>;
  96155. /** @hidden */
  96156. _workingContext: Nullable<CanvasRenderingContext2D>;
  96157. private _rescalePostProcess;
  96158. private _dummyFramebuffer;
  96159. private _externalData;
  96160. /** @hidden */
  96161. _bindedRenderFunction: any;
  96162. private _vaoRecordInProgress;
  96163. private _mustWipeVertexAttributes;
  96164. private _emptyTexture;
  96165. private _emptyCubeTexture;
  96166. private _emptyTexture3D;
  96167. /** @hidden */
  96168. _frameHandler: number;
  96169. private _nextFreeTextureSlots;
  96170. private _maxSimultaneousTextures;
  96171. private _activeRequests;
  96172. private _texturesSupported;
  96173. /** @hidden */
  96174. _textureFormatInUse: Nullable<string>;
  96175. /**
  96176. * Gets the list of texture formats supported
  96177. */
  96178. readonly texturesSupported: Array<string>;
  96179. /**
  96180. * Gets the list of texture formats in use
  96181. */
  96182. readonly textureFormatInUse: Nullable<string>;
  96183. /**
  96184. * Gets the current viewport
  96185. */
  96186. readonly currentViewport: Nullable<IViewportLike>;
  96187. /**
  96188. * Gets the default empty texture
  96189. */
  96190. readonly emptyTexture: InternalTexture;
  96191. /**
  96192. * Gets the default empty 3D texture
  96193. */
  96194. readonly emptyTexture3D: InternalTexture;
  96195. /**
  96196. * Gets the default empty cube texture
  96197. */
  96198. readonly emptyCubeTexture: InternalTexture;
  96199. /**
  96200. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96201. */
  96202. readonly premultipliedAlpha: boolean;
  96203. /**
  96204. * Creates a new engine
  96205. * @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
  96206. * @param antialias defines enable antialiasing (default: false)
  96207. * @param options defines further options to be sent to the getContext() function
  96208. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96209. */
  96210. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96211. /**
  96212. * Initializes a webVR display and starts listening to display change events
  96213. * The onVRDisplayChangedObservable will be notified upon these changes
  96214. * @returns The onVRDisplayChangedObservable
  96215. */
  96216. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96217. /** @hidden */
  96218. _prepareVRComponent(): void;
  96219. /** @hidden */
  96220. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96221. /** @hidden */
  96222. _submitVRFrame(): void;
  96223. /**
  96224. * Call this function to leave webVR mode
  96225. * Will do nothing if webVR is not supported or if there is no webVR device
  96226. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96227. */
  96228. disableVR(): void;
  96229. /**
  96230. * Gets a boolean indicating that the system is in VR mode and is presenting
  96231. * @returns true if VR mode is engaged
  96232. */
  96233. isVRPresenting(): boolean;
  96234. /** @hidden */
  96235. _requestVRFrame(): void;
  96236. private _disableTouchAction;
  96237. private _rebuildInternalTextures;
  96238. private _rebuildEffects;
  96239. /**
  96240. * Gets a boolean indicating if all created effects are ready
  96241. * @returns true if all effects are ready
  96242. */
  96243. areAllEffectsReady(): boolean;
  96244. private _rebuildBuffers;
  96245. private _initGLContext;
  96246. /**
  96247. * Gets version of the current webGL context
  96248. */
  96249. readonly webGLVersion: number;
  96250. /**
  96251. * Gets a string idenfifying the name of the class
  96252. * @returns "Engine" string
  96253. */
  96254. getClassName(): string;
  96255. /**
  96256. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96257. */
  96258. readonly isStencilEnable: boolean;
  96259. /** @hidden */
  96260. _prepareWorkingCanvas(): void;
  96261. /**
  96262. * Reset the texture cache to empty state
  96263. */
  96264. resetTextureCache(): void;
  96265. /**
  96266. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96267. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96268. * @returns true if engine is in deterministic lock step mode
  96269. */
  96270. isDeterministicLockStep(): boolean;
  96271. /**
  96272. * Gets the max steps when engine is running in deterministic lock step
  96273. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96274. * @returns the max steps
  96275. */
  96276. getLockstepMaxSteps(): number;
  96277. /**
  96278. * Gets an object containing information about the current webGL context
  96279. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96280. */
  96281. getGlInfo(): {
  96282. vendor: string;
  96283. renderer: string;
  96284. version: string;
  96285. };
  96286. /**
  96287. * Gets current aspect ratio
  96288. * @param viewportOwner defines the camera to use to get the aspect ratio
  96289. * @param useScreen defines if screen size must be used (or the current render target if any)
  96290. * @returns a number defining the aspect ratio
  96291. */
  96292. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96293. /**
  96294. * Gets current screen aspect ratio
  96295. * @returns a number defining the aspect ratio
  96296. */
  96297. getScreenAspectRatio(): number;
  96298. /**
  96299. * Gets the current render width
  96300. * @param useScreen defines if screen size must be used (or the current render target if any)
  96301. * @returns a number defining the current render width
  96302. */
  96303. getRenderWidth(useScreen?: boolean): number;
  96304. /**
  96305. * Gets the current render height
  96306. * @param useScreen defines if screen size must be used (or the current render target if any)
  96307. * @returns a number defining the current render height
  96308. */
  96309. getRenderHeight(useScreen?: boolean): number;
  96310. /**
  96311. * Gets the HTML canvas attached with the current webGL context
  96312. * @returns a HTML canvas
  96313. */
  96314. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96315. /**
  96316. * Gets host window
  96317. * @returns the host window object
  96318. */
  96319. getHostWindow(): Window;
  96320. /**
  96321. * Gets host document
  96322. * @returns the host document object
  96323. */
  96324. getHostDocument(): Document;
  96325. /**
  96326. * Gets the client rect of the HTML canvas attached with the current webGL context
  96327. * @returns a client rectanglee
  96328. */
  96329. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96330. /**
  96331. * Defines the hardware scaling level.
  96332. * By default the hardware scaling level is computed from the window device ratio.
  96333. * 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.
  96334. * @param level defines the level to use
  96335. */
  96336. setHardwareScalingLevel(level: number): void;
  96337. /**
  96338. * Gets the current hardware scaling level.
  96339. * By default the hardware scaling level is computed from the window device ratio.
  96340. * 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.
  96341. * @returns a number indicating the current hardware scaling level
  96342. */
  96343. getHardwareScalingLevel(): number;
  96344. /**
  96345. * Gets the list of loaded textures
  96346. * @returns an array containing all loaded textures
  96347. */
  96348. getLoadedTexturesCache(): InternalTexture[];
  96349. /**
  96350. * Gets the object containing all engine capabilities
  96351. * @returns the EngineCapabilities object
  96352. */
  96353. getCaps(): EngineCapabilities;
  96354. /**
  96355. * Gets the current depth function
  96356. * @returns a number defining the depth function
  96357. */
  96358. getDepthFunction(): Nullable<number>;
  96359. /**
  96360. * Sets the current depth function
  96361. * @param depthFunc defines the function to use
  96362. */
  96363. setDepthFunction(depthFunc: number): void;
  96364. /**
  96365. * Sets the current depth function to GREATER
  96366. */
  96367. setDepthFunctionToGreater(): void;
  96368. /**
  96369. * Sets the current depth function to GEQUAL
  96370. */
  96371. setDepthFunctionToGreaterOrEqual(): void;
  96372. /**
  96373. * Sets the current depth function to LESS
  96374. */
  96375. setDepthFunctionToLess(): void;
  96376. private _cachedStencilBuffer;
  96377. private _cachedStencilFunction;
  96378. private _cachedStencilMask;
  96379. private _cachedStencilOperationPass;
  96380. private _cachedStencilOperationFail;
  96381. private _cachedStencilOperationDepthFail;
  96382. private _cachedStencilReference;
  96383. /**
  96384. * Caches the the state of the stencil buffer
  96385. */
  96386. cacheStencilState(): void;
  96387. /**
  96388. * Restores the state of the stencil buffer
  96389. */
  96390. restoreStencilState(): void;
  96391. /**
  96392. * Sets the current depth function to LEQUAL
  96393. */
  96394. setDepthFunctionToLessOrEqual(): void;
  96395. /**
  96396. * Gets a boolean indicating if stencil buffer is enabled
  96397. * @returns the current stencil buffer state
  96398. */
  96399. getStencilBuffer(): boolean;
  96400. /**
  96401. * Enable or disable the stencil buffer
  96402. * @param enable defines if the stencil buffer must be enabled or disabled
  96403. */
  96404. setStencilBuffer(enable: boolean): void;
  96405. /**
  96406. * Gets the current stencil mask
  96407. * @returns a number defining the new stencil mask to use
  96408. */
  96409. getStencilMask(): number;
  96410. /**
  96411. * Sets the current stencil mask
  96412. * @param mask defines the new stencil mask to use
  96413. */
  96414. setStencilMask(mask: number): void;
  96415. /**
  96416. * Gets the current stencil function
  96417. * @returns a number defining the stencil function to use
  96418. */
  96419. getStencilFunction(): number;
  96420. /**
  96421. * Gets the current stencil reference value
  96422. * @returns a number defining the stencil reference value to use
  96423. */
  96424. getStencilFunctionReference(): number;
  96425. /**
  96426. * Gets the current stencil mask
  96427. * @returns a number defining the stencil mask to use
  96428. */
  96429. getStencilFunctionMask(): number;
  96430. /**
  96431. * Sets the current stencil function
  96432. * @param stencilFunc defines the new stencil function to use
  96433. */
  96434. setStencilFunction(stencilFunc: number): void;
  96435. /**
  96436. * Sets the current stencil reference
  96437. * @param reference defines the new stencil reference to use
  96438. */
  96439. setStencilFunctionReference(reference: number): void;
  96440. /**
  96441. * Sets the current stencil mask
  96442. * @param mask defines the new stencil mask to use
  96443. */
  96444. setStencilFunctionMask(mask: number): void;
  96445. /**
  96446. * Gets the current stencil operation when stencil fails
  96447. * @returns a number defining stencil operation to use when stencil fails
  96448. */
  96449. getStencilOperationFail(): number;
  96450. /**
  96451. * Gets the current stencil operation when depth fails
  96452. * @returns a number defining stencil operation to use when depth fails
  96453. */
  96454. getStencilOperationDepthFail(): number;
  96455. /**
  96456. * Gets the current stencil operation when stencil passes
  96457. * @returns a number defining stencil operation to use when stencil passes
  96458. */
  96459. getStencilOperationPass(): number;
  96460. /**
  96461. * Sets the stencil operation to use when stencil fails
  96462. * @param operation defines the stencil operation to use when stencil fails
  96463. */
  96464. setStencilOperationFail(operation: number): void;
  96465. /**
  96466. * Sets the stencil operation to use when depth fails
  96467. * @param operation defines the stencil operation to use when depth fails
  96468. */
  96469. setStencilOperationDepthFail(operation: number): void;
  96470. /**
  96471. * Sets the stencil operation to use when stencil passes
  96472. * @param operation defines the stencil operation to use when stencil passes
  96473. */
  96474. setStencilOperationPass(operation: number): void;
  96475. /**
  96476. * Sets a boolean indicating if the dithering state is enabled or disabled
  96477. * @param value defines the dithering state
  96478. */
  96479. setDitheringState(value: boolean): void;
  96480. /**
  96481. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96482. * @param value defines the rasterizer state
  96483. */
  96484. setRasterizerState(value: boolean): void;
  96485. /**
  96486. * stop executing a render loop function and remove it from the execution array
  96487. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96488. */
  96489. stopRenderLoop(renderFunction?: () => void): void;
  96490. /** @hidden */
  96491. _renderLoop(): void;
  96492. /**
  96493. * Can be used to override the current requestAnimationFrame requester.
  96494. * @hidden
  96495. */
  96496. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96497. /**
  96498. * Register and execute a render loop. The engine can have more than one render function
  96499. * @param renderFunction defines the function to continuously execute
  96500. */
  96501. runRenderLoop(renderFunction: () => void): void;
  96502. /**
  96503. * Toggle full screen mode
  96504. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96505. */
  96506. switchFullscreen(requestPointerLock: boolean): void;
  96507. /**
  96508. * Enters full screen mode
  96509. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96510. */
  96511. enterFullscreen(requestPointerLock: boolean): void;
  96512. /**
  96513. * Exits full screen mode
  96514. */
  96515. exitFullscreen(): void;
  96516. /**
  96517. * Enters Pointerlock mode
  96518. */
  96519. enterPointerlock(): void;
  96520. /**
  96521. * Exits Pointerlock mode
  96522. */
  96523. exitPointerlock(): void;
  96524. /**
  96525. * Clear the current render buffer or the current render target (if any is set up)
  96526. * @param color defines the color to use
  96527. * @param backBuffer defines if the back buffer must be cleared
  96528. * @param depth defines if the depth buffer must be cleared
  96529. * @param stencil defines if the stencil buffer must be cleared
  96530. */
  96531. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96532. /**
  96533. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96534. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96535. * @param y defines the y-coordinate of the corner of the clear rectangle
  96536. * @param width defines the width of the clear rectangle
  96537. * @param height defines the height of the clear rectangle
  96538. * @param clearColor defines the clear color
  96539. */
  96540. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96541. /**
  96542. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96543. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96544. * @param y defines the y-coordinate of the corner of the clear rectangle
  96545. * @param width defines the width of the clear rectangle
  96546. * @param height defines the height of the clear rectangle
  96547. */
  96548. enableScissor(x: number, y: number, width: number, height: number): void;
  96549. /**
  96550. * Disable previously set scissor test rectangle
  96551. */
  96552. disableScissor(): void;
  96553. private _viewportCached;
  96554. /** @hidden */
  96555. _viewport(x: number, y: number, width: number, height: number): void;
  96556. /**
  96557. * Set the WebGL's viewport
  96558. * @param viewport defines the viewport element to be used
  96559. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96560. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96561. */
  96562. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96563. /**
  96564. * Directly set the WebGL Viewport
  96565. * @param x defines the x coordinate of the viewport (in screen space)
  96566. * @param y defines the y coordinate of the viewport (in screen space)
  96567. * @param width defines the width of the viewport (in screen space)
  96568. * @param height defines the height of the viewport (in screen space)
  96569. * @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
  96570. */
  96571. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96572. /**
  96573. * Begin a new frame
  96574. */
  96575. beginFrame(): void;
  96576. /**
  96577. * Enf the current frame
  96578. */
  96579. endFrame(): void;
  96580. /**
  96581. * Resize the view according to the canvas' size
  96582. */
  96583. resize(): void;
  96584. /**
  96585. * Force a specific size of the canvas
  96586. * @param width defines the new canvas' width
  96587. * @param height defines the new canvas' height
  96588. */
  96589. setSize(width: number, height: number): void;
  96590. /**
  96591. * Binds the frame buffer to the specified texture.
  96592. * @param texture The texture to render to or null for the default canvas
  96593. * @param faceIndex The face of the texture to render to in case of cube texture
  96594. * @param requiredWidth The width of the target to render to
  96595. * @param requiredHeight The height of the target to render to
  96596. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96597. * @param depthStencilTexture The depth stencil texture to use to render
  96598. * @param lodLevel defines le lod level to bind to the frame buffer
  96599. */
  96600. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96601. /** @hidden */
  96602. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96603. /**
  96604. * Unbind the current render target texture from the webGL context
  96605. * @param texture defines the render target texture to unbind
  96606. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96607. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96608. */
  96609. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96610. /**
  96611. * Force the mipmap generation for the given render target texture
  96612. * @param texture defines the render target texture to use
  96613. */
  96614. generateMipMapsForCubemap(texture: InternalTexture): void;
  96615. /**
  96616. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96617. */
  96618. flushFramebuffer(): void;
  96619. /**
  96620. * Unbind the current render target and bind the default framebuffer
  96621. */
  96622. restoreDefaultFramebuffer(): void;
  96623. /**
  96624. * Create an uniform buffer
  96625. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96626. * @param elements defines the content of the uniform buffer
  96627. * @returns the webGL uniform buffer
  96628. */
  96629. createUniformBuffer(elements: FloatArray): DataBuffer;
  96630. /**
  96631. * Create a dynamic uniform buffer
  96632. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96633. * @param elements defines the content of the uniform buffer
  96634. * @returns the webGL uniform buffer
  96635. */
  96636. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96637. /**
  96638. * Update an existing uniform buffer
  96639. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96640. * @param uniformBuffer defines the target uniform buffer
  96641. * @param elements defines the content to update
  96642. * @param offset defines the offset in the uniform buffer where update should start
  96643. * @param count defines the size of the data to update
  96644. */
  96645. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96646. private _resetVertexBufferBinding;
  96647. /**
  96648. * Creates a vertex buffer
  96649. * @param data the data for the vertex buffer
  96650. * @returns the new WebGL static buffer
  96651. */
  96652. createVertexBuffer(data: DataArray): DataBuffer;
  96653. /**
  96654. * Creates a dynamic vertex buffer
  96655. * @param data the data for the dynamic vertex buffer
  96656. * @returns the new WebGL dynamic buffer
  96657. */
  96658. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96659. /**
  96660. * Update a dynamic index buffer
  96661. * @param indexBuffer defines the target index buffer
  96662. * @param indices defines the data to update
  96663. * @param offset defines the offset in the target index buffer where update should start
  96664. */
  96665. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96666. /**
  96667. * Updates a dynamic vertex buffer.
  96668. * @param vertexBuffer the vertex buffer to update
  96669. * @param data the data used to update the vertex buffer
  96670. * @param byteOffset the byte offset of the data
  96671. * @param byteLength the byte length of the data
  96672. */
  96673. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96674. private _resetIndexBufferBinding;
  96675. /**
  96676. * Creates a new index buffer
  96677. * @param indices defines the content of the index buffer
  96678. * @param updatable defines if the index buffer must be updatable
  96679. * @returns a new webGL buffer
  96680. */
  96681. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96682. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96683. /**
  96684. * Bind a webGL buffer to the webGL context
  96685. * @param buffer defines the buffer to bind
  96686. */
  96687. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96688. /**
  96689. * Bind an uniform buffer to the current webGL context
  96690. * @param buffer defines the buffer to bind
  96691. */
  96692. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96693. /**
  96694. * Bind a buffer to the current webGL context at a given location
  96695. * @param buffer defines the buffer to bind
  96696. * @param location defines the index where to bind the buffer
  96697. */
  96698. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96699. /**
  96700. * Bind a specific block at a given index in a specific shader program
  96701. * @param pipelineContext defines the pipeline context to use
  96702. * @param blockName defines the block name
  96703. * @param index defines the index where to bind the block
  96704. */
  96705. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96706. private bindIndexBuffer;
  96707. private bindBuffer;
  96708. /**
  96709. * update the bound buffer with the given data
  96710. * @param data defines the data to update
  96711. */
  96712. updateArrayBuffer(data: Float32Array): void;
  96713. private _vertexAttribPointer;
  96714. private _bindIndexBufferWithCache;
  96715. private _bindVertexBuffersAttributes;
  96716. /**
  96717. * Records a vertex array object
  96718. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96719. * @param vertexBuffers defines the list of vertex buffers to store
  96720. * @param indexBuffer defines the index buffer to store
  96721. * @param effect defines the effect to store
  96722. * @returns the new vertex array object
  96723. */
  96724. recordVertexArrayObject(vertexBuffers: {
  96725. [key: string]: VertexBuffer;
  96726. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96727. /**
  96728. * Bind a specific vertex array object
  96729. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96730. * @param vertexArrayObject defines the vertex array object to bind
  96731. * @param indexBuffer defines the index buffer to bind
  96732. */
  96733. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96734. /**
  96735. * Bind webGl buffers directly to the webGL context
  96736. * @param vertexBuffer defines the vertex buffer to bind
  96737. * @param indexBuffer defines the index buffer to bind
  96738. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96739. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96740. * @param effect defines the effect associated with the vertex buffer
  96741. */
  96742. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96743. private _unbindVertexArrayObject;
  96744. /**
  96745. * Bind a list of vertex buffers to the webGL context
  96746. * @param vertexBuffers defines the list of vertex buffers to bind
  96747. * @param indexBuffer defines the index buffer to bind
  96748. * @param effect defines the effect associated with the vertex buffers
  96749. */
  96750. bindBuffers(vertexBuffers: {
  96751. [key: string]: Nullable<VertexBuffer>;
  96752. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96753. /**
  96754. * Unbind all instance attributes
  96755. */
  96756. unbindInstanceAttributes(): void;
  96757. /**
  96758. * Release and free the memory of a vertex array object
  96759. * @param vao defines the vertex array object to delete
  96760. */
  96761. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96762. /** @hidden */
  96763. _releaseBuffer(buffer: DataBuffer): boolean;
  96764. protected _deleteBuffer(buffer: DataBuffer): void;
  96765. /**
  96766. * Creates a webGL buffer to use with instanciation
  96767. * @param capacity defines the size of the buffer
  96768. * @returns the webGL buffer
  96769. */
  96770. createInstancesBuffer(capacity: number): DataBuffer;
  96771. /**
  96772. * Delete a webGL buffer used with instanciation
  96773. * @param buffer defines the webGL buffer to delete
  96774. */
  96775. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96776. /**
  96777. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96778. * @param instancesBuffer defines the webGL buffer to update and bind
  96779. * @param data defines the data to store in the buffer
  96780. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96781. */
  96782. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96783. /**
  96784. * Apply all cached states (depth, culling, stencil and alpha)
  96785. */
  96786. applyStates(): void;
  96787. /**
  96788. * Send a draw order
  96789. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96790. * @param indexStart defines the starting index
  96791. * @param indexCount defines the number of index to draw
  96792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96793. */
  96794. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96795. /**
  96796. * Draw a list of points
  96797. * @param verticesStart defines the index of first vertex to draw
  96798. * @param verticesCount defines the count of vertices to draw
  96799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96800. */
  96801. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96802. /**
  96803. * Draw a list of unindexed primitives
  96804. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96805. * @param verticesStart defines the index of first vertex to draw
  96806. * @param verticesCount defines the count of vertices to draw
  96807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96808. */
  96809. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96810. /**
  96811. * Draw a list of indexed primitives
  96812. * @param fillMode defines the primitive to use
  96813. * @param indexStart defines the starting index
  96814. * @param indexCount defines the number of index to draw
  96815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96816. */
  96817. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96818. /**
  96819. * Draw a list of unindexed primitives
  96820. * @param fillMode defines the primitive to use
  96821. * @param verticesStart defines the index of first vertex to draw
  96822. * @param verticesCount defines the count of vertices to draw
  96823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96824. */
  96825. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96826. private _drawMode;
  96827. /** @hidden */
  96828. _releaseEffect(effect: Effect): void;
  96829. /** @hidden */
  96830. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96831. /**
  96832. * Create a new effect (used to store vertex/fragment shaders)
  96833. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96834. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96835. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96836. * @param samplers defines an array of string used to represent textures
  96837. * @param defines defines the string containing the defines to use to compile the shaders
  96838. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96839. * @param onCompiled defines a function to call when the effect creation is successful
  96840. * @param onError defines a function to call when the effect creation has failed
  96841. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96842. * @returns the new Effect
  96843. */
  96844. 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;
  96845. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96846. private _compileShader;
  96847. private _compileRawShader;
  96848. /**
  96849. * Directly creates a webGL program
  96850. * @param pipelineContext defines the pipeline context to attach to
  96851. * @param vertexCode defines the vertex shader code to use
  96852. * @param fragmentCode defines the fragment shader code to use
  96853. * @param context defines the webGL context to use (if not set, the current one will be used)
  96854. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96855. * @returns the new webGL program
  96856. */
  96857. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96858. /**
  96859. * Creates a webGL program
  96860. * @param pipelineContext defines the pipeline context to attach to
  96861. * @param vertexCode defines the vertex shader code to use
  96862. * @param fragmentCode defines the fragment shader code to use
  96863. * @param defines defines the string containing the defines to use to compile the shaders
  96864. * @param context defines the webGL context to use (if not set, the current one will be used)
  96865. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96866. * @returns the new webGL program
  96867. */
  96868. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96869. /**
  96870. * Creates a new pipeline context
  96871. * @returns the new pipeline
  96872. */
  96873. createPipelineContext(): IPipelineContext;
  96874. private _createShaderProgram;
  96875. private _finalizePipelineContext;
  96876. /** @hidden */
  96877. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96878. /** @hidden */
  96879. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96880. /** @hidden */
  96881. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96882. /**
  96883. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96884. * @param pipelineContext defines the pipeline context to use
  96885. * @param uniformsNames defines the list of uniform names
  96886. * @returns an array of webGL uniform locations
  96887. */
  96888. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96889. /**
  96890. * Gets the lsit of active attributes for a given webGL program
  96891. * @param pipelineContext defines the pipeline context to use
  96892. * @param attributesNames defines the list of attribute names to get
  96893. * @returns an array of indices indicating the offset of each attribute
  96894. */
  96895. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96896. /**
  96897. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96898. * @param effect defines the effect to activate
  96899. */
  96900. enableEffect(effect: Nullable<Effect>): void;
  96901. /**
  96902. * Set the value of an uniform to an array of int32
  96903. * @param uniform defines the webGL uniform location where to store the value
  96904. * @param array defines the array of int32 to store
  96905. */
  96906. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96907. /**
  96908. * Set the value of an uniform to an array of int32 (stored as vec2)
  96909. * @param uniform defines the webGL uniform location where to store the value
  96910. * @param array defines the array of int32 to store
  96911. */
  96912. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96913. /**
  96914. * Set the value of an uniform to an array of int32 (stored as vec3)
  96915. * @param uniform defines the webGL uniform location where to store the value
  96916. * @param array defines the array of int32 to store
  96917. */
  96918. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96919. /**
  96920. * Set the value of an uniform to an array of int32 (stored as vec4)
  96921. * @param uniform defines the webGL uniform location where to store the value
  96922. * @param array defines the array of int32 to store
  96923. */
  96924. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96925. /**
  96926. * Set the value of an uniform to an array of float32
  96927. * @param uniform defines the webGL uniform location where to store the value
  96928. * @param array defines the array of float32 to store
  96929. */
  96930. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96931. /**
  96932. * Set the value of an uniform to an array of float32 (stored as vec2)
  96933. * @param uniform defines the webGL uniform location where to store the value
  96934. * @param array defines the array of float32 to store
  96935. */
  96936. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96937. /**
  96938. * Set the value of an uniform to an array of float32 (stored as vec3)
  96939. * @param uniform defines the webGL uniform location where to store the value
  96940. * @param array defines the array of float32 to store
  96941. */
  96942. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96943. /**
  96944. * Set the value of an uniform to an array of float32 (stored as vec4)
  96945. * @param uniform defines the webGL uniform location where to store the value
  96946. * @param array defines the array of float32 to store
  96947. */
  96948. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96949. /**
  96950. * Set the value of an uniform to an array of number
  96951. * @param uniform defines the webGL uniform location where to store the value
  96952. * @param array defines the array of number to store
  96953. */
  96954. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96955. /**
  96956. * Set the value of an uniform to an array of number (stored as vec2)
  96957. * @param uniform defines the webGL uniform location where to store the value
  96958. * @param array defines the array of number to store
  96959. */
  96960. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96961. /**
  96962. * Set the value of an uniform to an array of number (stored as vec3)
  96963. * @param uniform defines the webGL uniform location where to store the value
  96964. * @param array defines the array of number to store
  96965. */
  96966. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96967. /**
  96968. * Set the value of an uniform to an array of number (stored as vec4)
  96969. * @param uniform defines the webGL uniform location where to store the value
  96970. * @param array defines the array of number to store
  96971. */
  96972. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96973. /**
  96974. * Set the value of an uniform to an array of float32 (stored as matrices)
  96975. * @param uniform defines the webGL uniform location where to store the value
  96976. * @param matrices defines the array of float32 to store
  96977. */
  96978. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96979. /**
  96980. * Set the value of an uniform to a matrix (3x3)
  96981. * @param uniform defines the webGL uniform location where to store the value
  96982. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96983. */
  96984. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96985. /**
  96986. * Set the value of an uniform to a matrix (2x2)
  96987. * @param uniform defines the webGL uniform location where to store the value
  96988. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96989. */
  96990. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96991. /**
  96992. * Set the value of an uniform to a number (int)
  96993. * @param uniform defines the webGL uniform location where to store the value
  96994. * @param value defines the int number to store
  96995. */
  96996. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96997. /**
  96998. * Set the value of an uniform to a number (float)
  96999. * @param uniform defines the webGL uniform location where to store the value
  97000. * @param value defines the float number to store
  97001. */
  97002. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97003. /**
  97004. * Set the value of an uniform to a vec2
  97005. * @param uniform defines the webGL uniform location where to store the value
  97006. * @param x defines the 1st component of the value
  97007. * @param y defines the 2nd component of the value
  97008. */
  97009. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97010. /**
  97011. * Set the value of an uniform to a vec3
  97012. * @param uniform defines the webGL uniform location where to store the value
  97013. * @param x defines the 1st component of the value
  97014. * @param y defines the 2nd component of the value
  97015. * @param z defines the 3rd component of the value
  97016. */
  97017. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97018. /**
  97019. * Set the value of an uniform to a boolean
  97020. * @param uniform defines the webGL uniform location where to store the value
  97021. * @param bool defines the boolean to store
  97022. */
  97023. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97024. /**
  97025. * Set the value of an uniform to a vec4
  97026. * @param uniform defines the webGL uniform location where to store the value
  97027. * @param x defines the 1st component of the value
  97028. * @param y defines the 2nd component of the value
  97029. * @param z defines the 3rd component of the value
  97030. * @param w defines the 4th component of the value
  97031. */
  97032. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97033. /**
  97034. * Sets a Color4 on a uniform variable
  97035. * @param uniform defines the uniform location
  97036. * @param color4 defines the value to be set
  97037. */
  97038. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97039. /**
  97040. * Set various states to the webGL context
  97041. * @param culling defines backface culling state
  97042. * @param zOffset defines the value to apply to zOffset (0 by default)
  97043. * @param force defines if states must be applied even if cache is up to date
  97044. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97045. */
  97046. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97047. /**
  97048. * Set the z offset to apply to current rendering
  97049. * @param value defines the offset to apply
  97050. */
  97051. setZOffset(value: number): void;
  97052. /**
  97053. * Gets the current value of the zOffset
  97054. * @returns the current zOffset state
  97055. */
  97056. getZOffset(): number;
  97057. /**
  97058. * Enable or disable depth buffering
  97059. * @param enable defines the state to set
  97060. */
  97061. setDepthBuffer(enable: boolean): void;
  97062. /**
  97063. * Gets a boolean indicating if depth writing is enabled
  97064. * @returns the current depth writing state
  97065. */
  97066. getDepthWrite(): boolean;
  97067. /**
  97068. * Enable or disable depth writing
  97069. * @param enable defines the state to set
  97070. */
  97071. setDepthWrite(enable: boolean): void;
  97072. /**
  97073. * Enable or disable color writing
  97074. * @param enable defines the state to set
  97075. */
  97076. setColorWrite(enable: boolean): void;
  97077. /**
  97078. * Gets a boolean indicating if color writing is enabled
  97079. * @returns the current color writing state
  97080. */
  97081. getColorWrite(): boolean;
  97082. /**
  97083. * Sets alpha constants used by some alpha blending modes
  97084. * @param r defines the red component
  97085. * @param g defines the green component
  97086. * @param b defines the blue component
  97087. * @param a defines the alpha component
  97088. */
  97089. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97090. /**
  97091. * Sets the current alpha mode
  97092. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97093. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97094. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97095. */
  97096. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97097. /**
  97098. * Gets the current alpha mode
  97099. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97100. * @returns the current alpha mode
  97101. */
  97102. getAlphaMode(): number;
  97103. /**
  97104. * Clears the list of texture accessible through engine.
  97105. * This can help preventing texture load conflict due to name collision.
  97106. */
  97107. clearInternalTexturesCache(): void;
  97108. /**
  97109. * Force the entire cache to be cleared
  97110. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97111. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97112. */
  97113. wipeCaches(bruteForce?: boolean): void;
  97114. /**
  97115. * Set the compressed texture format to use, based on the formats you have, and the formats
  97116. * supported by the hardware / browser.
  97117. *
  97118. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97119. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97120. * to API arguments needed to compressed textures. This puts the burden on the container
  97121. * generator to house the arcane code for determining these for current & future formats.
  97122. *
  97123. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97124. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97125. *
  97126. * Note: The result of this call is not taken into account when a texture is base64.
  97127. *
  97128. * @param formatsAvailable defines the list of those format families you have created
  97129. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97130. *
  97131. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97132. * @returns The extension selected.
  97133. */
  97134. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97135. /** @hidden */
  97136. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97137. min: number;
  97138. mag: number;
  97139. };
  97140. /** @hidden */
  97141. _createTexture(): WebGLTexture;
  97142. /**
  97143. * Usually called from Texture.ts.
  97144. * Passed information to create a WebGLTexture
  97145. * @param urlArg defines a value which contains one of the following:
  97146. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97147. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97148. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97149. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97150. * @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)
  97151. * @param scene needed for loading to the correct scene
  97152. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97153. * @param onLoad optional callback to be called upon successful completion
  97154. * @param onError optional callback to be called upon failure
  97155. * @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
  97156. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97157. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97158. * @param forcedExtension defines the extension to use to pick the right loader
  97159. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97160. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97161. */
  97162. 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;
  97163. /**
  97164. * @hidden
  97165. * Rescales a texture
  97166. * @param source input texutre
  97167. * @param destination destination texture
  97168. * @param scene scene to use to render the resize
  97169. * @param internalFormat format to use when resizing
  97170. * @param onComplete callback to be called when resize has completed
  97171. */
  97172. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97173. private _unpackFlipYCached;
  97174. /**
  97175. * In case you are sharing the context with other applications, it might
  97176. * be interested to not cache the unpack flip y state to ensure a consistent
  97177. * value would be set.
  97178. */
  97179. enableUnpackFlipYCached: boolean;
  97180. /** @hidden */
  97181. _unpackFlipY(value: boolean): void;
  97182. /** @hidden */
  97183. _getUnpackAlignement(): number;
  97184. /**
  97185. * Creates a dynamic texture
  97186. * @param width defines the width of the texture
  97187. * @param height defines the height of the texture
  97188. * @param generateMipMaps defines if the engine should generate the mip levels
  97189. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97190. * @returns the dynamic texture inside an InternalTexture
  97191. */
  97192. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97193. /**
  97194. * Update the sampling mode of a given texture
  97195. * @param samplingMode defines the required sampling mode
  97196. * @param texture defines the texture to update
  97197. */
  97198. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97199. /**
  97200. * Update the content of a dynamic texture
  97201. * @param texture defines the texture to update
  97202. * @param canvas defines the canvas containing the source
  97203. * @param invertY defines if data must be stored with Y axis inverted
  97204. * @param premulAlpha defines if alpha is stored as premultiplied
  97205. * @param format defines the format of the data
  97206. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97207. */
  97208. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97209. /**
  97210. * Update a video texture
  97211. * @param texture defines the texture to update
  97212. * @param video defines the video element to use
  97213. * @param invertY defines if data must be stored with Y axis inverted
  97214. */
  97215. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97216. /**
  97217. * Updates a depth texture Comparison Mode and Function.
  97218. * If the comparison Function is equal to 0, the mode will be set to none.
  97219. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97220. * @param texture The texture to set the comparison function for
  97221. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97222. */
  97223. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97224. /** @hidden */
  97225. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97226. width: number;
  97227. height: number;
  97228. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97229. /**
  97230. * Creates a depth stencil texture.
  97231. * This is only available in WebGL 2 or with the depth texture extension available.
  97232. * @param size The size of face edge in the texture.
  97233. * @param options The options defining the texture.
  97234. * @returns The texture
  97235. */
  97236. createDepthStencilTexture(size: number | {
  97237. width: number;
  97238. height: number;
  97239. }, options: DepthTextureCreationOptions): InternalTexture;
  97240. /**
  97241. * Creates a depth stencil texture.
  97242. * This is only available in WebGL 2 or with the depth texture extension available.
  97243. * @param size The size of face edge in the texture.
  97244. * @param options The options defining the texture.
  97245. * @returns The texture
  97246. */
  97247. private _createDepthStencilTexture;
  97248. /**
  97249. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97250. * @param renderTarget The render target to set the frame buffer for
  97251. */
  97252. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97253. /**
  97254. * Creates a new render target texture
  97255. * @param size defines the size of the texture
  97256. * @param options defines the options used to create the texture
  97257. * @returns a new render target texture stored in an InternalTexture
  97258. */
  97259. createRenderTargetTexture(size: number | {
  97260. width: number;
  97261. height: number;
  97262. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97263. /** @hidden */
  97264. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97265. /**
  97266. * Updates the sample count of a render target texture
  97267. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97268. * @param texture defines the texture to update
  97269. * @param samples defines the sample count to set
  97270. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97271. */
  97272. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97273. /** @hidden */
  97274. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97275. /** @hidden */
  97276. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97277. /** @hidden */
  97278. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97279. /** @hidden */
  97280. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97281. /**
  97282. * @hidden
  97283. */
  97284. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97285. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97286. private _prepareWebGLTexture;
  97287. /** @hidden */
  97288. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97289. /** @hidden */
  97290. _releaseFramebufferObjects(texture: InternalTexture): void;
  97291. /** @hidden */
  97292. _releaseTexture(texture: InternalTexture): void;
  97293. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97294. protected _setProgram(program: WebGLProgram): void;
  97295. protected _boundUniforms: {
  97296. [key: number]: WebGLUniformLocation;
  97297. };
  97298. /**
  97299. * Binds an effect to the webGL context
  97300. * @param effect defines the effect to bind
  97301. */
  97302. bindSamplers(effect: Effect): void;
  97303. private _activateCurrentTexture;
  97304. /** @hidden */
  97305. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97306. /** @hidden */
  97307. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97308. /**
  97309. * Sets a texture to the webGL context from a postprocess
  97310. * @param channel defines the channel to use
  97311. * @param postProcess defines the source postprocess
  97312. */
  97313. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97314. /**
  97315. * Binds the output of the passed in post process to the texture channel specified
  97316. * @param channel The channel the texture should be bound to
  97317. * @param postProcess The post process which's output should be bound
  97318. */
  97319. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97320. /**
  97321. * Unbind all textures from the webGL context
  97322. */
  97323. unbindAllTextures(): void;
  97324. /**
  97325. * Sets a texture to the according uniform.
  97326. * @param channel The texture channel
  97327. * @param uniform The uniform to set
  97328. * @param texture The texture to apply
  97329. */
  97330. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97331. /**
  97332. * Sets a depth stencil texture from a render target to the according uniform.
  97333. * @param channel The texture channel
  97334. * @param uniform The uniform to set
  97335. * @param texture The render target texture containing the depth stencil texture to apply
  97336. */
  97337. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97338. private _bindSamplerUniformToChannel;
  97339. private _getTextureWrapMode;
  97340. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97341. /**
  97342. * Sets an array of texture to the webGL context
  97343. * @param channel defines the channel where the texture array must be set
  97344. * @param uniform defines the associated uniform location
  97345. * @param textures defines the array of textures to bind
  97346. */
  97347. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97348. /** @hidden */
  97349. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97350. private _setTextureParameterFloat;
  97351. private _setTextureParameterInteger;
  97352. /**
  97353. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97354. * @param x defines the x coordinate of the rectangle where pixels must be read
  97355. * @param y defines the y coordinate of the rectangle where pixels must be read
  97356. * @param width defines the width of the rectangle where pixels must be read
  97357. * @param height defines the height of the rectangle where pixels must be read
  97358. * @returns a Uint8Array containing RGBA colors
  97359. */
  97360. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97361. /**
  97362. * Add an externaly attached data from its key.
  97363. * This method call will fail and return false, if such key already exists.
  97364. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97365. * @param key the unique key that identifies the data
  97366. * @param data the data object to associate to the key for this Engine instance
  97367. * @return true if no such key were already present and the data was added successfully, false otherwise
  97368. */
  97369. addExternalData<T>(key: string, data: T): boolean;
  97370. /**
  97371. * Get an externaly attached data from its key
  97372. * @param key the unique key that identifies the data
  97373. * @return the associated data, if present (can be null), or undefined if not present
  97374. */
  97375. getExternalData<T>(key: string): T;
  97376. /**
  97377. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97378. * @param key the unique key that identifies the data
  97379. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97380. * @return the associated data, can be null if the factory returned null.
  97381. */
  97382. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97383. /**
  97384. * Remove an externaly attached data from the Engine instance
  97385. * @param key the unique key that identifies the data
  97386. * @return true if the data was successfully removed, false if it doesn't exist
  97387. */
  97388. removeExternalData(key: string): boolean;
  97389. /**
  97390. * Unbind all vertex attributes from the webGL context
  97391. */
  97392. unbindAllAttributes(): void;
  97393. /**
  97394. * 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
  97395. */
  97396. releaseEffects(): void;
  97397. /**
  97398. * Dispose and release all associated resources
  97399. */
  97400. dispose(): void;
  97401. /**
  97402. * Display the loading screen
  97403. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97404. */
  97405. displayLoadingUI(): void;
  97406. /**
  97407. * Hide the loading screen
  97408. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97409. */
  97410. hideLoadingUI(): void;
  97411. /**
  97412. * Gets the current loading screen object
  97413. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97414. */
  97415. /**
  97416. * Sets the current loading screen object
  97417. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97418. */
  97419. loadingScreen: ILoadingScreen;
  97420. /**
  97421. * Sets the current loading screen text
  97422. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97423. */
  97424. loadingUIText: string;
  97425. /**
  97426. * Sets the current loading screen background color
  97427. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97428. */
  97429. loadingUIBackgroundColor: string;
  97430. /**
  97431. * Attach a new callback raised when context lost event is fired
  97432. * @param callback defines the callback to call
  97433. */
  97434. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97435. /**
  97436. * Attach a new callback raised when context restored event is fired
  97437. * @param callback defines the callback to call
  97438. */
  97439. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97440. /**
  97441. * Gets the source code of the vertex shader associated with a specific webGL program
  97442. * @param program defines the program to use
  97443. * @returns a string containing the source code of the vertex shader associated with the program
  97444. */
  97445. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97446. /**
  97447. * Gets the source code of the fragment shader associated with a specific webGL program
  97448. * @param program defines the program to use
  97449. * @returns a string containing the source code of the fragment shader associated with the program
  97450. */
  97451. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97452. /**
  97453. * Get the current error code of the webGL context
  97454. * @returns the error code
  97455. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97456. */
  97457. getError(): number;
  97458. /**
  97459. * Gets the current framerate
  97460. * @returns a number representing the framerate
  97461. */
  97462. getFps(): number;
  97463. /**
  97464. * Gets the time spent between current and previous frame
  97465. * @returns a number representing the delta time in ms
  97466. */
  97467. getDeltaTime(): number;
  97468. private _measureFps;
  97469. /** @hidden */
  97470. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97471. private _canRenderToFloatFramebuffer;
  97472. private _canRenderToHalfFloatFramebuffer;
  97473. private _canRenderToFramebuffer;
  97474. /** @hidden */
  97475. _getWebGLTextureType(type: number): number;
  97476. /** @hidden */
  97477. _getInternalFormat(format: number): number;
  97478. /** @hidden */
  97479. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97480. /** @hidden */
  97481. _getRGBAMultiSampleBufferFormat(type: number): number;
  97482. /** @hidden */
  97483. _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;
  97484. /** @hidden */
  97485. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97486. /**
  97487. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97488. * @returns true if the engine can be created
  97489. * @ignorenaming
  97490. */
  97491. static isSupported(): boolean;
  97492. /**
  97493. * Find the next highest power of two.
  97494. * @param x Number to start search from.
  97495. * @return Next highest power of two.
  97496. */
  97497. static CeilingPOT(x: number): number;
  97498. /**
  97499. * Find the next lowest power of two.
  97500. * @param x Number to start search from.
  97501. * @return Next lowest power of two.
  97502. */
  97503. static FloorPOT(x: number): number;
  97504. /**
  97505. * Find the nearest power of two.
  97506. * @param x Number to start search from.
  97507. * @return Next nearest power of two.
  97508. */
  97509. static NearestPOT(x: number): number;
  97510. /**
  97511. * Get the closest exponent of two
  97512. * @param value defines the value to approximate
  97513. * @param max defines the maximum value to return
  97514. * @param mode defines how to define the closest value
  97515. * @returns closest exponent of two of the given value
  97516. */
  97517. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97518. /**
  97519. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97520. * @param func - the function to be called
  97521. * @param requester - the object that will request the next frame. Falls back to window.
  97522. * @returns frame number
  97523. */
  97524. static QueueNewFrame(func: () => void, requester?: any): number;
  97525. /**
  97526. * Ask the browser to promote the current element to pointerlock mode
  97527. * @param element defines the DOM element to promote
  97528. */
  97529. static _RequestPointerlock(element: HTMLElement): void;
  97530. /**
  97531. * Asks the browser to exit pointerlock mode
  97532. */
  97533. static _ExitPointerlock(): void;
  97534. /**
  97535. * Ask the browser to promote the current element to fullscreen rendering mode
  97536. * @param element defines the DOM element to promote
  97537. */
  97538. static _RequestFullscreen(element: HTMLElement): void;
  97539. /**
  97540. * Asks the browser to exit fullscreen mode
  97541. */
  97542. static _ExitFullscreen(): void;
  97543. }
  97544. }
  97545. declare module BABYLON {
  97546. /**
  97547. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97548. * during the life time of the application.
  97549. */
  97550. export class EngineStore {
  97551. /** Gets the list of created engines */
  97552. static Instances: Engine[];
  97553. /** @hidden */
  97554. static _LastCreatedScene: Nullable<Scene>;
  97555. /**
  97556. * Gets the latest created engine
  97557. */
  97558. static readonly LastCreatedEngine: Nullable<Engine>;
  97559. /**
  97560. * Gets the latest created scene
  97561. */
  97562. static readonly LastCreatedScene: Nullable<Scene>;
  97563. /**
  97564. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97565. * @ignorenaming
  97566. */
  97567. static UseFallbackTexture: boolean;
  97568. /**
  97569. * Texture content used if a texture cannot loaded
  97570. * @ignorenaming
  97571. */
  97572. static FallbackTexture: string;
  97573. }
  97574. }
  97575. declare module BABYLON {
  97576. /**
  97577. * Helper class that provides a small promise polyfill
  97578. */
  97579. export class PromisePolyfill {
  97580. /**
  97581. * Static function used to check if the polyfill is required
  97582. * If this is the case then the function will inject the polyfill to window.Promise
  97583. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97584. */
  97585. static Apply(force?: boolean): void;
  97586. }
  97587. }
  97588. declare module BABYLON {
  97589. /**
  97590. * Interface for screenshot methods with describe argument called `size` as object with options
  97591. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97592. */
  97593. export interface IScreenshotSize {
  97594. /**
  97595. * number in pixels for canvas height
  97596. */
  97597. height?: number;
  97598. /**
  97599. * multiplier allowing render at a higher or lower resolution
  97600. * If value is defined then height and width will be ignored and taken from camera
  97601. */
  97602. precision?: number;
  97603. /**
  97604. * number in pixels for canvas width
  97605. */
  97606. width?: number;
  97607. }
  97608. }
  97609. declare module BABYLON {
  97610. interface IColor4Like {
  97611. r: float;
  97612. g: float;
  97613. b: float;
  97614. a: float;
  97615. }
  97616. /**
  97617. * Class containing a set of static utilities functions
  97618. */
  97619. export class Tools {
  97620. /**
  97621. * Gets or sets the base URL to use to load assets
  97622. */
  97623. static BaseUrl: string;
  97624. /**
  97625. * Enable/Disable Custom HTTP Request Headers globally.
  97626. * default = false
  97627. * @see CustomRequestHeaders
  97628. */
  97629. static UseCustomRequestHeaders: boolean;
  97630. /**
  97631. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97632. * i.e. when loading files, where the server/service expects an Authorization header
  97633. */
  97634. static CustomRequestHeaders: {
  97635. [key: string]: string;
  97636. };
  97637. /**
  97638. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97639. */
  97640. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97641. /**
  97642. * Default behaviour for cors in the application.
  97643. * It can be a string if the expected behavior is identical in the entire app.
  97644. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97645. */
  97646. static CorsBehavior: string | ((url: string | string[]) => string);
  97647. /**
  97648. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97649. * @ignorenaming
  97650. */
  97651. static UseFallbackTexture: boolean;
  97652. /**
  97653. * Use this object to register external classes like custom textures or material
  97654. * to allow the laoders to instantiate them
  97655. */
  97656. static RegisteredExternalClasses: {
  97657. [key: string]: Object;
  97658. };
  97659. /**
  97660. * Texture content used if a texture cannot loaded
  97661. * @ignorenaming
  97662. */
  97663. static fallbackTexture: string;
  97664. /**
  97665. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97666. * @param u defines the coordinate on X axis
  97667. * @param v defines the coordinate on Y axis
  97668. * @param width defines the width of the source data
  97669. * @param height defines the height of the source data
  97670. * @param pixels defines the source byte array
  97671. * @param color defines the output color
  97672. */
  97673. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97674. /**
  97675. * Interpolates between a and b via alpha
  97676. * @param a The lower value (returned when alpha = 0)
  97677. * @param b The upper value (returned when alpha = 1)
  97678. * @param alpha The interpolation-factor
  97679. * @return The mixed value
  97680. */
  97681. static Mix(a: number, b: number, alpha: number): number;
  97682. /**
  97683. * Tries to instantiate a new object from a given class name
  97684. * @param className defines the class name to instantiate
  97685. * @returns the new object or null if the system was not able to do the instantiation
  97686. */
  97687. static Instantiate(className: string): any;
  97688. /**
  97689. * Provides a slice function that will work even on IE
  97690. * @param data defines the array to slice
  97691. * @param start defines the start of the data (optional)
  97692. * @param end defines the end of the data (optional)
  97693. * @returns the new sliced array
  97694. */
  97695. static Slice<T>(data: T, start?: number, end?: number): T;
  97696. /**
  97697. * Polyfill for setImmediate
  97698. * @param action defines the action to execute after the current execution block
  97699. */
  97700. static SetImmediate(action: () => void): void;
  97701. /**
  97702. * Function indicating if a number is an exponent of 2
  97703. * @param value defines the value to test
  97704. * @returns true if the value is an exponent of 2
  97705. */
  97706. static IsExponentOfTwo(value: number): boolean;
  97707. private static _tmpFloatArray;
  97708. /**
  97709. * Returns the nearest 32-bit single precision float representation of a Number
  97710. * @param value A Number. If the parameter is of a different type, it will get converted
  97711. * to a number or to NaN if it cannot be converted
  97712. * @returns number
  97713. */
  97714. static FloatRound(value: number): number;
  97715. /**
  97716. * Extracts the filename from a path
  97717. * @param path defines the path to use
  97718. * @returns the filename
  97719. */
  97720. static GetFilename(path: string): string;
  97721. /**
  97722. * Extracts the "folder" part of a path (everything before the filename).
  97723. * @param uri The URI to extract the info from
  97724. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97725. * @returns The "folder" part of the path
  97726. */
  97727. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97728. /**
  97729. * Extracts text content from a DOM element hierarchy
  97730. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97731. */
  97732. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97733. /**
  97734. * Convert an angle in radians to degrees
  97735. * @param angle defines the angle to convert
  97736. * @returns the angle in degrees
  97737. */
  97738. static ToDegrees(angle: number): number;
  97739. /**
  97740. * Convert an angle in degrees to radians
  97741. * @param angle defines the angle to convert
  97742. * @returns the angle in radians
  97743. */
  97744. static ToRadians(angle: number): number;
  97745. /**
  97746. * Encode a buffer to a base64 string
  97747. * @param buffer defines the buffer to encode
  97748. * @returns the encoded string
  97749. */
  97750. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97751. /**
  97752. * Returns an array if obj is not an array
  97753. * @param obj defines the object to evaluate as an array
  97754. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97755. * @returns either obj directly if obj is an array or a new array containing obj
  97756. */
  97757. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97758. /**
  97759. * Gets the pointer prefix to use
  97760. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97761. */
  97762. static GetPointerPrefix(): string;
  97763. /**
  97764. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97765. * @param url define the url we are trying
  97766. * @param element define the dom element where to configure the cors policy
  97767. */
  97768. static SetCorsBehavior(url: string | string[], element: {
  97769. crossOrigin: string | null;
  97770. }): void;
  97771. /**
  97772. * Removes unwanted characters from an url
  97773. * @param url defines the url to clean
  97774. * @returns the cleaned url
  97775. */
  97776. static CleanUrl(url: string): string;
  97777. /**
  97778. * Gets or sets a function used to pre-process url before using them to load assets
  97779. */
  97780. static PreprocessUrl: (url: string) => string;
  97781. /**
  97782. * Loads an image as an HTMLImageElement.
  97783. * @param input url string, ArrayBuffer, or Blob to load
  97784. * @param onLoad callback called when the image successfully loads
  97785. * @param onError callback called when the image fails to load
  97786. * @param offlineProvider offline provider for caching
  97787. * @returns the HTMLImageElement of the loaded image
  97788. */
  97789. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97790. /**
  97791. * Loads a file
  97792. * @param url url string, ArrayBuffer, or Blob to load
  97793. * @param onSuccess callback called when the file successfully loads
  97794. * @param onProgress callback called while file is loading (if the server supports this mode)
  97795. * @param offlineProvider defines the offline provider for caching
  97796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97797. * @param onError callback called when the file fails to load
  97798. * @returns a file request object
  97799. */
  97800. 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;
  97801. /**
  97802. * Loads a file from a url
  97803. * @param url the file url to load
  97804. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97805. */
  97806. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97807. /**
  97808. * Load a script (identified by an url). When the url returns, the
  97809. * content of this file is added into a new script element, attached to the DOM (body element)
  97810. * @param scriptUrl defines the url of the script to laod
  97811. * @param onSuccess defines the callback called when the script is loaded
  97812. * @param onError defines the callback to call if an error occurs
  97813. * @param scriptId defines the id of the script element
  97814. */
  97815. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97816. /**
  97817. * Load an asynchronous script (identified by an url). When the url returns, the
  97818. * content of this file is added into a new script element, attached to the DOM (body element)
  97819. * @param scriptUrl defines the url of the script to laod
  97820. * @param scriptId defines the id of the script element
  97821. * @returns a promise request object
  97822. */
  97823. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97824. /**
  97825. * Loads a file from a blob
  97826. * @param fileToLoad defines the blob to use
  97827. * @param callback defines the callback to call when data is loaded
  97828. * @param progressCallback defines the callback to call during loading process
  97829. * @returns a file request object
  97830. */
  97831. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97832. /**
  97833. * Loads a file
  97834. * @param fileToLoad defines the file to load
  97835. * @param callback defines the callback to call when data is loaded
  97836. * @param progressCallBack defines the callback to call during loading process
  97837. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97838. * @returns a file request object
  97839. */
  97840. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97841. /**
  97842. * Creates a data url from a given string content
  97843. * @param content defines the content to convert
  97844. * @returns the new data url link
  97845. */
  97846. static FileAsURL(content: string): string;
  97847. /**
  97848. * Format the given number to a specific decimal format
  97849. * @param value defines the number to format
  97850. * @param decimals defines the number of decimals to use
  97851. * @returns the formatted string
  97852. */
  97853. static Format(value: number, decimals?: number): string;
  97854. /**
  97855. * Tries to copy an object by duplicating every property
  97856. * @param source defines the source object
  97857. * @param destination defines the target object
  97858. * @param doNotCopyList defines a list of properties to avoid
  97859. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97860. */
  97861. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97862. /**
  97863. * Gets a boolean indicating if the given object has no own property
  97864. * @param obj defines the object to test
  97865. * @returns true if object has no own property
  97866. */
  97867. static IsEmpty(obj: any): boolean;
  97868. /**
  97869. * Function used to register events at window level
  97870. * @param windowElement defines the Window object to use
  97871. * @param events defines the events to register
  97872. */
  97873. static RegisterTopRootEvents(windowElement: Window, events: {
  97874. name: string;
  97875. handler: Nullable<(e: FocusEvent) => any>;
  97876. }[]): void;
  97877. /**
  97878. * Function used to unregister events from window level
  97879. * @param windowElement defines the Window object to use
  97880. * @param events defines the events to unregister
  97881. */
  97882. static UnregisterTopRootEvents(windowElement: Window, events: {
  97883. name: string;
  97884. handler: Nullable<(e: FocusEvent) => any>;
  97885. }[]): void;
  97886. /**
  97887. * @ignore
  97888. */
  97889. static _ScreenshotCanvas: HTMLCanvasElement;
  97890. /**
  97891. * Dumps the current bound framebuffer
  97892. * @param width defines the rendering width
  97893. * @param height defines the rendering height
  97894. * @param engine defines the hosting engine
  97895. * @param successCallback defines the callback triggered once the data are available
  97896. * @param mimeType defines the mime type of the result
  97897. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97898. */
  97899. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97900. /**
  97901. * Converts the canvas data to blob.
  97902. * This acts as a polyfill for browsers not supporting the to blob function.
  97903. * @param canvas Defines the canvas to extract the data from
  97904. * @param successCallback Defines the callback triggered once the data are available
  97905. * @param mimeType Defines the mime type of the result
  97906. */
  97907. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97908. /**
  97909. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97910. * @param successCallback defines the callback triggered once the data are available
  97911. * @param mimeType defines the mime type of the result
  97912. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97913. */
  97914. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97915. /**
  97916. * Downloads a blob in the browser
  97917. * @param blob defines the blob to download
  97918. * @param fileName defines the name of the downloaded file
  97919. */
  97920. static Download(blob: Blob, fileName: string): void;
  97921. /**
  97922. * Captures a screenshot of the current rendering
  97923. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97924. * @param engine defines the rendering engine
  97925. * @param camera defines the source camera
  97926. * @param size This parameter can be set to a single number or to an object with the
  97927. * following (optional) properties: precision, width, height. If a single number is passed,
  97928. * it will be used for both width and height. If an object is passed, the screenshot size
  97929. * will be derived from the parameters. The precision property is a multiplier allowing
  97930. * rendering at a higher or lower resolution
  97931. * @param successCallback defines the callback receives a single parameter which contains the
  97932. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97933. * src parameter of an <img> to display it
  97934. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97935. * Check your browser for supported MIME types
  97936. */
  97937. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97938. /**
  97939. * Captures a screenshot of the current rendering
  97940. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97941. * @param engine defines the rendering engine
  97942. * @param camera defines the source camera
  97943. * @param size This parameter can be set to a single number or to an object with the
  97944. * following (optional) properties: precision, width, height. If a single number is passed,
  97945. * it will be used for both width and height. If an object is passed, the screenshot size
  97946. * will be derived from the parameters. The precision property is a multiplier allowing
  97947. * rendering at a higher or lower resolution
  97948. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97949. * Check your browser for supported MIME types
  97950. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97951. * to the src parameter of an <img> to display it
  97952. */
  97953. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97954. /**
  97955. * Generates an image screenshot from the specified camera.
  97956. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97957. * @param engine The engine to use for rendering
  97958. * @param camera The camera to use for rendering
  97959. * @param size This parameter can be set to a single number or to an object with the
  97960. * following (optional) properties: precision, width, height. If a single number is passed,
  97961. * it will be used for both width and height. If an object is passed, the screenshot size
  97962. * will be derived from the parameters. The precision property is a multiplier allowing
  97963. * rendering at a higher or lower resolution
  97964. * @param successCallback The callback receives a single parameter which contains the
  97965. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97966. * src parameter of an <img> to display it
  97967. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97968. * Check your browser for supported MIME types
  97969. * @param samples Texture samples (default: 1)
  97970. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97971. * @param fileName A name for for the downloaded file.
  97972. */
  97973. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97974. /**
  97975. * Generates an image screenshot from the specified camera.
  97976. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97977. * @param engine The engine to use for rendering
  97978. * @param camera The camera to use for rendering
  97979. * @param size This parameter can be set to a single number or to an object with the
  97980. * following (optional) properties: precision, width, height. If a single number is passed,
  97981. * it will be used for both width and height. If an object is passed, the screenshot size
  97982. * will be derived from the parameters. The precision property is a multiplier allowing
  97983. * rendering at a higher or lower resolution
  97984. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97985. * Check your browser for supported MIME types
  97986. * @param samples Texture samples (default: 1)
  97987. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97988. * @param fileName A name for for the downloaded file.
  97989. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97990. * to the src parameter of an <img> to display it
  97991. */
  97992. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97993. /**
  97994. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97995. * Be aware Math.random() could cause collisions, but:
  97996. * "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"
  97997. * @returns a pseudo random id
  97998. */
  97999. static RandomId(): string;
  98000. /**
  98001. * Test if the given uri is a base64 string
  98002. * @param uri The uri to test
  98003. * @return True if the uri is a base64 string or false otherwise
  98004. */
  98005. static IsBase64(uri: string): boolean;
  98006. /**
  98007. * Decode the given base64 uri.
  98008. * @param uri The uri to decode
  98009. * @return The decoded base64 data.
  98010. */
  98011. static DecodeBase64(uri: string): ArrayBuffer;
  98012. /**
  98013. * Gets the absolute url.
  98014. * @param url the input url
  98015. * @return the absolute url
  98016. */
  98017. static GetAbsoluteUrl(url: string): string;
  98018. /**
  98019. * No log
  98020. */
  98021. static readonly NoneLogLevel: number;
  98022. /**
  98023. * Only message logs
  98024. */
  98025. static readonly MessageLogLevel: number;
  98026. /**
  98027. * Only warning logs
  98028. */
  98029. static readonly WarningLogLevel: number;
  98030. /**
  98031. * Only error logs
  98032. */
  98033. static readonly ErrorLogLevel: number;
  98034. /**
  98035. * All logs
  98036. */
  98037. static readonly AllLogLevel: number;
  98038. /**
  98039. * Gets a value indicating the number of loading errors
  98040. * @ignorenaming
  98041. */
  98042. static readonly errorsCount: number;
  98043. /**
  98044. * Callback called when a new log is added
  98045. */
  98046. static OnNewCacheEntry: (entry: string) => void;
  98047. /**
  98048. * Log a message to the console
  98049. * @param message defines the message to log
  98050. */
  98051. static Log(message: string): void;
  98052. /**
  98053. * Write a warning message to the console
  98054. * @param message defines the message to log
  98055. */
  98056. static Warn(message: string): void;
  98057. /**
  98058. * Write an error message to the console
  98059. * @param message defines the message to log
  98060. */
  98061. static Error(message: string): void;
  98062. /**
  98063. * Gets current log cache (list of logs)
  98064. */
  98065. static readonly LogCache: string;
  98066. /**
  98067. * Clears the log cache
  98068. */
  98069. static ClearLogCache(): void;
  98070. /**
  98071. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98072. */
  98073. static LogLevels: number;
  98074. /**
  98075. * Checks if the window object exists
  98076. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98077. */
  98078. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98079. /**
  98080. * No performance log
  98081. */
  98082. static readonly PerformanceNoneLogLevel: number;
  98083. /**
  98084. * Use user marks to log performance
  98085. */
  98086. static readonly PerformanceUserMarkLogLevel: number;
  98087. /**
  98088. * Log performance to the console
  98089. */
  98090. static readonly PerformanceConsoleLogLevel: number;
  98091. private static _performance;
  98092. /**
  98093. * Sets the current performance log level
  98094. */
  98095. static PerformanceLogLevel: number;
  98096. private static _StartPerformanceCounterDisabled;
  98097. private static _EndPerformanceCounterDisabled;
  98098. private static _StartUserMark;
  98099. private static _EndUserMark;
  98100. private static _StartPerformanceConsole;
  98101. private static _EndPerformanceConsole;
  98102. /**
  98103. * Starts a performance counter
  98104. */
  98105. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98106. /**
  98107. * Ends a specific performance coutner
  98108. */
  98109. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98110. /**
  98111. * Gets either window.performance.now() if supported or Date.now() else
  98112. */
  98113. static readonly Now: number;
  98114. /**
  98115. * This method will return the name of the class used to create the instance of the given object.
  98116. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98117. * @param object the object to get the class name from
  98118. * @param isType defines if the object is actually a type
  98119. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98120. */
  98121. static GetClassName(object: any, isType?: boolean): string;
  98122. /**
  98123. * Gets the first element of an array satisfying a given predicate
  98124. * @param array defines the array to browse
  98125. * @param predicate defines the predicate to use
  98126. * @returns null if not found or the element
  98127. */
  98128. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98129. /**
  98130. * This method will return the name of the full name of the class, including its owning module (if any).
  98131. * 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).
  98132. * @param object the object to get the class name from
  98133. * @param isType defines if the object is actually a type
  98134. * @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.
  98135. * @ignorenaming
  98136. */
  98137. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98138. /**
  98139. * Returns a promise that resolves after the given amount of time.
  98140. * @param delay Number of milliseconds to delay
  98141. * @returns Promise that resolves after the given amount of time
  98142. */
  98143. static DelayAsync(delay: number): Promise<void>;
  98144. }
  98145. /**
  98146. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98147. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98148. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98149. * @param name The name of the class, case should be preserved
  98150. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98151. */
  98152. export function className(name: string, module?: string): (target: Object) => void;
  98153. /**
  98154. * An implementation of a loop for asynchronous functions.
  98155. */
  98156. export class AsyncLoop {
  98157. /**
  98158. * Defines the number of iterations for the loop
  98159. */
  98160. iterations: number;
  98161. /**
  98162. * Defines the current index of the loop.
  98163. */
  98164. index: number;
  98165. private _done;
  98166. private _fn;
  98167. private _successCallback;
  98168. /**
  98169. * Constructor.
  98170. * @param iterations the number of iterations.
  98171. * @param func the function to run each iteration
  98172. * @param successCallback the callback that will be called upon succesful execution
  98173. * @param offset starting offset.
  98174. */
  98175. constructor(
  98176. /**
  98177. * Defines the number of iterations for the loop
  98178. */
  98179. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98180. /**
  98181. * Execute the next iteration. Must be called after the last iteration was finished.
  98182. */
  98183. executeNext(): void;
  98184. /**
  98185. * Break the loop and run the success callback.
  98186. */
  98187. breakLoop(): void;
  98188. /**
  98189. * Create and run an async loop.
  98190. * @param iterations the number of iterations.
  98191. * @param fn the function to run each iteration
  98192. * @param successCallback the callback that will be called upon succesful execution
  98193. * @param offset starting offset.
  98194. * @returns the created async loop object
  98195. */
  98196. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98197. /**
  98198. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98199. * @param iterations total number of iterations
  98200. * @param syncedIterations number of synchronous iterations in each async iteration.
  98201. * @param fn the function to call each iteration.
  98202. * @param callback a success call back that will be called when iterating stops.
  98203. * @param breakFunction a break condition (optional)
  98204. * @param timeout timeout settings for the setTimeout function. default - 0.
  98205. * @returns the created async loop object
  98206. */
  98207. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98208. }
  98209. }
  98210. declare module BABYLON {
  98211. /** @hidden */
  98212. export interface ICollisionCoordinator {
  98213. createCollider(): Collider;
  98214. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98215. init(scene: Scene): void;
  98216. }
  98217. /** @hidden */
  98218. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98219. private _scene;
  98220. private _scaledPosition;
  98221. private _scaledVelocity;
  98222. private _finalPosition;
  98223. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98224. createCollider(): Collider;
  98225. init(scene: Scene): void;
  98226. private _collideWithWorld;
  98227. }
  98228. }
  98229. declare module BABYLON {
  98230. /**
  98231. * Class used to manage all inputs for the scene.
  98232. */
  98233. export class InputManager {
  98234. /** The distance in pixel that you have to move to prevent some events */
  98235. static DragMovementThreshold: number;
  98236. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98237. static LongPressDelay: number;
  98238. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98239. static DoubleClickDelay: number;
  98240. /** If you need to check double click without raising a single click at first click, enable this flag */
  98241. static ExclusiveDoubleClickMode: boolean;
  98242. private _wheelEventName;
  98243. private _onPointerMove;
  98244. private _onPointerDown;
  98245. private _onPointerUp;
  98246. private _initClickEvent;
  98247. private _initActionManager;
  98248. private _delayedSimpleClick;
  98249. private _delayedSimpleClickTimeout;
  98250. private _previousDelayedSimpleClickTimeout;
  98251. private _meshPickProceed;
  98252. private _previousButtonPressed;
  98253. private _currentPickResult;
  98254. private _previousPickResult;
  98255. private _totalPointersPressed;
  98256. private _doubleClickOccured;
  98257. private _pointerOverMesh;
  98258. private _pickedDownMesh;
  98259. private _pickedUpMesh;
  98260. private _pointerX;
  98261. private _pointerY;
  98262. private _unTranslatedPointerX;
  98263. private _unTranslatedPointerY;
  98264. private _startingPointerPosition;
  98265. private _previousStartingPointerPosition;
  98266. private _startingPointerTime;
  98267. private _previousStartingPointerTime;
  98268. private _pointerCaptures;
  98269. private _onKeyDown;
  98270. private _onKeyUp;
  98271. private _onCanvasFocusObserver;
  98272. private _onCanvasBlurObserver;
  98273. private _scene;
  98274. /**
  98275. * Creates a new InputManager
  98276. * @param scene defines the hosting scene
  98277. */
  98278. constructor(scene: Scene);
  98279. /**
  98280. * Gets the mesh that is currently under the pointer
  98281. */
  98282. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98283. /**
  98284. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98285. */
  98286. readonly unTranslatedPointer: Vector2;
  98287. /**
  98288. * Gets or sets the current on-screen X position of the pointer
  98289. */
  98290. pointerX: number;
  98291. /**
  98292. * Gets or sets the current on-screen Y position of the pointer
  98293. */
  98294. pointerY: number;
  98295. private _updatePointerPosition;
  98296. private _processPointerMove;
  98297. private _setRayOnPointerInfo;
  98298. private _checkPrePointerObservable;
  98299. /**
  98300. * Use this method to simulate a pointer move on a mesh
  98301. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98302. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98303. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98304. */
  98305. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98306. /**
  98307. * Use this method to simulate a pointer down on a mesh
  98308. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98309. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98310. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98311. */
  98312. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98313. private _processPointerDown;
  98314. /** @hidden */
  98315. _isPointerSwiping(): boolean;
  98316. /**
  98317. * Use this method to simulate a pointer up on a mesh
  98318. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98319. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98320. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98321. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98322. */
  98323. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98324. private _processPointerUp;
  98325. /**
  98326. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98327. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98328. * @returns true if the pointer was captured
  98329. */
  98330. isPointerCaptured(pointerId?: number): boolean;
  98331. /**
  98332. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98333. * @param attachUp defines if you want to attach events to pointerup
  98334. * @param attachDown defines if you want to attach events to pointerdown
  98335. * @param attachMove defines if you want to attach events to pointermove
  98336. */
  98337. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98338. /**
  98339. * Detaches all event handlers
  98340. */
  98341. detachControl(): void;
  98342. /**
  98343. * Force the value of meshUnderPointer
  98344. * @param mesh defines the mesh to use
  98345. */
  98346. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98347. /**
  98348. * Gets the mesh under the pointer
  98349. * @returns a Mesh or null if no mesh is under the pointer
  98350. */
  98351. getPointerOverMesh(): Nullable<AbstractMesh>;
  98352. }
  98353. }
  98354. declare module BABYLON {
  98355. /**
  98356. * Helper class used to generate session unique ID
  98357. */
  98358. export class UniqueIdGenerator {
  98359. private static _UniqueIdCounter;
  98360. /**
  98361. * Gets an unique (relatively to the current scene) Id
  98362. */
  98363. static readonly UniqueId: number;
  98364. }
  98365. }
  98366. declare module BABYLON {
  98367. /**
  98368. * This class defines the direct association between an animation and a target
  98369. */
  98370. export class TargetedAnimation {
  98371. /**
  98372. * Animation to perform
  98373. */
  98374. animation: Animation;
  98375. /**
  98376. * Target to animate
  98377. */
  98378. target: any;
  98379. /**
  98380. * Serialize the object
  98381. * @returns the JSON object representing the current entity
  98382. */
  98383. serialize(): any;
  98384. }
  98385. /**
  98386. * Use this class to create coordinated animations on multiple targets
  98387. */
  98388. export class AnimationGroup implements IDisposable {
  98389. /** The name of the animation group */
  98390. name: string;
  98391. private _scene;
  98392. private _targetedAnimations;
  98393. private _animatables;
  98394. private _from;
  98395. private _to;
  98396. private _isStarted;
  98397. private _isPaused;
  98398. private _speedRatio;
  98399. private _loopAnimation;
  98400. /**
  98401. * Gets or sets the unique id of the node
  98402. */
  98403. uniqueId: number;
  98404. /**
  98405. * This observable will notify when one animation have ended
  98406. */
  98407. onAnimationEndObservable: Observable<TargetedAnimation>;
  98408. /**
  98409. * Observer raised when one animation loops
  98410. */
  98411. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98412. /**
  98413. * This observable will notify when all animations have ended.
  98414. */
  98415. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98416. /**
  98417. * This observable will notify when all animations have paused.
  98418. */
  98419. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98420. /**
  98421. * This observable will notify when all animations are playing.
  98422. */
  98423. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98424. /**
  98425. * Gets the first frame
  98426. */
  98427. readonly from: number;
  98428. /**
  98429. * Gets the last frame
  98430. */
  98431. readonly to: number;
  98432. /**
  98433. * Define if the animations are started
  98434. */
  98435. readonly isStarted: boolean;
  98436. /**
  98437. * Gets a value indicating that the current group is playing
  98438. */
  98439. readonly isPlaying: boolean;
  98440. /**
  98441. * Gets or sets the speed ratio to use for all animations
  98442. */
  98443. /**
  98444. * Gets or sets the speed ratio to use for all animations
  98445. */
  98446. speedRatio: number;
  98447. /**
  98448. * Gets or sets if all animations should loop or not
  98449. */
  98450. loopAnimation: boolean;
  98451. /**
  98452. * Gets the targeted animations for this animation group
  98453. */
  98454. readonly targetedAnimations: Array<TargetedAnimation>;
  98455. /**
  98456. * returning the list of animatables controlled by this animation group.
  98457. */
  98458. readonly animatables: Array<Animatable>;
  98459. /**
  98460. * Instantiates a new Animation Group.
  98461. * This helps managing several animations at once.
  98462. * @see http://doc.babylonjs.com/how_to/group
  98463. * @param name Defines the name of the group
  98464. * @param scene Defines the scene the group belongs to
  98465. */
  98466. constructor(
  98467. /** The name of the animation group */
  98468. name: string, scene?: Nullable<Scene>);
  98469. /**
  98470. * Add an animation (with its target) in the group
  98471. * @param animation defines the animation we want to add
  98472. * @param target defines the target of the animation
  98473. * @returns the TargetedAnimation object
  98474. */
  98475. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98476. /**
  98477. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98478. * It can add constant keys at begin or end
  98479. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98480. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98481. * @returns the animation group
  98482. */
  98483. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98484. /**
  98485. * Start all animations on given targets
  98486. * @param loop defines if animations must loop
  98487. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98488. * @param from defines the from key (optional)
  98489. * @param to defines the to key (optional)
  98490. * @returns the current animation group
  98491. */
  98492. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98493. /**
  98494. * Pause all animations
  98495. * @returns the animation group
  98496. */
  98497. pause(): AnimationGroup;
  98498. /**
  98499. * Play all animations to initial state
  98500. * This function will start() the animations if they were not started or will restart() them if they were paused
  98501. * @param loop defines if animations must loop
  98502. * @returns the animation group
  98503. */
  98504. play(loop?: boolean): AnimationGroup;
  98505. /**
  98506. * Reset all animations to initial state
  98507. * @returns the animation group
  98508. */
  98509. reset(): AnimationGroup;
  98510. /**
  98511. * Restart animations from key 0
  98512. * @returns the animation group
  98513. */
  98514. restart(): AnimationGroup;
  98515. /**
  98516. * Stop all animations
  98517. * @returns the animation group
  98518. */
  98519. stop(): AnimationGroup;
  98520. /**
  98521. * Set animation weight for all animatables
  98522. * @param weight defines the weight to use
  98523. * @return the animationGroup
  98524. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98525. */
  98526. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98527. /**
  98528. * Synchronize and normalize all animatables with a source animatable
  98529. * @param root defines the root animatable to synchronize with
  98530. * @return the animationGroup
  98531. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98532. */
  98533. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98534. /**
  98535. * Goes to a specific frame in this animation group
  98536. * @param frame the frame number to go to
  98537. * @return the animationGroup
  98538. */
  98539. goToFrame(frame: number): AnimationGroup;
  98540. /**
  98541. * Dispose all associated resources
  98542. */
  98543. dispose(): void;
  98544. private _checkAnimationGroupEnded;
  98545. /**
  98546. * Clone the current animation group and returns a copy
  98547. * @param newName defines the name of the new group
  98548. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98549. * @returns the new aniamtion group
  98550. */
  98551. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98552. /**
  98553. * Serializes the animationGroup to an object
  98554. * @returns Serialized object
  98555. */
  98556. serialize(): any;
  98557. /**
  98558. * Returns a new AnimationGroup object parsed from the source provided.
  98559. * @param parsedAnimationGroup defines the source
  98560. * @param scene defines the scene that will receive the animationGroup
  98561. * @returns a new AnimationGroup
  98562. */
  98563. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98564. /**
  98565. * Returns the string "AnimationGroup"
  98566. * @returns "AnimationGroup"
  98567. */
  98568. getClassName(): string;
  98569. /**
  98570. * Creates a detailled string about the object
  98571. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98572. * @returns a string representing the object
  98573. */
  98574. toString(fullDetails?: boolean): string;
  98575. }
  98576. }
  98577. declare module BABYLON {
  98578. /**
  98579. * Define an interface for all classes that will hold resources
  98580. */
  98581. export interface IDisposable {
  98582. /**
  98583. * Releases all held resources
  98584. */
  98585. dispose(): void;
  98586. }
  98587. /** Interface defining initialization parameters for Scene class */
  98588. export interface SceneOptions {
  98589. /**
  98590. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98591. * It will improve performance when the number of geometries becomes important.
  98592. */
  98593. useGeometryUniqueIdsMap?: boolean;
  98594. /**
  98595. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98596. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98597. */
  98598. useMaterialMeshMap?: boolean;
  98599. /**
  98600. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98601. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98602. */
  98603. useClonedMeshhMap?: boolean;
  98604. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98605. virtual?: boolean;
  98606. }
  98607. /**
  98608. * Represents a scene to be rendered by the engine.
  98609. * @see http://doc.babylonjs.com/features/scene
  98610. */
  98611. export class Scene extends AbstractScene implements IAnimatable {
  98612. /** The fog is deactivated */
  98613. static readonly FOGMODE_NONE: number;
  98614. /** The fog density is following an exponential function */
  98615. static readonly FOGMODE_EXP: number;
  98616. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98617. static readonly FOGMODE_EXP2: number;
  98618. /** The fog density is following a linear function. */
  98619. static readonly FOGMODE_LINEAR: number;
  98620. /**
  98621. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98623. */
  98624. static MinDeltaTime: number;
  98625. /**
  98626. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98628. */
  98629. static MaxDeltaTime: number;
  98630. /**
  98631. * Factory used to create the default material.
  98632. * @param name The name of the material to create
  98633. * @param scene The scene to create the material for
  98634. * @returns The default material
  98635. */
  98636. static DefaultMaterialFactory(scene: Scene): Material;
  98637. /**
  98638. * Factory used to create the a collision coordinator.
  98639. * @returns The collision coordinator
  98640. */
  98641. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98642. /** @hidden */
  98643. _inputManager: InputManager;
  98644. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98645. cameraToUseForPointers: Nullable<Camera>;
  98646. /** @hidden */
  98647. readonly _isScene: boolean;
  98648. /**
  98649. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98650. */
  98651. autoClear: boolean;
  98652. /**
  98653. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98654. */
  98655. autoClearDepthAndStencil: boolean;
  98656. /**
  98657. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98658. */
  98659. clearColor: Color4;
  98660. /**
  98661. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98662. */
  98663. ambientColor: Color3;
  98664. /**
  98665. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98666. * It should only be one of the following (if not the default embedded one):
  98667. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98668. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98669. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98670. * The material properties need to be setup according to the type of texture in use.
  98671. */
  98672. environmentBRDFTexture: BaseTexture;
  98673. /** @hidden */
  98674. protected _environmentTexture: Nullable<BaseTexture>;
  98675. /**
  98676. * Texture used in all pbr material as the reflection texture.
  98677. * As in the majority of the scene they are the same (exception for multi room and so on),
  98678. * this is easier to reference from here than from all the materials.
  98679. */
  98680. /**
  98681. * Texture used in all pbr material as the reflection texture.
  98682. * As in the majority of the scene they are the same (exception for multi room and so on),
  98683. * this is easier to set here than in all the materials.
  98684. */
  98685. environmentTexture: Nullable<BaseTexture>;
  98686. /** @hidden */
  98687. protected _environmentIntensity: number;
  98688. /**
  98689. * Intensity of the environment in all pbr material.
  98690. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98691. * As in the majority of the scene they are the same (exception for multi room and so on),
  98692. * this is easier to reference from here than from all the materials.
  98693. */
  98694. /**
  98695. * Intensity of the environment in all pbr material.
  98696. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98697. * As in the majority of the scene they are the same (exception for multi room and so on),
  98698. * this is easier to set here than in all the materials.
  98699. */
  98700. environmentIntensity: number;
  98701. /** @hidden */
  98702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98703. /**
  98704. * Default image processing configuration used either in the rendering
  98705. * Forward main pass or through the imageProcessingPostProcess if present.
  98706. * As in the majority of the scene they are the same (exception for multi camera),
  98707. * this is easier to reference from here than from all the materials and post process.
  98708. *
  98709. * No setter as we it is a shared configuration, you can set the values instead.
  98710. */
  98711. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98712. private _forceWireframe;
  98713. /**
  98714. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98715. */
  98716. forceWireframe: boolean;
  98717. private _forcePointsCloud;
  98718. /**
  98719. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98720. */
  98721. forcePointsCloud: boolean;
  98722. /**
  98723. * Gets or sets the active clipplane 1
  98724. */
  98725. clipPlane: Nullable<Plane>;
  98726. /**
  98727. * Gets or sets the active clipplane 2
  98728. */
  98729. clipPlane2: Nullable<Plane>;
  98730. /**
  98731. * Gets or sets the active clipplane 3
  98732. */
  98733. clipPlane3: Nullable<Plane>;
  98734. /**
  98735. * Gets or sets the active clipplane 4
  98736. */
  98737. clipPlane4: Nullable<Plane>;
  98738. /**
  98739. * Gets or sets a boolean indicating if animations are enabled
  98740. */
  98741. animationsEnabled: boolean;
  98742. private _animationPropertiesOverride;
  98743. /**
  98744. * Gets or sets the animation properties override
  98745. */
  98746. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98747. /**
  98748. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98749. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98750. */
  98751. useConstantAnimationDeltaTime: boolean;
  98752. /**
  98753. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98754. * Please note that it requires to run a ray cast through the scene on every frame
  98755. */
  98756. constantlyUpdateMeshUnderPointer: boolean;
  98757. /**
  98758. * Defines the HTML cursor to use when hovering over interactive elements
  98759. */
  98760. hoverCursor: string;
  98761. /**
  98762. * Defines the HTML default cursor to use (empty by default)
  98763. */
  98764. defaultCursor: string;
  98765. /**
  98766. * This is used to call preventDefault() on pointer down
  98767. * in order to block unwanted artifacts like system double clicks
  98768. */
  98769. preventDefaultOnPointerDown: boolean;
  98770. /**
  98771. * This is used to call preventDefault() on pointer up
  98772. * in order to block unwanted artifacts like system double clicks
  98773. */
  98774. preventDefaultOnPointerUp: boolean;
  98775. /**
  98776. * Gets or sets user defined metadata
  98777. */
  98778. metadata: any;
  98779. /**
  98780. * For internal use only. Please do not use.
  98781. */
  98782. reservedDataStore: any;
  98783. /**
  98784. * Gets the name of the plugin used to load this scene (null by default)
  98785. */
  98786. loadingPluginName: string;
  98787. /**
  98788. * Use this array to add regular expressions used to disable offline support for specific urls
  98789. */
  98790. disableOfflineSupportExceptionRules: RegExp[];
  98791. /**
  98792. * An event triggered when the scene is disposed.
  98793. */
  98794. onDisposeObservable: Observable<Scene>;
  98795. private _onDisposeObserver;
  98796. /** Sets a function to be executed when this scene is disposed. */
  98797. onDispose: () => void;
  98798. /**
  98799. * An event triggered before rendering the scene (right after animations and physics)
  98800. */
  98801. onBeforeRenderObservable: Observable<Scene>;
  98802. private _onBeforeRenderObserver;
  98803. /** Sets a function to be executed before rendering this scene */
  98804. beforeRender: Nullable<() => void>;
  98805. /**
  98806. * An event triggered after rendering the scene
  98807. */
  98808. onAfterRenderObservable: Observable<Scene>;
  98809. /**
  98810. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98811. */
  98812. onAfterRenderCameraObservable: Observable<Camera>;
  98813. private _onAfterRenderObserver;
  98814. /** Sets a function to be executed after rendering this scene */
  98815. afterRender: Nullable<() => void>;
  98816. /**
  98817. * An event triggered before animating the scene
  98818. */
  98819. onBeforeAnimationsObservable: Observable<Scene>;
  98820. /**
  98821. * An event triggered after animations processing
  98822. */
  98823. onAfterAnimationsObservable: Observable<Scene>;
  98824. /**
  98825. * An event triggered before draw calls are ready to be sent
  98826. */
  98827. onBeforeDrawPhaseObservable: Observable<Scene>;
  98828. /**
  98829. * An event triggered after draw calls have been sent
  98830. */
  98831. onAfterDrawPhaseObservable: Observable<Scene>;
  98832. /**
  98833. * An event triggered when the scene is ready
  98834. */
  98835. onReadyObservable: Observable<Scene>;
  98836. /**
  98837. * An event triggered before rendering a camera
  98838. */
  98839. onBeforeCameraRenderObservable: Observable<Camera>;
  98840. private _onBeforeCameraRenderObserver;
  98841. /** Sets a function to be executed before rendering a camera*/
  98842. beforeCameraRender: () => void;
  98843. /**
  98844. * An event triggered after rendering a camera
  98845. */
  98846. onAfterCameraRenderObservable: Observable<Camera>;
  98847. private _onAfterCameraRenderObserver;
  98848. /** Sets a function to be executed after rendering a camera*/
  98849. afterCameraRender: () => void;
  98850. /**
  98851. * An event triggered when active meshes evaluation is about to start
  98852. */
  98853. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98854. /**
  98855. * An event triggered when active meshes evaluation is done
  98856. */
  98857. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98858. /**
  98859. * An event triggered when particles rendering is about to start
  98860. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98861. */
  98862. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98863. /**
  98864. * An event triggered when particles rendering is done
  98865. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98866. */
  98867. onAfterParticlesRenderingObservable: Observable<Scene>;
  98868. /**
  98869. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98870. */
  98871. onDataLoadedObservable: Observable<Scene>;
  98872. /**
  98873. * An event triggered when a camera is created
  98874. */
  98875. onNewCameraAddedObservable: Observable<Camera>;
  98876. /**
  98877. * An event triggered when a camera is removed
  98878. */
  98879. onCameraRemovedObservable: Observable<Camera>;
  98880. /**
  98881. * An event triggered when a light is created
  98882. */
  98883. onNewLightAddedObservable: Observable<Light>;
  98884. /**
  98885. * An event triggered when a light is removed
  98886. */
  98887. onLightRemovedObservable: Observable<Light>;
  98888. /**
  98889. * An event triggered when a geometry is created
  98890. */
  98891. onNewGeometryAddedObservable: Observable<Geometry>;
  98892. /**
  98893. * An event triggered when a geometry is removed
  98894. */
  98895. onGeometryRemovedObservable: Observable<Geometry>;
  98896. /**
  98897. * An event triggered when a transform node is created
  98898. */
  98899. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98900. /**
  98901. * An event triggered when a transform node is removed
  98902. */
  98903. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98904. /**
  98905. * An event triggered when a mesh is created
  98906. */
  98907. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98908. /**
  98909. * An event triggered when a mesh is removed
  98910. */
  98911. onMeshRemovedObservable: Observable<AbstractMesh>;
  98912. /**
  98913. * An event triggered when a skeleton is created
  98914. */
  98915. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98916. /**
  98917. * An event triggered when a skeleton is removed
  98918. */
  98919. onSkeletonRemovedObservable: Observable<Skeleton>;
  98920. /**
  98921. * An event triggered when a material is created
  98922. */
  98923. onNewMaterialAddedObservable: Observable<Material>;
  98924. /**
  98925. * An event triggered when a material is removed
  98926. */
  98927. onMaterialRemovedObservable: Observable<Material>;
  98928. /**
  98929. * An event triggered when a texture is created
  98930. */
  98931. onNewTextureAddedObservable: Observable<BaseTexture>;
  98932. /**
  98933. * An event triggered when a texture is removed
  98934. */
  98935. onTextureRemovedObservable: Observable<BaseTexture>;
  98936. /**
  98937. * An event triggered when render targets are about to be rendered
  98938. * Can happen multiple times per frame.
  98939. */
  98940. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98941. /**
  98942. * An event triggered when render targets were rendered.
  98943. * Can happen multiple times per frame.
  98944. */
  98945. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98946. /**
  98947. * An event triggered before calculating deterministic simulation step
  98948. */
  98949. onBeforeStepObservable: Observable<Scene>;
  98950. /**
  98951. * An event triggered after calculating deterministic simulation step
  98952. */
  98953. onAfterStepObservable: Observable<Scene>;
  98954. /**
  98955. * An event triggered when the activeCamera property is updated
  98956. */
  98957. onActiveCameraChanged: Observable<Scene>;
  98958. /**
  98959. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98960. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98961. * 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)
  98962. */
  98963. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98964. /**
  98965. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98966. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98967. * 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)
  98968. */
  98969. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98970. /**
  98971. * This Observable will when a mesh has been imported into the scene.
  98972. */
  98973. onMeshImportedObservable: Observable<AbstractMesh>;
  98974. /**
  98975. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98976. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98977. */
  98978. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98979. /** @hidden */
  98980. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98981. /**
  98982. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98983. */
  98984. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98985. /**
  98986. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98987. */
  98988. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98989. /**
  98990. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98991. */
  98992. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98993. /** Callback called when a pointer move is detected */
  98994. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98995. /** Callback called when a pointer down is detected */
  98996. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98997. /** Callback called when a pointer up is detected */
  98998. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98999. /** Callback called when a pointer pick is detected */
  99000. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99001. /**
  99002. * 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).
  99003. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99004. */
  99005. onPrePointerObservable: Observable<PointerInfoPre>;
  99006. /**
  99007. * Observable event triggered each time an input event is received from the rendering canvas
  99008. */
  99009. onPointerObservable: Observable<PointerInfo>;
  99010. /**
  99011. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99012. */
  99013. readonly unTranslatedPointer: Vector2;
  99014. /**
  99015. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99016. */
  99017. static DragMovementThreshold: number;
  99018. /**
  99019. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99020. */
  99021. static LongPressDelay: number;
  99022. /**
  99023. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99024. */
  99025. static DoubleClickDelay: number;
  99026. /** If you need to check double click without raising a single click at first click, enable this flag */
  99027. static ExclusiveDoubleClickMode: boolean;
  99028. /** @hidden */
  99029. _mirroredCameraPosition: Nullable<Vector3>;
  99030. /**
  99031. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99032. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99033. */
  99034. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99035. /**
  99036. * Observable event triggered each time an keyboard event is received from the hosting window
  99037. */
  99038. onKeyboardObservable: Observable<KeyboardInfo>;
  99039. private _useRightHandedSystem;
  99040. /**
  99041. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99042. */
  99043. useRightHandedSystem: boolean;
  99044. private _timeAccumulator;
  99045. private _currentStepId;
  99046. private _currentInternalStep;
  99047. /**
  99048. * Sets the step Id used by deterministic lock step
  99049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99050. * @param newStepId defines the step Id
  99051. */
  99052. setStepId(newStepId: number): void;
  99053. /**
  99054. * Gets the step Id used by deterministic lock step
  99055. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99056. * @returns the step Id
  99057. */
  99058. getStepId(): number;
  99059. /**
  99060. * Gets the internal step used by deterministic lock step
  99061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99062. * @returns the internal step
  99063. */
  99064. getInternalStep(): number;
  99065. private _fogEnabled;
  99066. /**
  99067. * Gets or sets a boolean indicating if fog is enabled on this scene
  99068. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99069. * (Default is true)
  99070. */
  99071. fogEnabled: boolean;
  99072. private _fogMode;
  99073. /**
  99074. * Gets or sets the fog mode to use
  99075. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99076. * | mode | value |
  99077. * | --- | --- |
  99078. * | FOGMODE_NONE | 0 |
  99079. * | FOGMODE_EXP | 1 |
  99080. * | FOGMODE_EXP2 | 2 |
  99081. * | FOGMODE_LINEAR | 3 |
  99082. */
  99083. fogMode: number;
  99084. /**
  99085. * Gets or sets the fog color to use
  99086. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99087. * (Default is Color3(0.2, 0.2, 0.3))
  99088. */
  99089. fogColor: Color3;
  99090. /**
  99091. * Gets or sets the fog density to use
  99092. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99093. * (Default is 0.1)
  99094. */
  99095. fogDensity: number;
  99096. /**
  99097. * Gets or sets the fog start distance to use
  99098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99099. * (Default is 0)
  99100. */
  99101. fogStart: number;
  99102. /**
  99103. * Gets or sets the fog end distance to use
  99104. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99105. * (Default is 1000)
  99106. */
  99107. fogEnd: number;
  99108. private _shadowsEnabled;
  99109. /**
  99110. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99111. */
  99112. shadowsEnabled: boolean;
  99113. private _lightsEnabled;
  99114. /**
  99115. * Gets or sets a boolean indicating if lights are enabled on this scene
  99116. */
  99117. lightsEnabled: boolean;
  99118. /** All of the active cameras added to this scene. */
  99119. activeCameras: Camera[];
  99120. /** @hidden */
  99121. _activeCamera: Nullable<Camera>;
  99122. /** Gets or sets the current active camera */
  99123. activeCamera: Nullable<Camera>;
  99124. private _defaultMaterial;
  99125. /** The default material used on meshes when no material is affected */
  99126. /** The default material used on meshes when no material is affected */
  99127. defaultMaterial: Material;
  99128. private _texturesEnabled;
  99129. /**
  99130. * Gets or sets a boolean indicating if textures are enabled on this scene
  99131. */
  99132. texturesEnabled: boolean;
  99133. /**
  99134. * Gets or sets a boolean indicating if particles are enabled on this scene
  99135. */
  99136. particlesEnabled: boolean;
  99137. /**
  99138. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99139. */
  99140. spritesEnabled: boolean;
  99141. private _skeletonsEnabled;
  99142. /**
  99143. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99144. */
  99145. skeletonsEnabled: boolean;
  99146. /**
  99147. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99148. */
  99149. lensFlaresEnabled: boolean;
  99150. /**
  99151. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99153. */
  99154. collisionsEnabled: boolean;
  99155. private _collisionCoordinator;
  99156. /** @hidden */
  99157. readonly collisionCoordinator: ICollisionCoordinator;
  99158. /**
  99159. * Defines the gravity applied to this scene (used only for collisions)
  99160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99161. */
  99162. gravity: Vector3;
  99163. /**
  99164. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99165. */
  99166. postProcessesEnabled: boolean;
  99167. /**
  99168. * The list of postprocesses added to the scene
  99169. */
  99170. postProcesses: PostProcess[];
  99171. /**
  99172. * Gets the current postprocess manager
  99173. */
  99174. postProcessManager: PostProcessManager;
  99175. /**
  99176. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99177. */
  99178. renderTargetsEnabled: boolean;
  99179. /**
  99180. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99181. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99182. */
  99183. dumpNextRenderTargets: boolean;
  99184. /**
  99185. * The list of user defined render targets added to the scene
  99186. */
  99187. customRenderTargets: RenderTargetTexture[];
  99188. /**
  99189. * Defines if texture loading must be delayed
  99190. * If true, textures will only be loaded when they need to be rendered
  99191. */
  99192. useDelayedTextureLoading: boolean;
  99193. /**
  99194. * Gets the list of meshes imported to the scene through SceneLoader
  99195. */
  99196. importedMeshesFiles: String[];
  99197. /**
  99198. * Gets or sets a boolean indicating if probes are enabled on this scene
  99199. */
  99200. probesEnabled: boolean;
  99201. /**
  99202. * Gets or sets the current offline provider to use to store scene data
  99203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99204. */
  99205. offlineProvider: IOfflineProvider;
  99206. /**
  99207. * Gets or sets the action manager associated with the scene
  99208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99209. */
  99210. actionManager: AbstractActionManager;
  99211. private _meshesForIntersections;
  99212. /**
  99213. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99214. */
  99215. proceduralTexturesEnabled: boolean;
  99216. private _engine;
  99217. private _totalVertices;
  99218. /** @hidden */
  99219. _activeIndices: PerfCounter;
  99220. /** @hidden */
  99221. _activeParticles: PerfCounter;
  99222. /** @hidden */
  99223. _activeBones: PerfCounter;
  99224. private _animationRatio;
  99225. /** @hidden */
  99226. _animationTimeLast: number;
  99227. /** @hidden */
  99228. _animationTime: number;
  99229. /**
  99230. * Gets or sets a general scale for animation speed
  99231. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99232. */
  99233. animationTimeScale: number;
  99234. /** @hidden */
  99235. _cachedMaterial: Nullable<Material>;
  99236. /** @hidden */
  99237. _cachedEffect: Nullable<Effect>;
  99238. /** @hidden */
  99239. _cachedVisibility: Nullable<number>;
  99240. private _renderId;
  99241. private _frameId;
  99242. private _executeWhenReadyTimeoutId;
  99243. private _intermediateRendering;
  99244. private _viewUpdateFlag;
  99245. private _projectionUpdateFlag;
  99246. /** @hidden */
  99247. _toBeDisposed: Nullable<IDisposable>[];
  99248. private _activeRequests;
  99249. /** @hidden */
  99250. _pendingData: any[];
  99251. private _isDisposed;
  99252. /**
  99253. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99254. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99255. */
  99256. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99257. private _activeMeshes;
  99258. private _processedMaterials;
  99259. private _renderTargets;
  99260. /** @hidden */
  99261. _activeParticleSystems: SmartArray<IParticleSystem>;
  99262. private _activeSkeletons;
  99263. private _softwareSkinnedMeshes;
  99264. private _renderingManager;
  99265. /** @hidden */
  99266. _activeAnimatables: Animatable[];
  99267. private _transformMatrix;
  99268. private _sceneUbo;
  99269. /** @hidden */
  99270. _viewMatrix: Matrix;
  99271. private _projectionMatrix;
  99272. /** @hidden */
  99273. _forcedViewPosition: Nullable<Vector3>;
  99274. /** @hidden */
  99275. _frustumPlanes: Plane[];
  99276. /**
  99277. * Gets the list of frustum planes (built from the active camera)
  99278. */
  99279. readonly frustumPlanes: Plane[];
  99280. /**
  99281. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99282. * This is useful if there are more lights that the maximum simulteanous authorized
  99283. */
  99284. requireLightSorting: boolean;
  99285. /** @hidden */
  99286. readonly useMaterialMeshMap: boolean;
  99287. /** @hidden */
  99288. readonly useClonedMeshhMap: boolean;
  99289. private _externalData;
  99290. private _uid;
  99291. /**
  99292. * @hidden
  99293. * Backing store of defined scene components.
  99294. */
  99295. _components: ISceneComponent[];
  99296. /**
  99297. * @hidden
  99298. * Backing store of defined scene components.
  99299. */
  99300. _serializableComponents: ISceneSerializableComponent[];
  99301. /**
  99302. * List of components to register on the next registration step.
  99303. */
  99304. private _transientComponents;
  99305. /**
  99306. * Registers the transient components if needed.
  99307. */
  99308. private _registerTransientComponents;
  99309. /**
  99310. * @hidden
  99311. * Add a component to the scene.
  99312. * Note that the ccomponent could be registered on th next frame if this is called after
  99313. * the register component stage.
  99314. * @param component Defines the component to add to the scene
  99315. */
  99316. _addComponent(component: ISceneComponent): void;
  99317. /**
  99318. * @hidden
  99319. * Gets a component from the scene.
  99320. * @param name defines the name of the component to retrieve
  99321. * @returns the component or null if not present
  99322. */
  99323. _getComponent(name: string): Nullable<ISceneComponent>;
  99324. /**
  99325. * @hidden
  99326. * Defines the actions happening before camera updates.
  99327. */
  99328. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99329. /**
  99330. * @hidden
  99331. * Defines the actions happening before clear the canvas.
  99332. */
  99333. _beforeClearStage: Stage<SimpleStageAction>;
  99334. /**
  99335. * @hidden
  99336. * Defines the actions when collecting render targets for the frame.
  99337. */
  99338. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99339. /**
  99340. * @hidden
  99341. * Defines the actions happening for one camera in the frame.
  99342. */
  99343. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99344. /**
  99345. * @hidden
  99346. * Defines the actions happening during the per mesh ready checks.
  99347. */
  99348. _isReadyForMeshStage: Stage<MeshStageAction>;
  99349. /**
  99350. * @hidden
  99351. * Defines the actions happening before evaluate active mesh checks.
  99352. */
  99353. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99354. /**
  99355. * @hidden
  99356. * Defines the actions happening during the evaluate sub mesh checks.
  99357. */
  99358. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99359. /**
  99360. * @hidden
  99361. * Defines the actions happening during the active mesh stage.
  99362. */
  99363. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99364. /**
  99365. * @hidden
  99366. * Defines the actions happening during the per camera render target step.
  99367. */
  99368. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99369. /**
  99370. * @hidden
  99371. * Defines the actions happening just before the active camera is drawing.
  99372. */
  99373. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99374. /**
  99375. * @hidden
  99376. * Defines the actions happening just before a render target is drawing.
  99377. */
  99378. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99379. /**
  99380. * @hidden
  99381. * Defines the actions happening just before a rendering group is drawing.
  99382. */
  99383. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99384. /**
  99385. * @hidden
  99386. * Defines the actions happening just before a mesh is drawing.
  99387. */
  99388. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99389. /**
  99390. * @hidden
  99391. * Defines the actions happening just after a mesh has been drawn.
  99392. */
  99393. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99394. /**
  99395. * @hidden
  99396. * Defines the actions happening just after a rendering group has been drawn.
  99397. */
  99398. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99399. /**
  99400. * @hidden
  99401. * Defines the actions happening just after the active camera has been drawn.
  99402. */
  99403. _afterCameraDrawStage: Stage<CameraStageAction>;
  99404. /**
  99405. * @hidden
  99406. * Defines the actions happening just after a render target has been drawn.
  99407. */
  99408. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99409. /**
  99410. * @hidden
  99411. * Defines the actions happening just after rendering all cameras and computing intersections.
  99412. */
  99413. _afterRenderStage: Stage<SimpleStageAction>;
  99414. /**
  99415. * @hidden
  99416. * Defines the actions happening when a pointer move event happens.
  99417. */
  99418. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99419. /**
  99420. * @hidden
  99421. * Defines the actions happening when a pointer down event happens.
  99422. */
  99423. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99424. /**
  99425. * @hidden
  99426. * Defines the actions happening when a pointer up event happens.
  99427. */
  99428. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99429. /**
  99430. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99431. */
  99432. private geometriesByUniqueId;
  99433. /**
  99434. * Creates a new Scene
  99435. * @param engine defines the engine to use to render this scene
  99436. * @param options defines the scene options
  99437. */
  99438. constructor(engine: Engine, options?: SceneOptions);
  99439. /**
  99440. * Gets a string idenfifying the name of the class
  99441. * @returns "Scene" string
  99442. */
  99443. getClassName(): string;
  99444. private _defaultMeshCandidates;
  99445. /**
  99446. * @hidden
  99447. */
  99448. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99449. private _defaultSubMeshCandidates;
  99450. /**
  99451. * @hidden
  99452. */
  99453. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99454. /**
  99455. * Sets the default candidate providers for the scene.
  99456. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99457. * and getCollidingSubMeshCandidates to their default function
  99458. */
  99459. setDefaultCandidateProviders(): void;
  99460. /**
  99461. * Gets the mesh that is currently under the pointer
  99462. */
  99463. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99464. /**
  99465. * Gets or sets the current on-screen X position of the pointer
  99466. */
  99467. pointerX: number;
  99468. /**
  99469. * Gets or sets the current on-screen Y position of the pointer
  99470. */
  99471. pointerY: number;
  99472. /**
  99473. * Gets the cached material (ie. the latest rendered one)
  99474. * @returns the cached material
  99475. */
  99476. getCachedMaterial(): Nullable<Material>;
  99477. /**
  99478. * Gets the cached effect (ie. the latest rendered one)
  99479. * @returns the cached effect
  99480. */
  99481. getCachedEffect(): Nullable<Effect>;
  99482. /**
  99483. * Gets the cached visibility state (ie. the latest rendered one)
  99484. * @returns the cached visibility state
  99485. */
  99486. getCachedVisibility(): Nullable<number>;
  99487. /**
  99488. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99489. * @param material defines the current material
  99490. * @param effect defines the current effect
  99491. * @param visibility defines the current visibility state
  99492. * @returns true if one parameter is not cached
  99493. */
  99494. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99495. /**
  99496. * Gets the engine associated with the scene
  99497. * @returns an Engine
  99498. */
  99499. getEngine(): Engine;
  99500. /**
  99501. * Gets the total number of vertices rendered per frame
  99502. * @returns the total number of vertices rendered per frame
  99503. */
  99504. getTotalVertices(): number;
  99505. /**
  99506. * Gets the performance counter for total vertices
  99507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99508. */
  99509. readonly totalVerticesPerfCounter: PerfCounter;
  99510. /**
  99511. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99512. * @returns the total number of active indices rendered per frame
  99513. */
  99514. getActiveIndices(): number;
  99515. /**
  99516. * Gets the performance counter for active indices
  99517. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99518. */
  99519. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99520. /**
  99521. * Gets the total number of active particles rendered per frame
  99522. * @returns the total number of active particles rendered per frame
  99523. */
  99524. getActiveParticles(): number;
  99525. /**
  99526. * Gets the performance counter for active particles
  99527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99528. */
  99529. readonly activeParticlesPerfCounter: PerfCounter;
  99530. /**
  99531. * Gets the total number of active bones rendered per frame
  99532. * @returns the total number of active bones rendered per frame
  99533. */
  99534. getActiveBones(): number;
  99535. /**
  99536. * Gets the performance counter for active bones
  99537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99538. */
  99539. readonly activeBonesPerfCounter: PerfCounter;
  99540. /**
  99541. * Gets the array of active meshes
  99542. * @returns an array of AbstractMesh
  99543. */
  99544. getActiveMeshes(): SmartArray<AbstractMesh>;
  99545. /**
  99546. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99547. * @returns a number
  99548. */
  99549. getAnimationRatio(): number;
  99550. /**
  99551. * Gets an unique Id for the current render phase
  99552. * @returns a number
  99553. */
  99554. getRenderId(): number;
  99555. /**
  99556. * Gets an unique Id for the current frame
  99557. * @returns a number
  99558. */
  99559. getFrameId(): number;
  99560. /** Call this function if you want to manually increment the render Id*/
  99561. incrementRenderId(): void;
  99562. private _createUbo;
  99563. /**
  99564. * Use this method to simulate a pointer move on a mesh
  99565. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99566. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99567. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99568. * @returns the current scene
  99569. */
  99570. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99571. /**
  99572. * Use this method to simulate a pointer down on a mesh
  99573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99576. * @returns the current scene
  99577. */
  99578. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99579. /**
  99580. * Use this method to simulate a pointer up on a mesh
  99581. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99582. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99583. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99584. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99585. * @returns the current scene
  99586. */
  99587. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99588. /**
  99589. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99590. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99591. * @returns true if the pointer was captured
  99592. */
  99593. isPointerCaptured(pointerId?: number): boolean;
  99594. /**
  99595. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99596. * @param attachUp defines if you want to attach events to pointerup
  99597. * @param attachDown defines if you want to attach events to pointerdown
  99598. * @param attachMove defines if you want to attach events to pointermove
  99599. */
  99600. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99601. /** Detaches all event handlers*/
  99602. detachControl(): void;
  99603. /**
  99604. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99605. * Delay loaded resources are not taking in account
  99606. * @return true if all required resources are ready
  99607. */
  99608. isReady(): boolean;
  99609. /** Resets all cached information relative to material (including effect and visibility) */
  99610. resetCachedMaterial(): void;
  99611. /**
  99612. * Registers a function to be called before every frame render
  99613. * @param func defines the function to register
  99614. */
  99615. registerBeforeRender(func: () => void): void;
  99616. /**
  99617. * Unregisters a function called before every frame render
  99618. * @param func defines the function to unregister
  99619. */
  99620. unregisterBeforeRender(func: () => void): void;
  99621. /**
  99622. * Registers a function to be called after every frame render
  99623. * @param func defines the function to register
  99624. */
  99625. registerAfterRender(func: () => void): void;
  99626. /**
  99627. * Unregisters a function called after every frame render
  99628. * @param func defines the function to unregister
  99629. */
  99630. unregisterAfterRender(func: () => void): void;
  99631. private _executeOnceBeforeRender;
  99632. /**
  99633. * The provided function will run before render once and will be disposed afterwards.
  99634. * A timeout delay can be provided so that the function will be executed in N ms.
  99635. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99636. * @param func The function to be executed.
  99637. * @param timeout optional delay in ms
  99638. */
  99639. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99640. /** @hidden */
  99641. _addPendingData(data: any): void;
  99642. /** @hidden */
  99643. _removePendingData(data: any): void;
  99644. /**
  99645. * Returns the number of items waiting to be loaded
  99646. * @returns the number of items waiting to be loaded
  99647. */
  99648. getWaitingItemsCount(): number;
  99649. /**
  99650. * Returns a boolean indicating if the scene is still loading data
  99651. */
  99652. readonly isLoading: boolean;
  99653. /**
  99654. * Registers a function to be executed when the scene is ready
  99655. * @param {Function} func - the function to be executed
  99656. */
  99657. executeWhenReady(func: () => void): void;
  99658. /**
  99659. * Returns a promise that resolves when the scene is ready
  99660. * @returns A promise that resolves when the scene is ready
  99661. */
  99662. whenReadyAsync(): Promise<void>;
  99663. /** @hidden */
  99664. _checkIsReady(): void;
  99665. /**
  99666. * Gets all animatable attached to the scene
  99667. */
  99668. readonly animatables: Animatable[];
  99669. /**
  99670. * Resets the last animation time frame.
  99671. * Useful to override when animations start running when loading a scene for the first time.
  99672. */
  99673. resetLastAnimationTimeFrame(): void;
  99674. /**
  99675. * Gets the current view matrix
  99676. * @returns a Matrix
  99677. */
  99678. getViewMatrix(): Matrix;
  99679. /**
  99680. * Gets the current projection matrix
  99681. * @returns a Matrix
  99682. */
  99683. getProjectionMatrix(): Matrix;
  99684. /**
  99685. * Gets the current transform matrix
  99686. * @returns a Matrix made of View * Projection
  99687. */
  99688. getTransformMatrix(): Matrix;
  99689. /**
  99690. * Sets the current transform matrix
  99691. * @param viewL defines the View matrix to use
  99692. * @param projectionL defines the Projection matrix to use
  99693. * @param viewR defines the right View matrix to use (if provided)
  99694. * @param projectionR defines the right Projection matrix to use (if provided)
  99695. */
  99696. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99697. /**
  99698. * Gets the uniform buffer used to store scene data
  99699. * @returns a UniformBuffer
  99700. */
  99701. getSceneUniformBuffer(): UniformBuffer;
  99702. /**
  99703. * Gets an unique (relatively to the current scene) Id
  99704. * @returns an unique number for the scene
  99705. */
  99706. getUniqueId(): number;
  99707. /**
  99708. * Add a mesh to the list of scene's meshes
  99709. * @param newMesh defines the mesh to add
  99710. * @param recursive if all child meshes should also be added to the scene
  99711. */
  99712. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99713. /**
  99714. * Remove a mesh for the list of scene's meshes
  99715. * @param toRemove defines the mesh to remove
  99716. * @param recursive if all child meshes should also be removed from the scene
  99717. * @returns the index where the mesh was in the mesh list
  99718. */
  99719. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99720. /**
  99721. * Add a transform node to the list of scene's transform nodes
  99722. * @param newTransformNode defines the transform node to add
  99723. */
  99724. addTransformNode(newTransformNode: TransformNode): void;
  99725. /**
  99726. * Remove a transform node for the list of scene's transform nodes
  99727. * @param toRemove defines the transform node to remove
  99728. * @returns the index where the transform node was in the transform node list
  99729. */
  99730. removeTransformNode(toRemove: TransformNode): number;
  99731. /**
  99732. * Remove a skeleton for the list of scene's skeletons
  99733. * @param toRemove defines the skeleton to remove
  99734. * @returns the index where the skeleton was in the skeleton list
  99735. */
  99736. removeSkeleton(toRemove: Skeleton): number;
  99737. /**
  99738. * Remove a morph target for the list of scene's morph targets
  99739. * @param toRemove defines the morph target to remove
  99740. * @returns the index where the morph target was in the morph target list
  99741. */
  99742. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99743. /**
  99744. * Remove a light for the list of scene's lights
  99745. * @param toRemove defines the light to remove
  99746. * @returns the index where the light was in the light list
  99747. */
  99748. removeLight(toRemove: Light): number;
  99749. /**
  99750. * Remove a camera for the list of scene's cameras
  99751. * @param toRemove defines the camera to remove
  99752. * @returns the index where the camera was in the camera list
  99753. */
  99754. removeCamera(toRemove: Camera): number;
  99755. /**
  99756. * Remove a particle system for the list of scene's particle systems
  99757. * @param toRemove defines the particle system to remove
  99758. * @returns the index where the particle system was in the particle system list
  99759. */
  99760. removeParticleSystem(toRemove: IParticleSystem): number;
  99761. /**
  99762. * Remove a animation for the list of scene's animations
  99763. * @param toRemove defines the animation to remove
  99764. * @returns the index where the animation was in the animation list
  99765. */
  99766. removeAnimation(toRemove: Animation): number;
  99767. /**
  99768. * Will stop the animation of the given target
  99769. * @param target - the target
  99770. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99771. * @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)
  99772. */
  99773. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99774. /**
  99775. * Removes the given animation group from this scene.
  99776. * @param toRemove The animation group to remove
  99777. * @returns The index of the removed animation group
  99778. */
  99779. removeAnimationGroup(toRemove: AnimationGroup): number;
  99780. /**
  99781. * Removes the given multi-material from this scene.
  99782. * @param toRemove The multi-material to remove
  99783. * @returns The index of the removed multi-material
  99784. */
  99785. removeMultiMaterial(toRemove: MultiMaterial): number;
  99786. /**
  99787. * Removes the given material from this scene.
  99788. * @param toRemove The material to remove
  99789. * @returns The index of the removed material
  99790. */
  99791. removeMaterial(toRemove: Material): number;
  99792. /**
  99793. * Removes the given action manager from this scene.
  99794. * @param toRemove The action manager to remove
  99795. * @returns The index of the removed action manager
  99796. */
  99797. removeActionManager(toRemove: AbstractActionManager): number;
  99798. /**
  99799. * Removes the given texture from this scene.
  99800. * @param toRemove The texture to remove
  99801. * @returns The index of the removed texture
  99802. */
  99803. removeTexture(toRemove: BaseTexture): number;
  99804. /**
  99805. * Adds the given light to this scene
  99806. * @param newLight The light to add
  99807. */
  99808. addLight(newLight: Light): void;
  99809. /**
  99810. * Sorts the list list based on light priorities
  99811. */
  99812. sortLightsByPriority(): void;
  99813. /**
  99814. * Adds the given camera to this scene
  99815. * @param newCamera The camera to add
  99816. */
  99817. addCamera(newCamera: Camera): void;
  99818. /**
  99819. * Adds the given skeleton to this scene
  99820. * @param newSkeleton The skeleton to add
  99821. */
  99822. addSkeleton(newSkeleton: Skeleton): void;
  99823. /**
  99824. * Adds the given particle system to this scene
  99825. * @param newParticleSystem The particle system to add
  99826. */
  99827. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99828. /**
  99829. * Adds the given animation to this scene
  99830. * @param newAnimation The animation to add
  99831. */
  99832. addAnimation(newAnimation: Animation): void;
  99833. /**
  99834. * Adds the given animation group to this scene.
  99835. * @param newAnimationGroup The animation group to add
  99836. */
  99837. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99838. /**
  99839. * Adds the given multi-material to this scene
  99840. * @param newMultiMaterial The multi-material to add
  99841. */
  99842. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99843. /**
  99844. * Adds the given material to this scene
  99845. * @param newMaterial The material to add
  99846. */
  99847. addMaterial(newMaterial: Material): void;
  99848. /**
  99849. * Adds the given morph target to this scene
  99850. * @param newMorphTargetManager The morph target to add
  99851. */
  99852. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99853. /**
  99854. * Adds the given geometry to this scene
  99855. * @param newGeometry The geometry to add
  99856. */
  99857. addGeometry(newGeometry: Geometry): void;
  99858. /**
  99859. * Adds the given action manager to this scene
  99860. * @param newActionManager The action manager to add
  99861. */
  99862. addActionManager(newActionManager: AbstractActionManager): void;
  99863. /**
  99864. * Adds the given texture to this scene.
  99865. * @param newTexture The texture to add
  99866. */
  99867. addTexture(newTexture: BaseTexture): void;
  99868. /**
  99869. * Switch active camera
  99870. * @param newCamera defines the new active camera
  99871. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99872. */
  99873. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99874. /**
  99875. * sets the active camera of the scene using its ID
  99876. * @param id defines the camera's ID
  99877. * @return the new active camera or null if none found.
  99878. */
  99879. setActiveCameraByID(id: string): Nullable<Camera>;
  99880. /**
  99881. * sets the active camera of the scene using its name
  99882. * @param name defines the camera's name
  99883. * @returns the new active camera or null if none found.
  99884. */
  99885. setActiveCameraByName(name: string): Nullable<Camera>;
  99886. /**
  99887. * get an animation group using its name
  99888. * @param name defines the material's name
  99889. * @return the animation group or null if none found.
  99890. */
  99891. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99892. /**
  99893. * Get a material using its unique id
  99894. * @param uniqueId defines the material's unique id
  99895. * @return the material or null if none found.
  99896. */
  99897. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99898. /**
  99899. * get a material using its id
  99900. * @param id defines the material's ID
  99901. * @return the material or null if none found.
  99902. */
  99903. getMaterialByID(id: string): Nullable<Material>;
  99904. /**
  99905. * Gets a the last added material using a given id
  99906. * @param id defines the material's ID
  99907. * @return the last material with the given id or null if none found.
  99908. */
  99909. getLastMaterialByID(id: string): Nullable<Material>;
  99910. /**
  99911. * Gets a material using its name
  99912. * @param name defines the material's name
  99913. * @return the material or null if none found.
  99914. */
  99915. getMaterialByName(name: string): Nullable<Material>;
  99916. /**
  99917. * Get a texture using its unique id
  99918. * @param uniqueId defines the texture's unique id
  99919. * @return the texture or null if none found.
  99920. */
  99921. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99922. /**
  99923. * Gets a camera using its id
  99924. * @param id defines the id to look for
  99925. * @returns the camera or null if not found
  99926. */
  99927. getCameraByID(id: string): Nullable<Camera>;
  99928. /**
  99929. * Gets a camera using its unique id
  99930. * @param uniqueId defines the unique id to look for
  99931. * @returns the camera or null if not found
  99932. */
  99933. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99934. /**
  99935. * Gets a camera using its name
  99936. * @param name defines the camera's name
  99937. * @return the camera or null if none found.
  99938. */
  99939. getCameraByName(name: string): Nullable<Camera>;
  99940. /**
  99941. * Gets a bone using its id
  99942. * @param id defines the bone's id
  99943. * @return the bone or null if not found
  99944. */
  99945. getBoneByID(id: string): Nullable<Bone>;
  99946. /**
  99947. * Gets a bone using its id
  99948. * @param name defines the bone's name
  99949. * @return the bone or null if not found
  99950. */
  99951. getBoneByName(name: string): Nullable<Bone>;
  99952. /**
  99953. * Gets a light node using its name
  99954. * @param name defines the the light's name
  99955. * @return the light or null if none found.
  99956. */
  99957. getLightByName(name: string): Nullable<Light>;
  99958. /**
  99959. * Gets a light node using its id
  99960. * @param id defines the light's id
  99961. * @return the light or null if none found.
  99962. */
  99963. getLightByID(id: string): Nullable<Light>;
  99964. /**
  99965. * Gets a light node using its scene-generated unique ID
  99966. * @param uniqueId defines the light's unique id
  99967. * @return the light or null if none found.
  99968. */
  99969. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99970. /**
  99971. * Gets a particle system by id
  99972. * @param id defines the particle system id
  99973. * @return the corresponding system or null if none found
  99974. */
  99975. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99976. /**
  99977. * Gets a geometry using its ID
  99978. * @param id defines the geometry's id
  99979. * @return the geometry or null if none found.
  99980. */
  99981. getGeometryByID(id: string): Nullable<Geometry>;
  99982. private _getGeometryByUniqueID;
  99983. /**
  99984. * Add a new geometry to this scene
  99985. * @param geometry defines the geometry to be added to the scene.
  99986. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99987. * @return a boolean defining if the geometry was added or not
  99988. */
  99989. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99990. /**
  99991. * Removes an existing geometry
  99992. * @param geometry defines the geometry to be removed from the scene
  99993. * @return a boolean defining if the geometry was removed or not
  99994. */
  99995. removeGeometry(geometry: Geometry): boolean;
  99996. /**
  99997. * Gets the list of geometries attached to the scene
  99998. * @returns an array of Geometry
  99999. */
  100000. getGeometries(): Geometry[];
  100001. /**
  100002. * Gets the first added mesh found of a given ID
  100003. * @param id defines the id to search for
  100004. * @return the mesh found or null if not found at all
  100005. */
  100006. getMeshByID(id: string): Nullable<AbstractMesh>;
  100007. /**
  100008. * Gets a list of meshes using their id
  100009. * @param id defines the id to search for
  100010. * @returns a list of meshes
  100011. */
  100012. getMeshesByID(id: string): Array<AbstractMesh>;
  100013. /**
  100014. * Gets the first added transform node found of a given ID
  100015. * @param id defines the id to search for
  100016. * @return the found transform node or null if not found at all.
  100017. */
  100018. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100019. /**
  100020. * Gets a transform node with its auto-generated unique id
  100021. * @param uniqueId efines the unique id to search for
  100022. * @return the found transform node or null if not found at all.
  100023. */
  100024. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100025. /**
  100026. * Gets a list of transform nodes using their id
  100027. * @param id defines the id to search for
  100028. * @returns a list of transform nodes
  100029. */
  100030. getTransformNodesByID(id: string): Array<TransformNode>;
  100031. /**
  100032. * Gets a mesh with its auto-generated unique id
  100033. * @param uniqueId defines the unique id to search for
  100034. * @return the found mesh or null if not found at all.
  100035. */
  100036. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100037. /**
  100038. * Gets a the last added mesh using a given id
  100039. * @param id defines the id to search for
  100040. * @return the found mesh or null if not found at all.
  100041. */
  100042. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100043. /**
  100044. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100045. * @param id defines the id to search for
  100046. * @return the found node or null if not found at all
  100047. */
  100048. getLastEntryByID(id: string): Nullable<Node>;
  100049. /**
  100050. * Gets a node (Mesh, Camera, Light) using a given id
  100051. * @param id defines the id to search for
  100052. * @return the found node or null if not found at all
  100053. */
  100054. getNodeByID(id: string): Nullable<Node>;
  100055. /**
  100056. * Gets a node (Mesh, Camera, Light) using a given name
  100057. * @param name defines the name to search for
  100058. * @return the found node or null if not found at all.
  100059. */
  100060. getNodeByName(name: string): Nullable<Node>;
  100061. /**
  100062. * Gets a mesh using a given name
  100063. * @param name defines the name to search for
  100064. * @return the found mesh or null if not found at all.
  100065. */
  100066. getMeshByName(name: string): Nullable<AbstractMesh>;
  100067. /**
  100068. * Gets a transform node using a given name
  100069. * @param name defines the name to search for
  100070. * @return the found transform node or null if not found at all.
  100071. */
  100072. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100073. /**
  100074. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100075. * @param id defines the id to search for
  100076. * @return the found skeleton or null if not found at all.
  100077. */
  100078. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100079. /**
  100080. * Gets a skeleton using a given auto generated unique id
  100081. * @param uniqueId defines the unique id to search for
  100082. * @return the found skeleton or null if not found at all.
  100083. */
  100084. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100085. /**
  100086. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100087. * @param id defines the id to search for
  100088. * @return the found skeleton or null if not found at all.
  100089. */
  100090. getSkeletonById(id: string): Nullable<Skeleton>;
  100091. /**
  100092. * Gets a skeleton using a given name
  100093. * @param name defines the name to search for
  100094. * @return the found skeleton or null if not found at all.
  100095. */
  100096. getSkeletonByName(name: string): Nullable<Skeleton>;
  100097. /**
  100098. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100099. * @param id defines the id to search for
  100100. * @return the found morph target manager or null if not found at all.
  100101. */
  100102. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100103. /**
  100104. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100105. * @param id defines the id to search for
  100106. * @return the found morph target or null if not found at all.
  100107. */
  100108. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100109. /**
  100110. * Gets a boolean indicating if the given mesh is active
  100111. * @param mesh defines the mesh to look for
  100112. * @returns true if the mesh is in the active list
  100113. */
  100114. isActiveMesh(mesh: AbstractMesh): boolean;
  100115. /**
  100116. * Return a unique id as a string which can serve as an identifier for the scene
  100117. */
  100118. readonly uid: string;
  100119. /**
  100120. * Add an externaly attached data from its key.
  100121. * This method call will fail and return false, if such key already exists.
  100122. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100123. * @param key the unique key that identifies the data
  100124. * @param data the data object to associate to the key for this Engine instance
  100125. * @return true if no such key were already present and the data was added successfully, false otherwise
  100126. */
  100127. addExternalData<T>(key: string, data: T): boolean;
  100128. /**
  100129. * Get an externaly attached data from its key
  100130. * @param key the unique key that identifies the data
  100131. * @return the associated data, if present (can be null), or undefined if not present
  100132. */
  100133. getExternalData<T>(key: string): Nullable<T>;
  100134. /**
  100135. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100136. * @param key the unique key that identifies the data
  100137. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100138. * @return the associated data, can be null if the factory returned null.
  100139. */
  100140. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100141. /**
  100142. * Remove an externaly attached data from the Engine instance
  100143. * @param key the unique key that identifies the data
  100144. * @return true if the data was successfully removed, false if it doesn't exist
  100145. */
  100146. removeExternalData(key: string): boolean;
  100147. private _evaluateSubMesh;
  100148. /**
  100149. * Clear the processed materials smart array preventing retention point in material dispose.
  100150. */
  100151. freeProcessedMaterials(): void;
  100152. private _preventFreeActiveMeshesAndRenderingGroups;
  100153. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100154. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100155. * when disposing several meshes in a row or a hierarchy of meshes.
  100156. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100157. */
  100158. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100159. /**
  100160. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100161. */
  100162. freeActiveMeshes(): void;
  100163. /**
  100164. * Clear the info related to rendering groups preventing retention points during dispose.
  100165. */
  100166. freeRenderingGroups(): void;
  100167. /** @hidden */
  100168. _isInIntermediateRendering(): boolean;
  100169. /**
  100170. * Lambda returning the list of potentially active meshes.
  100171. */
  100172. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100173. /**
  100174. * Lambda returning the list of potentially active sub meshes.
  100175. */
  100176. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100177. /**
  100178. * Lambda returning the list of potentially intersecting sub meshes.
  100179. */
  100180. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100181. /**
  100182. * Lambda returning the list of potentially colliding sub meshes.
  100183. */
  100184. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100185. private _activeMeshesFrozen;
  100186. /**
  100187. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100188. * @returns the current scene
  100189. */
  100190. freezeActiveMeshes(): Scene;
  100191. /**
  100192. * Use this function to restart evaluating active meshes on every frame
  100193. * @returns the current scene
  100194. */
  100195. unfreezeActiveMeshes(): Scene;
  100196. private _evaluateActiveMeshes;
  100197. private _activeMesh;
  100198. /**
  100199. * Update the transform matrix to update from the current active camera
  100200. * @param force defines a boolean used to force the update even if cache is up to date
  100201. */
  100202. updateTransformMatrix(force?: boolean): void;
  100203. private _bindFrameBuffer;
  100204. /** @hidden */
  100205. _allowPostProcessClearColor: boolean;
  100206. /** @hidden */
  100207. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100208. private _processSubCameras;
  100209. private _checkIntersections;
  100210. /** @hidden */
  100211. _advancePhysicsEngineStep(step: number): void;
  100212. /**
  100213. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100214. */
  100215. getDeterministicFrameTime: () => number;
  100216. /** @hidden */
  100217. _animate(): void;
  100218. /** Execute all animations (for a frame) */
  100219. animate(): void;
  100220. /**
  100221. * Render the scene
  100222. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100223. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100224. */
  100225. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100226. /**
  100227. * Freeze all materials
  100228. * A frozen material will not be updatable but should be faster to render
  100229. */
  100230. freezeMaterials(): void;
  100231. /**
  100232. * Unfreeze all materials
  100233. * A frozen material will not be updatable but should be faster to render
  100234. */
  100235. unfreezeMaterials(): void;
  100236. /**
  100237. * Releases all held ressources
  100238. */
  100239. dispose(): void;
  100240. /**
  100241. * Gets if the scene is already disposed
  100242. */
  100243. readonly isDisposed: boolean;
  100244. /**
  100245. * Call this function to reduce memory footprint of the scene.
  100246. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100247. */
  100248. clearCachedVertexData(): void;
  100249. /**
  100250. * This function will remove the local cached buffer data from texture.
  100251. * It will save memory but will prevent the texture from being rebuilt
  100252. */
  100253. cleanCachedTextureBuffer(): void;
  100254. /**
  100255. * Get the world extend vectors with an optional filter
  100256. *
  100257. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100258. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100259. */
  100260. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100261. min: Vector3;
  100262. max: Vector3;
  100263. };
  100264. /**
  100265. * Creates a ray that can be used to pick in the scene
  100266. * @param x defines the x coordinate of the origin (on-screen)
  100267. * @param y defines the y coordinate of the origin (on-screen)
  100268. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100269. * @param camera defines the camera to use for the picking
  100270. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100271. * @returns a Ray
  100272. */
  100273. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100274. /**
  100275. * Creates a ray that can be used to pick in the scene
  100276. * @param x defines the x coordinate of the origin (on-screen)
  100277. * @param y defines the y coordinate of the origin (on-screen)
  100278. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100279. * @param result defines the ray where to store the picking ray
  100280. * @param camera defines the camera to use for the picking
  100281. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100282. * @returns the current scene
  100283. */
  100284. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100285. /**
  100286. * Creates a ray that can be used to pick in the scene
  100287. * @param x defines the x coordinate of the origin (on-screen)
  100288. * @param y defines the y coordinate of the origin (on-screen)
  100289. * @param camera defines the camera to use for the picking
  100290. * @returns a Ray
  100291. */
  100292. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100293. /**
  100294. * Creates a ray that can be used to pick in the scene
  100295. * @param x defines the x coordinate of the origin (on-screen)
  100296. * @param y defines the y coordinate of the origin (on-screen)
  100297. * @param result defines the ray where to store the picking ray
  100298. * @param camera defines the camera to use for the picking
  100299. * @returns the current scene
  100300. */
  100301. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100302. /** Launch a ray to try to pick a mesh in the scene
  100303. * @param x position on screen
  100304. * @param y position on screen
  100305. * @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
  100306. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100307. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100308. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100309. * @returns a PickingInfo
  100310. */
  100311. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100312. /** Use the given ray to pick a mesh in the scene
  100313. * @param ray The ray to use to pick meshes
  100314. * @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
  100315. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100316. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100317. * @returns a PickingInfo
  100318. */
  100319. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100320. /**
  100321. * Launch a ray to try to pick a mesh in the scene
  100322. * @param x X position on screen
  100323. * @param y Y position on screen
  100324. * @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
  100325. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100326. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100327. * @returns an array of PickingInfo
  100328. */
  100329. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100330. /**
  100331. * Launch a ray to try to pick a mesh in the scene
  100332. * @param ray Ray to use
  100333. * @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
  100334. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100335. * @returns an array of PickingInfo
  100336. */
  100337. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100338. /**
  100339. * Force the value of meshUnderPointer
  100340. * @param mesh defines the mesh to use
  100341. */
  100342. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100343. /**
  100344. * Gets the mesh under the pointer
  100345. * @returns a Mesh or null if no mesh is under the pointer
  100346. */
  100347. getPointerOverMesh(): Nullable<AbstractMesh>;
  100348. /** @hidden */
  100349. _rebuildGeometries(): void;
  100350. /** @hidden */
  100351. _rebuildTextures(): void;
  100352. private _getByTags;
  100353. /**
  100354. * Get a list of meshes by tags
  100355. * @param tagsQuery defines the tags query to use
  100356. * @param forEach defines a predicate used to filter results
  100357. * @returns an array of Mesh
  100358. */
  100359. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100360. /**
  100361. * Get a list of cameras by tags
  100362. * @param tagsQuery defines the tags query to use
  100363. * @param forEach defines a predicate used to filter results
  100364. * @returns an array of Camera
  100365. */
  100366. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100367. /**
  100368. * Get a list of lights by tags
  100369. * @param tagsQuery defines the tags query to use
  100370. * @param forEach defines a predicate used to filter results
  100371. * @returns an array of Light
  100372. */
  100373. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100374. /**
  100375. * Get a list of materials by tags
  100376. * @param tagsQuery defines the tags query to use
  100377. * @param forEach defines a predicate used to filter results
  100378. * @returns an array of Material
  100379. */
  100380. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100381. /**
  100382. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100383. * This allowed control for front to back rendering or reversly depending of the special needs.
  100384. *
  100385. * @param renderingGroupId The rendering group id corresponding to its index
  100386. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100387. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100388. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100389. */
  100390. 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;
  100391. /**
  100392. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100393. *
  100394. * @param renderingGroupId The rendering group id corresponding to its index
  100395. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100396. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100397. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100398. */
  100399. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100400. /**
  100401. * Gets the current auto clear configuration for one rendering group of the rendering
  100402. * manager.
  100403. * @param index the rendering group index to get the information for
  100404. * @returns The auto clear setup for the requested rendering group
  100405. */
  100406. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100407. private _blockMaterialDirtyMechanism;
  100408. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100409. blockMaterialDirtyMechanism: boolean;
  100410. /**
  100411. * Will flag all materials as dirty to trigger new shader compilation
  100412. * @param flag defines the flag used to specify which material part must be marked as dirty
  100413. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100414. */
  100415. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100416. /** @hidden */
  100417. _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;
  100418. /** @hidden */
  100419. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100420. }
  100421. }
  100422. declare module BABYLON {
  100423. /**
  100424. * Set of assets to keep when moving a scene into an asset container.
  100425. */
  100426. export class KeepAssets extends AbstractScene {
  100427. }
  100428. /**
  100429. * Container with a set of assets that can be added or removed from a scene.
  100430. */
  100431. export class AssetContainer extends AbstractScene {
  100432. /**
  100433. * The scene the AssetContainer belongs to.
  100434. */
  100435. scene: Scene;
  100436. /**
  100437. * Instantiates an AssetContainer.
  100438. * @param scene The scene the AssetContainer belongs to.
  100439. */
  100440. constructor(scene: Scene);
  100441. /**
  100442. * Adds all the assets from the container to the scene.
  100443. */
  100444. addAllToScene(): void;
  100445. /**
  100446. * Removes all the assets in the container from the scene
  100447. */
  100448. removeAllFromScene(): void;
  100449. /**
  100450. * Disposes all the assets in the container
  100451. */
  100452. dispose(): void;
  100453. private _moveAssets;
  100454. /**
  100455. * Removes all the assets contained in the scene and adds them to the container.
  100456. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100457. */
  100458. moveAllFromScene(keepAssets?: KeepAssets): void;
  100459. /**
  100460. * 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.
  100461. * @returns the root mesh
  100462. */
  100463. createRootMesh(): Mesh;
  100464. }
  100465. }
  100466. declare module BABYLON {
  100467. /**
  100468. * Defines how the parser contract is defined.
  100469. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100470. */
  100471. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100472. /**
  100473. * Defines how the individual parser contract is defined.
  100474. * These parser can parse an individual asset
  100475. */
  100476. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100477. /**
  100478. * Base class of the scene acting as a container for the different elements composing a scene.
  100479. * This class is dynamically extended by the different components of the scene increasing
  100480. * flexibility and reducing coupling
  100481. */
  100482. export abstract class AbstractScene {
  100483. /**
  100484. * Stores the list of available parsers in the application.
  100485. */
  100486. private static _BabylonFileParsers;
  100487. /**
  100488. * Stores the list of available individual parsers in the application.
  100489. */
  100490. private static _IndividualBabylonFileParsers;
  100491. /**
  100492. * Adds a parser in the list of available ones
  100493. * @param name Defines the name of the parser
  100494. * @param parser Defines the parser to add
  100495. */
  100496. static AddParser(name: string, parser: BabylonFileParser): void;
  100497. /**
  100498. * Gets a general parser from the list of avaialble ones
  100499. * @param name Defines the name of the parser
  100500. * @returns the requested parser or null
  100501. */
  100502. static GetParser(name: string): Nullable<BabylonFileParser>;
  100503. /**
  100504. * Adds n individual parser in the list of available ones
  100505. * @param name Defines the name of the parser
  100506. * @param parser Defines the parser to add
  100507. */
  100508. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100509. /**
  100510. * Gets an individual parser from the list of avaialble ones
  100511. * @param name Defines the name of the parser
  100512. * @returns the requested parser or null
  100513. */
  100514. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100515. /**
  100516. * Parser json data and populate both a scene and its associated container object
  100517. * @param jsonData Defines the data to parse
  100518. * @param scene Defines the scene to parse the data for
  100519. * @param container Defines the container attached to the parsing sequence
  100520. * @param rootUrl Defines the root url of the data
  100521. */
  100522. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100523. /**
  100524. * Gets the list of root nodes (ie. nodes with no parent)
  100525. */
  100526. rootNodes: Node[];
  100527. /** All of the cameras added to this scene
  100528. * @see http://doc.babylonjs.com/babylon101/cameras
  100529. */
  100530. cameras: Camera[];
  100531. /**
  100532. * All of the lights added to this scene
  100533. * @see http://doc.babylonjs.com/babylon101/lights
  100534. */
  100535. lights: Light[];
  100536. /**
  100537. * All of the (abstract) meshes added to this scene
  100538. */
  100539. meshes: AbstractMesh[];
  100540. /**
  100541. * The list of skeletons added to the scene
  100542. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100543. */
  100544. skeletons: Skeleton[];
  100545. /**
  100546. * All of the particle systems added to this scene
  100547. * @see http://doc.babylonjs.com/babylon101/particles
  100548. */
  100549. particleSystems: IParticleSystem[];
  100550. /**
  100551. * Gets a list of Animations associated with the scene
  100552. */
  100553. animations: Animation[];
  100554. /**
  100555. * All of the animation groups added to this scene
  100556. * @see http://doc.babylonjs.com/how_to/group
  100557. */
  100558. animationGroups: AnimationGroup[];
  100559. /**
  100560. * All of the multi-materials added to this scene
  100561. * @see http://doc.babylonjs.com/how_to/multi_materials
  100562. */
  100563. multiMaterials: MultiMaterial[];
  100564. /**
  100565. * All of the materials added to this scene
  100566. * In the context of a Scene, it is not supposed to be modified manually.
  100567. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100568. * Note also that the order of the Material wihin the array is not significant and might change.
  100569. * @see http://doc.babylonjs.com/babylon101/materials
  100570. */
  100571. materials: Material[];
  100572. /**
  100573. * The list of morph target managers added to the scene
  100574. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100575. */
  100576. morphTargetManagers: MorphTargetManager[];
  100577. /**
  100578. * The list of geometries used in the scene.
  100579. */
  100580. geometries: Geometry[];
  100581. /**
  100582. * All of the tranform nodes added to this scene
  100583. * In the context of a Scene, it is not supposed to be modified manually.
  100584. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100585. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100586. * @see http://doc.babylonjs.com/how_to/transformnode
  100587. */
  100588. transformNodes: TransformNode[];
  100589. /**
  100590. * ActionManagers available on the scene.
  100591. */
  100592. actionManagers: AbstractActionManager[];
  100593. /**
  100594. * Textures to keep.
  100595. */
  100596. textures: BaseTexture[];
  100597. /**
  100598. * Environment texture for the scene
  100599. */
  100600. environmentTexture: Nullable<BaseTexture>;
  100601. }
  100602. }
  100603. declare module BABYLON {
  100604. /**
  100605. * Interface used to define options for Sound class
  100606. */
  100607. export interface ISoundOptions {
  100608. /**
  100609. * Does the sound autoplay once loaded.
  100610. */
  100611. autoplay?: boolean;
  100612. /**
  100613. * Does the sound loop after it finishes playing once.
  100614. */
  100615. loop?: boolean;
  100616. /**
  100617. * Sound's volume
  100618. */
  100619. volume?: number;
  100620. /**
  100621. * Is it a spatial sound?
  100622. */
  100623. spatialSound?: boolean;
  100624. /**
  100625. * Maximum distance to hear that sound
  100626. */
  100627. maxDistance?: number;
  100628. /**
  100629. * Uses user defined attenuation function
  100630. */
  100631. useCustomAttenuation?: boolean;
  100632. /**
  100633. * Define the roll off factor of spatial sounds.
  100634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100635. */
  100636. rolloffFactor?: number;
  100637. /**
  100638. * Define the reference distance the sound should be heard perfectly.
  100639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100640. */
  100641. refDistance?: number;
  100642. /**
  100643. * Define the distance attenuation model the sound will follow.
  100644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100645. */
  100646. distanceModel?: string;
  100647. /**
  100648. * Defines the playback speed (1 by default)
  100649. */
  100650. playbackRate?: number;
  100651. /**
  100652. * Defines if the sound is from a streaming source
  100653. */
  100654. streaming?: boolean;
  100655. /**
  100656. * Defines an optional length (in seconds) inside the sound file
  100657. */
  100658. length?: number;
  100659. /**
  100660. * Defines an optional offset (in seconds) inside the sound file
  100661. */
  100662. offset?: number;
  100663. /**
  100664. * If true, URLs will not be required to state the audio file codec to use.
  100665. */
  100666. skipCodecCheck?: boolean;
  100667. }
  100668. /**
  100669. * Defines a sound that can be played in the application.
  100670. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100672. */
  100673. export class Sound {
  100674. /**
  100675. * The name of the sound in the scene.
  100676. */
  100677. name: string;
  100678. /**
  100679. * Does the sound autoplay once loaded.
  100680. */
  100681. autoplay: boolean;
  100682. /**
  100683. * Does the sound loop after it finishes playing once.
  100684. */
  100685. loop: boolean;
  100686. /**
  100687. * Does the sound use a custom attenuation curve to simulate the falloff
  100688. * happening when the source gets further away from the camera.
  100689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100690. */
  100691. useCustomAttenuation: boolean;
  100692. /**
  100693. * The sound track id this sound belongs to.
  100694. */
  100695. soundTrackId: number;
  100696. /**
  100697. * Is this sound currently played.
  100698. */
  100699. isPlaying: boolean;
  100700. /**
  100701. * Is this sound currently paused.
  100702. */
  100703. isPaused: boolean;
  100704. /**
  100705. * Does this sound enables spatial sound.
  100706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100707. */
  100708. spatialSound: boolean;
  100709. /**
  100710. * Define the reference distance the sound should be heard perfectly.
  100711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100712. */
  100713. refDistance: number;
  100714. /**
  100715. * Define the roll off factor of spatial sounds.
  100716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100717. */
  100718. rolloffFactor: number;
  100719. /**
  100720. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100722. */
  100723. maxDistance: number;
  100724. /**
  100725. * Define the distance attenuation model the sound will follow.
  100726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100727. */
  100728. distanceModel: string;
  100729. /**
  100730. * @hidden
  100731. * Back Compat
  100732. **/
  100733. onended: () => any;
  100734. /**
  100735. * Observable event when the current playing sound finishes.
  100736. */
  100737. onEndedObservable: Observable<Sound>;
  100738. private _panningModel;
  100739. private _playbackRate;
  100740. private _streaming;
  100741. private _startTime;
  100742. private _startOffset;
  100743. private _position;
  100744. /** @hidden */
  100745. _positionInEmitterSpace: boolean;
  100746. private _localDirection;
  100747. private _volume;
  100748. private _isReadyToPlay;
  100749. private _isDirectional;
  100750. private _readyToPlayCallback;
  100751. private _audioBuffer;
  100752. private _soundSource;
  100753. private _streamingSource;
  100754. private _soundPanner;
  100755. private _soundGain;
  100756. private _inputAudioNode;
  100757. private _outputAudioNode;
  100758. private _coneInnerAngle;
  100759. private _coneOuterAngle;
  100760. private _coneOuterGain;
  100761. private _scene;
  100762. private _connectedTransformNode;
  100763. private _customAttenuationFunction;
  100764. private _registerFunc;
  100765. private _isOutputConnected;
  100766. private _htmlAudioElement;
  100767. private _urlType;
  100768. private _length?;
  100769. private _offset?;
  100770. /** @hidden */
  100771. static _SceneComponentInitialization: (scene: Scene) => void;
  100772. /**
  100773. * Create a sound and attach it to a scene
  100774. * @param name Name of your sound
  100775. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100776. * @param scene defines the scene the sound belongs to
  100777. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100778. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100779. */
  100780. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100781. /**
  100782. * Release the sound and its associated resources
  100783. */
  100784. dispose(): void;
  100785. /**
  100786. * Gets if the sounds is ready to be played or not.
  100787. * @returns true if ready, otherwise false
  100788. */
  100789. isReady(): boolean;
  100790. private _soundLoaded;
  100791. /**
  100792. * Sets the data of the sound from an audiobuffer
  100793. * @param audioBuffer The audioBuffer containing the data
  100794. */
  100795. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100796. /**
  100797. * Updates the current sounds options such as maxdistance, loop...
  100798. * @param options A JSON object containing values named as the object properties
  100799. */
  100800. updateOptions(options: ISoundOptions): void;
  100801. private _createSpatialParameters;
  100802. private _updateSpatialParameters;
  100803. /**
  100804. * Switch the panning model to HRTF:
  100805. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100807. */
  100808. switchPanningModelToHRTF(): void;
  100809. /**
  100810. * Switch the panning model to Equal Power:
  100811. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100813. */
  100814. switchPanningModelToEqualPower(): void;
  100815. private _switchPanningModel;
  100816. /**
  100817. * Connect this sound to a sound track audio node like gain...
  100818. * @param soundTrackAudioNode the sound track audio node to connect to
  100819. */
  100820. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100821. /**
  100822. * Transform this sound into a directional source
  100823. * @param coneInnerAngle Size of the inner cone in degree
  100824. * @param coneOuterAngle Size of the outer cone in degree
  100825. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100826. */
  100827. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100828. /**
  100829. * Gets or sets the inner angle for the directional cone.
  100830. */
  100831. /**
  100832. * Gets or sets the inner angle for the directional cone.
  100833. */
  100834. directionalConeInnerAngle: number;
  100835. /**
  100836. * Gets or sets the outer angle for the directional cone.
  100837. */
  100838. /**
  100839. * Gets or sets the outer angle for the directional cone.
  100840. */
  100841. directionalConeOuterAngle: number;
  100842. /**
  100843. * Sets the position of the emitter if spatial sound is enabled
  100844. * @param newPosition Defines the new posisiton
  100845. */
  100846. setPosition(newPosition: Vector3): void;
  100847. /**
  100848. * Sets the local direction of the emitter if spatial sound is enabled
  100849. * @param newLocalDirection Defines the new local direction
  100850. */
  100851. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100852. private _updateDirection;
  100853. /** @hidden */
  100854. updateDistanceFromListener(): void;
  100855. /**
  100856. * Sets a new custom attenuation function for the sound.
  100857. * @param callback Defines the function used for the attenuation
  100858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100859. */
  100860. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100861. /**
  100862. * Play the sound
  100863. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100864. * @param offset (optional) Start the sound at a specific time in seconds
  100865. * @param length (optional) Sound duration (in seconds)
  100866. */
  100867. play(time?: number, offset?: number, length?: number): void;
  100868. private _onended;
  100869. /**
  100870. * Stop the sound
  100871. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100872. */
  100873. stop(time?: number): void;
  100874. /**
  100875. * Put the sound in pause
  100876. */
  100877. pause(): void;
  100878. /**
  100879. * Sets a dedicated volume for this sounds
  100880. * @param newVolume Define the new volume of the sound
  100881. * @param time Define time for gradual change to new volume
  100882. */
  100883. setVolume(newVolume: number, time?: number): void;
  100884. /**
  100885. * Set the sound play back rate
  100886. * @param newPlaybackRate Define the playback rate the sound should be played at
  100887. */
  100888. setPlaybackRate(newPlaybackRate: number): void;
  100889. /**
  100890. * Gets the volume of the sound.
  100891. * @returns the volume of the sound
  100892. */
  100893. getVolume(): number;
  100894. /**
  100895. * Attach the sound to a dedicated mesh
  100896. * @param transformNode The transform node to connect the sound with
  100897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100898. */
  100899. attachToMesh(transformNode: TransformNode): void;
  100900. /**
  100901. * Detach the sound from the previously attached mesh
  100902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100903. */
  100904. detachFromMesh(): void;
  100905. private _onRegisterAfterWorldMatrixUpdate;
  100906. /**
  100907. * Clone the current sound in the scene.
  100908. * @returns the new sound clone
  100909. */
  100910. clone(): Nullable<Sound>;
  100911. /**
  100912. * Gets the current underlying audio buffer containing the data
  100913. * @returns the audio buffer
  100914. */
  100915. getAudioBuffer(): Nullable<AudioBuffer>;
  100916. /**
  100917. * Serializes the Sound in a JSON representation
  100918. * @returns the JSON representation of the sound
  100919. */
  100920. serialize(): any;
  100921. /**
  100922. * Parse a JSON representation of a sound to innstantiate in a given scene
  100923. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100924. * @param scene Define the scene the new parsed sound should be created in
  100925. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100926. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100927. * @returns the newly parsed sound
  100928. */
  100929. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100930. }
  100931. }
  100932. declare module BABYLON {
  100933. /**
  100934. * This defines an action helpful to play a defined sound on a triggered action.
  100935. */
  100936. export class PlaySoundAction extends Action {
  100937. private _sound;
  100938. /**
  100939. * Instantiate the action
  100940. * @param triggerOptions defines the trigger options
  100941. * @param sound defines the sound to play
  100942. * @param condition defines the trigger related conditions
  100943. */
  100944. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100945. /** @hidden */
  100946. _prepare(): void;
  100947. /**
  100948. * Execute the action and play the sound.
  100949. */
  100950. execute(): void;
  100951. /**
  100952. * Serializes the actions and its related information.
  100953. * @param parent defines the object to serialize in
  100954. * @returns the serialized object
  100955. */
  100956. serialize(parent: any): any;
  100957. }
  100958. /**
  100959. * This defines an action helpful to stop a defined sound on a triggered action.
  100960. */
  100961. export class StopSoundAction extends Action {
  100962. private _sound;
  100963. /**
  100964. * Instantiate the action
  100965. * @param triggerOptions defines the trigger options
  100966. * @param sound defines the sound to stop
  100967. * @param condition defines the trigger related conditions
  100968. */
  100969. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100970. /** @hidden */
  100971. _prepare(): void;
  100972. /**
  100973. * Execute the action and stop the sound.
  100974. */
  100975. execute(): void;
  100976. /**
  100977. * Serializes the actions and its related information.
  100978. * @param parent defines the object to serialize in
  100979. * @returns the serialized object
  100980. */
  100981. serialize(parent: any): any;
  100982. }
  100983. }
  100984. declare module BABYLON {
  100985. /**
  100986. * This defines an action responsible to change the value of a property
  100987. * by interpolating between its current value and the newly set one once triggered.
  100988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100989. */
  100990. export class InterpolateValueAction extends Action {
  100991. /**
  100992. * Defines the path of the property where the value should be interpolated
  100993. */
  100994. propertyPath: string;
  100995. /**
  100996. * Defines the target value at the end of the interpolation.
  100997. */
  100998. value: any;
  100999. /**
  101000. * Defines the time it will take for the property to interpolate to the value.
  101001. */
  101002. duration: number;
  101003. /**
  101004. * Defines if the other scene animations should be stopped when the action has been triggered
  101005. */
  101006. stopOtherAnimations?: boolean;
  101007. /**
  101008. * Defines a callback raised once the interpolation animation has been done.
  101009. */
  101010. onInterpolationDone?: () => void;
  101011. /**
  101012. * Observable triggered once the interpolation animation has been done.
  101013. */
  101014. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101015. private _target;
  101016. private _effectiveTarget;
  101017. private _property;
  101018. /**
  101019. * Instantiate the action
  101020. * @param triggerOptions defines the trigger options
  101021. * @param target defines the object containing the value to interpolate
  101022. * @param propertyPath defines the path to the property in the target object
  101023. * @param value defines the target value at the end of the interpolation
  101024. * @param duration deines the time it will take for the property to interpolate to the value.
  101025. * @param condition defines the trigger related conditions
  101026. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101027. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101028. */
  101029. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101030. /** @hidden */
  101031. _prepare(): void;
  101032. /**
  101033. * Execute the action starts the value interpolation.
  101034. */
  101035. execute(): void;
  101036. /**
  101037. * Serializes the actions and its related information.
  101038. * @param parent defines the object to serialize in
  101039. * @returns the serialized object
  101040. */
  101041. serialize(parent: any): any;
  101042. }
  101043. }
  101044. declare module BABYLON {
  101045. /**
  101046. * Options allowed during the creation of a sound track.
  101047. */
  101048. export interface ISoundTrackOptions {
  101049. /**
  101050. * The volume the sound track should take during creation
  101051. */
  101052. volume?: number;
  101053. /**
  101054. * Define if the sound track is the main sound track of the scene
  101055. */
  101056. mainTrack?: boolean;
  101057. }
  101058. /**
  101059. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101060. * It will be also used in a future release to apply effects on a specific track.
  101061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101062. */
  101063. export class SoundTrack {
  101064. /**
  101065. * The unique identifier of the sound track in the scene.
  101066. */
  101067. id: number;
  101068. /**
  101069. * The list of sounds included in the sound track.
  101070. */
  101071. soundCollection: Array<Sound>;
  101072. private _outputAudioNode;
  101073. private _scene;
  101074. private _isMainTrack;
  101075. private _connectedAnalyser;
  101076. private _options;
  101077. private _isInitialized;
  101078. /**
  101079. * Creates a new sound track.
  101080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101081. * @param scene Define the scene the sound track belongs to
  101082. * @param options
  101083. */
  101084. constructor(scene: Scene, options?: ISoundTrackOptions);
  101085. private _initializeSoundTrackAudioGraph;
  101086. /**
  101087. * Release the sound track and its associated resources
  101088. */
  101089. dispose(): void;
  101090. /**
  101091. * Adds a sound to this sound track
  101092. * @param sound define the cound to add
  101093. * @ignoreNaming
  101094. */
  101095. AddSound(sound: Sound): void;
  101096. /**
  101097. * Removes a sound to this sound track
  101098. * @param sound define the cound to remove
  101099. * @ignoreNaming
  101100. */
  101101. RemoveSound(sound: Sound): void;
  101102. /**
  101103. * Set a global volume for the full sound track.
  101104. * @param newVolume Define the new volume of the sound track
  101105. */
  101106. setVolume(newVolume: number): void;
  101107. /**
  101108. * Switch the panning model to HRTF:
  101109. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101111. */
  101112. switchPanningModelToHRTF(): void;
  101113. /**
  101114. * Switch the panning model to Equal Power:
  101115. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101117. */
  101118. switchPanningModelToEqualPower(): void;
  101119. /**
  101120. * Connect the sound track to an audio analyser allowing some amazing
  101121. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101123. * @param analyser The analyser to connect to the engine
  101124. */
  101125. connectToAnalyser(analyser: Analyser): void;
  101126. }
  101127. }
  101128. declare module BABYLON {
  101129. interface AbstractScene {
  101130. /**
  101131. * The list of sounds used in the scene.
  101132. */
  101133. sounds: Nullable<Array<Sound>>;
  101134. }
  101135. interface Scene {
  101136. /**
  101137. * @hidden
  101138. * Backing field
  101139. */
  101140. _mainSoundTrack: SoundTrack;
  101141. /**
  101142. * The main sound track played by the scene.
  101143. * It cotains your primary collection of sounds.
  101144. */
  101145. mainSoundTrack: SoundTrack;
  101146. /**
  101147. * The list of sound tracks added to the scene
  101148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101149. */
  101150. soundTracks: Nullable<Array<SoundTrack>>;
  101151. /**
  101152. * Gets a sound using a given name
  101153. * @param name defines the name to search for
  101154. * @return the found sound or null if not found at all.
  101155. */
  101156. getSoundByName(name: string): Nullable<Sound>;
  101157. /**
  101158. * Gets or sets if audio support is enabled
  101159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101160. */
  101161. audioEnabled: boolean;
  101162. /**
  101163. * Gets or sets if audio will be output to headphones
  101164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101165. */
  101166. headphone: boolean;
  101167. /**
  101168. * Gets or sets custom audio listener position provider
  101169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101170. */
  101171. audioListenerPositionProvider: Nullable<() => Vector3>;
  101172. }
  101173. /**
  101174. * Defines the sound scene component responsible to manage any sounds
  101175. * in a given scene.
  101176. */
  101177. export class AudioSceneComponent implements ISceneSerializableComponent {
  101178. /**
  101179. * The component name helpfull to identify the component in the list of scene components.
  101180. */
  101181. readonly name: string;
  101182. /**
  101183. * The scene the component belongs to.
  101184. */
  101185. scene: Scene;
  101186. private _audioEnabled;
  101187. /**
  101188. * Gets whether audio is enabled or not.
  101189. * Please use related enable/disable method to switch state.
  101190. */
  101191. readonly audioEnabled: boolean;
  101192. private _headphone;
  101193. /**
  101194. * Gets whether audio is outputing to headphone or not.
  101195. * Please use the according Switch methods to change output.
  101196. */
  101197. readonly headphone: boolean;
  101198. private _audioListenerPositionProvider;
  101199. /**
  101200. * Gets the current audio listener position provider
  101201. */
  101202. /**
  101203. * Sets a custom listener position for all sounds in the scene
  101204. * By default, this is the position of the first active camera
  101205. */
  101206. audioListenerPositionProvider: Nullable<() => Vector3>;
  101207. /**
  101208. * Creates a new instance of the component for the given scene
  101209. * @param scene Defines the scene to register the component in
  101210. */
  101211. constructor(scene: Scene);
  101212. /**
  101213. * Registers the component in a given scene
  101214. */
  101215. register(): void;
  101216. /**
  101217. * Rebuilds the elements related to this component in case of
  101218. * context lost for instance.
  101219. */
  101220. rebuild(): void;
  101221. /**
  101222. * Serializes the component data to the specified json object
  101223. * @param serializationObject The object to serialize to
  101224. */
  101225. serialize(serializationObject: any): void;
  101226. /**
  101227. * Adds all the elements from the container to the scene
  101228. * @param container the container holding the elements
  101229. */
  101230. addFromContainer(container: AbstractScene): void;
  101231. /**
  101232. * Removes all the elements in the container from the scene
  101233. * @param container contains the elements to remove
  101234. * @param dispose if the removed element should be disposed (default: false)
  101235. */
  101236. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101237. /**
  101238. * Disposes the component and the associated ressources.
  101239. */
  101240. dispose(): void;
  101241. /**
  101242. * Disables audio in the associated scene.
  101243. */
  101244. disableAudio(): void;
  101245. /**
  101246. * Enables audio in the associated scene.
  101247. */
  101248. enableAudio(): void;
  101249. /**
  101250. * Switch audio to headphone output.
  101251. */
  101252. switchAudioModeForHeadphones(): void;
  101253. /**
  101254. * Switch audio to normal speakers.
  101255. */
  101256. switchAudioModeForNormalSpeakers(): void;
  101257. private _afterRender;
  101258. }
  101259. }
  101260. declare module BABYLON {
  101261. /**
  101262. * Wraps one or more Sound objects and selects one with random weight for playback.
  101263. */
  101264. export class WeightedSound {
  101265. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101266. loop: boolean;
  101267. private _coneInnerAngle;
  101268. private _coneOuterAngle;
  101269. private _volume;
  101270. /** A Sound is currently playing. */
  101271. isPlaying: boolean;
  101272. /** A Sound is currently paused. */
  101273. isPaused: boolean;
  101274. private _sounds;
  101275. private _weights;
  101276. private _currentIndex?;
  101277. /**
  101278. * Creates a new WeightedSound from the list of sounds given.
  101279. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101280. * @param sounds Array of Sounds that will be selected from.
  101281. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101282. */
  101283. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101284. /**
  101285. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101286. */
  101287. /**
  101288. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101289. */
  101290. directionalConeInnerAngle: number;
  101291. /**
  101292. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101293. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101294. */
  101295. /**
  101296. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101297. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101298. */
  101299. directionalConeOuterAngle: number;
  101300. /**
  101301. * Playback volume.
  101302. */
  101303. /**
  101304. * Playback volume.
  101305. */
  101306. volume: number;
  101307. private _onended;
  101308. /**
  101309. * Suspend playback
  101310. */
  101311. pause(): void;
  101312. /**
  101313. * Stop playback
  101314. */
  101315. stop(): void;
  101316. /**
  101317. * Start playback.
  101318. * @param startOffset Position the clip head at a specific time in seconds.
  101319. */
  101320. play(startOffset?: number): void;
  101321. }
  101322. }
  101323. declare module BABYLON {
  101324. /**
  101325. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101326. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101327. */
  101328. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101329. /**
  101330. * Gets the name of the behavior.
  101331. */
  101332. readonly name: string;
  101333. /**
  101334. * The easing function used by animations
  101335. */
  101336. static EasingFunction: BackEase;
  101337. /**
  101338. * The easing mode used by animations
  101339. */
  101340. static EasingMode: number;
  101341. /**
  101342. * The duration of the animation, in milliseconds
  101343. */
  101344. transitionDuration: number;
  101345. /**
  101346. * Length of the distance animated by the transition when lower radius is reached
  101347. */
  101348. lowerRadiusTransitionRange: number;
  101349. /**
  101350. * Length of the distance animated by the transition when upper radius is reached
  101351. */
  101352. upperRadiusTransitionRange: number;
  101353. private _autoTransitionRange;
  101354. /**
  101355. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101356. */
  101357. /**
  101358. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101359. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101360. */
  101361. autoTransitionRange: boolean;
  101362. private _attachedCamera;
  101363. private _onAfterCheckInputsObserver;
  101364. private _onMeshTargetChangedObserver;
  101365. /**
  101366. * Initializes the behavior.
  101367. */
  101368. init(): void;
  101369. /**
  101370. * Attaches the behavior to its arc rotate camera.
  101371. * @param camera Defines the camera to attach the behavior to
  101372. */
  101373. attach(camera: ArcRotateCamera): void;
  101374. /**
  101375. * Detaches the behavior from its current arc rotate camera.
  101376. */
  101377. detach(): void;
  101378. private _radiusIsAnimating;
  101379. private _radiusBounceTransition;
  101380. private _animatables;
  101381. private _cachedWheelPrecision;
  101382. /**
  101383. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101384. * @param radiusLimit The limit to check against.
  101385. * @return Bool to indicate if at limit.
  101386. */
  101387. private _isRadiusAtLimit;
  101388. /**
  101389. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101390. * @param radiusDelta The delta by which to animate to. Can be negative.
  101391. */
  101392. private _applyBoundRadiusAnimation;
  101393. /**
  101394. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101395. */
  101396. protected _clearAnimationLocks(): void;
  101397. /**
  101398. * Stops and removes all animations that have been applied to the camera
  101399. */
  101400. stopAllAnimations(): void;
  101401. }
  101402. }
  101403. declare module BABYLON {
  101404. /**
  101405. * 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.
  101406. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101407. */
  101408. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101409. /**
  101410. * Gets the name of the behavior.
  101411. */
  101412. readonly name: string;
  101413. private _mode;
  101414. private _radiusScale;
  101415. private _positionScale;
  101416. private _defaultElevation;
  101417. private _elevationReturnTime;
  101418. private _elevationReturnWaitTime;
  101419. private _zoomStopsAnimation;
  101420. private _framingTime;
  101421. /**
  101422. * The easing function used by animations
  101423. */
  101424. static EasingFunction: ExponentialEase;
  101425. /**
  101426. * The easing mode used by animations
  101427. */
  101428. static EasingMode: number;
  101429. /**
  101430. * Sets the current mode used by the behavior
  101431. */
  101432. /**
  101433. * Gets current mode used by the behavior.
  101434. */
  101435. mode: number;
  101436. /**
  101437. * Sets the scale applied to the radius (1 by default)
  101438. */
  101439. /**
  101440. * Gets the scale applied to the radius
  101441. */
  101442. radiusScale: number;
  101443. /**
  101444. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101445. */
  101446. /**
  101447. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101448. */
  101449. positionScale: number;
  101450. /**
  101451. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101452. * behaviour is triggered, in radians.
  101453. */
  101454. /**
  101455. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101456. * behaviour is triggered, in radians.
  101457. */
  101458. defaultElevation: number;
  101459. /**
  101460. * Sets the time (in milliseconds) taken to return to the default beta position.
  101461. * Negative value indicates camera should not return to default.
  101462. */
  101463. /**
  101464. * Gets the time (in milliseconds) taken to return to the default beta position.
  101465. * Negative value indicates camera should not return to default.
  101466. */
  101467. elevationReturnTime: number;
  101468. /**
  101469. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101470. */
  101471. /**
  101472. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101473. */
  101474. elevationReturnWaitTime: number;
  101475. /**
  101476. * Sets the flag that indicates if user zooming should stop animation.
  101477. */
  101478. /**
  101479. * Gets the flag that indicates if user zooming should stop animation.
  101480. */
  101481. zoomStopsAnimation: boolean;
  101482. /**
  101483. * Sets the transition time when framing the mesh, in milliseconds
  101484. */
  101485. /**
  101486. * Gets the transition time when framing the mesh, in milliseconds
  101487. */
  101488. framingTime: number;
  101489. /**
  101490. * Define if the behavior should automatically change the configured
  101491. * camera limits and sensibilities.
  101492. */
  101493. autoCorrectCameraLimitsAndSensibility: boolean;
  101494. private _onPrePointerObservableObserver;
  101495. private _onAfterCheckInputsObserver;
  101496. private _onMeshTargetChangedObserver;
  101497. private _attachedCamera;
  101498. private _isPointerDown;
  101499. private _lastInteractionTime;
  101500. /**
  101501. * Initializes the behavior.
  101502. */
  101503. init(): void;
  101504. /**
  101505. * Attaches the behavior to its arc rotate camera.
  101506. * @param camera Defines the camera to attach the behavior to
  101507. */
  101508. attach(camera: ArcRotateCamera): void;
  101509. /**
  101510. * Detaches the behavior from its current arc rotate camera.
  101511. */
  101512. detach(): void;
  101513. private _animatables;
  101514. private _betaIsAnimating;
  101515. private _betaTransition;
  101516. private _radiusTransition;
  101517. private _vectorTransition;
  101518. /**
  101519. * Targets the given mesh and updates zoom level accordingly.
  101520. * @param mesh The mesh to target.
  101521. * @param radius Optional. If a cached radius position already exists, overrides default.
  101522. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101523. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101524. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101525. */
  101526. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101527. /**
  101528. * Targets the given mesh with its children and updates zoom level accordingly.
  101529. * @param mesh The mesh to target.
  101530. * @param radius Optional. If a cached radius position already exists, overrides default.
  101531. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101532. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101533. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101534. */
  101535. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101536. /**
  101537. * Targets the given meshes with their children and updates zoom level accordingly.
  101538. * @param meshes The mesh to target.
  101539. * @param radius Optional. If a cached radius position already exists, overrides default.
  101540. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101541. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101542. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101543. */
  101544. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101545. /**
  101546. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101547. * @param minimumWorld Determines the smaller position of the bounding box extend
  101548. * @param maximumWorld Determines the bigger position of the bounding box extend
  101549. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101550. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101551. */
  101552. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101553. /**
  101554. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101555. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101556. * frustum width.
  101557. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101558. * to fully enclose the mesh in the viewing frustum.
  101559. */
  101560. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101561. /**
  101562. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101563. * is automatically returned to its default position (expected to be above ground plane).
  101564. */
  101565. private _maintainCameraAboveGround;
  101566. /**
  101567. * Returns the frustum slope based on the canvas ratio and camera FOV
  101568. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101569. */
  101570. private _getFrustumSlope;
  101571. /**
  101572. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101573. */
  101574. private _clearAnimationLocks;
  101575. /**
  101576. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101577. */
  101578. private _applyUserInteraction;
  101579. /**
  101580. * Stops and removes all animations that have been applied to the camera
  101581. */
  101582. stopAllAnimations(): void;
  101583. /**
  101584. * Gets a value indicating if the user is moving the camera
  101585. */
  101586. readonly isUserIsMoving: boolean;
  101587. /**
  101588. * The camera can move all the way towards the mesh.
  101589. */
  101590. static IgnoreBoundsSizeMode: number;
  101591. /**
  101592. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101593. */
  101594. static FitFrustumSidesMode: number;
  101595. }
  101596. }
  101597. declare module BABYLON {
  101598. /**
  101599. * Base class for Camera Pointer Inputs.
  101600. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101601. * for example usage.
  101602. */
  101603. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101604. /**
  101605. * Defines the camera the input is attached to.
  101606. */
  101607. abstract camera: Camera;
  101608. /**
  101609. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101610. */
  101611. protected _altKey: boolean;
  101612. protected _ctrlKey: boolean;
  101613. protected _metaKey: boolean;
  101614. protected _shiftKey: boolean;
  101615. /**
  101616. * Which mouse buttons were pressed at time of last mouse event.
  101617. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101618. */
  101619. protected _buttonsPressed: number;
  101620. /**
  101621. * Defines the buttons associated with the input to handle camera move.
  101622. */
  101623. buttons: number[];
  101624. /**
  101625. * Attach the input controls to a specific dom element to get the input from.
  101626. * @param element Defines the element the controls should be listened from
  101627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101628. */
  101629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101630. /**
  101631. * Detach the current controls from the specified dom element.
  101632. * @param element Defines the element to stop listening the inputs from
  101633. */
  101634. detachControl(element: Nullable<HTMLElement>): void;
  101635. /**
  101636. * Gets the class name of the current input.
  101637. * @returns the class name
  101638. */
  101639. getClassName(): string;
  101640. /**
  101641. * Get the friendly name associated with the input class.
  101642. * @returns the input friendly name
  101643. */
  101644. getSimpleName(): string;
  101645. /**
  101646. * Called on pointer POINTERDOUBLETAP event.
  101647. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101648. */
  101649. protected onDoubleTap(type: string): void;
  101650. /**
  101651. * Called on pointer POINTERMOVE event if only a single touch is active.
  101652. * Override this method to provide functionality.
  101653. */
  101654. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101655. /**
  101656. * Called on pointer POINTERMOVE event if multiple touches are active.
  101657. * Override this method to provide functionality.
  101658. */
  101659. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101660. /**
  101661. * Called on JS contextmenu event.
  101662. * Override this method to provide functionality.
  101663. */
  101664. protected onContextMenu(evt: PointerEvent): void;
  101665. /**
  101666. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101667. * press.
  101668. * Override this method to provide functionality.
  101669. */
  101670. protected onButtonDown(evt: PointerEvent): void;
  101671. /**
  101672. * Called each time a new POINTERUP event occurs. Ie, for each button
  101673. * release.
  101674. * Override this method to provide functionality.
  101675. */
  101676. protected onButtonUp(evt: PointerEvent): void;
  101677. /**
  101678. * Called when window becomes inactive.
  101679. * Override this method to provide functionality.
  101680. */
  101681. protected onLostFocus(): void;
  101682. private _pointerInput;
  101683. private _observer;
  101684. private _onLostFocus;
  101685. private pointA;
  101686. private pointB;
  101687. }
  101688. }
  101689. declare module BABYLON {
  101690. /**
  101691. * Manage the pointers inputs to control an arc rotate camera.
  101692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101693. */
  101694. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101695. /**
  101696. * Defines the camera the input is attached to.
  101697. */
  101698. camera: ArcRotateCamera;
  101699. /**
  101700. * Gets the class name of the current input.
  101701. * @returns the class name
  101702. */
  101703. getClassName(): string;
  101704. /**
  101705. * Defines the buttons associated with the input to handle camera move.
  101706. */
  101707. buttons: number[];
  101708. /**
  101709. * Defines the pointer angular sensibility along the X axis or how fast is
  101710. * the camera rotating.
  101711. */
  101712. angularSensibilityX: number;
  101713. /**
  101714. * Defines the pointer angular sensibility along the Y axis or how fast is
  101715. * the camera rotating.
  101716. */
  101717. angularSensibilityY: number;
  101718. /**
  101719. * Defines the pointer pinch precision or how fast is the camera zooming.
  101720. */
  101721. pinchPrecision: number;
  101722. /**
  101723. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101724. * from 0.
  101725. * It defines the percentage of current camera.radius to use as delta when
  101726. * pinch zoom is used.
  101727. */
  101728. pinchDeltaPercentage: number;
  101729. /**
  101730. * Defines the pointer panning sensibility or how fast is the camera moving.
  101731. */
  101732. panningSensibility: number;
  101733. /**
  101734. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101735. */
  101736. multiTouchPanning: boolean;
  101737. /**
  101738. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101739. * zoom (pinch) through multitouch.
  101740. */
  101741. multiTouchPanAndZoom: boolean;
  101742. /**
  101743. * Revers pinch action direction.
  101744. */
  101745. pinchInwards: boolean;
  101746. private _isPanClick;
  101747. private _twoFingerActivityCount;
  101748. private _isPinching;
  101749. /**
  101750. * Called on pointer POINTERMOVE event if only a single touch is active.
  101751. */
  101752. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101753. /**
  101754. * Called on pointer POINTERDOUBLETAP event.
  101755. */
  101756. protected onDoubleTap(type: string): void;
  101757. /**
  101758. * Called on pointer POINTERMOVE event if multiple touches are active.
  101759. */
  101760. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101761. /**
  101762. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101763. * press.
  101764. */
  101765. protected onButtonDown(evt: PointerEvent): void;
  101766. /**
  101767. * Called each time a new POINTERUP event occurs. Ie, for each button
  101768. * release.
  101769. */
  101770. protected onButtonUp(evt: PointerEvent): void;
  101771. /**
  101772. * Called when window becomes inactive.
  101773. */
  101774. protected onLostFocus(): void;
  101775. }
  101776. }
  101777. declare module BABYLON {
  101778. /**
  101779. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101781. */
  101782. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101783. /**
  101784. * Defines the camera the input is attached to.
  101785. */
  101786. camera: ArcRotateCamera;
  101787. /**
  101788. * Defines the list of key codes associated with the up action (increase alpha)
  101789. */
  101790. keysUp: number[];
  101791. /**
  101792. * Defines the list of key codes associated with the down action (decrease alpha)
  101793. */
  101794. keysDown: number[];
  101795. /**
  101796. * Defines the list of key codes associated with the left action (increase beta)
  101797. */
  101798. keysLeft: number[];
  101799. /**
  101800. * Defines the list of key codes associated with the right action (decrease beta)
  101801. */
  101802. keysRight: number[];
  101803. /**
  101804. * Defines the list of key codes associated with the reset action.
  101805. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101806. */
  101807. keysReset: number[];
  101808. /**
  101809. * Defines the panning sensibility of the inputs.
  101810. * (How fast is the camera paning)
  101811. */
  101812. panningSensibility: number;
  101813. /**
  101814. * Defines the zooming sensibility of the inputs.
  101815. * (How fast is the camera zooming)
  101816. */
  101817. zoomingSensibility: number;
  101818. /**
  101819. * Defines wether maintaining the alt key down switch the movement mode from
  101820. * orientation to zoom.
  101821. */
  101822. useAltToZoom: boolean;
  101823. /**
  101824. * Rotation speed of the camera
  101825. */
  101826. angularSpeed: number;
  101827. private _keys;
  101828. private _ctrlPressed;
  101829. private _altPressed;
  101830. private _onCanvasBlurObserver;
  101831. private _onKeyboardObserver;
  101832. private _engine;
  101833. private _scene;
  101834. /**
  101835. * Attach the input controls to a specific dom element to get the input from.
  101836. * @param element Defines the element the controls should be listened from
  101837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101838. */
  101839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101840. /**
  101841. * Detach the current controls from the specified dom element.
  101842. * @param element Defines the element to stop listening the inputs from
  101843. */
  101844. detachControl(element: Nullable<HTMLElement>): void;
  101845. /**
  101846. * Update the current camera state depending on the inputs that have been used this frame.
  101847. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101848. */
  101849. checkInputs(): void;
  101850. /**
  101851. * Gets the class name of the current intput.
  101852. * @returns the class name
  101853. */
  101854. getClassName(): string;
  101855. /**
  101856. * Get the friendly name associated with the input class.
  101857. * @returns the input friendly name
  101858. */
  101859. getSimpleName(): string;
  101860. }
  101861. }
  101862. declare module BABYLON {
  101863. /**
  101864. * Manage the mouse wheel inputs to control an arc rotate camera.
  101865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101866. */
  101867. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101868. /**
  101869. * Defines the camera the input is attached to.
  101870. */
  101871. camera: ArcRotateCamera;
  101872. /**
  101873. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101874. */
  101875. wheelPrecision: number;
  101876. /**
  101877. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101878. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101879. */
  101880. wheelDeltaPercentage: number;
  101881. private _wheel;
  101882. private _observer;
  101883. private computeDeltaFromMouseWheelLegacyEvent;
  101884. /**
  101885. * Attach the input controls to a specific dom element to get the input from.
  101886. * @param element Defines the element the controls should be listened from
  101887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101888. */
  101889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101890. /**
  101891. * Detach the current controls from the specified dom element.
  101892. * @param element Defines the element to stop listening the inputs from
  101893. */
  101894. detachControl(element: Nullable<HTMLElement>): void;
  101895. /**
  101896. * Gets the class name of the current intput.
  101897. * @returns the class name
  101898. */
  101899. getClassName(): string;
  101900. /**
  101901. * Get the friendly name associated with the input class.
  101902. * @returns the input friendly name
  101903. */
  101904. getSimpleName(): string;
  101905. }
  101906. }
  101907. declare module BABYLON {
  101908. /**
  101909. * Default Inputs manager for the ArcRotateCamera.
  101910. * It groups all the default supported inputs for ease of use.
  101911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101912. */
  101913. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101914. /**
  101915. * Instantiates a new ArcRotateCameraInputsManager.
  101916. * @param camera Defines the camera the inputs belong to
  101917. */
  101918. constructor(camera: ArcRotateCamera);
  101919. /**
  101920. * Add mouse wheel input support to the input manager.
  101921. * @returns the current input manager
  101922. */
  101923. addMouseWheel(): ArcRotateCameraInputsManager;
  101924. /**
  101925. * Add pointers input support to the input manager.
  101926. * @returns the current input manager
  101927. */
  101928. addPointers(): ArcRotateCameraInputsManager;
  101929. /**
  101930. * Add keyboard input support to the input manager.
  101931. * @returns the current input manager
  101932. */
  101933. addKeyboard(): ArcRotateCameraInputsManager;
  101934. }
  101935. }
  101936. declare module BABYLON {
  101937. /**
  101938. * This represents an orbital type of camera.
  101939. *
  101940. * 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.
  101941. * 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.
  101942. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101943. */
  101944. export class ArcRotateCamera extends TargetCamera {
  101945. /**
  101946. * Defines the rotation angle of the camera along the longitudinal axis.
  101947. */
  101948. alpha: number;
  101949. /**
  101950. * Defines the rotation angle of the camera along the latitudinal axis.
  101951. */
  101952. beta: number;
  101953. /**
  101954. * Defines the radius of the camera from it s target point.
  101955. */
  101956. radius: number;
  101957. protected _target: Vector3;
  101958. protected _targetHost: Nullable<AbstractMesh>;
  101959. /**
  101960. * Defines the target point of the camera.
  101961. * The camera looks towards it form the radius distance.
  101962. */
  101963. target: Vector3;
  101964. /**
  101965. * Define the current local position of the camera in the scene
  101966. */
  101967. position: Vector3;
  101968. protected _upVector: Vector3;
  101969. protected _upToYMatrix: Matrix;
  101970. protected _YToUpMatrix: Matrix;
  101971. /**
  101972. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101973. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101974. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101975. */
  101976. upVector: Vector3;
  101977. /**
  101978. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101979. */
  101980. setMatUp(): void;
  101981. /**
  101982. * Current inertia value on the longitudinal axis.
  101983. * The bigger this number the longer it will take for the camera to stop.
  101984. */
  101985. inertialAlphaOffset: number;
  101986. /**
  101987. * Current inertia value on the latitudinal axis.
  101988. * The bigger this number the longer it will take for the camera to stop.
  101989. */
  101990. inertialBetaOffset: number;
  101991. /**
  101992. * Current inertia value on the radius axis.
  101993. * The bigger this number the longer it will take for the camera to stop.
  101994. */
  101995. inertialRadiusOffset: number;
  101996. /**
  101997. * Minimum allowed angle on the longitudinal axis.
  101998. * This can help limiting how the Camera is able to move in the scene.
  101999. */
  102000. lowerAlphaLimit: Nullable<number>;
  102001. /**
  102002. * Maximum allowed angle on the longitudinal axis.
  102003. * This can help limiting how the Camera is able to move in the scene.
  102004. */
  102005. upperAlphaLimit: Nullable<number>;
  102006. /**
  102007. * Minimum allowed angle on the latitudinal axis.
  102008. * This can help limiting how the Camera is able to move in the scene.
  102009. */
  102010. lowerBetaLimit: number;
  102011. /**
  102012. * Maximum allowed angle on the latitudinal axis.
  102013. * This can help limiting how the Camera is able to move in the scene.
  102014. */
  102015. upperBetaLimit: number;
  102016. /**
  102017. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102018. * This can help limiting how the Camera is able to move in the scene.
  102019. */
  102020. lowerRadiusLimit: Nullable<number>;
  102021. /**
  102022. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102023. * This can help limiting how the Camera is able to move in the scene.
  102024. */
  102025. upperRadiusLimit: Nullable<number>;
  102026. /**
  102027. * Defines the current inertia value used during panning of the camera along the X axis.
  102028. */
  102029. inertialPanningX: number;
  102030. /**
  102031. * Defines the current inertia value used during panning of the camera along the Y axis.
  102032. */
  102033. inertialPanningY: number;
  102034. /**
  102035. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102036. * Basically if your fingers moves away from more than this distance you will be considered
  102037. * in pinch mode.
  102038. */
  102039. pinchToPanMaxDistance: number;
  102040. /**
  102041. * Defines the maximum distance the camera can pan.
  102042. * This could help keeping the cammera always in your scene.
  102043. */
  102044. panningDistanceLimit: Nullable<number>;
  102045. /**
  102046. * Defines the target of the camera before paning.
  102047. */
  102048. panningOriginTarget: Vector3;
  102049. /**
  102050. * Defines the value of the inertia used during panning.
  102051. * 0 would mean stop inertia and one would mean no decelleration at all.
  102052. */
  102053. panningInertia: number;
  102054. /**
  102055. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102056. */
  102057. angularSensibilityX: number;
  102058. /**
  102059. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102060. */
  102061. angularSensibilityY: number;
  102062. /**
  102063. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102064. */
  102065. pinchPrecision: number;
  102066. /**
  102067. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102068. * It will be used instead of pinchDeltaPrecision if different from 0.
  102069. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102070. */
  102071. pinchDeltaPercentage: number;
  102072. /**
  102073. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102074. */
  102075. panningSensibility: number;
  102076. /**
  102077. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102078. */
  102079. keysUp: number[];
  102080. /**
  102081. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102082. */
  102083. keysDown: number[];
  102084. /**
  102085. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102086. */
  102087. keysLeft: number[];
  102088. /**
  102089. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102090. */
  102091. keysRight: number[];
  102092. /**
  102093. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102094. */
  102095. wheelPrecision: number;
  102096. /**
  102097. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102098. * It will be used instead of pinchDeltaPrecision if different from 0.
  102099. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102100. */
  102101. wheelDeltaPercentage: number;
  102102. /**
  102103. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102104. */
  102105. zoomOnFactor: number;
  102106. /**
  102107. * Defines a screen offset for the camera position.
  102108. */
  102109. targetScreenOffset: Vector2;
  102110. /**
  102111. * Allows the camera to be completely reversed.
  102112. * If false the camera can not arrive upside down.
  102113. */
  102114. allowUpsideDown: boolean;
  102115. /**
  102116. * Define if double tap/click is used to restore the previously saved state of the camera.
  102117. */
  102118. useInputToRestoreState: boolean;
  102119. /** @hidden */
  102120. _viewMatrix: Matrix;
  102121. /** @hidden */
  102122. _useCtrlForPanning: boolean;
  102123. /** @hidden */
  102124. _panningMouseButton: number;
  102125. /**
  102126. * Defines the input associated to the camera.
  102127. */
  102128. inputs: ArcRotateCameraInputsManager;
  102129. /** @hidden */
  102130. _reset: () => void;
  102131. /**
  102132. * Defines the allowed panning axis.
  102133. */
  102134. panningAxis: Vector3;
  102135. protected _localDirection: Vector3;
  102136. protected _transformedDirection: Vector3;
  102137. private _bouncingBehavior;
  102138. /**
  102139. * Gets the bouncing behavior of the camera if it has been enabled.
  102140. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102141. */
  102142. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102143. /**
  102144. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102145. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102146. */
  102147. useBouncingBehavior: boolean;
  102148. private _framingBehavior;
  102149. /**
  102150. * Gets the framing behavior of the camera if it has been enabled.
  102151. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102152. */
  102153. readonly framingBehavior: Nullable<FramingBehavior>;
  102154. /**
  102155. * Defines if the framing behavior of the camera is enabled on the camera.
  102156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102157. */
  102158. useFramingBehavior: boolean;
  102159. private _autoRotationBehavior;
  102160. /**
  102161. * Gets the auto rotation behavior of the camera if it has been enabled.
  102162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102163. */
  102164. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102165. /**
  102166. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102168. */
  102169. useAutoRotationBehavior: boolean;
  102170. /**
  102171. * Observable triggered when the mesh target has been changed on the camera.
  102172. */
  102173. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102174. /**
  102175. * Event raised when the camera is colliding with a mesh.
  102176. */
  102177. onCollide: (collidedMesh: AbstractMesh) => void;
  102178. /**
  102179. * Defines whether the camera should check collision with the objects oh the scene.
  102180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102181. */
  102182. checkCollisions: boolean;
  102183. /**
  102184. * Defines the collision radius of the camera.
  102185. * This simulates a sphere around the camera.
  102186. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102187. */
  102188. collisionRadius: Vector3;
  102189. protected _collider: Collider;
  102190. protected _previousPosition: Vector3;
  102191. protected _collisionVelocity: Vector3;
  102192. protected _newPosition: Vector3;
  102193. protected _previousAlpha: number;
  102194. protected _previousBeta: number;
  102195. protected _previousRadius: number;
  102196. protected _collisionTriggered: boolean;
  102197. protected _targetBoundingCenter: Nullable<Vector3>;
  102198. private _computationVector;
  102199. /**
  102200. * Instantiates a new ArcRotateCamera in a given scene
  102201. * @param name Defines the name of the camera
  102202. * @param alpha Defines the camera rotation along the logitudinal axis
  102203. * @param beta Defines the camera rotation along the latitudinal axis
  102204. * @param radius Defines the camera distance from its target
  102205. * @param target Defines the camera target
  102206. * @param scene Defines the scene the camera belongs to
  102207. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102208. */
  102209. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102210. /** @hidden */
  102211. _initCache(): void;
  102212. /** @hidden */
  102213. _updateCache(ignoreParentClass?: boolean): void;
  102214. protected _getTargetPosition(): Vector3;
  102215. private _storedAlpha;
  102216. private _storedBeta;
  102217. private _storedRadius;
  102218. private _storedTarget;
  102219. private _storedTargetScreenOffset;
  102220. /**
  102221. * Stores the current state of the camera (alpha, beta, radius and target)
  102222. * @returns the camera itself
  102223. */
  102224. storeState(): Camera;
  102225. /**
  102226. * @hidden
  102227. * Restored camera state. You must call storeState() first
  102228. */
  102229. _restoreStateValues(): boolean;
  102230. /** @hidden */
  102231. _isSynchronizedViewMatrix(): boolean;
  102232. /**
  102233. * Attached controls to the current camera.
  102234. * @param element Defines the element the controls should be listened from
  102235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102236. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102237. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102238. */
  102239. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102240. /**
  102241. * Detach the current controls from the camera.
  102242. * The camera will stop reacting to inputs.
  102243. * @param element Defines the element to stop listening the inputs from
  102244. */
  102245. detachControl(element: HTMLElement): void;
  102246. /** @hidden */
  102247. _checkInputs(): void;
  102248. protected _checkLimits(): void;
  102249. /**
  102250. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102251. */
  102252. rebuildAnglesAndRadius(): void;
  102253. /**
  102254. * Use a position to define the current camera related information like aplha, beta and radius
  102255. * @param position Defines the position to set the camera at
  102256. */
  102257. setPosition(position: Vector3): void;
  102258. /**
  102259. * Defines the target the camera should look at.
  102260. * This will automatically adapt alpha beta and radius to fit within the new target.
  102261. * @param target Defines the new target as a Vector or a mesh
  102262. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102263. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102264. */
  102265. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102266. /** @hidden */
  102267. _getViewMatrix(): Matrix;
  102268. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102269. /**
  102270. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102271. * @param meshes Defines the mesh to zoom on
  102272. * @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)
  102273. */
  102274. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102275. /**
  102276. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102277. * The target will be changed but the radius
  102278. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102279. * @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)
  102280. */
  102281. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102282. min: Vector3;
  102283. max: Vector3;
  102284. distance: number;
  102285. }, doNotUpdateMaxZ?: boolean): void;
  102286. /**
  102287. * @override
  102288. * Override Camera.createRigCamera
  102289. */
  102290. createRigCamera(name: string, cameraIndex: number): Camera;
  102291. /**
  102292. * @hidden
  102293. * @override
  102294. * Override Camera._updateRigCameras
  102295. */
  102296. _updateRigCameras(): void;
  102297. /**
  102298. * Destroy the camera and release the current resources hold by it.
  102299. */
  102300. dispose(): void;
  102301. /**
  102302. * Gets the current object class name.
  102303. * @return the class name
  102304. */
  102305. getClassName(): string;
  102306. }
  102307. }
  102308. declare module BABYLON {
  102309. /**
  102310. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102311. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102312. */
  102313. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102314. /**
  102315. * Gets the name of the behavior.
  102316. */
  102317. readonly name: string;
  102318. private _zoomStopsAnimation;
  102319. private _idleRotationSpeed;
  102320. private _idleRotationWaitTime;
  102321. private _idleRotationSpinupTime;
  102322. /**
  102323. * Sets the flag that indicates if user zooming should stop animation.
  102324. */
  102325. /**
  102326. * Gets the flag that indicates if user zooming should stop animation.
  102327. */
  102328. zoomStopsAnimation: boolean;
  102329. /**
  102330. * Sets the default speed at which the camera rotates around the model.
  102331. */
  102332. /**
  102333. * Gets the default speed at which the camera rotates around the model.
  102334. */
  102335. idleRotationSpeed: number;
  102336. /**
  102337. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102338. */
  102339. /**
  102340. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102341. */
  102342. idleRotationWaitTime: number;
  102343. /**
  102344. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102345. */
  102346. /**
  102347. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102348. */
  102349. idleRotationSpinupTime: number;
  102350. /**
  102351. * Gets a value indicating if the camera is currently rotating because of this behavior
  102352. */
  102353. readonly rotationInProgress: boolean;
  102354. private _onPrePointerObservableObserver;
  102355. private _onAfterCheckInputsObserver;
  102356. private _attachedCamera;
  102357. private _isPointerDown;
  102358. private _lastFrameTime;
  102359. private _lastInteractionTime;
  102360. private _cameraRotationSpeed;
  102361. /**
  102362. * Initializes the behavior.
  102363. */
  102364. init(): void;
  102365. /**
  102366. * Attaches the behavior to its arc rotate camera.
  102367. * @param camera Defines the camera to attach the behavior to
  102368. */
  102369. attach(camera: ArcRotateCamera): void;
  102370. /**
  102371. * Detaches the behavior from its current arc rotate camera.
  102372. */
  102373. detach(): void;
  102374. /**
  102375. * Returns true if user is scrolling.
  102376. * @return true if user is scrolling.
  102377. */
  102378. private _userIsZooming;
  102379. private _lastFrameRadius;
  102380. private _shouldAnimationStopForInteraction;
  102381. /**
  102382. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102383. */
  102384. private _applyUserInteraction;
  102385. private _userIsMoving;
  102386. }
  102387. }
  102388. declare module BABYLON {
  102389. /**
  102390. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102391. */
  102392. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102393. private ui;
  102394. /**
  102395. * The name of the behavior
  102396. */
  102397. name: string;
  102398. /**
  102399. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102400. */
  102401. distanceAwayFromFace: number;
  102402. /**
  102403. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102404. */
  102405. distanceAwayFromBottomOfFace: number;
  102406. private _faceVectors;
  102407. private _target;
  102408. private _scene;
  102409. private _onRenderObserver;
  102410. private _tmpMatrix;
  102411. private _tmpVector;
  102412. /**
  102413. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102414. * @param ui The transform node that should be attched to the mesh
  102415. */
  102416. constructor(ui: TransformNode);
  102417. /**
  102418. * Initializes the behavior
  102419. */
  102420. init(): void;
  102421. private _closestFace;
  102422. private _zeroVector;
  102423. private _lookAtTmpMatrix;
  102424. private _lookAtToRef;
  102425. /**
  102426. * Attaches the AttachToBoxBehavior to the passed in mesh
  102427. * @param target The mesh that the specified node will be attached to
  102428. */
  102429. attach(target: Mesh): void;
  102430. /**
  102431. * Detaches the behavior from the mesh
  102432. */
  102433. detach(): void;
  102434. }
  102435. }
  102436. declare module BABYLON {
  102437. /**
  102438. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102439. */
  102440. export class FadeInOutBehavior implements Behavior<Mesh> {
  102441. /**
  102442. * Time in milliseconds to delay before fading in (Default: 0)
  102443. */
  102444. delay: number;
  102445. /**
  102446. * Time in milliseconds for the mesh to fade in (Default: 300)
  102447. */
  102448. fadeInTime: number;
  102449. private _millisecondsPerFrame;
  102450. private _hovered;
  102451. private _hoverValue;
  102452. private _ownerNode;
  102453. /**
  102454. * Instatiates the FadeInOutBehavior
  102455. */
  102456. constructor();
  102457. /**
  102458. * The name of the behavior
  102459. */
  102460. readonly name: string;
  102461. /**
  102462. * Initializes the behavior
  102463. */
  102464. init(): void;
  102465. /**
  102466. * Attaches the fade behavior on the passed in mesh
  102467. * @param ownerNode The mesh that will be faded in/out once attached
  102468. */
  102469. attach(ownerNode: Mesh): void;
  102470. /**
  102471. * Detaches the behavior from the mesh
  102472. */
  102473. detach(): void;
  102474. /**
  102475. * Triggers the mesh to begin fading in or out
  102476. * @param value if the object should fade in or out (true to fade in)
  102477. */
  102478. fadeIn(value: boolean): void;
  102479. private _update;
  102480. private _setAllVisibility;
  102481. }
  102482. }
  102483. declare module BABYLON {
  102484. /**
  102485. * Class containing a set of static utilities functions for managing Pivots
  102486. * @hidden
  102487. */
  102488. export class PivotTools {
  102489. private static _PivotCached;
  102490. private static _OldPivotPoint;
  102491. private static _PivotTranslation;
  102492. private static _PivotTmpVector;
  102493. /** @hidden */
  102494. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102495. /** @hidden */
  102496. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102497. }
  102498. }
  102499. declare module BABYLON {
  102500. /**
  102501. * Class containing static functions to help procedurally build meshes
  102502. */
  102503. export class PlaneBuilder {
  102504. /**
  102505. * Creates a plane mesh
  102506. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102507. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102508. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102512. * @param name defines the name of the mesh
  102513. * @param options defines the options used to create the mesh
  102514. * @param scene defines the hosting scene
  102515. * @returns the plane mesh
  102516. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102517. */
  102518. static CreatePlane(name: string, options: {
  102519. size?: number;
  102520. width?: number;
  102521. height?: number;
  102522. sideOrientation?: number;
  102523. frontUVs?: Vector4;
  102524. backUVs?: Vector4;
  102525. updatable?: boolean;
  102526. sourcePlane?: Plane;
  102527. }, scene?: Nullable<Scene>): Mesh;
  102528. }
  102529. }
  102530. declare module BABYLON {
  102531. /**
  102532. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102533. */
  102534. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102535. private static _AnyMouseID;
  102536. /**
  102537. * Abstract mesh the behavior is set on
  102538. */
  102539. attachedNode: AbstractMesh;
  102540. private _dragPlane;
  102541. private _scene;
  102542. private _pointerObserver;
  102543. private _beforeRenderObserver;
  102544. private static _planeScene;
  102545. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102546. /**
  102547. * 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)
  102548. */
  102549. maxDragAngle: number;
  102550. /**
  102551. * @hidden
  102552. */
  102553. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102554. /**
  102555. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102556. */
  102557. currentDraggingPointerID: number;
  102558. /**
  102559. * The last position where the pointer hit the drag plane in world space
  102560. */
  102561. lastDragPosition: Vector3;
  102562. /**
  102563. * If the behavior is currently in a dragging state
  102564. */
  102565. dragging: boolean;
  102566. /**
  102567. * 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)
  102568. */
  102569. dragDeltaRatio: number;
  102570. /**
  102571. * If the drag plane orientation should be updated during the dragging (Default: true)
  102572. */
  102573. updateDragPlane: boolean;
  102574. private _debugMode;
  102575. private _moving;
  102576. /**
  102577. * Fires each time the attached mesh is dragged with the pointer
  102578. * * delta between last drag position and current drag position in world space
  102579. * * dragDistance along the drag axis
  102580. * * dragPlaneNormal normal of the current drag plane used during the drag
  102581. * * dragPlanePoint in world space where the drag intersects the drag plane
  102582. */
  102583. onDragObservable: Observable<{
  102584. delta: Vector3;
  102585. dragPlanePoint: Vector3;
  102586. dragPlaneNormal: Vector3;
  102587. dragDistance: number;
  102588. pointerId: number;
  102589. }>;
  102590. /**
  102591. * Fires each time a drag begins (eg. mouse down on mesh)
  102592. */
  102593. onDragStartObservable: Observable<{
  102594. dragPlanePoint: Vector3;
  102595. pointerId: number;
  102596. }>;
  102597. /**
  102598. * Fires each time a drag ends (eg. mouse release after drag)
  102599. */
  102600. onDragEndObservable: Observable<{
  102601. dragPlanePoint: Vector3;
  102602. pointerId: number;
  102603. }>;
  102604. /**
  102605. * If the attached mesh should be moved when dragged
  102606. */
  102607. moveAttached: boolean;
  102608. /**
  102609. * If the drag behavior will react to drag events (Default: true)
  102610. */
  102611. enabled: boolean;
  102612. /**
  102613. * If pointer events should start and release the drag (Default: true)
  102614. */
  102615. startAndReleaseDragOnPointerEvents: boolean;
  102616. /**
  102617. * If camera controls should be detached during the drag
  102618. */
  102619. detachCameraControls: boolean;
  102620. /**
  102621. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102622. */
  102623. useObjectOrienationForDragging: boolean;
  102624. private _options;
  102625. /**
  102626. * Creates a pointer drag behavior that can be attached to a mesh
  102627. * @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)
  102628. */
  102629. constructor(options?: {
  102630. dragAxis?: Vector3;
  102631. dragPlaneNormal?: Vector3;
  102632. });
  102633. /**
  102634. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102635. */
  102636. validateDrag: (targetPosition: Vector3) => boolean;
  102637. /**
  102638. * The name of the behavior
  102639. */
  102640. readonly name: string;
  102641. /**
  102642. * Initializes the behavior
  102643. */
  102644. init(): void;
  102645. private _tmpVector;
  102646. private _alternatePickedPoint;
  102647. private _worldDragAxis;
  102648. private _targetPosition;
  102649. private _attachedElement;
  102650. /**
  102651. * Attaches the drag behavior the passed in mesh
  102652. * @param ownerNode The mesh that will be dragged around once attached
  102653. * @param predicate Predicate to use for pick filtering
  102654. */
  102655. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102656. /**
  102657. * Force relase the drag action by code.
  102658. */
  102659. releaseDrag(): void;
  102660. private _startDragRay;
  102661. private _lastPointerRay;
  102662. /**
  102663. * Simulates the start of a pointer drag event on the behavior
  102664. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102665. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102666. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102667. */
  102668. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102669. private _startDrag;
  102670. private _dragDelta;
  102671. private _moveDrag;
  102672. private _pickWithRayOnDragPlane;
  102673. private _pointA;
  102674. private _pointB;
  102675. private _pointC;
  102676. private _lineA;
  102677. private _lineB;
  102678. private _localAxis;
  102679. private _lookAt;
  102680. private _updateDragPlanePosition;
  102681. /**
  102682. * Detaches the behavior from the mesh
  102683. */
  102684. detach(): void;
  102685. }
  102686. }
  102687. declare module BABYLON {
  102688. /**
  102689. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102690. */
  102691. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102692. private _dragBehaviorA;
  102693. private _dragBehaviorB;
  102694. private _startDistance;
  102695. private _initialScale;
  102696. private _targetScale;
  102697. private _ownerNode;
  102698. private _sceneRenderObserver;
  102699. /**
  102700. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102701. */
  102702. constructor();
  102703. /**
  102704. * The name of the behavior
  102705. */
  102706. readonly name: string;
  102707. /**
  102708. * Initializes the behavior
  102709. */
  102710. init(): void;
  102711. private _getCurrentDistance;
  102712. /**
  102713. * Attaches the scale behavior the passed in mesh
  102714. * @param ownerNode The mesh that will be scaled around once attached
  102715. */
  102716. attach(ownerNode: Mesh): void;
  102717. /**
  102718. * Detaches the behavior from the mesh
  102719. */
  102720. detach(): void;
  102721. }
  102722. }
  102723. declare module BABYLON {
  102724. /**
  102725. * 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
  102726. */
  102727. export class SixDofDragBehavior implements Behavior<Mesh> {
  102728. private static _virtualScene;
  102729. private _ownerNode;
  102730. private _sceneRenderObserver;
  102731. private _scene;
  102732. private _targetPosition;
  102733. private _virtualOriginMesh;
  102734. private _virtualDragMesh;
  102735. private _pointerObserver;
  102736. private _moving;
  102737. private _startingOrientation;
  102738. /**
  102739. * 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)
  102740. */
  102741. private zDragFactor;
  102742. /**
  102743. * If the object should rotate to face the drag origin
  102744. */
  102745. rotateDraggedObject: boolean;
  102746. /**
  102747. * If the behavior is currently in a dragging state
  102748. */
  102749. dragging: boolean;
  102750. /**
  102751. * 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)
  102752. */
  102753. dragDeltaRatio: number;
  102754. /**
  102755. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102756. */
  102757. currentDraggingPointerID: number;
  102758. /**
  102759. * If camera controls should be detached during the drag
  102760. */
  102761. detachCameraControls: boolean;
  102762. /**
  102763. * Fires each time a drag starts
  102764. */
  102765. onDragStartObservable: Observable<{}>;
  102766. /**
  102767. * Fires each time a drag ends (eg. mouse release after drag)
  102768. */
  102769. onDragEndObservable: Observable<{}>;
  102770. /**
  102771. * 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
  102772. */
  102773. constructor();
  102774. /**
  102775. * The name of the behavior
  102776. */
  102777. readonly name: string;
  102778. /**
  102779. * Initializes the behavior
  102780. */
  102781. init(): void;
  102782. /**
  102783. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102784. */
  102785. private readonly _pointerCamera;
  102786. /**
  102787. * Attaches the scale behavior the passed in mesh
  102788. * @param ownerNode The mesh that will be scaled around once attached
  102789. */
  102790. attach(ownerNode: Mesh): void;
  102791. /**
  102792. * Detaches the behavior from the mesh
  102793. */
  102794. detach(): void;
  102795. }
  102796. }
  102797. declare module BABYLON {
  102798. /**
  102799. * Class used to apply inverse kinematics to bones
  102800. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102801. */
  102802. export class BoneIKController {
  102803. private static _tmpVecs;
  102804. private static _tmpQuat;
  102805. private static _tmpMats;
  102806. /**
  102807. * Gets or sets the target mesh
  102808. */
  102809. targetMesh: AbstractMesh;
  102810. /** Gets or sets the mesh used as pole */
  102811. poleTargetMesh: AbstractMesh;
  102812. /**
  102813. * Gets or sets the bone used as pole
  102814. */
  102815. poleTargetBone: Nullable<Bone>;
  102816. /**
  102817. * Gets or sets the target position
  102818. */
  102819. targetPosition: Vector3;
  102820. /**
  102821. * Gets or sets the pole target position
  102822. */
  102823. poleTargetPosition: Vector3;
  102824. /**
  102825. * Gets or sets the pole target local offset
  102826. */
  102827. poleTargetLocalOffset: Vector3;
  102828. /**
  102829. * Gets or sets the pole angle
  102830. */
  102831. poleAngle: number;
  102832. /**
  102833. * Gets or sets the mesh associated with the controller
  102834. */
  102835. mesh: AbstractMesh;
  102836. /**
  102837. * 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)
  102838. */
  102839. slerpAmount: number;
  102840. private _bone1Quat;
  102841. private _bone1Mat;
  102842. private _bone2Ang;
  102843. private _bone1;
  102844. private _bone2;
  102845. private _bone1Length;
  102846. private _bone2Length;
  102847. private _maxAngle;
  102848. private _maxReach;
  102849. private _rightHandedSystem;
  102850. private _bendAxis;
  102851. private _slerping;
  102852. private _adjustRoll;
  102853. /**
  102854. * Gets or sets maximum allowed angle
  102855. */
  102856. maxAngle: number;
  102857. /**
  102858. * Creates a new BoneIKController
  102859. * @param mesh defines the mesh to control
  102860. * @param bone defines the bone to control
  102861. * @param options defines options to set up the controller
  102862. */
  102863. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102864. targetMesh?: AbstractMesh;
  102865. poleTargetMesh?: AbstractMesh;
  102866. poleTargetBone?: Bone;
  102867. poleTargetLocalOffset?: Vector3;
  102868. poleAngle?: number;
  102869. bendAxis?: Vector3;
  102870. maxAngle?: number;
  102871. slerpAmount?: number;
  102872. });
  102873. private _setMaxAngle;
  102874. /**
  102875. * Force the controller to update the bones
  102876. */
  102877. update(): void;
  102878. }
  102879. }
  102880. declare module BABYLON {
  102881. /**
  102882. * Class used to make a bone look toward a point in space
  102883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102884. */
  102885. export class BoneLookController {
  102886. private static _tmpVecs;
  102887. private static _tmpQuat;
  102888. private static _tmpMats;
  102889. /**
  102890. * The target Vector3 that the bone will look at
  102891. */
  102892. target: Vector3;
  102893. /**
  102894. * The mesh that the bone is attached to
  102895. */
  102896. mesh: AbstractMesh;
  102897. /**
  102898. * The bone that will be looking to the target
  102899. */
  102900. bone: Bone;
  102901. /**
  102902. * The up axis of the coordinate system that is used when the bone is rotated
  102903. */
  102904. upAxis: Vector3;
  102905. /**
  102906. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102907. */
  102908. upAxisSpace: Space;
  102909. /**
  102910. * Used to make an adjustment to the yaw of the bone
  102911. */
  102912. adjustYaw: number;
  102913. /**
  102914. * Used to make an adjustment to the pitch of the bone
  102915. */
  102916. adjustPitch: number;
  102917. /**
  102918. * Used to make an adjustment to the roll of the bone
  102919. */
  102920. adjustRoll: number;
  102921. /**
  102922. * 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)
  102923. */
  102924. slerpAmount: number;
  102925. private _minYaw;
  102926. private _maxYaw;
  102927. private _minPitch;
  102928. private _maxPitch;
  102929. private _minYawSin;
  102930. private _minYawCos;
  102931. private _maxYawSin;
  102932. private _maxYawCos;
  102933. private _midYawConstraint;
  102934. private _minPitchTan;
  102935. private _maxPitchTan;
  102936. private _boneQuat;
  102937. private _slerping;
  102938. private _transformYawPitch;
  102939. private _transformYawPitchInv;
  102940. private _firstFrameSkipped;
  102941. private _yawRange;
  102942. private _fowardAxis;
  102943. /**
  102944. * Gets or sets the minimum yaw angle that the bone can look to
  102945. */
  102946. minYaw: number;
  102947. /**
  102948. * Gets or sets the maximum yaw angle that the bone can look to
  102949. */
  102950. maxYaw: number;
  102951. /**
  102952. * Gets or sets the minimum pitch angle that the bone can look to
  102953. */
  102954. minPitch: number;
  102955. /**
  102956. * Gets or sets the maximum pitch angle that the bone can look to
  102957. */
  102958. maxPitch: number;
  102959. /**
  102960. * Create a BoneLookController
  102961. * @param mesh the mesh that the bone belongs to
  102962. * @param bone the bone that will be looking to the target
  102963. * @param target the target Vector3 to look at
  102964. * @param options optional settings:
  102965. * * maxYaw: the maximum angle the bone will yaw to
  102966. * * minYaw: the minimum angle the bone will yaw to
  102967. * * maxPitch: the maximum angle the bone will pitch to
  102968. * * minPitch: the minimum angle the bone will yaw to
  102969. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102970. * * upAxis: the up axis of the coordinate system
  102971. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102972. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102973. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102974. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102975. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102976. * * adjustRoll: used to make an adjustment to the roll of the bone
  102977. **/
  102978. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102979. maxYaw?: number;
  102980. minYaw?: number;
  102981. maxPitch?: number;
  102982. minPitch?: number;
  102983. slerpAmount?: number;
  102984. upAxis?: Vector3;
  102985. upAxisSpace?: Space;
  102986. yawAxis?: Vector3;
  102987. pitchAxis?: Vector3;
  102988. adjustYaw?: number;
  102989. adjustPitch?: number;
  102990. adjustRoll?: number;
  102991. });
  102992. /**
  102993. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102994. */
  102995. update(): void;
  102996. private _getAngleDiff;
  102997. private _getAngleBetween;
  102998. private _isAngleBetween;
  102999. }
  103000. }
  103001. declare module BABYLON {
  103002. /**
  103003. * Manage the gamepad inputs to control an arc rotate camera.
  103004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103005. */
  103006. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103007. /**
  103008. * Defines the camera the input is attached to.
  103009. */
  103010. camera: ArcRotateCamera;
  103011. /**
  103012. * Defines the gamepad the input is gathering event from.
  103013. */
  103014. gamepad: Nullable<Gamepad>;
  103015. /**
  103016. * Defines the gamepad rotation sensiblity.
  103017. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103018. */
  103019. gamepadRotationSensibility: number;
  103020. /**
  103021. * Defines the gamepad move sensiblity.
  103022. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103023. */
  103024. gamepadMoveSensibility: number;
  103025. private _onGamepadConnectedObserver;
  103026. private _onGamepadDisconnectedObserver;
  103027. /**
  103028. * Attach the input controls to a specific dom element to get the input from.
  103029. * @param element Defines the element the controls should be listened from
  103030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103031. */
  103032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103033. /**
  103034. * Detach the current controls from the specified dom element.
  103035. * @param element Defines the element to stop listening the inputs from
  103036. */
  103037. detachControl(element: Nullable<HTMLElement>): void;
  103038. /**
  103039. * Update the current camera state depending on the inputs that have been used this frame.
  103040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103041. */
  103042. checkInputs(): void;
  103043. /**
  103044. * Gets the class name of the current intput.
  103045. * @returns the class name
  103046. */
  103047. getClassName(): string;
  103048. /**
  103049. * Get the friendly name associated with the input class.
  103050. * @returns the input friendly name
  103051. */
  103052. getSimpleName(): string;
  103053. }
  103054. }
  103055. declare module BABYLON {
  103056. interface ArcRotateCameraInputsManager {
  103057. /**
  103058. * Add orientation input support to the input manager.
  103059. * @returns the current input manager
  103060. */
  103061. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103062. }
  103063. /**
  103064. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103066. */
  103067. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103068. /**
  103069. * Defines the camera the input is attached to.
  103070. */
  103071. camera: ArcRotateCamera;
  103072. /**
  103073. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103074. */
  103075. alphaCorrection: number;
  103076. /**
  103077. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103078. */
  103079. gammaCorrection: number;
  103080. private _alpha;
  103081. private _gamma;
  103082. private _dirty;
  103083. private _deviceOrientationHandler;
  103084. /**
  103085. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103086. */
  103087. constructor();
  103088. /**
  103089. * Attach the input controls to a specific dom element to get the input from.
  103090. * @param element Defines the element the controls should be listened from
  103091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103092. */
  103093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103094. /** @hidden */
  103095. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103096. /**
  103097. * Update the current camera state depending on the inputs that have been used this frame.
  103098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103099. */
  103100. checkInputs(): void;
  103101. /**
  103102. * Detach the current controls from the specified dom element.
  103103. * @param element Defines the element to stop listening the inputs from
  103104. */
  103105. detachControl(element: Nullable<HTMLElement>): void;
  103106. /**
  103107. * Gets the class name of the current intput.
  103108. * @returns the class name
  103109. */
  103110. getClassName(): string;
  103111. /**
  103112. * Get the friendly name associated with the input class.
  103113. * @returns the input friendly name
  103114. */
  103115. getSimpleName(): string;
  103116. }
  103117. }
  103118. declare module BABYLON {
  103119. /**
  103120. * Listen to mouse events to control the camera.
  103121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103122. */
  103123. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103124. /**
  103125. * Defines the camera the input is attached to.
  103126. */
  103127. camera: FlyCamera;
  103128. /**
  103129. * Defines if touch is enabled. (Default is true.)
  103130. */
  103131. touchEnabled: boolean;
  103132. /**
  103133. * Defines the buttons associated with the input to handle camera rotation.
  103134. */
  103135. buttons: number[];
  103136. /**
  103137. * Assign buttons for Yaw control.
  103138. */
  103139. buttonsYaw: number[];
  103140. /**
  103141. * Assign buttons for Pitch control.
  103142. */
  103143. buttonsPitch: number[];
  103144. /**
  103145. * Assign buttons for Roll control.
  103146. */
  103147. buttonsRoll: number[];
  103148. /**
  103149. * Detect if any button is being pressed while mouse is moved.
  103150. * -1 = Mouse locked.
  103151. * 0 = Left button.
  103152. * 1 = Middle Button.
  103153. * 2 = Right Button.
  103154. */
  103155. activeButton: number;
  103156. /**
  103157. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103158. * Higher values reduce its sensitivity.
  103159. */
  103160. angularSensibility: number;
  103161. private _mousemoveCallback;
  103162. private _observer;
  103163. private _rollObserver;
  103164. private previousPosition;
  103165. private noPreventDefault;
  103166. private element;
  103167. /**
  103168. * Listen to mouse events to control the camera.
  103169. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103171. */
  103172. constructor(touchEnabled?: boolean);
  103173. /**
  103174. * Attach the mouse control to the HTML DOM element.
  103175. * @param element Defines the element that listens to the input events.
  103176. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103177. */
  103178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103179. /**
  103180. * Detach the current controls from the specified dom element.
  103181. * @param element Defines the element to stop listening the inputs from
  103182. */
  103183. detachControl(element: Nullable<HTMLElement>): void;
  103184. /**
  103185. * Gets the class name of the current input.
  103186. * @returns the class name.
  103187. */
  103188. getClassName(): string;
  103189. /**
  103190. * Get the friendly name associated with the input class.
  103191. * @returns the input's friendly name.
  103192. */
  103193. getSimpleName(): string;
  103194. private _pointerInput;
  103195. private _onMouseMove;
  103196. /**
  103197. * Rotate camera by mouse offset.
  103198. */
  103199. private rotateCamera;
  103200. }
  103201. }
  103202. declare module BABYLON {
  103203. /**
  103204. * Default Inputs manager for the FlyCamera.
  103205. * It groups all the default supported inputs for ease of use.
  103206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103207. */
  103208. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103209. /**
  103210. * Instantiates a new FlyCameraInputsManager.
  103211. * @param camera Defines the camera the inputs belong to.
  103212. */
  103213. constructor(camera: FlyCamera);
  103214. /**
  103215. * Add keyboard input support to the input manager.
  103216. * @returns the new FlyCameraKeyboardMoveInput().
  103217. */
  103218. addKeyboard(): FlyCameraInputsManager;
  103219. /**
  103220. * Add mouse input support to the input manager.
  103221. * @param touchEnabled Enable touch screen support.
  103222. * @returns the new FlyCameraMouseInput().
  103223. */
  103224. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103225. }
  103226. }
  103227. declare module BABYLON {
  103228. /**
  103229. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103230. * such as in a 3D Space Shooter or a Flight Simulator.
  103231. */
  103232. export class FlyCamera extends TargetCamera {
  103233. /**
  103234. * Define the collision ellipsoid of the camera.
  103235. * This is helpful for simulating a camera body, like a player's body.
  103236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103237. */
  103238. ellipsoid: Vector3;
  103239. /**
  103240. * Define an offset for the position of the ellipsoid around the camera.
  103241. * This can be helpful if the camera is attached away from the player's body center,
  103242. * such as at its head.
  103243. */
  103244. ellipsoidOffset: Vector3;
  103245. /**
  103246. * Enable or disable collisions of the camera with the rest of the scene objects.
  103247. */
  103248. checkCollisions: boolean;
  103249. /**
  103250. * Enable or disable gravity on the camera.
  103251. */
  103252. applyGravity: boolean;
  103253. /**
  103254. * Define the current direction the camera is moving to.
  103255. */
  103256. cameraDirection: Vector3;
  103257. /**
  103258. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103259. * This overrides and empties cameraRotation.
  103260. */
  103261. rotationQuaternion: Quaternion;
  103262. /**
  103263. * Track Roll to maintain the wanted Rolling when looking around.
  103264. */
  103265. _trackRoll: number;
  103266. /**
  103267. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103268. */
  103269. rollCorrect: number;
  103270. /**
  103271. * Mimic a banked turn, Rolling the camera when Yawing.
  103272. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103273. */
  103274. bankedTurn: boolean;
  103275. /**
  103276. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103277. */
  103278. bankedTurnLimit: number;
  103279. /**
  103280. * Value of 0 disables the banked Roll.
  103281. * Value of 1 is equal to the Yaw angle in radians.
  103282. */
  103283. bankedTurnMultiplier: number;
  103284. /**
  103285. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103286. */
  103287. inputs: FlyCameraInputsManager;
  103288. /**
  103289. * Gets the input sensibility for mouse input.
  103290. * Higher values reduce sensitivity.
  103291. */
  103292. /**
  103293. * Sets the input sensibility for a mouse input.
  103294. * Higher values reduce sensitivity.
  103295. */
  103296. angularSensibility: number;
  103297. /**
  103298. * Get the keys for camera movement forward.
  103299. */
  103300. /**
  103301. * Set the keys for camera movement forward.
  103302. */
  103303. keysForward: number[];
  103304. /**
  103305. * Get the keys for camera movement backward.
  103306. */
  103307. keysBackward: number[];
  103308. /**
  103309. * Get the keys for camera movement up.
  103310. */
  103311. /**
  103312. * Set the keys for camera movement up.
  103313. */
  103314. keysUp: number[];
  103315. /**
  103316. * Get the keys for camera movement down.
  103317. */
  103318. /**
  103319. * Set the keys for camera movement down.
  103320. */
  103321. keysDown: number[];
  103322. /**
  103323. * Get the keys for camera movement left.
  103324. */
  103325. /**
  103326. * Set the keys for camera movement left.
  103327. */
  103328. keysLeft: number[];
  103329. /**
  103330. * Set the keys for camera movement right.
  103331. */
  103332. /**
  103333. * Set the keys for camera movement right.
  103334. */
  103335. keysRight: number[];
  103336. /**
  103337. * Event raised when the camera collides with a mesh in the scene.
  103338. */
  103339. onCollide: (collidedMesh: AbstractMesh) => void;
  103340. private _collider;
  103341. private _needMoveForGravity;
  103342. private _oldPosition;
  103343. private _diffPosition;
  103344. private _newPosition;
  103345. /** @hidden */
  103346. _localDirection: Vector3;
  103347. /** @hidden */
  103348. _transformedDirection: Vector3;
  103349. /**
  103350. * Instantiates a FlyCamera.
  103351. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103352. * such as in a 3D Space Shooter or a Flight Simulator.
  103353. * @param name Define the name of the camera in the scene.
  103354. * @param position Define the starting position of the camera in the scene.
  103355. * @param scene Define the scene the camera belongs to.
  103356. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103357. */
  103358. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103359. /**
  103360. * Attach a control to the HTML DOM element.
  103361. * @param element Defines the element that listens to the input events.
  103362. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103363. */
  103364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103365. /**
  103366. * Detach a control from the HTML DOM element.
  103367. * The camera will stop reacting to that input.
  103368. * @param element Defines the element that listens to the input events.
  103369. */
  103370. detachControl(element: HTMLElement): void;
  103371. private _collisionMask;
  103372. /**
  103373. * Get the mask that the camera ignores in collision events.
  103374. */
  103375. /**
  103376. * Set the mask that the camera ignores in collision events.
  103377. */
  103378. collisionMask: number;
  103379. /** @hidden */
  103380. _collideWithWorld(displacement: Vector3): void;
  103381. /** @hidden */
  103382. private _onCollisionPositionChange;
  103383. /** @hidden */
  103384. _checkInputs(): void;
  103385. /** @hidden */
  103386. _decideIfNeedsToMove(): boolean;
  103387. /** @hidden */
  103388. _updatePosition(): void;
  103389. /**
  103390. * Restore the Roll to its target value at the rate specified.
  103391. * @param rate - Higher means slower restoring.
  103392. * @hidden
  103393. */
  103394. restoreRoll(rate: number): void;
  103395. /**
  103396. * Destroy the camera and release the current resources held by it.
  103397. */
  103398. dispose(): void;
  103399. /**
  103400. * Get the current object class name.
  103401. * @returns the class name.
  103402. */
  103403. getClassName(): string;
  103404. }
  103405. }
  103406. declare module BABYLON {
  103407. /**
  103408. * Listen to keyboard events to control the camera.
  103409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103410. */
  103411. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103412. /**
  103413. * Defines the camera the input is attached to.
  103414. */
  103415. camera: FlyCamera;
  103416. /**
  103417. * The list of keyboard keys used to control the forward move of the camera.
  103418. */
  103419. keysForward: number[];
  103420. /**
  103421. * The list of keyboard keys used to control the backward move of the camera.
  103422. */
  103423. keysBackward: number[];
  103424. /**
  103425. * The list of keyboard keys used to control the forward move of the camera.
  103426. */
  103427. keysUp: number[];
  103428. /**
  103429. * The list of keyboard keys used to control the backward move of the camera.
  103430. */
  103431. keysDown: number[];
  103432. /**
  103433. * The list of keyboard keys used to control the right strafe move of the camera.
  103434. */
  103435. keysRight: number[];
  103436. /**
  103437. * The list of keyboard keys used to control the left strafe move of the camera.
  103438. */
  103439. keysLeft: number[];
  103440. private _keys;
  103441. private _onCanvasBlurObserver;
  103442. private _onKeyboardObserver;
  103443. private _engine;
  103444. private _scene;
  103445. /**
  103446. * Attach the input controls to a specific dom element to get the input from.
  103447. * @param element Defines the element the controls should be listened from
  103448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103449. */
  103450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103451. /**
  103452. * Detach the current controls from the specified dom element.
  103453. * @param element Defines the element to stop listening the inputs from
  103454. */
  103455. detachControl(element: Nullable<HTMLElement>): void;
  103456. /**
  103457. * Gets the class name of the current intput.
  103458. * @returns the class name
  103459. */
  103460. getClassName(): string;
  103461. /** @hidden */
  103462. _onLostFocus(e: FocusEvent): void;
  103463. /**
  103464. * Get the friendly name associated with the input class.
  103465. * @returns the input friendly name
  103466. */
  103467. getSimpleName(): string;
  103468. /**
  103469. * Update the current camera state depending on the inputs that have been used this frame.
  103470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103471. */
  103472. checkInputs(): void;
  103473. }
  103474. }
  103475. declare module BABYLON {
  103476. /**
  103477. * Manage the mouse wheel inputs to control a follow camera.
  103478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103479. */
  103480. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103481. /**
  103482. * Defines the camera the input is attached to.
  103483. */
  103484. camera: FollowCamera;
  103485. /**
  103486. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103487. */
  103488. axisControlRadius: boolean;
  103489. /**
  103490. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103491. */
  103492. axisControlHeight: boolean;
  103493. /**
  103494. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103495. */
  103496. axisControlRotation: boolean;
  103497. /**
  103498. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103499. * relation to mouseWheel events.
  103500. */
  103501. wheelPrecision: number;
  103502. /**
  103503. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103504. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103505. */
  103506. wheelDeltaPercentage: number;
  103507. private _wheel;
  103508. private _observer;
  103509. /**
  103510. * Attach the input controls to a specific dom element to get the input from.
  103511. * @param element Defines the element the controls should be listened from
  103512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103513. */
  103514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103515. /**
  103516. * Detach the current controls from the specified dom element.
  103517. * @param element Defines the element to stop listening the inputs from
  103518. */
  103519. detachControl(element: Nullable<HTMLElement>): void;
  103520. /**
  103521. * Gets the class name of the current intput.
  103522. * @returns the class name
  103523. */
  103524. getClassName(): string;
  103525. /**
  103526. * Get the friendly name associated with the input class.
  103527. * @returns the input friendly name
  103528. */
  103529. getSimpleName(): string;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * Manage the pointers inputs to control an follow camera.
  103535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103536. */
  103537. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103538. /**
  103539. * Defines the camera the input is attached to.
  103540. */
  103541. camera: FollowCamera;
  103542. /**
  103543. * Gets the class name of the current input.
  103544. * @returns the class name
  103545. */
  103546. getClassName(): string;
  103547. /**
  103548. * Defines the pointer angular sensibility along the X axis or how fast is
  103549. * the camera rotating.
  103550. * A negative number will reverse the axis direction.
  103551. */
  103552. angularSensibilityX: number;
  103553. /**
  103554. * Defines the pointer angular sensibility along the Y axis or how fast is
  103555. * the camera rotating.
  103556. * A negative number will reverse the axis direction.
  103557. */
  103558. angularSensibilityY: number;
  103559. /**
  103560. * Defines the pointer pinch precision or how fast is the camera zooming.
  103561. * A negative number will reverse the axis direction.
  103562. */
  103563. pinchPrecision: number;
  103564. /**
  103565. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103566. * from 0.
  103567. * It defines the percentage of current camera.radius to use as delta when
  103568. * pinch zoom is used.
  103569. */
  103570. pinchDeltaPercentage: number;
  103571. /**
  103572. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103573. */
  103574. axisXControlRadius: boolean;
  103575. /**
  103576. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103577. */
  103578. axisXControlHeight: boolean;
  103579. /**
  103580. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103581. */
  103582. axisXControlRotation: boolean;
  103583. /**
  103584. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103585. */
  103586. axisYControlRadius: boolean;
  103587. /**
  103588. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103589. */
  103590. axisYControlHeight: boolean;
  103591. /**
  103592. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103593. */
  103594. axisYControlRotation: boolean;
  103595. /**
  103596. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103597. */
  103598. axisPinchControlRadius: boolean;
  103599. /**
  103600. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103601. */
  103602. axisPinchControlHeight: boolean;
  103603. /**
  103604. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103605. */
  103606. axisPinchControlRotation: boolean;
  103607. /**
  103608. * Log error messages if basic misconfiguration has occurred.
  103609. */
  103610. warningEnable: boolean;
  103611. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103612. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103613. private _warningCounter;
  103614. private _warning;
  103615. }
  103616. }
  103617. declare module BABYLON {
  103618. /**
  103619. * Default Inputs manager for the FollowCamera.
  103620. * It groups all the default supported inputs for ease of use.
  103621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103622. */
  103623. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103624. /**
  103625. * Instantiates a new FollowCameraInputsManager.
  103626. * @param camera Defines the camera the inputs belong to
  103627. */
  103628. constructor(camera: FollowCamera);
  103629. /**
  103630. * Add keyboard input support to the input manager.
  103631. * @returns the current input manager
  103632. */
  103633. addKeyboard(): FollowCameraInputsManager;
  103634. /**
  103635. * Add mouse wheel input support to the input manager.
  103636. * @returns the current input manager
  103637. */
  103638. addMouseWheel(): FollowCameraInputsManager;
  103639. /**
  103640. * Add pointers input support to the input manager.
  103641. * @returns the current input manager
  103642. */
  103643. addPointers(): FollowCameraInputsManager;
  103644. /**
  103645. * Add orientation input support to the input manager.
  103646. * @returns the current input manager
  103647. */
  103648. addVRDeviceOrientation(): FollowCameraInputsManager;
  103649. }
  103650. }
  103651. declare module BABYLON {
  103652. /**
  103653. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103654. * an arc rotate version arcFollowCamera are available.
  103655. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103656. */
  103657. export class FollowCamera extends TargetCamera {
  103658. /**
  103659. * Distance the follow camera should follow an object at
  103660. */
  103661. radius: number;
  103662. /**
  103663. * Minimum allowed distance of the camera to the axis of rotation
  103664. * (The camera can not get closer).
  103665. * This can help limiting how the Camera is able to move in the scene.
  103666. */
  103667. lowerRadiusLimit: Nullable<number>;
  103668. /**
  103669. * Maximum allowed distance of the camera to the axis of rotation
  103670. * (The camera can not get further).
  103671. * This can help limiting how the Camera is able to move in the scene.
  103672. */
  103673. upperRadiusLimit: Nullable<number>;
  103674. /**
  103675. * Define a rotation offset between the camera and the object it follows
  103676. */
  103677. rotationOffset: number;
  103678. /**
  103679. * Minimum allowed angle to camera position relative to target object.
  103680. * This can help limiting how the Camera is able to move in the scene.
  103681. */
  103682. lowerRotationOffsetLimit: Nullable<number>;
  103683. /**
  103684. * Maximum allowed angle to camera position relative to target object.
  103685. * This can help limiting how the Camera is able to move in the scene.
  103686. */
  103687. upperRotationOffsetLimit: Nullable<number>;
  103688. /**
  103689. * Define a height offset between the camera and the object it follows.
  103690. * It can help following an object from the top (like a car chaing a plane)
  103691. */
  103692. heightOffset: number;
  103693. /**
  103694. * Minimum allowed height of camera position relative to target object.
  103695. * This can help limiting how the Camera is able to move in the scene.
  103696. */
  103697. lowerHeightOffsetLimit: Nullable<number>;
  103698. /**
  103699. * Maximum allowed height of camera position relative to target object.
  103700. * This can help limiting how the Camera is able to move in the scene.
  103701. */
  103702. upperHeightOffsetLimit: Nullable<number>;
  103703. /**
  103704. * Define how fast the camera can accelerate to follow it s target.
  103705. */
  103706. cameraAcceleration: number;
  103707. /**
  103708. * Define the speed limit of the camera following an object.
  103709. */
  103710. maxCameraSpeed: number;
  103711. /**
  103712. * Define the target of the camera.
  103713. */
  103714. lockedTarget: Nullable<AbstractMesh>;
  103715. /**
  103716. * Defines the input associated with the camera.
  103717. */
  103718. inputs: FollowCameraInputsManager;
  103719. /**
  103720. * Instantiates the follow camera.
  103721. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103722. * @param name Define the name of the camera in the scene
  103723. * @param position Define the position of the camera
  103724. * @param scene Define the scene the camera belong to
  103725. * @param lockedTarget Define the target of the camera
  103726. */
  103727. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103728. private _follow;
  103729. /**
  103730. * Attached controls to the current camera.
  103731. * @param element Defines the element the controls should be listened from
  103732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103733. */
  103734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103735. /**
  103736. * Detach the current controls from the camera.
  103737. * The camera will stop reacting to inputs.
  103738. * @param element Defines the element to stop listening the inputs from
  103739. */
  103740. detachControl(element: HTMLElement): void;
  103741. /** @hidden */
  103742. _checkInputs(): void;
  103743. private _checkLimits;
  103744. /**
  103745. * Gets the camera class name.
  103746. * @returns the class name
  103747. */
  103748. getClassName(): string;
  103749. }
  103750. /**
  103751. * Arc Rotate version of the follow camera.
  103752. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103753. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103754. */
  103755. export class ArcFollowCamera extends TargetCamera {
  103756. /** The longitudinal angle of the camera */
  103757. alpha: number;
  103758. /** The latitudinal angle of the camera */
  103759. beta: number;
  103760. /** The radius of the camera from its target */
  103761. radius: number;
  103762. /** Define the camera target (the messh it should follow) */
  103763. target: Nullable<AbstractMesh>;
  103764. private _cartesianCoordinates;
  103765. /**
  103766. * Instantiates a new ArcFollowCamera
  103767. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103768. * @param name Define the name of the camera
  103769. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103770. * @param beta Define the rotation angle of the camera around the elevation axis
  103771. * @param radius Define the radius of the camera from its target point
  103772. * @param target Define the target of the camera
  103773. * @param scene Define the scene the camera belongs to
  103774. */
  103775. constructor(name: string,
  103776. /** The longitudinal angle of the camera */
  103777. alpha: number,
  103778. /** The latitudinal angle of the camera */
  103779. beta: number,
  103780. /** The radius of the camera from its target */
  103781. radius: number,
  103782. /** Define the camera target (the messh it should follow) */
  103783. target: Nullable<AbstractMesh>, scene: Scene);
  103784. private _follow;
  103785. /** @hidden */
  103786. _checkInputs(): void;
  103787. /**
  103788. * Returns the class name of the object.
  103789. * It is mostly used internally for serialization purposes.
  103790. */
  103791. getClassName(): string;
  103792. }
  103793. }
  103794. declare module BABYLON {
  103795. /**
  103796. * Manage the keyboard inputs to control the movement of a follow camera.
  103797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103798. */
  103799. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103800. /**
  103801. * Defines the camera the input is attached to.
  103802. */
  103803. camera: FollowCamera;
  103804. /**
  103805. * Defines the list of key codes associated with the up action (increase heightOffset)
  103806. */
  103807. keysHeightOffsetIncr: number[];
  103808. /**
  103809. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103810. */
  103811. keysHeightOffsetDecr: number[];
  103812. /**
  103813. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103814. */
  103815. keysHeightOffsetModifierAlt: boolean;
  103816. /**
  103817. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103818. */
  103819. keysHeightOffsetModifierCtrl: boolean;
  103820. /**
  103821. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103822. */
  103823. keysHeightOffsetModifierShift: boolean;
  103824. /**
  103825. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103826. */
  103827. keysRotationOffsetIncr: number[];
  103828. /**
  103829. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103830. */
  103831. keysRotationOffsetDecr: number[];
  103832. /**
  103833. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103834. */
  103835. keysRotationOffsetModifierAlt: boolean;
  103836. /**
  103837. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103838. */
  103839. keysRotationOffsetModifierCtrl: boolean;
  103840. /**
  103841. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103842. */
  103843. keysRotationOffsetModifierShift: boolean;
  103844. /**
  103845. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103846. */
  103847. keysRadiusIncr: number[];
  103848. /**
  103849. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103850. */
  103851. keysRadiusDecr: number[];
  103852. /**
  103853. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103854. */
  103855. keysRadiusModifierAlt: boolean;
  103856. /**
  103857. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103858. */
  103859. keysRadiusModifierCtrl: boolean;
  103860. /**
  103861. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103862. */
  103863. keysRadiusModifierShift: boolean;
  103864. /**
  103865. * Defines the rate of change of heightOffset.
  103866. */
  103867. heightSensibility: number;
  103868. /**
  103869. * Defines the rate of change of rotationOffset.
  103870. */
  103871. rotationSensibility: number;
  103872. /**
  103873. * Defines the rate of change of radius.
  103874. */
  103875. radiusSensibility: number;
  103876. private _keys;
  103877. private _ctrlPressed;
  103878. private _altPressed;
  103879. private _shiftPressed;
  103880. private _onCanvasBlurObserver;
  103881. private _onKeyboardObserver;
  103882. private _engine;
  103883. private _scene;
  103884. /**
  103885. * Attach the input controls to a specific dom element to get the input from.
  103886. * @param element Defines the element the controls should be listened from
  103887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103888. */
  103889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103890. /**
  103891. * Detach the current controls from the specified dom element.
  103892. * @param element Defines the element to stop listening the inputs from
  103893. */
  103894. detachControl(element: Nullable<HTMLElement>): void;
  103895. /**
  103896. * Update the current camera state depending on the inputs that have been used this frame.
  103897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103898. */
  103899. checkInputs(): void;
  103900. /**
  103901. * Gets the class name of the current input.
  103902. * @returns the class name
  103903. */
  103904. getClassName(): string;
  103905. /**
  103906. * Get the friendly name associated with the input class.
  103907. * @returns the input friendly name
  103908. */
  103909. getSimpleName(): string;
  103910. /**
  103911. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103912. * allow modification of the heightOffset value.
  103913. */
  103914. private _modifierHeightOffset;
  103915. /**
  103916. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103917. * allow modification of the rotationOffset value.
  103918. */
  103919. private _modifierRotationOffset;
  103920. /**
  103921. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103922. * allow modification of the radius value.
  103923. */
  103924. private _modifierRadius;
  103925. }
  103926. }
  103927. declare module BABYLON {
  103928. interface FreeCameraInputsManager {
  103929. /**
  103930. * @hidden
  103931. */
  103932. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103933. /**
  103934. * Add orientation input support to the input manager.
  103935. * @returns the current input manager
  103936. */
  103937. addDeviceOrientation(): FreeCameraInputsManager;
  103938. }
  103939. /**
  103940. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103941. * Screen rotation is taken into account.
  103942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103943. */
  103944. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103945. private _camera;
  103946. private _screenOrientationAngle;
  103947. private _constantTranform;
  103948. private _screenQuaternion;
  103949. private _alpha;
  103950. private _beta;
  103951. private _gamma;
  103952. /**
  103953. * Can be used to detect if a device orientation sensor is availible on a device
  103954. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103955. * @returns a promise that will resolve on orientation change
  103956. */
  103957. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103958. /**
  103959. * @hidden
  103960. */
  103961. _onDeviceOrientationChangedObservable: Observable<void>;
  103962. /**
  103963. * Instantiates a new input
  103964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103965. */
  103966. constructor();
  103967. /**
  103968. * Define the camera controlled by the input.
  103969. */
  103970. camera: FreeCamera;
  103971. /**
  103972. * Attach the input controls to a specific dom element to get the input from.
  103973. * @param element Defines the element the controls should be listened from
  103974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103975. */
  103976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103977. private _orientationChanged;
  103978. private _deviceOrientation;
  103979. /**
  103980. * Detach the current controls from the specified dom element.
  103981. * @param element Defines the element to stop listening the inputs from
  103982. */
  103983. detachControl(element: Nullable<HTMLElement>): void;
  103984. /**
  103985. * Update the current camera state depending on the inputs that have been used this frame.
  103986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103987. */
  103988. checkInputs(): void;
  103989. /**
  103990. * Gets the class name of the current intput.
  103991. * @returns the class name
  103992. */
  103993. getClassName(): string;
  103994. /**
  103995. * Get the friendly name associated with the input class.
  103996. * @returns the input friendly name
  103997. */
  103998. getSimpleName(): string;
  103999. }
  104000. }
  104001. declare module BABYLON {
  104002. /**
  104003. * Manage the gamepad inputs to control a free camera.
  104004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104005. */
  104006. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104007. /**
  104008. * Define the camera the input is attached to.
  104009. */
  104010. camera: FreeCamera;
  104011. /**
  104012. * Define the Gamepad controlling the input
  104013. */
  104014. gamepad: Nullable<Gamepad>;
  104015. /**
  104016. * Defines the gamepad rotation sensiblity.
  104017. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104018. */
  104019. gamepadAngularSensibility: number;
  104020. /**
  104021. * Defines the gamepad move sensiblity.
  104022. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104023. */
  104024. gamepadMoveSensibility: number;
  104025. private _onGamepadConnectedObserver;
  104026. private _onGamepadDisconnectedObserver;
  104027. private _cameraTransform;
  104028. private _deltaTransform;
  104029. private _vector3;
  104030. private _vector2;
  104031. /**
  104032. * Attach the input controls to a specific dom element to get the input from.
  104033. * @param element Defines the element the controls should be listened from
  104034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104035. */
  104036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104037. /**
  104038. * Detach the current controls from the specified dom element.
  104039. * @param element Defines the element to stop listening the inputs from
  104040. */
  104041. detachControl(element: Nullable<HTMLElement>): void;
  104042. /**
  104043. * Update the current camera state depending on the inputs that have been used this frame.
  104044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104045. */
  104046. checkInputs(): void;
  104047. /**
  104048. * Gets the class name of the current intput.
  104049. * @returns the class name
  104050. */
  104051. getClassName(): string;
  104052. /**
  104053. * Get the friendly name associated with the input class.
  104054. * @returns the input friendly name
  104055. */
  104056. getSimpleName(): string;
  104057. }
  104058. }
  104059. declare module BABYLON {
  104060. /**
  104061. * Defines the potential axis of a Joystick
  104062. */
  104063. export enum JoystickAxis {
  104064. /** X axis */
  104065. X = 0,
  104066. /** Y axis */
  104067. Y = 1,
  104068. /** Z axis */
  104069. Z = 2
  104070. }
  104071. /**
  104072. * Class used to define virtual joystick (used in touch mode)
  104073. */
  104074. export class VirtualJoystick {
  104075. /**
  104076. * Gets or sets a boolean indicating that left and right values must be inverted
  104077. */
  104078. reverseLeftRight: boolean;
  104079. /**
  104080. * Gets or sets a boolean indicating that up and down values must be inverted
  104081. */
  104082. reverseUpDown: boolean;
  104083. /**
  104084. * Gets the offset value for the position (ie. the change of the position value)
  104085. */
  104086. deltaPosition: Vector3;
  104087. /**
  104088. * Gets a boolean indicating if the virtual joystick was pressed
  104089. */
  104090. pressed: boolean;
  104091. /**
  104092. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104093. */
  104094. static Canvas: Nullable<HTMLCanvasElement>;
  104095. private static _globalJoystickIndex;
  104096. private static vjCanvasContext;
  104097. private static vjCanvasWidth;
  104098. private static vjCanvasHeight;
  104099. private static halfWidth;
  104100. private _action;
  104101. private _axisTargetedByLeftAndRight;
  104102. private _axisTargetedByUpAndDown;
  104103. private _joystickSensibility;
  104104. private _inversedSensibility;
  104105. private _joystickPointerID;
  104106. private _joystickColor;
  104107. private _joystickPointerPos;
  104108. private _joystickPreviousPointerPos;
  104109. private _joystickPointerStartPos;
  104110. private _deltaJoystickVector;
  104111. private _leftJoystick;
  104112. private _touches;
  104113. private _onPointerDownHandlerRef;
  104114. private _onPointerMoveHandlerRef;
  104115. private _onPointerUpHandlerRef;
  104116. private _onResize;
  104117. /**
  104118. * Creates a new virtual joystick
  104119. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104120. */
  104121. constructor(leftJoystick?: boolean);
  104122. /**
  104123. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104124. * @param newJoystickSensibility defines the new sensibility
  104125. */
  104126. setJoystickSensibility(newJoystickSensibility: number): void;
  104127. private _onPointerDown;
  104128. private _onPointerMove;
  104129. private _onPointerUp;
  104130. /**
  104131. * Change the color of the virtual joystick
  104132. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104133. */
  104134. setJoystickColor(newColor: string): void;
  104135. /**
  104136. * Defines a callback to call when the joystick is touched
  104137. * @param action defines the callback
  104138. */
  104139. setActionOnTouch(action: () => any): void;
  104140. /**
  104141. * Defines which axis you'd like to control for left & right
  104142. * @param axis defines the axis to use
  104143. */
  104144. setAxisForLeftRight(axis: JoystickAxis): void;
  104145. /**
  104146. * Defines which axis you'd like to control for up & down
  104147. * @param axis defines the axis to use
  104148. */
  104149. setAxisForUpDown(axis: JoystickAxis): void;
  104150. private _drawVirtualJoystick;
  104151. /**
  104152. * Release internal HTML canvas
  104153. */
  104154. releaseCanvas(): void;
  104155. }
  104156. }
  104157. declare module BABYLON {
  104158. interface FreeCameraInputsManager {
  104159. /**
  104160. * Add virtual joystick input support to the input manager.
  104161. * @returns the current input manager
  104162. */
  104163. addVirtualJoystick(): FreeCameraInputsManager;
  104164. }
  104165. /**
  104166. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104168. */
  104169. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104170. /**
  104171. * Defines the camera the input is attached to.
  104172. */
  104173. camera: FreeCamera;
  104174. private _leftjoystick;
  104175. private _rightjoystick;
  104176. /**
  104177. * Gets the left stick of the virtual joystick.
  104178. * @returns The virtual Joystick
  104179. */
  104180. getLeftJoystick(): VirtualJoystick;
  104181. /**
  104182. * Gets the right stick of the virtual joystick.
  104183. * @returns The virtual Joystick
  104184. */
  104185. getRightJoystick(): VirtualJoystick;
  104186. /**
  104187. * Update the current camera state depending on the inputs that have been used this frame.
  104188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104189. */
  104190. checkInputs(): void;
  104191. /**
  104192. * Attach the input controls to a specific dom element to get the input from.
  104193. * @param element Defines the element the controls should be listened from
  104194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104195. */
  104196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104197. /**
  104198. * Detach the current controls from the specified dom element.
  104199. * @param element Defines the element to stop listening the inputs from
  104200. */
  104201. detachControl(element: Nullable<HTMLElement>): void;
  104202. /**
  104203. * Gets the class name of the current intput.
  104204. * @returns the class name
  104205. */
  104206. getClassName(): string;
  104207. /**
  104208. * Get the friendly name associated with the input class.
  104209. * @returns the input friendly name
  104210. */
  104211. getSimpleName(): string;
  104212. }
  104213. }
  104214. declare module BABYLON {
  104215. /**
  104216. * This represents a FPS type of camera controlled by touch.
  104217. * This is like a universal camera minus the Gamepad controls.
  104218. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104219. */
  104220. export class TouchCamera extends FreeCamera {
  104221. /**
  104222. * Defines the touch sensibility for rotation.
  104223. * The higher the faster.
  104224. */
  104225. touchAngularSensibility: number;
  104226. /**
  104227. * Defines the touch sensibility for move.
  104228. * The higher the faster.
  104229. */
  104230. touchMoveSensibility: number;
  104231. /**
  104232. * Instantiates a new touch camera.
  104233. * This represents a FPS type of camera controlled by touch.
  104234. * This is like a universal camera minus the Gamepad controls.
  104235. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104236. * @param name Define the name of the camera in the scene
  104237. * @param position Define the start position of the camera in the scene
  104238. * @param scene Define the scene the camera belongs to
  104239. */
  104240. constructor(name: string, position: Vector3, scene: Scene);
  104241. /**
  104242. * Gets the current object class name.
  104243. * @return the class name
  104244. */
  104245. getClassName(): string;
  104246. /** @hidden */
  104247. _setupInputs(): void;
  104248. }
  104249. }
  104250. declare module BABYLON {
  104251. /**
  104252. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104253. * being tilted forward or back and left or right.
  104254. */
  104255. export class DeviceOrientationCamera extends FreeCamera {
  104256. private _initialQuaternion;
  104257. private _quaternionCache;
  104258. private _tmpDragQuaternion;
  104259. private _disablePointerInputWhenUsingDeviceOrientation;
  104260. /**
  104261. * Creates a new device orientation camera
  104262. * @param name The name of the camera
  104263. * @param position The start position camera
  104264. * @param scene The scene the camera belongs to
  104265. */
  104266. constructor(name: string, position: Vector3, scene: Scene);
  104267. /**
  104268. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104269. */
  104270. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104271. private _dragFactor;
  104272. /**
  104273. * Enabled turning on the y axis when the orientation sensor is active
  104274. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104275. */
  104276. enableHorizontalDragging(dragFactor?: number): void;
  104277. /**
  104278. * Gets the current instance class name ("DeviceOrientationCamera").
  104279. * This helps avoiding instanceof at run time.
  104280. * @returns the class name
  104281. */
  104282. getClassName(): string;
  104283. /**
  104284. * @hidden
  104285. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104286. */
  104287. _checkInputs(): void;
  104288. /**
  104289. * Reset the camera to its default orientation on the specified axis only.
  104290. * @param axis The axis to reset
  104291. */
  104292. resetToCurrentRotation(axis?: Axis): void;
  104293. }
  104294. }
  104295. declare module BABYLON {
  104296. /**
  104297. * Defines supported buttons for XBox360 compatible gamepads
  104298. */
  104299. export enum Xbox360Button {
  104300. /** A */
  104301. A = 0,
  104302. /** B */
  104303. B = 1,
  104304. /** X */
  104305. X = 2,
  104306. /** Y */
  104307. Y = 3,
  104308. /** Start */
  104309. Start = 4,
  104310. /** Back */
  104311. Back = 5,
  104312. /** Left button */
  104313. LB = 6,
  104314. /** Right button */
  104315. RB = 7,
  104316. /** Left stick */
  104317. LeftStick = 8,
  104318. /** Right stick */
  104319. RightStick = 9
  104320. }
  104321. /** Defines values for XBox360 DPad */
  104322. export enum Xbox360Dpad {
  104323. /** Up */
  104324. Up = 0,
  104325. /** Down */
  104326. Down = 1,
  104327. /** Left */
  104328. Left = 2,
  104329. /** Right */
  104330. Right = 3
  104331. }
  104332. /**
  104333. * Defines a XBox360 gamepad
  104334. */
  104335. export class Xbox360Pad extends Gamepad {
  104336. private _leftTrigger;
  104337. private _rightTrigger;
  104338. private _onlefttriggerchanged;
  104339. private _onrighttriggerchanged;
  104340. private _onbuttondown;
  104341. private _onbuttonup;
  104342. private _ondpaddown;
  104343. private _ondpadup;
  104344. /** Observable raised when a button is pressed */
  104345. onButtonDownObservable: Observable<Xbox360Button>;
  104346. /** Observable raised when a button is released */
  104347. onButtonUpObservable: Observable<Xbox360Button>;
  104348. /** Observable raised when a pad is pressed */
  104349. onPadDownObservable: Observable<Xbox360Dpad>;
  104350. /** Observable raised when a pad is released */
  104351. onPadUpObservable: Observable<Xbox360Dpad>;
  104352. private _buttonA;
  104353. private _buttonB;
  104354. private _buttonX;
  104355. private _buttonY;
  104356. private _buttonBack;
  104357. private _buttonStart;
  104358. private _buttonLB;
  104359. private _buttonRB;
  104360. private _buttonLeftStick;
  104361. private _buttonRightStick;
  104362. private _dPadUp;
  104363. private _dPadDown;
  104364. private _dPadLeft;
  104365. private _dPadRight;
  104366. private _isXboxOnePad;
  104367. /**
  104368. * Creates a new XBox360 gamepad object
  104369. * @param id defines the id of this gamepad
  104370. * @param index defines its index
  104371. * @param gamepad defines the internal HTML gamepad object
  104372. * @param xboxOne defines if it is a XBox One gamepad
  104373. */
  104374. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104375. /**
  104376. * Defines the callback to call when left trigger is pressed
  104377. * @param callback defines the callback to use
  104378. */
  104379. onlefttriggerchanged(callback: (value: number) => void): void;
  104380. /**
  104381. * Defines the callback to call when right trigger is pressed
  104382. * @param callback defines the callback to use
  104383. */
  104384. onrighttriggerchanged(callback: (value: number) => void): void;
  104385. /**
  104386. * Gets the left trigger value
  104387. */
  104388. /**
  104389. * Sets the left trigger value
  104390. */
  104391. leftTrigger: number;
  104392. /**
  104393. * Gets the right trigger value
  104394. */
  104395. /**
  104396. * Sets the right trigger value
  104397. */
  104398. rightTrigger: number;
  104399. /**
  104400. * Defines the callback to call when a button is pressed
  104401. * @param callback defines the callback to use
  104402. */
  104403. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104404. /**
  104405. * Defines the callback to call when a button is released
  104406. * @param callback defines the callback to use
  104407. */
  104408. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104409. /**
  104410. * Defines the callback to call when a pad is pressed
  104411. * @param callback defines the callback to use
  104412. */
  104413. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104414. /**
  104415. * Defines the callback to call when a pad is released
  104416. * @param callback defines the callback to use
  104417. */
  104418. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104419. private _setButtonValue;
  104420. private _setDPadValue;
  104421. /**
  104422. * Gets the value of the `A` button
  104423. */
  104424. /**
  104425. * Sets the value of the `A` button
  104426. */
  104427. buttonA: number;
  104428. /**
  104429. * Gets the value of the `B` button
  104430. */
  104431. /**
  104432. * Sets the value of the `B` button
  104433. */
  104434. buttonB: number;
  104435. /**
  104436. * Gets the value of the `X` button
  104437. */
  104438. /**
  104439. * Sets the value of the `X` button
  104440. */
  104441. buttonX: number;
  104442. /**
  104443. * Gets the value of the `Y` button
  104444. */
  104445. /**
  104446. * Sets the value of the `Y` button
  104447. */
  104448. buttonY: number;
  104449. /**
  104450. * Gets the value of the `Start` button
  104451. */
  104452. /**
  104453. * Sets the value of the `Start` button
  104454. */
  104455. buttonStart: number;
  104456. /**
  104457. * Gets the value of the `Back` button
  104458. */
  104459. /**
  104460. * Sets the value of the `Back` button
  104461. */
  104462. buttonBack: number;
  104463. /**
  104464. * Gets the value of the `Left` button
  104465. */
  104466. /**
  104467. * Sets the value of the `Left` button
  104468. */
  104469. buttonLB: number;
  104470. /**
  104471. * Gets the value of the `Right` button
  104472. */
  104473. /**
  104474. * Sets the value of the `Right` button
  104475. */
  104476. buttonRB: number;
  104477. /**
  104478. * Gets the value of the Left joystick
  104479. */
  104480. /**
  104481. * Sets the value of the Left joystick
  104482. */
  104483. buttonLeftStick: number;
  104484. /**
  104485. * Gets the value of the Right joystick
  104486. */
  104487. /**
  104488. * Sets the value of the Right joystick
  104489. */
  104490. buttonRightStick: number;
  104491. /**
  104492. * Gets the value of D-pad up
  104493. */
  104494. /**
  104495. * Sets the value of D-pad up
  104496. */
  104497. dPadUp: number;
  104498. /**
  104499. * Gets the value of D-pad down
  104500. */
  104501. /**
  104502. * Sets the value of D-pad down
  104503. */
  104504. dPadDown: number;
  104505. /**
  104506. * Gets the value of D-pad left
  104507. */
  104508. /**
  104509. * Sets the value of D-pad left
  104510. */
  104511. dPadLeft: number;
  104512. /**
  104513. * Gets the value of D-pad right
  104514. */
  104515. /**
  104516. * Sets the value of D-pad right
  104517. */
  104518. dPadRight: number;
  104519. /**
  104520. * Force the gamepad to synchronize with device values
  104521. */
  104522. update(): void;
  104523. /**
  104524. * Disposes the gamepad
  104525. */
  104526. dispose(): void;
  104527. }
  104528. }
  104529. declare module BABYLON {
  104530. /**
  104531. * Defines supported buttons for DualShock compatible gamepads
  104532. */
  104533. export enum DualShockButton {
  104534. /** Cross */
  104535. Cross = 0,
  104536. /** Circle */
  104537. Circle = 1,
  104538. /** Square */
  104539. Square = 2,
  104540. /** Triangle */
  104541. Triangle = 3,
  104542. /** Options */
  104543. Options = 4,
  104544. /** Share */
  104545. Share = 5,
  104546. /** L1 */
  104547. L1 = 6,
  104548. /** R1 */
  104549. R1 = 7,
  104550. /** Left stick */
  104551. LeftStick = 8,
  104552. /** Right stick */
  104553. RightStick = 9
  104554. }
  104555. /** Defines values for DualShock DPad */
  104556. export enum DualShockDpad {
  104557. /** Up */
  104558. Up = 0,
  104559. /** Down */
  104560. Down = 1,
  104561. /** Left */
  104562. Left = 2,
  104563. /** Right */
  104564. Right = 3
  104565. }
  104566. /**
  104567. * Defines a DualShock gamepad
  104568. */
  104569. export class DualShockPad extends Gamepad {
  104570. private _leftTrigger;
  104571. private _rightTrigger;
  104572. private _onlefttriggerchanged;
  104573. private _onrighttriggerchanged;
  104574. private _onbuttondown;
  104575. private _onbuttonup;
  104576. private _ondpaddown;
  104577. private _ondpadup;
  104578. /** Observable raised when a button is pressed */
  104579. onButtonDownObservable: Observable<DualShockButton>;
  104580. /** Observable raised when a button is released */
  104581. onButtonUpObservable: Observable<DualShockButton>;
  104582. /** Observable raised when a pad is pressed */
  104583. onPadDownObservable: Observable<DualShockDpad>;
  104584. /** Observable raised when a pad is released */
  104585. onPadUpObservable: Observable<DualShockDpad>;
  104586. private _buttonCross;
  104587. private _buttonCircle;
  104588. private _buttonSquare;
  104589. private _buttonTriangle;
  104590. private _buttonShare;
  104591. private _buttonOptions;
  104592. private _buttonL1;
  104593. private _buttonR1;
  104594. private _buttonLeftStick;
  104595. private _buttonRightStick;
  104596. private _dPadUp;
  104597. private _dPadDown;
  104598. private _dPadLeft;
  104599. private _dPadRight;
  104600. /**
  104601. * Creates a new DualShock gamepad object
  104602. * @param id defines the id of this gamepad
  104603. * @param index defines its index
  104604. * @param gamepad defines the internal HTML gamepad object
  104605. */
  104606. constructor(id: string, index: number, gamepad: any);
  104607. /**
  104608. * Defines the callback to call when left trigger is pressed
  104609. * @param callback defines the callback to use
  104610. */
  104611. onlefttriggerchanged(callback: (value: number) => void): void;
  104612. /**
  104613. * Defines the callback to call when right trigger is pressed
  104614. * @param callback defines the callback to use
  104615. */
  104616. onrighttriggerchanged(callback: (value: number) => void): void;
  104617. /**
  104618. * Gets the left trigger value
  104619. */
  104620. /**
  104621. * Sets the left trigger value
  104622. */
  104623. leftTrigger: number;
  104624. /**
  104625. * Gets the right trigger value
  104626. */
  104627. /**
  104628. * Sets the right trigger value
  104629. */
  104630. rightTrigger: number;
  104631. /**
  104632. * Defines the callback to call when a button is pressed
  104633. * @param callback defines the callback to use
  104634. */
  104635. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104636. /**
  104637. * Defines the callback to call when a button is released
  104638. * @param callback defines the callback to use
  104639. */
  104640. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104641. /**
  104642. * Defines the callback to call when a pad is pressed
  104643. * @param callback defines the callback to use
  104644. */
  104645. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104646. /**
  104647. * Defines the callback to call when a pad is released
  104648. * @param callback defines the callback to use
  104649. */
  104650. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104651. private _setButtonValue;
  104652. private _setDPadValue;
  104653. /**
  104654. * Gets the value of the `Cross` button
  104655. */
  104656. /**
  104657. * Sets the value of the `Cross` button
  104658. */
  104659. buttonCross: number;
  104660. /**
  104661. * Gets the value of the `Circle` button
  104662. */
  104663. /**
  104664. * Sets the value of the `Circle` button
  104665. */
  104666. buttonCircle: number;
  104667. /**
  104668. * Gets the value of the `Square` button
  104669. */
  104670. /**
  104671. * Sets the value of the `Square` button
  104672. */
  104673. buttonSquare: number;
  104674. /**
  104675. * Gets the value of the `Triangle` button
  104676. */
  104677. /**
  104678. * Sets the value of the `Triangle` button
  104679. */
  104680. buttonTriangle: number;
  104681. /**
  104682. * Gets the value of the `Options` button
  104683. */
  104684. /**
  104685. * Sets the value of the `Options` button
  104686. */
  104687. buttonOptions: number;
  104688. /**
  104689. * Gets the value of the `Share` button
  104690. */
  104691. /**
  104692. * Sets the value of the `Share` button
  104693. */
  104694. buttonShare: number;
  104695. /**
  104696. * Gets the value of the `L1` button
  104697. */
  104698. /**
  104699. * Sets the value of the `L1` button
  104700. */
  104701. buttonL1: number;
  104702. /**
  104703. * Gets the value of the `R1` button
  104704. */
  104705. /**
  104706. * Sets the value of the `R1` button
  104707. */
  104708. buttonR1: number;
  104709. /**
  104710. * Gets the value of the Left joystick
  104711. */
  104712. /**
  104713. * Sets the value of the Left joystick
  104714. */
  104715. buttonLeftStick: number;
  104716. /**
  104717. * Gets the value of the Right joystick
  104718. */
  104719. /**
  104720. * Sets the value of the Right joystick
  104721. */
  104722. buttonRightStick: number;
  104723. /**
  104724. * Gets the value of D-pad up
  104725. */
  104726. /**
  104727. * Sets the value of D-pad up
  104728. */
  104729. dPadUp: number;
  104730. /**
  104731. * Gets the value of D-pad down
  104732. */
  104733. /**
  104734. * Sets the value of D-pad down
  104735. */
  104736. dPadDown: number;
  104737. /**
  104738. * Gets the value of D-pad left
  104739. */
  104740. /**
  104741. * Sets the value of D-pad left
  104742. */
  104743. dPadLeft: number;
  104744. /**
  104745. * Gets the value of D-pad right
  104746. */
  104747. /**
  104748. * Sets the value of D-pad right
  104749. */
  104750. dPadRight: number;
  104751. /**
  104752. * Force the gamepad to synchronize with device values
  104753. */
  104754. update(): void;
  104755. /**
  104756. * Disposes the gamepad
  104757. */
  104758. dispose(): void;
  104759. }
  104760. }
  104761. declare module BABYLON {
  104762. /**
  104763. * Manager for handling gamepads
  104764. */
  104765. export class GamepadManager {
  104766. private _scene?;
  104767. private _babylonGamepads;
  104768. private _oneGamepadConnected;
  104769. /** @hidden */
  104770. _isMonitoring: boolean;
  104771. private _gamepadEventSupported;
  104772. private _gamepadSupport;
  104773. /**
  104774. * observable to be triggered when the gamepad controller has been connected
  104775. */
  104776. onGamepadConnectedObservable: Observable<Gamepad>;
  104777. /**
  104778. * observable to be triggered when the gamepad controller has been disconnected
  104779. */
  104780. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104781. private _onGamepadConnectedEvent;
  104782. private _onGamepadDisconnectedEvent;
  104783. /**
  104784. * Initializes the gamepad manager
  104785. * @param _scene BabylonJS scene
  104786. */
  104787. constructor(_scene?: Scene | undefined);
  104788. /**
  104789. * The gamepads in the game pad manager
  104790. */
  104791. readonly gamepads: Gamepad[];
  104792. /**
  104793. * Get the gamepad controllers based on type
  104794. * @param type The type of gamepad controller
  104795. * @returns Nullable gamepad
  104796. */
  104797. getGamepadByType(type?: number): Nullable<Gamepad>;
  104798. /**
  104799. * Disposes the gamepad manager
  104800. */
  104801. dispose(): void;
  104802. private _addNewGamepad;
  104803. private _startMonitoringGamepads;
  104804. private _stopMonitoringGamepads;
  104805. /** @hidden */
  104806. _checkGamepadsStatus(): void;
  104807. private _updateGamepadObjects;
  104808. }
  104809. }
  104810. declare module BABYLON {
  104811. interface Scene {
  104812. /** @hidden */
  104813. _gamepadManager: Nullable<GamepadManager>;
  104814. /**
  104815. * Gets the gamepad manager associated with the scene
  104816. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104817. */
  104818. gamepadManager: GamepadManager;
  104819. }
  104820. /**
  104821. * Interface representing a free camera inputs manager
  104822. */
  104823. interface FreeCameraInputsManager {
  104824. /**
  104825. * Adds gamepad input support to the FreeCameraInputsManager.
  104826. * @returns the FreeCameraInputsManager
  104827. */
  104828. addGamepad(): FreeCameraInputsManager;
  104829. }
  104830. /**
  104831. * Interface representing an arc rotate camera inputs manager
  104832. */
  104833. interface ArcRotateCameraInputsManager {
  104834. /**
  104835. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104836. * @returns the camera inputs manager
  104837. */
  104838. addGamepad(): ArcRotateCameraInputsManager;
  104839. }
  104840. /**
  104841. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104842. */
  104843. export class GamepadSystemSceneComponent implements ISceneComponent {
  104844. /**
  104845. * The component name helpfull to identify the component in the list of scene components.
  104846. */
  104847. readonly name: string;
  104848. /**
  104849. * The scene the component belongs to.
  104850. */
  104851. scene: Scene;
  104852. /**
  104853. * Creates a new instance of the component for the given scene
  104854. * @param scene Defines the scene to register the component in
  104855. */
  104856. constructor(scene: Scene);
  104857. /**
  104858. * Registers the component in a given scene
  104859. */
  104860. register(): void;
  104861. /**
  104862. * Rebuilds the elements related to this component in case of
  104863. * context lost for instance.
  104864. */
  104865. rebuild(): void;
  104866. /**
  104867. * Disposes the component and the associated ressources
  104868. */
  104869. dispose(): void;
  104870. private _beforeCameraUpdate;
  104871. }
  104872. }
  104873. declare module BABYLON {
  104874. /**
  104875. * 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,
  104876. * which still works and will still be found in many Playgrounds.
  104877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104878. */
  104879. export class UniversalCamera extends TouchCamera {
  104880. /**
  104881. * Defines the gamepad rotation sensiblity.
  104882. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104883. */
  104884. gamepadAngularSensibility: number;
  104885. /**
  104886. * Defines the gamepad move sensiblity.
  104887. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104888. */
  104889. gamepadMoveSensibility: number;
  104890. /**
  104891. * 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,
  104892. * which still works and will still be found in many Playgrounds.
  104893. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104894. * @param name Define the name of the camera in the scene
  104895. * @param position Define the start position of the camera in the scene
  104896. * @param scene Define the scene the camera belongs to
  104897. */
  104898. constructor(name: string, position: Vector3, scene: Scene);
  104899. /**
  104900. * Gets the current object class name.
  104901. * @return the class name
  104902. */
  104903. getClassName(): string;
  104904. }
  104905. }
  104906. declare module BABYLON {
  104907. /**
  104908. * This represents a FPS type of camera. This is only here for back compat purpose.
  104909. * Please use the UniversalCamera instead as both are identical.
  104910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104911. */
  104912. export class GamepadCamera extends UniversalCamera {
  104913. /**
  104914. * Instantiates a new Gamepad Camera
  104915. * This represents a FPS type of camera. This is only here for back compat purpose.
  104916. * Please use the UniversalCamera instead as both are identical.
  104917. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104918. * @param name Define the name of the camera in the scene
  104919. * @param position Define the start position of the camera in the scene
  104920. * @param scene Define the scene the camera belongs to
  104921. */
  104922. constructor(name: string, position: Vector3, scene: Scene);
  104923. /**
  104924. * Gets the current object class name.
  104925. * @return the class name
  104926. */
  104927. getClassName(): string;
  104928. }
  104929. }
  104930. declare module BABYLON {
  104931. /** @hidden */
  104932. export var passPixelShader: {
  104933. name: string;
  104934. shader: string;
  104935. };
  104936. }
  104937. declare module BABYLON {
  104938. /** @hidden */
  104939. export var passCubePixelShader: {
  104940. name: string;
  104941. shader: string;
  104942. };
  104943. }
  104944. declare module BABYLON {
  104945. /**
  104946. * PassPostProcess which produces an output the same as it's input
  104947. */
  104948. export class PassPostProcess extends PostProcess {
  104949. /**
  104950. * Creates the PassPostProcess
  104951. * @param name The name of the effect.
  104952. * @param options The required width/height ratio to downsize to before computing the render pass.
  104953. * @param camera The camera to apply the render pass to.
  104954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104955. * @param engine The engine which the post process will be applied. (default: current engine)
  104956. * @param reusable If the post process can be reused on the same frame. (default: false)
  104957. * @param textureType The type of texture to be used when performing the post processing.
  104958. * @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)
  104959. */
  104960. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104961. }
  104962. /**
  104963. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104964. */
  104965. export class PassCubePostProcess extends PostProcess {
  104966. private _face;
  104967. /**
  104968. * Gets or sets the cube face to display.
  104969. * * 0 is +X
  104970. * * 1 is -X
  104971. * * 2 is +Y
  104972. * * 3 is -Y
  104973. * * 4 is +Z
  104974. * * 5 is -Z
  104975. */
  104976. face: number;
  104977. /**
  104978. * Creates the PassCubePostProcess
  104979. * @param name The name of the effect.
  104980. * @param options The required width/height ratio to downsize to before computing the render pass.
  104981. * @param camera The camera to apply the render pass to.
  104982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104983. * @param engine The engine which the post process will be applied. (default: current engine)
  104984. * @param reusable If the post process can be reused on the same frame. (default: false)
  104985. * @param textureType The type of texture to be used when performing the post processing.
  104986. * @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)
  104987. */
  104988. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104989. }
  104990. }
  104991. declare module BABYLON {
  104992. /** @hidden */
  104993. export var anaglyphPixelShader: {
  104994. name: string;
  104995. shader: string;
  104996. };
  104997. }
  104998. declare module BABYLON {
  104999. /**
  105000. * Postprocess used to generate anaglyphic rendering
  105001. */
  105002. export class AnaglyphPostProcess extends PostProcess {
  105003. private _passedProcess;
  105004. /**
  105005. * Creates a new AnaglyphPostProcess
  105006. * @param name defines postprocess name
  105007. * @param options defines creation options or target ratio scale
  105008. * @param rigCameras defines cameras using this postprocess
  105009. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105010. * @param engine defines hosting engine
  105011. * @param reusable defines if the postprocess will be reused multiple times per frame
  105012. */
  105013. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105014. }
  105015. }
  105016. declare module BABYLON {
  105017. /**
  105018. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105019. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105020. */
  105021. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105022. /**
  105023. * Creates a new AnaglyphArcRotateCamera
  105024. * @param name defines camera name
  105025. * @param alpha defines alpha angle (in radians)
  105026. * @param beta defines beta angle (in radians)
  105027. * @param radius defines radius
  105028. * @param target defines camera target
  105029. * @param interaxialDistance defines distance between each color axis
  105030. * @param scene defines the hosting scene
  105031. */
  105032. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105033. /**
  105034. * Gets camera class name
  105035. * @returns AnaglyphArcRotateCamera
  105036. */
  105037. getClassName(): string;
  105038. }
  105039. }
  105040. declare module BABYLON {
  105041. /**
  105042. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105043. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105044. */
  105045. export class AnaglyphFreeCamera extends FreeCamera {
  105046. /**
  105047. * Creates a new AnaglyphFreeCamera
  105048. * @param name defines camera name
  105049. * @param position defines initial position
  105050. * @param interaxialDistance defines distance between each color axis
  105051. * @param scene defines the hosting scene
  105052. */
  105053. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105054. /**
  105055. * Gets camera class name
  105056. * @returns AnaglyphFreeCamera
  105057. */
  105058. getClassName(): string;
  105059. }
  105060. }
  105061. declare module BABYLON {
  105062. /**
  105063. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105064. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105065. */
  105066. export class AnaglyphGamepadCamera extends GamepadCamera {
  105067. /**
  105068. * Creates a new AnaglyphGamepadCamera
  105069. * @param name defines camera name
  105070. * @param position defines initial position
  105071. * @param interaxialDistance defines distance between each color axis
  105072. * @param scene defines the hosting scene
  105073. */
  105074. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105075. /**
  105076. * Gets camera class name
  105077. * @returns AnaglyphGamepadCamera
  105078. */
  105079. getClassName(): string;
  105080. }
  105081. }
  105082. declare module BABYLON {
  105083. /**
  105084. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105085. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105086. */
  105087. export class AnaglyphUniversalCamera extends UniversalCamera {
  105088. /**
  105089. * Creates a new AnaglyphUniversalCamera
  105090. * @param name defines camera name
  105091. * @param position defines initial position
  105092. * @param interaxialDistance defines distance between each color axis
  105093. * @param scene defines the hosting scene
  105094. */
  105095. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105096. /**
  105097. * Gets camera class name
  105098. * @returns AnaglyphUniversalCamera
  105099. */
  105100. getClassName(): string;
  105101. }
  105102. }
  105103. declare module BABYLON {
  105104. /** @hidden */
  105105. export var stereoscopicInterlacePixelShader: {
  105106. name: string;
  105107. shader: string;
  105108. };
  105109. }
  105110. declare module BABYLON {
  105111. /**
  105112. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105113. */
  105114. export class StereoscopicInterlacePostProcess extends PostProcess {
  105115. private _stepSize;
  105116. private _passedProcess;
  105117. /**
  105118. * Initializes a StereoscopicInterlacePostProcess
  105119. * @param name The name of the effect.
  105120. * @param rigCameras The rig cameras to be appled to the post process
  105121. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105123. * @param engine The engine which the post process will be applied. (default: current engine)
  105124. * @param reusable If the post process can be reused on the same frame. (default: false)
  105125. */
  105126. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105127. }
  105128. }
  105129. declare module BABYLON {
  105130. /**
  105131. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105132. * @see http://doc.babylonjs.com/features/cameras
  105133. */
  105134. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105135. /**
  105136. * Creates a new StereoscopicArcRotateCamera
  105137. * @param name defines camera name
  105138. * @param alpha defines alpha angle (in radians)
  105139. * @param beta defines beta angle (in radians)
  105140. * @param radius defines radius
  105141. * @param target defines camera target
  105142. * @param interaxialDistance defines distance between each color axis
  105143. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105144. * @param scene defines the hosting scene
  105145. */
  105146. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105147. /**
  105148. * Gets camera class name
  105149. * @returns StereoscopicArcRotateCamera
  105150. */
  105151. getClassName(): string;
  105152. }
  105153. }
  105154. declare module BABYLON {
  105155. /**
  105156. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105157. * @see http://doc.babylonjs.com/features/cameras
  105158. */
  105159. export class StereoscopicFreeCamera extends FreeCamera {
  105160. /**
  105161. * Creates a new StereoscopicFreeCamera
  105162. * @param name defines camera name
  105163. * @param position defines initial position
  105164. * @param interaxialDistance defines distance between each color axis
  105165. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105166. * @param scene defines the hosting scene
  105167. */
  105168. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105169. /**
  105170. * Gets camera class name
  105171. * @returns StereoscopicFreeCamera
  105172. */
  105173. getClassName(): string;
  105174. }
  105175. }
  105176. declare module BABYLON {
  105177. /**
  105178. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105179. * @see http://doc.babylonjs.com/features/cameras
  105180. */
  105181. export class StereoscopicGamepadCamera extends GamepadCamera {
  105182. /**
  105183. * Creates a new StereoscopicGamepadCamera
  105184. * @param name defines camera name
  105185. * @param position defines initial position
  105186. * @param interaxialDistance defines distance between each color axis
  105187. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105188. * @param scene defines the hosting scene
  105189. */
  105190. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105191. /**
  105192. * Gets camera class name
  105193. * @returns StereoscopicGamepadCamera
  105194. */
  105195. getClassName(): string;
  105196. }
  105197. }
  105198. declare module BABYLON {
  105199. /**
  105200. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105201. * @see http://doc.babylonjs.com/features/cameras
  105202. */
  105203. export class StereoscopicUniversalCamera extends UniversalCamera {
  105204. /**
  105205. * Creates a new StereoscopicUniversalCamera
  105206. * @param name defines camera name
  105207. * @param position defines initial position
  105208. * @param interaxialDistance defines distance between each color axis
  105209. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105210. * @param scene defines the hosting scene
  105211. */
  105212. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105213. /**
  105214. * Gets camera class name
  105215. * @returns StereoscopicUniversalCamera
  105216. */
  105217. getClassName(): string;
  105218. }
  105219. }
  105220. declare module BABYLON {
  105221. /**
  105222. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105223. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105224. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105225. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105226. */
  105227. export class VirtualJoysticksCamera extends FreeCamera {
  105228. /**
  105229. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105230. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105231. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105232. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105233. * @param name Define the name of the camera in the scene
  105234. * @param position Define the start position of the camera in the scene
  105235. * @param scene Define the scene the camera belongs to
  105236. */
  105237. constructor(name: string, position: Vector3, scene: Scene);
  105238. /**
  105239. * Gets the current object class name.
  105240. * @return the class name
  105241. */
  105242. getClassName(): string;
  105243. }
  105244. }
  105245. declare module BABYLON {
  105246. /**
  105247. * This represents all the required metrics to create a VR camera.
  105248. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105249. */
  105250. export class VRCameraMetrics {
  105251. /**
  105252. * Define the horizontal resolution off the screen.
  105253. */
  105254. hResolution: number;
  105255. /**
  105256. * Define the vertical resolution off the screen.
  105257. */
  105258. vResolution: number;
  105259. /**
  105260. * Define the horizontal screen size.
  105261. */
  105262. hScreenSize: number;
  105263. /**
  105264. * Define the vertical screen size.
  105265. */
  105266. vScreenSize: number;
  105267. /**
  105268. * Define the vertical screen center position.
  105269. */
  105270. vScreenCenter: number;
  105271. /**
  105272. * Define the distance of the eyes to the screen.
  105273. */
  105274. eyeToScreenDistance: number;
  105275. /**
  105276. * Define the distance between both lenses
  105277. */
  105278. lensSeparationDistance: number;
  105279. /**
  105280. * Define the distance between both viewer's eyes.
  105281. */
  105282. interpupillaryDistance: number;
  105283. /**
  105284. * Define the distortion factor of the VR postprocess.
  105285. * Please, touch with care.
  105286. */
  105287. distortionK: number[];
  105288. /**
  105289. * Define the chromatic aberration correction factors for the VR post process.
  105290. */
  105291. chromaAbCorrection: number[];
  105292. /**
  105293. * Define the scale factor of the post process.
  105294. * The smaller the better but the slower.
  105295. */
  105296. postProcessScaleFactor: number;
  105297. /**
  105298. * Define an offset for the lens center.
  105299. */
  105300. lensCenterOffset: number;
  105301. /**
  105302. * Define if the current vr camera should compensate the distortion of the lense or not.
  105303. */
  105304. compensateDistortion: boolean;
  105305. /**
  105306. * Defines if multiview should be enabled when rendering (Default: false)
  105307. */
  105308. multiviewEnabled: boolean;
  105309. /**
  105310. * Gets the rendering aspect ratio based on the provided resolutions.
  105311. */
  105312. readonly aspectRatio: number;
  105313. /**
  105314. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105315. */
  105316. readonly aspectRatioFov: number;
  105317. /**
  105318. * @hidden
  105319. */
  105320. readonly leftHMatrix: Matrix;
  105321. /**
  105322. * @hidden
  105323. */
  105324. readonly rightHMatrix: Matrix;
  105325. /**
  105326. * @hidden
  105327. */
  105328. readonly leftPreViewMatrix: Matrix;
  105329. /**
  105330. * @hidden
  105331. */
  105332. readonly rightPreViewMatrix: Matrix;
  105333. /**
  105334. * Get the default VRMetrics based on the most generic setup.
  105335. * @returns the default vr metrics
  105336. */
  105337. static GetDefault(): VRCameraMetrics;
  105338. }
  105339. }
  105340. declare module BABYLON {
  105341. /** @hidden */
  105342. export var vrDistortionCorrectionPixelShader: {
  105343. name: string;
  105344. shader: string;
  105345. };
  105346. }
  105347. declare module BABYLON {
  105348. /**
  105349. * VRDistortionCorrectionPostProcess used for mobile VR
  105350. */
  105351. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105352. private _isRightEye;
  105353. private _distortionFactors;
  105354. private _postProcessScaleFactor;
  105355. private _lensCenterOffset;
  105356. private _scaleIn;
  105357. private _scaleFactor;
  105358. private _lensCenter;
  105359. /**
  105360. * Initializes the VRDistortionCorrectionPostProcess
  105361. * @param name The name of the effect.
  105362. * @param camera The camera to apply the render pass to.
  105363. * @param isRightEye If this is for the right eye distortion
  105364. * @param vrMetrics All the required metrics for the VR camera
  105365. */
  105366. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105367. }
  105368. }
  105369. declare module BABYLON {
  105370. /**
  105371. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105372. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105373. */
  105374. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105375. /**
  105376. * Creates a new VRDeviceOrientationArcRotateCamera
  105377. * @param name defines camera name
  105378. * @param alpha defines the camera rotation along the logitudinal axis
  105379. * @param beta defines the camera rotation along the latitudinal axis
  105380. * @param radius defines the camera distance from its target
  105381. * @param target defines the camera target
  105382. * @param scene defines the scene the camera belongs to
  105383. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105384. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105385. */
  105386. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105387. /**
  105388. * Gets camera class name
  105389. * @returns VRDeviceOrientationArcRotateCamera
  105390. */
  105391. getClassName(): string;
  105392. }
  105393. }
  105394. declare module BABYLON {
  105395. /**
  105396. * Camera used to simulate VR rendering (based on FreeCamera)
  105397. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105398. */
  105399. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105400. /**
  105401. * Creates a new VRDeviceOrientationFreeCamera
  105402. * @param name defines camera name
  105403. * @param position defines the start position of the camera
  105404. * @param scene defines the scene the camera belongs to
  105405. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105406. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105407. */
  105408. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105409. /**
  105410. * Gets camera class name
  105411. * @returns VRDeviceOrientationFreeCamera
  105412. */
  105413. getClassName(): string;
  105414. }
  105415. }
  105416. declare module BABYLON {
  105417. /**
  105418. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105419. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105420. */
  105421. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105422. /**
  105423. * Creates a new VRDeviceOrientationGamepadCamera
  105424. * @param name defines camera name
  105425. * @param position defines the start position of the camera
  105426. * @param scene defines the scene the camera belongs to
  105427. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105428. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105429. */
  105430. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105431. /**
  105432. * Gets camera class name
  105433. * @returns VRDeviceOrientationGamepadCamera
  105434. */
  105435. getClassName(): string;
  105436. }
  105437. }
  105438. declare module BABYLON {
  105439. /**
  105440. * Base class of materials working in push mode in babylon JS
  105441. * @hidden
  105442. */
  105443. export class PushMaterial extends Material {
  105444. protected _activeEffect: Effect;
  105445. protected _normalMatrix: Matrix;
  105446. /**
  105447. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105448. * This means that the material can keep using a previous shader while a new one is being compiled.
  105449. * This is mostly used when shader parallel compilation is supported (true by default)
  105450. */
  105451. allowShaderHotSwapping: boolean;
  105452. constructor(name: string, scene: Scene);
  105453. getEffect(): Effect;
  105454. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105455. /**
  105456. * Binds the given world matrix to the active effect
  105457. *
  105458. * @param world the matrix to bind
  105459. */
  105460. bindOnlyWorldMatrix(world: Matrix): void;
  105461. /**
  105462. * Binds the given normal matrix to the active effect
  105463. *
  105464. * @param normalMatrix the matrix to bind
  105465. */
  105466. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105467. bind(world: Matrix, mesh?: Mesh): void;
  105468. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105469. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105470. }
  105471. }
  105472. declare module BABYLON {
  105473. /**
  105474. * This groups all the flags used to control the materials channel.
  105475. */
  105476. export class MaterialFlags {
  105477. private static _DiffuseTextureEnabled;
  105478. /**
  105479. * Are diffuse textures enabled in the application.
  105480. */
  105481. static DiffuseTextureEnabled: boolean;
  105482. private static _AmbientTextureEnabled;
  105483. /**
  105484. * Are ambient textures enabled in the application.
  105485. */
  105486. static AmbientTextureEnabled: boolean;
  105487. private static _OpacityTextureEnabled;
  105488. /**
  105489. * Are opacity textures enabled in the application.
  105490. */
  105491. static OpacityTextureEnabled: boolean;
  105492. private static _ReflectionTextureEnabled;
  105493. /**
  105494. * Are reflection textures enabled in the application.
  105495. */
  105496. static ReflectionTextureEnabled: boolean;
  105497. private static _EmissiveTextureEnabled;
  105498. /**
  105499. * Are emissive textures enabled in the application.
  105500. */
  105501. static EmissiveTextureEnabled: boolean;
  105502. private static _SpecularTextureEnabled;
  105503. /**
  105504. * Are specular textures enabled in the application.
  105505. */
  105506. static SpecularTextureEnabled: boolean;
  105507. private static _BumpTextureEnabled;
  105508. /**
  105509. * Are bump textures enabled in the application.
  105510. */
  105511. static BumpTextureEnabled: boolean;
  105512. private static _LightmapTextureEnabled;
  105513. /**
  105514. * Are lightmap textures enabled in the application.
  105515. */
  105516. static LightmapTextureEnabled: boolean;
  105517. private static _RefractionTextureEnabled;
  105518. /**
  105519. * Are refraction textures enabled in the application.
  105520. */
  105521. static RefractionTextureEnabled: boolean;
  105522. private static _ColorGradingTextureEnabled;
  105523. /**
  105524. * Are color grading textures enabled in the application.
  105525. */
  105526. static ColorGradingTextureEnabled: boolean;
  105527. private static _FresnelEnabled;
  105528. /**
  105529. * Are fresnels enabled in the application.
  105530. */
  105531. static FresnelEnabled: boolean;
  105532. private static _ClearCoatTextureEnabled;
  105533. /**
  105534. * Are clear coat textures enabled in the application.
  105535. */
  105536. static ClearCoatTextureEnabled: boolean;
  105537. private static _ClearCoatBumpTextureEnabled;
  105538. /**
  105539. * Are clear coat bump textures enabled in the application.
  105540. */
  105541. static ClearCoatBumpTextureEnabled: boolean;
  105542. private static _ClearCoatTintTextureEnabled;
  105543. /**
  105544. * Are clear coat tint textures enabled in the application.
  105545. */
  105546. static ClearCoatTintTextureEnabled: boolean;
  105547. private static _SheenTextureEnabled;
  105548. /**
  105549. * Are sheen textures enabled in the application.
  105550. */
  105551. static SheenTextureEnabled: boolean;
  105552. private static _AnisotropicTextureEnabled;
  105553. /**
  105554. * Are anisotropic textures enabled in the application.
  105555. */
  105556. static AnisotropicTextureEnabled: boolean;
  105557. private static _ThicknessTextureEnabled;
  105558. /**
  105559. * Are thickness textures enabled in the application.
  105560. */
  105561. static ThicknessTextureEnabled: boolean;
  105562. }
  105563. }
  105564. declare module BABYLON {
  105565. /** @hidden */
  105566. export var defaultFragmentDeclaration: {
  105567. name: string;
  105568. shader: string;
  105569. };
  105570. }
  105571. declare module BABYLON {
  105572. /** @hidden */
  105573. export var defaultUboDeclaration: {
  105574. name: string;
  105575. shader: string;
  105576. };
  105577. }
  105578. declare module BABYLON {
  105579. /** @hidden */
  105580. export var lightFragmentDeclaration: {
  105581. name: string;
  105582. shader: string;
  105583. };
  105584. }
  105585. declare module BABYLON {
  105586. /** @hidden */
  105587. export var lightUboDeclaration: {
  105588. name: string;
  105589. shader: string;
  105590. };
  105591. }
  105592. declare module BABYLON {
  105593. /** @hidden */
  105594. export var lightsFragmentFunctions: {
  105595. name: string;
  105596. shader: string;
  105597. };
  105598. }
  105599. declare module BABYLON {
  105600. /** @hidden */
  105601. export var shadowsFragmentFunctions: {
  105602. name: string;
  105603. shader: string;
  105604. };
  105605. }
  105606. declare module BABYLON {
  105607. /** @hidden */
  105608. export var fresnelFunction: {
  105609. name: string;
  105610. shader: string;
  105611. };
  105612. }
  105613. declare module BABYLON {
  105614. /** @hidden */
  105615. export var reflectionFunction: {
  105616. name: string;
  105617. shader: string;
  105618. };
  105619. }
  105620. declare module BABYLON {
  105621. /** @hidden */
  105622. export var bumpFragmentFunctions: {
  105623. name: string;
  105624. shader: string;
  105625. };
  105626. }
  105627. declare module BABYLON {
  105628. /** @hidden */
  105629. export var logDepthDeclaration: {
  105630. name: string;
  105631. shader: string;
  105632. };
  105633. }
  105634. declare module BABYLON {
  105635. /** @hidden */
  105636. export var bumpFragment: {
  105637. name: string;
  105638. shader: string;
  105639. };
  105640. }
  105641. declare module BABYLON {
  105642. /** @hidden */
  105643. export var depthPrePass: {
  105644. name: string;
  105645. shader: string;
  105646. };
  105647. }
  105648. declare module BABYLON {
  105649. /** @hidden */
  105650. export var lightFragment: {
  105651. name: string;
  105652. shader: string;
  105653. };
  105654. }
  105655. declare module BABYLON {
  105656. /** @hidden */
  105657. export var logDepthFragment: {
  105658. name: string;
  105659. shader: string;
  105660. };
  105661. }
  105662. declare module BABYLON {
  105663. /** @hidden */
  105664. export var defaultPixelShader: {
  105665. name: string;
  105666. shader: string;
  105667. };
  105668. }
  105669. declare module BABYLON {
  105670. /** @hidden */
  105671. export var defaultVertexDeclaration: {
  105672. name: string;
  105673. shader: string;
  105674. };
  105675. }
  105676. declare module BABYLON {
  105677. /** @hidden */
  105678. export var bumpVertexDeclaration: {
  105679. name: string;
  105680. shader: string;
  105681. };
  105682. }
  105683. declare module BABYLON {
  105684. /** @hidden */
  105685. export var bumpVertex: {
  105686. name: string;
  105687. shader: string;
  105688. };
  105689. }
  105690. declare module BABYLON {
  105691. /** @hidden */
  105692. export var fogVertex: {
  105693. name: string;
  105694. shader: string;
  105695. };
  105696. }
  105697. declare module BABYLON {
  105698. /** @hidden */
  105699. export var shadowsVertex: {
  105700. name: string;
  105701. shader: string;
  105702. };
  105703. }
  105704. declare module BABYLON {
  105705. /** @hidden */
  105706. export var pointCloudVertex: {
  105707. name: string;
  105708. shader: string;
  105709. };
  105710. }
  105711. declare module BABYLON {
  105712. /** @hidden */
  105713. export var logDepthVertex: {
  105714. name: string;
  105715. shader: string;
  105716. };
  105717. }
  105718. declare module BABYLON {
  105719. /** @hidden */
  105720. export var defaultVertexShader: {
  105721. name: string;
  105722. shader: string;
  105723. };
  105724. }
  105725. declare module BABYLON {
  105726. /** @hidden */
  105727. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105728. MAINUV1: boolean;
  105729. MAINUV2: boolean;
  105730. DIFFUSE: boolean;
  105731. DIFFUSEDIRECTUV: number;
  105732. AMBIENT: boolean;
  105733. AMBIENTDIRECTUV: number;
  105734. OPACITY: boolean;
  105735. OPACITYDIRECTUV: number;
  105736. OPACITYRGB: boolean;
  105737. REFLECTION: boolean;
  105738. EMISSIVE: boolean;
  105739. EMISSIVEDIRECTUV: number;
  105740. SPECULAR: boolean;
  105741. SPECULARDIRECTUV: number;
  105742. BUMP: boolean;
  105743. BUMPDIRECTUV: number;
  105744. PARALLAX: boolean;
  105745. PARALLAXOCCLUSION: boolean;
  105746. SPECULAROVERALPHA: boolean;
  105747. CLIPPLANE: boolean;
  105748. CLIPPLANE2: boolean;
  105749. CLIPPLANE3: boolean;
  105750. CLIPPLANE4: boolean;
  105751. ALPHATEST: boolean;
  105752. DEPTHPREPASS: boolean;
  105753. ALPHAFROMDIFFUSE: boolean;
  105754. POINTSIZE: boolean;
  105755. FOG: boolean;
  105756. SPECULARTERM: boolean;
  105757. DIFFUSEFRESNEL: boolean;
  105758. OPACITYFRESNEL: boolean;
  105759. REFLECTIONFRESNEL: boolean;
  105760. REFRACTIONFRESNEL: boolean;
  105761. EMISSIVEFRESNEL: boolean;
  105762. FRESNEL: boolean;
  105763. NORMAL: boolean;
  105764. UV1: boolean;
  105765. UV2: boolean;
  105766. VERTEXCOLOR: boolean;
  105767. VERTEXALPHA: boolean;
  105768. NUM_BONE_INFLUENCERS: number;
  105769. BonesPerMesh: number;
  105770. BONETEXTURE: boolean;
  105771. INSTANCES: boolean;
  105772. GLOSSINESS: boolean;
  105773. ROUGHNESS: boolean;
  105774. EMISSIVEASILLUMINATION: boolean;
  105775. LINKEMISSIVEWITHDIFFUSE: boolean;
  105776. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105777. LIGHTMAP: boolean;
  105778. LIGHTMAPDIRECTUV: number;
  105779. OBJECTSPACE_NORMALMAP: boolean;
  105780. USELIGHTMAPASSHADOWMAP: boolean;
  105781. REFLECTIONMAP_3D: boolean;
  105782. REFLECTIONMAP_SPHERICAL: boolean;
  105783. REFLECTIONMAP_PLANAR: boolean;
  105784. REFLECTIONMAP_CUBIC: boolean;
  105785. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105786. REFLECTIONMAP_PROJECTION: boolean;
  105787. REFLECTIONMAP_SKYBOX: boolean;
  105788. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105789. REFLECTIONMAP_EXPLICIT: boolean;
  105790. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105791. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105792. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105793. INVERTCUBICMAP: boolean;
  105794. LOGARITHMICDEPTH: boolean;
  105795. REFRACTION: boolean;
  105796. REFRACTIONMAP_3D: boolean;
  105797. REFLECTIONOVERALPHA: boolean;
  105798. TWOSIDEDLIGHTING: boolean;
  105799. SHADOWFLOAT: boolean;
  105800. MORPHTARGETS: boolean;
  105801. MORPHTARGETS_NORMAL: boolean;
  105802. MORPHTARGETS_TANGENT: boolean;
  105803. MORPHTARGETS_UV: boolean;
  105804. NUM_MORPH_INFLUENCERS: number;
  105805. NONUNIFORMSCALING: boolean;
  105806. PREMULTIPLYALPHA: boolean;
  105807. IMAGEPROCESSING: boolean;
  105808. VIGNETTE: boolean;
  105809. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105810. VIGNETTEBLENDMODEOPAQUE: boolean;
  105811. TONEMAPPING: boolean;
  105812. TONEMAPPING_ACES: boolean;
  105813. CONTRAST: boolean;
  105814. COLORCURVES: boolean;
  105815. COLORGRADING: boolean;
  105816. COLORGRADING3D: boolean;
  105817. SAMPLER3DGREENDEPTH: boolean;
  105818. SAMPLER3DBGRMAP: boolean;
  105819. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105820. MULTIVIEW: boolean;
  105821. /**
  105822. * If the reflection texture on this material is in linear color space
  105823. * @hidden
  105824. */
  105825. IS_REFLECTION_LINEAR: boolean;
  105826. /**
  105827. * If the refraction texture on this material is in linear color space
  105828. * @hidden
  105829. */
  105830. IS_REFRACTION_LINEAR: boolean;
  105831. EXPOSURE: boolean;
  105832. constructor();
  105833. setReflectionMode(modeToEnable: string): void;
  105834. }
  105835. /**
  105836. * This is the default material used in Babylon. It is the best trade off between quality
  105837. * and performances.
  105838. * @see http://doc.babylonjs.com/babylon101/materials
  105839. */
  105840. export class StandardMaterial extends PushMaterial {
  105841. private _diffuseTexture;
  105842. /**
  105843. * The basic texture of the material as viewed under a light.
  105844. */
  105845. diffuseTexture: Nullable<BaseTexture>;
  105846. private _ambientTexture;
  105847. /**
  105848. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105849. */
  105850. ambientTexture: Nullable<BaseTexture>;
  105851. private _opacityTexture;
  105852. /**
  105853. * Define the transparency of the material from a texture.
  105854. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105855. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105856. */
  105857. opacityTexture: Nullable<BaseTexture>;
  105858. private _reflectionTexture;
  105859. /**
  105860. * Define the texture used to display the reflection.
  105861. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105862. */
  105863. reflectionTexture: Nullable<BaseTexture>;
  105864. private _emissiveTexture;
  105865. /**
  105866. * Define texture of the material as if self lit.
  105867. * This will be mixed in the final result even in the absence of light.
  105868. */
  105869. emissiveTexture: Nullable<BaseTexture>;
  105870. private _specularTexture;
  105871. /**
  105872. * Define how the color and intensity of the highlight given by the light in the material.
  105873. */
  105874. specularTexture: Nullable<BaseTexture>;
  105875. private _bumpTexture;
  105876. /**
  105877. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105878. * 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.
  105879. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105880. */
  105881. bumpTexture: Nullable<BaseTexture>;
  105882. private _lightmapTexture;
  105883. /**
  105884. * Complex lighting can be computationally expensive to compute at runtime.
  105885. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105886. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105887. */
  105888. lightmapTexture: Nullable<BaseTexture>;
  105889. private _refractionTexture;
  105890. /**
  105891. * Define the texture used to display the refraction.
  105892. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105893. */
  105894. refractionTexture: Nullable<BaseTexture>;
  105895. /**
  105896. * The color of the material lit by the environmental background lighting.
  105897. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105898. */
  105899. ambientColor: Color3;
  105900. /**
  105901. * The basic color of the material as viewed under a light.
  105902. */
  105903. diffuseColor: Color3;
  105904. /**
  105905. * Define how the color and intensity of the highlight given by the light in the material.
  105906. */
  105907. specularColor: Color3;
  105908. /**
  105909. * Define the color of the material as if self lit.
  105910. * This will be mixed in the final result even in the absence of light.
  105911. */
  105912. emissiveColor: Color3;
  105913. /**
  105914. * Defines how sharp are the highlights in the material.
  105915. * The bigger the value the sharper giving a more glossy feeling to the result.
  105916. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105917. */
  105918. specularPower: number;
  105919. private _useAlphaFromDiffuseTexture;
  105920. /**
  105921. * Does the transparency come from the diffuse texture alpha channel.
  105922. */
  105923. useAlphaFromDiffuseTexture: boolean;
  105924. private _useEmissiveAsIllumination;
  105925. /**
  105926. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105927. */
  105928. useEmissiveAsIllumination: boolean;
  105929. private _linkEmissiveWithDiffuse;
  105930. /**
  105931. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105932. * the emissive level when the final color is close to one.
  105933. */
  105934. linkEmissiveWithDiffuse: boolean;
  105935. private _useSpecularOverAlpha;
  105936. /**
  105937. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105938. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105939. */
  105940. useSpecularOverAlpha: boolean;
  105941. private _useReflectionOverAlpha;
  105942. /**
  105943. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105944. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105945. */
  105946. useReflectionOverAlpha: boolean;
  105947. private _disableLighting;
  105948. /**
  105949. * Does lights from the scene impacts this material.
  105950. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105951. */
  105952. disableLighting: boolean;
  105953. private _useObjectSpaceNormalMap;
  105954. /**
  105955. * Allows using an object space normal map (instead of tangent space).
  105956. */
  105957. useObjectSpaceNormalMap: boolean;
  105958. private _useParallax;
  105959. /**
  105960. * Is parallax enabled or not.
  105961. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105962. */
  105963. useParallax: boolean;
  105964. private _useParallaxOcclusion;
  105965. /**
  105966. * Is parallax occlusion enabled or not.
  105967. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105968. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105969. */
  105970. useParallaxOcclusion: boolean;
  105971. /**
  105972. * 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.
  105973. */
  105974. parallaxScaleBias: number;
  105975. private _roughness;
  105976. /**
  105977. * Helps to define how blurry the reflections should appears in the material.
  105978. */
  105979. roughness: number;
  105980. /**
  105981. * In case of refraction, define the value of the index of refraction.
  105982. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105983. */
  105984. indexOfRefraction: number;
  105985. /**
  105986. * Invert the refraction texture alongside the y axis.
  105987. * It can be useful with procedural textures or probe for instance.
  105988. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105989. */
  105990. invertRefractionY: boolean;
  105991. /**
  105992. * Defines the alpha limits in alpha test mode.
  105993. */
  105994. alphaCutOff: number;
  105995. private _useLightmapAsShadowmap;
  105996. /**
  105997. * In case of light mapping, define whether the map contains light or shadow informations.
  105998. */
  105999. useLightmapAsShadowmap: boolean;
  106000. private _diffuseFresnelParameters;
  106001. /**
  106002. * Define the diffuse fresnel parameters of the material.
  106003. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106004. */
  106005. diffuseFresnelParameters: FresnelParameters;
  106006. private _opacityFresnelParameters;
  106007. /**
  106008. * Define the opacity fresnel parameters of the material.
  106009. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106010. */
  106011. opacityFresnelParameters: FresnelParameters;
  106012. private _reflectionFresnelParameters;
  106013. /**
  106014. * Define the reflection fresnel parameters of the material.
  106015. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106016. */
  106017. reflectionFresnelParameters: FresnelParameters;
  106018. private _refractionFresnelParameters;
  106019. /**
  106020. * Define the refraction fresnel parameters of the material.
  106021. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106022. */
  106023. refractionFresnelParameters: FresnelParameters;
  106024. private _emissiveFresnelParameters;
  106025. /**
  106026. * Define the emissive fresnel parameters of the material.
  106027. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106028. */
  106029. emissiveFresnelParameters: FresnelParameters;
  106030. private _useReflectionFresnelFromSpecular;
  106031. /**
  106032. * If true automatically deducts the fresnels values from the material specularity.
  106033. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106034. */
  106035. useReflectionFresnelFromSpecular: boolean;
  106036. private _useGlossinessFromSpecularMapAlpha;
  106037. /**
  106038. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106039. */
  106040. useGlossinessFromSpecularMapAlpha: boolean;
  106041. private _maxSimultaneousLights;
  106042. /**
  106043. * Defines the maximum number of lights that can be used in the material
  106044. */
  106045. maxSimultaneousLights: number;
  106046. private _invertNormalMapX;
  106047. /**
  106048. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106049. */
  106050. invertNormalMapX: boolean;
  106051. private _invertNormalMapY;
  106052. /**
  106053. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106054. */
  106055. invertNormalMapY: boolean;
  106056. private _twoSidedLighting;
  106057. /**
  106058. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106059. */
  106060. twoSidedLighting: boolean;
  106061. /**
  106062. * Default configuration related to image processing available in the standard Material.
  106063. */
  106064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106065. /**
  106066. * Gets the image processing configuration used either in this material.
  106067. */
  106068. /**
  106069. * Sets the Default image processing configuration used either in the this material.
  106070. *
  106071. * If sets to null, the scene one is in use.
  106072. */
  106073. imageProcessingConfiguration: ImageProcessingConfiguration;
  106074. /**
  106075. * Keep track of the image processing observer to allow dispose and replace.
  106076. */
  106077. private _imageProcessingObserver;
  106078. /**
  106079. * Attaches a new image processing configuration to the Standard Material.
  106080. * @param configuration
  106081. */
  106082. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106083. /**
  106084. * Gets wether the color curves effect is enabled.
  106085. */
  106086. /**
  106087. * Sets wether the color curves effect is enabled.
  106088. */
  106089. cameraColorCurvesEnabled: boolean;
  106090. /**
  106091. * Gets wether the color grading effect is enabled.
  106092. */
  106093. /**
  106094. * Gets wether the color grading effect is enabled.
  106095. */
  106096. cameraColorGradingEnabled: boolean;
  106097. /**
  106098. * Gets wether tonemapping is enabled or not.
  106099. */
  106100. /**
  106101. * Sets wether tonemapping is enabled or not
  106102. */
  106103. cameraToneMappingEnabled: boolean;
  106104. /**
  106105. * The camera exposure used on this material.
  106106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106107. * This corresponds to a photographic exposure.
  106108. */
  106109. /**
  106110. * The camera exposure used on this material.
  106111. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106112. * This corresponds to a photographic exposure.
  106113. */
  106114. cameraExposure: number;
  106115. /**
  106116. * Gets The camera contrast used on this material.
  106117. */
  106118. /**
  106119. * Sets The camera contrast used on this material.
  106120. */
  106121. cameraContrast: number;
  106122. /**
  106123. * Gets the Color Grading 2D Lookup Texture.
  106124. */
  106125. /**
  106126. * Sets the Color Grading 2D Lookup Texture.
  106127. */
  106128. cameraColorGradingTexture: Nullable<BaseTexture>;
  106129. /**
  106130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106132. * 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;
  106133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106134. */
  106135. /**
  106136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106138. * 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;
  106139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106140. */
  106141. cameraColorCurves: Nullable<ColorCurves>;
  106142. /**
  106143. * Custom callback helping to override the default shader used in the material.
  106144. */
  106145. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106146. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106147. protected _worldViewProjectionMatrix: Matrix;
  106148. protected _globalAmbientColor: Color3;
  106149. protected _useLogarithmicDepth: boolean;
  106150. protected _rebuildInParallel: boolean;
  106151. /**
  106152. * Instantiates a new standard material.
  106153. * This is the default material used in Babylon. It is the best trade off between quality
  106154. * and performances.
  106155. * @see http://doc.babylonjs.com/babylon101/materials
  106156. * @param name Define the name of the material in the scene
  106157. * @param scene Define the scene the material belong to
  106158. */
  106159. constructor(name: string, scene: Scene);
  106160. /**
  106161. * Gets a boolean indicating that current material needs to register RTT
  106162. */
  106163. readonly hasRenderTargetTextures: boolean;
  106164. /**
  106165. * Gets the current class name of the material e.g. "StandardMaterial"
  106166. * Mainly use in serialization.
  106167. * @returns the class name
  106168. */
  106169. getClassName(): string;
  106170. /**
  106171. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106172. * You can try switching to logarithmic depth.
  106173. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106174. */
  106175. useLogarithmicDepth: boolean;
  106176. /**
  106177. * Specifies if the material will require alpha blending
  106178. * @returns a boolean specifying if alpha blending is needed
  106179. */
  106180. needAlphaBlending(): boolean;
  106181. /**
  106182. * Specifies if this material should be rendered in alpha test mode
  106183. * @returns a boolean specifying if an alpha test is needed.
  106184. */
  106185. needAlphaTesting(): boolean;
  106186. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106187. /**
  106188. * Get the texture used for alpha test purpose.
  106189. * @returns the diffuse texture in case of the standard material.
  106190. */
  106191. getAlphaTestTexture(): Nullable<BaseTexture>;
  106192. /**
  106193. * Get if the submesh is ready to be used and all its information available.
  106194. * Child classes can use it to update shaders
  106195. * @param mesh defines the mesh to check
  106196. * @param subMesh defines which submesh to check
  106197. * @param useInstances specifies that instances should be used
  106198. * @returns a boolean indicating that the submesh is ready or not
  106199. */
  106200. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106201. /**
  106202. * Builds the material UBO layouts.
  106203. * Used internally during the effect preparation.
  106204. */
  106205. buildUniformLayout(): void;
  106206. /**
  106207. * Unbinds the material from the mesh
  106208. */
  106209. unbind(): void;
  106210. /**
  106211. * Binds the submesh to this material by preparing the effect and shader to draw
  106212. * @param world defines the world transformation matrix
  106213. * @param mesh defines the mesh containing the submesh
  106214. * @param subMesh defines the submesh to bind the material to
  106215. */
  106216. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106217. /**
  106218. * Get the list of animatables in the material.
  106219. * @returns the list of animatables object used in the material
  106220. */
  106221. getAnimatables(): IAnimatable[];
  106222. /**
  106223. * Gets the active textures from the material
  106224. * @returns an array of textures
  106225. */
  106226. getActiveTextures(): BaseTexture[];
  106227. /**
  106228. * Specifies if the material uses a texture
  106229. * @param texture defines the texture to check against the material
  106230. * @returns a boolean specifying if the material uses the texture
  106231. */
  106232. hasTexture(texture: BaseTexture): boolean;
  106233. /**
  106234. * Disposes the material
  106235. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106236. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106237. */
  106238. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106239. /**
  106240. * Makes a duplicate of the material, and gives it a new name
  106241. * @param name defines the new name for the duplicated material
  106242. * @returns the cloned material
  106243. */
  106244. clone(name: string): StandardMaterial;
  106245. /**
  106246. * Serializes this material in a JSON representation
  106247. * @returns the serialized material object
  106248. */
  106249. serialize(): any;
  106250. /**
  106251. * Creates a standard material from parsed material data
  106252. * @param source defines the JSON representation of the material
  106253. * @param scene defines the hosting scene
  106254. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106255. * @returns a new standard material
  106256. */
  106257. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106258. /**
  106259. * Are diffuse textures enabled in the application.
  106260. */
  106261. static DiffuseTextureEnabled: boolean;
  106262. /**
  106263. * Are ambient textures enabled in the application.
  106264. */
  106265. static AmbientTextureEnabled: boolean;
  106266. /**
  106267. * Are opacity textures enabled in the application.
  106268. */
  106269. static OpacityTextureEnabled: boolean;
  106270. /**
  106271. * Are reflection textures enabled in the application.
  106272. */
  106273. static ReflectionTextureEnabled: boolean;
  106274. /**
  106275. * Are emissive textures enabled in the application.
  106276. */
  106277. static EmissiveTextureEnabled: boolean;
  106278. /**
  106279. * Are specular textures enabled in the application.
  106280. */
  106281. static SpecularTextureEnabled: boolean;
  106282. /**
  106283. * Are bump textures enabled in the application.
  106284. */
  106285. static BumpTextureEnabled: boolean;
  106286. /**
  106287. * Are lightmap textures enabled in the application.
  106288. */
  106289. static LightmapTextureEnabled: boolean;
  106290. /**
  106291. * Are refraction textures enabled in the application.
  106292. */
  106293. static RefractionTextureEnabled: boolean;
  106294. /**
  106295. * Are color grading textures enabled in the application.
  106296. */
  106297. static ColorGradingTextureEnabled: boolean;
  106298. /**
  106299. * Are fresnels enabled in the application.
  106300. */
  106301. static FresnelEnabled: boolean;
  106302. }
  106303. }
  106304. declare module BABYLON {
  106305. /** @hidden */
  106306. export var imageProcessingPixelShader: {
  106307. name: string;
  106308. shader: string;
  106309. };
  106310. }
  106311. declare module BABYLON {
  106312. /**
  106313. * ImageProcessingPostProcess
  106314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106315. */
  106316. export class ImageProcessingPostProcess extends PostProcess {
  106317. /**
  106318. * Default configuration related to image processing available in the PBR Material.
  106319. */
  106320. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106321. /**
  106322. * Gets the image processing configuration used either in this material.
  106323. */
  106324. /**
  106325. * Sets the Default image processing configuration used either in the this material.
  106326. *
  106327. * If sets to null, the scene one is in use.
  106328. */
  106329. imageProcessingConfiguration: ImageProcessingConfiguration;
  106330. /**
  106331. * Keep track of the image processing observer to allow dispose and replace.
  106332. */
  106333. private _imageProcessingObserver;
  106334. /**
  106335. * Attaches a new image processing configuration to the PBR Material.
  106336. * @param configuration
  106337. */
  106338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106339. /**
  106340. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106341. */
  106342. /**
  106343. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106344. */
  106345. colorCurves: Nullable<ColorCurves>;
  106346. /**
  106347. * Gets wether the color curves effect is enabled.
  106348. */
  106349. /**
  106350. * Sets wether the color curves effect is enabled.
  106351. */
  106352. colorCurvesEnabled: boolean;
  106353. /**
  106354. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106355. */
  106356. /**
  106357. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106358. */
  106359. colorGradingTexture: Nullable<BaseTexture>;
  106360. /**
  106361. * Gets wether the color grading effect is enabled.
  106362. */
  106363. /**
  106364. * Gets wether the color grading effect is enabled.
  106365. */
  106366. colorGradingEnabled: boolean;
  106367. /**
  106368. * Gets exposure used in the effect.
  106369. */
  106370. /**
  106371. * Sets exposure used in the effect.
  106372. */
  106373. exposure: number;
  106374. /**
  106375. * Gets wether tonemapping is enabled or not.
  106376. */
  106377. /**
  106378. * Sets wether tonemapping is enabled or not
  106379. */
  106380. toneMappingEnabled: boolean;
  106381. /**
  106382. * Gets the type of tone mapping effect.
  106383. */
  106384. /**
  106385. * Sets the type of tone mapping effect.
  106386. */
  106387. toneMappingType: number;
  106388. /**
  106389. * Gets contrast used in the effect.
  106390. */
  106391. /**
  106392. * Sets contrast used in the effect.
  106393. */
  106394. contrast: number;
  106395. /**
  106396. * Gets Vignette stretch size.
  106397. */
  106398. /**
  106399. * Sets Vignette stretch size.
  106400. */
  106401. vignetteStretch: number;
  106402. /**
  106403. * Gets Vignette centre X Offset.
  106404. */
  106405. /**
  106406. * Sets Vignette centre X Offset.
  106407. */
  106408. vignetteCentreX: number;
  106409. /**
  106410. * Gets Vignette centre Y Offset.
  106411. */
  106412. /**
  106413. * Sets Vignette centre Y Offset.
  106414. */
  106415. vignetteCentreY: number;
  106416. /**
  106417. * Gets Vignette weight or intensity of the vignette effect.
  106418. */
  106419. /**
  106420. * Sets Vignette weight or intensity of the vignette effect.
  106421. */
  106422. vignetteWeight: number;
  106423. /**
  106424. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106425. * if vignetteEnabled is set to true.
  106426. */
  106427. /**
  106428. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106429. * if vignetteEnabled is set to true.
  106430. */
  106431. vignetteColor: Color4;
  106432. /**
  106433. * Gets Camera field of view used by the Vignette effect.
  106434. */
  106435. /**
  106436. * Sets Camera field of view used by the Vignette effect.
  106437. */
  106438. vignetteCameraFov: number;
  106439. /**
  106440. * Gets the vignette blend mode allowing different kind of effect.
  106441. */
  106442. /**
  106443. * Sets the vignette blend mode allowing different kind of effect.
  106444. */
  106445. vignetteBlendMode: number;
  106446. /**
  106447. * Gets wether the vignette effect is enabled.
  106448. */
  106449. /**
  106450. * Sets wether the vignette effect is enabled.
  106451. */
  106452. vignetteEnabled: boolean;
  106453. private _fromLinearSpace;
  106454. /**
  106455. * Gets wether the input of the processing is in Gamma or Linear Space.
  106456. */
  106457. /**
  106458. * Sets wether the input of the processing is in Gamma or Linear Space.
  106459. */
  106460. fromLinearSpace: boolean;
  106461. /**
  106462. * Defines cache preventing GC.
  106463. */
  106464. private _defines;
  106465. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106466. /**
  106467. * "ImageProcessingPostProcess"
  106468. * @returns "ImageProcessingPostProcess"
  106469. */
  106470. getClassName(): string;
  106471. protected _updateParameters(): void;
  106472. dispose(camera?: Camera): void;
  106473. }
  106474. }
  106475. declare module BABYLON {
  106476. /**
  106477. * Class containing static functions to help procedurally build meshes
  106478. */
  106479. export class GroundBuilder {
  106480. /**
  106481. * Creates a ground mesh
  106482. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106483. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106485. * @param name defines the name of the mesh
  106486. * @param options defines the options used to create the mesh
  106487. * @param scene defines the hosting scene
  106488. * @returns the ground mesh
  106489. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106490. */
  106491. static CreateGround(name: string, options: {
  106492. width?: number;
  106493. height?: number;
  106494. subdivisions?: number;
  106495. subdivisionsX?: number;
  106496. subdivisionsY?: number;
  106497. updatable?: boolean;
  106498. }, scene: any): Mesh;
  106499. /**
  106500. * Creates a tiled ground mesh
  106501. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106502. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106503. * * 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
  106504. * * 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
  106505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106506. * @param name defines the name of the mesh
  106507. * @param options defines the options used to create the mesh
  106508. * @param scene defines the hosting scene
  106509. * @returns the tiled ground mesh
  106510. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106511. */
  106512. static CreateTiledGround(name: string, options: {
  106513. xmin: number;
  106514. zmin: number;
  106515. xmax: number;
  106516. zmax: number;
  106517. subdivisions?: {
  106518. w: number;
  106519. h: number;
  106520. };
  106521. precision?: {
  106522. w: number;
  106523. h: number;
  106524. };
  106525. updatable?: boolean;
  106526. }, scene?: Nullable<Scene>): Mesh;
  106527. /**
  106528. * Creates a ground mesh from a height map
  106529. * * The parameter `url` sets the URL of the height map image resource.
  106530. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106531. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106532. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106533. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106534. * * 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.
  106535. * * 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).
  106536. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106538. * @param name defines the name of the mesh
  106539. * @param url defines the url to the height map
  106540. * @param options defines the options used to create the mesh
  106541. * @param scene defines the hosting scene
  106542. * @returns the ground mesh
  106543. * @see https://doc.babylonjs.com/babylon101/height_map
  106544. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106545. */
  106546. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106547. width?: number;
  106548. height?: number;
  106549. subdivisions?: number;
  106550. minHeight?: number;
  106551. maxHeight?: number;
  106552. colorFilter?: Color3;
  106553. alphaFilter?: number;
  106554. updatable?: boolean;
  106555. onReady?: (mesh: GroundMesh) => void;
  106556. }, scene?: Nullable<Scene>): GroundMesh;
  106557. }
  106558. }
  106559. declare module BABYLON {
  106560. /**
  106561. * Class containing static functions to help procedurally build meshes
  106562. */
  106563. export class TorusBuilder {
  106564. /**
  106565. * Creates a torus mesh
  106566. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106567. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106568. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106572. * @param name defines the name of the mesh
  106573. * @param options defines the options used to create the mesh
  106574. * @param scene defines the hosting scene
  106575. * @returns the torus mesh
  106576. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106577. */
  106578. static CreateTorus(name: string, options: {
  106579. diameter?: number;
  106580. thickness?: number;
  106581. tessellation?: number;
  106582. updatable?: boolean;
  106583. sideOrientation?: number;
  106584. frontUVs?: Vector4;
  106585. backUVs?: Vector4;
  106586. }, scene: any): Mesh;
  106587. }
  106588. }
  106589. declare module BABYLON {
  106590. /**
  106591. * Class containing static functions to help procedurally build meshes
  106592. */
  106593. export class CylinderBuilder {
  106594. /**
  106595. * Creates a cylinder or a cone mesh
  106596. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106597. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106598. * * 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.
  106599. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106600. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106601. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106602. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106603. * * 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).
  106604. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106605. * * 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).
  106606. * * 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
  106607. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106608. * * 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
  106609. * * 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.
  106610. * * If `enclose` is false, a ring surface is one element.
  106611. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106612. * * 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
  106613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106616. * @param name defines the name of the mesh
  106617. * @param options defines the options used to create the mesh
  106618. * @param scene defines the hosting scene
  106619. * @returns the cylinder mesh
  106620. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106621. */
  106622. static CreateCylinder(name: string, options: {
  106623. height?: number;
  106624. diameterTop?: number;
  106625. diameterBottom?: number;
  106626. diameter?: number;
  106627. tessellation?: number;
  106628. subdivisions?: number;
  106629. arc?: number;
  106630. faceColors?: Color4[];
  106631. faceUV?: Vector4[];
  106632. updatable?: boolean;
  106633. hasRings?: boolean;
  106634. enclose?: boolean;
  106635. cap?: number;
  106636. sideOrientation?: number;
  106637. frontUVs?: Vector4;
  106638. backUVs?: Vector4;
  106639. }, scene: any): Mesh;
  106640. }
  106641. }
  106642. declare module BABYLON {
  106643. /**
  106644. * Options to modify the vr teleportation behavior.
  106645. */
  106646. export interface VRTeleportationOptions {
  106647. /**
  106648. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106649. */
  106650. floorMeshName?: string;
  106651. /**
  106652. * A list of meshes to be used as the teleportation floor. (default: empty)
  106653. */
  106654. floorMeshes?: Mesh[];
  106655. }
  106656. /**
  106657. * Options to modify the vr experience helper's behavior.
  106658. */
  106659. export interface VRExperienceHelperOptions extends WebVROptions {
  106660. /**
  106661. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106662. */
  106663. createDeviceOrientationCamera?: boolean;
  106664. /**
  106665. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106666. */
  106667. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106668. /**
  106669. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106670. */
  106671. laserToggle?: boolean;
  106672. /**
  106673. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106674. */
  106675. floorMeshes?: Mesh[];
  106676. /**
  106677. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106678. */
  106679. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106680. }
  106681. /**
  106682. * Event containing information after VR has been entered
  106683. */
  106684. export class OnAfterEnteringVRObservableEvent {
  106685. /**
  106686. * If entering vr was successful
  106687. */
  106688. success: boolean;
  106689. }
  106690. /**
  106691. * Helps to quickly add VR support to an existing scene.
  106692. * See http://doc.babylonjs.com/how_to/webvr_helper
  106693. */
  106694. export class VRExperienceHelper {
  106695. /** Options to modify the vr experience helper's behavior. */
  106696. webVROptions: VRExperienceHelperOptions;
  106697. private _scene;
  106698. private _position;
  106699. private _btnVR;
  106700. private _btnVRDisplayed;
  106701. private _webVRsupported;
  106702. private _webVRready;
  106703. private _webVRrequesting;
  106704. private _webVRpresenting;
  106705. private _hasEnteredVR;
  106706. private _fullscreenVRpresenting;
  106707. private _canvas;
  106708. private _webVRCamera;
  106709. private _vrDeviceOrientationCamera;
  106710. private _deviceOrientationCamera;
  106711. private _existingCamera;
  106712. private _onKeyDown;
  106713. private _onVrDisplayPresentChange;
  106714. private _onVRDisplayChanged;
  106715. private _onVRRequestPresentStart;
  106716. private _onVRRequestPresentComplete;
  106717. /**
  106718. * 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)
  106719. */
  106720. enableGazeEvenWhenNoPointerLock: boolean;
  106721. /**
  106722. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106723. */
  106724. exitVROnDoubleTap: boolean;
  106725. /**
  106726. * Observable raised right before entering VR.
  106727. */
  106728. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106729. /**
  106730. * Observable raised when entering VR has completed.
  106731. */
  106732. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106733. /**
  106734. * Observable raised when exiting VR.
  106735. */
  106736. onExitingVRObservable: Observable<VRExperienceHelper>;
  106737. /**
  106738. * Observable raised when controller mesh is loaded.
  106739. */
  106740. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106741. /** Return this.onEnteringVRObservable
  106742. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106743. */
  106744. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106745. /** Return this.onExitingVRObservable
  106746. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106747. */
  106748. readonly onExitingVR: Observable<VRExperienceHelper>;
  106749. /** Return this.onControllerMeshLoadedObservable
  106750. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106751. */
  106752. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106753. private _rayLength;
  106754. private _useCustomVRButton;
  106755. private _teleportationRequested;
  106756. private _teleportActive;
  106757. private _floorMeshName;
  106758. private _floorMeshesCollection;
  106759. private _rotationAllowed;
  106760. private _teleportBackwardsVector;
  106761. private _teleportationTarget;
  106762. private _isDefaultTeleportationTarget;
  106763. private _postProcessMove;
  106764. private _teleportationFillColor;
  106765. private _teleportationBorderColor;
  106766. private _rotationAngle;
  106767. private _haloCenter;
  106768. private _cameraGazer;
  106769. private _padSensibilityUp;
  106770. private _padSensibilityDown;
  106771. private _leftController;
  106772. private _rightController;
  106773. /**
  106774. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106775. */
  106776. onNewMeshSelected: Observable<AbstractMesh>;
  106777. /**
  106778. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106779. * This observable will provide the mesh and the controller used to select the mesh
  106780. */
  106781. onMeshSelectedWithController: Observable<{
  106782. mesh: AbstractMesh;
  106783. controller: WebVRController;
  106784. }>;
  106785. /**
  106786. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106787. */
  106788. onNewMeshPicked: Observable<PickingInfo>;
  106789. private _circleEase;
  106790. /**
  106791. * Observable raised before camera teleportation
  106792. */
  106793. onBeforeCameraTeleport: Observable<Vector3>;
  106794. /**
  106795. * Observable raised after camera teleportation
  106796. */
  106797. onAfterCameraTeleport: Observable<Vector3>;
  106798. /**
  106799. * Observable raised when current selected mesh gets unselected
  106800. */
  106801. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106802. private _raySelectionPredicate;
  106803. /**
  106804. * To be optionaly changed by user to define custom ray selection
  106805. */
  106806. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106807. /**
  106808. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106809. */
  106810. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106811. /**
  106812. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106813. */
  106814. teleportationEnabled: boolean;
  106815. private _defaultHeight;
  106816. private _teleportationInitialized;
  106817. private _interactionsEnabled;
  106818. private _interactionsRequested;
  106819. private _displayGaze;
  106820. private _displayLaserPointer;
  106821. /**
  106822. * The mesh used to display where the user is going to teleport.
  106823. */
  106824. /**
  106825. * Sets the mesh to be used to display where the user is going to teleport.
  106826. */
  106827. teleportationTarget: Mesh;
  106828. /**
  106829. * 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
  106830. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106831. * See http://doc.babylonjs.com/resources/baking_transformations
  106832. */
  106833. gazeTrackerMesh: Mesh;
  106834. /**
  106835. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106836. */
  106837. updateGazeTrackerScale: boolean;
  106838. /**
  106839. * If the gaze trackers color should be updated when selecting meshes
  106840. */
  106841. updateGazeTrackerColor: boolean;
  106842. /**
  106843. * If the controller laser color should be updated when selecting meshes
  106844. */
  106845. updateControllerLaserColor: boolean;
  106846. /**
  106847. * The gaze tracking mesh corresponding to the left controller
  106848. */
  106849. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106850. /**
  106851. * The gaze tracking mesh corresponding to the right controller
  106852. */
  106853. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106854. /**
  106855. * If the ray of the gaze should be displayed.
  106856. */
  106857. /**
  106858. * Sets if the ray of the gaze should be displayed.
  106859. */
  106860. displayGaze: boolean;
  106861. /**
  106862. * If the ray of the LaserPointer should be displayed.
  106863. */
  106864. /**
  106865. * Sets if the ray of the LaserPointer should be displayed.
  106866. */
  106867. displayLaserPointer: boolean;
  106868. /**
  106869. * The deviceOrientationCamera used as the camera when not in VR.
  106870. */
  106871. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106872. /**
  106873. * Based on the current WebVR support, returns the current VR camera used.
  106874. */
  106875. readonly currentVRCamera: Nullable<Camera>;
  106876. /**
  106877. * The webVRCamera which is used when in VR.
  106878. */
  106879. readonly webVRCamera: WebVRFreeCamera;
  106880. /**
  106881. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106882. */
  106883. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106884. /**
  106885. * The html button that is used to trigger entering into VR.
  106886. */
  106887. readonly vrButton: Nullable<HTMLButtonElement>;
  106888. private readonly _teleportationRequestInitiated;
  106889. /**
  106890. * Defines wether or not Pointer lock should be requested when switching to
  106891. * full screen.
  106892. */
  106893. requestPointerLockOnFullScreen: boolean;
  106894. /**
  106895. * Instantiates a VRExperienceHelper.
  106896. * Helps to quickly add VR support to an existing scene.
  106897. * @param scene The scene the VRExperienceHelper belongs to.
  106898. * @param webVROptions Options to modify the vr experience helper's behavior.
  106899. */
  106900. constructor(scene: Scene,
  106901. /** Options to modify the vr experience helper's behavior. */
  106902. webVROptions?: VRExperienceHelperOptions);
  106903. private _onDefaultMeshLoaded;
  106904. private _onResize;
  106905. private _onFullscreenChange;
  106906. /**
  106907. * Gets a value indicating if we are currently in VR mode.
  106908. */
  106909. readonly isInVRMode: boolean;
  106910. private onVrDisplayPresentChange;
  106911. private onVRDisplayChanged;
  106912. private moveButtonToBottomRight;
  106913. private displayVRButton;
  106914. private updateButtonVisibility;
  106915. private _cachedAngularSensibility;
  106916. /**
  106917. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106918. * Otherwise, will use the fullscreen API.
  106919. */
  106920. enterVR(): void;
  106921. /**
  106922. * Attempt to exit VR, or fullscreen.
  106923. */
  106924. exitVR(): void;
  106925. /**
  106926. * The position of the vr experience helper.
  106927. */
  106928. /**
  106929. * Sets the position of the vr experience helper.
  106930. */
  106931. position: Vector3;
  106932. /**
  106933. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106934. */
  106935. enableInteractions(): void;
  106936. private readonly _noControllerIsActive;
  106937. private beforeRender;
  106938. private _isTeleportationFloor;
  106939. /**
  106940. * Adds a floor mesh to be used for teleportation.
  106941. * @param floorMesh the mesh to be used for teleportation.
  106942. */
  106943. addFloorMesh(floorMesh: Mesh): void;
  106944. /**
  106945. * Removes a floor mesh from being used for teleportation.
  106946. * @param floorMesh the mesh to be removed.
  106947. */
  106948. removeFloorMesh(floorMesh: Mesh): void;
  106949. /**
  106950. * Enables interactions and teleportation using the VR controllers and gaze.
  106951. * @param vrTeleportationOptions options to modify teleportation behavior.
  106952. */
  106953. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106954. private _onNewGamepadConnected;
  106955. private _tryEnableInteractionOnController;
  106956. private _onNewGamepadDisconnected;
  106957. private _enableInteractionOnController;
  106958. private _checkTeleportWithRay;
  106959. private _checkRotate;
  106960. private _checkTeleportBackwards;
  106961. private _enableTeleportationOnController;
  106962. private _createTeleportationCircles;
  106963. private _displayTeleportationTarget;
  106964. private _hideTeleportationTarget;
  106965. private _rotateCamera;
  106966. private _moveTeleportationSelectorTo;
  106967. private _workingVector;
  106968. private _workingQuaternion;
  106969. private _workingMatrix;
  106970. /**
  106971. * Teleports the users feet to the desired location
  106972. * @param location The location where the user's feet should be placed
  106973. */
  106974. teleportCamera(location: Vector3): void;
  106975. private _convertNormalToDirectionOfRay;
  106976. private _castRayAndSelectObject;
  106977. private _notifySelectedMeshUnselected;
  106978. /**
  106979. * Sets the color of the laser ray from the vr controllers.
  106980. * @param color new color for the ray.
  106981. */
  106982. changeLaserColor(color: Color3): void;
  106983. /**
  106984. * Sets the color of the ray from the vr headsets gaze.
  106985. * @param color new color for the ray.
  106986. */
  106987. changeGazeColor(color: Color3): void;
  106988. /**
  106989. * Exits VR and disposes of the vr experience helper
  106990. */
  106991. dispose(): void;
  106992. /**
  106993. * Gets the name of the VRExperienceHelper class
  106994. * @returns "VRExperienceHelper"
  106995. */
  106996. getClassName(): string;
  106997. }
  106998. }
  106999. declare module BABYLON {
  107000. /**
  107001. * Manages an XRSession to work with Babylon's engine
  107002. * @see https://doc.babylonjs.com/how_to/webxr
  107003. */
  107004. export class WebXRSessionManager implements IDisposable {
  107005. private scene;
  107006. /**
  107007. * Fires every time a new xrFrame arrives which can be used to update the camera
  107008. */
  107009. onXRFrameObservable: Observable<any>;
  107010. /**
  107011. * Fires when the xr session is ended either by the device or manually done
  107012. */
  107013. onXRSessionEnded: Observable<any>;
  107014. /**
  107015. * Underlying xr session
  107016. */
  107017. session: XRSession;
  107018. /**
  107019. * Type of reference space used when creating the session
  107020. */
  107021. referenceSpace: XRReferenceSpace;
  107022. /** @hidden */
  107023. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107024. /**
  107025. * Current XR frame
  107026. */
  107027. currentFrame: Nullable<XRFrame>;
  107028. private _xrNavigator;
  107029. private baseLayer;
  107030. /**
  107031. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107032. * @param scene The scene which the session should be created for
  107033. */
  107034. constructor(scene: Scene);
  107035. /**
  107036. * Initializes the manager
  107037. * After initialization enterXR can be called to start an XR session
  107038. * @returns Promise which resolves after it is initialized
  107039. */
  107040. initializeAsync(): Promise<void>;
  107041. /**
  107042. * Initializes an xr session
  107043. * @param xrSessionMode mode to initialize
  107044. * @returns a promise which will resolve once the session has been initialized
  107045. */
  107046. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107047. /**
  107048. * Sets the reference space on the xr session
  107049. * @param referenceSpace space to set
  107050. * @returns a promise that will resolve once the reference space has been set
  107051. */
  107052. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107053. /**
  107054. * Updates the render state of the session
  107055. * @param state state to set
  107056. * @returns a promise that resolves once the render state has been updated
  107057. */
  107058. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107059. /**
  107060. * Starts rendering to the xr layer
  107061. * @returns a promise that will resolve once rendering has started
  107062. */
  107063. startRenderingToXRAsync(): Promise<void>;
  107064. /**
  107065. * Stops the xrSession and restores the renderloop
  107066. * @returns Promise which resolves after it exits XR
  107067. */
  107068. exitXRAsync(): Promise<unknown>;
  107069. /**
  107070. * Checks if a session would be supported for the creation options specified
  107071. * @param sessionMode session mode to check if supported eg. immersive-vr
  107072. * @returns true if supported
  107073. */
  107074. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107075. /**
  107076. * @hidden
  107077. * Converts the render layer of xrSession to a render target
  107078. * @param session session to create render target for
  107079. * @param scene scene the new render target should be created for
  107080. */
  107081. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107082. /**
  107083. * Disposes of the session manager
  107084. */
  107085. dispose(): void;
  107086. }
  107087. }
  107088. declare module BABYLON {
  107089. /**
  107090. * WebXR Camera which holds the views for the xrSession
  107091. * @see https://doc.babylonjs.com/how_to/webxr
  107092. */
  107093. export class WebXRCamera extends FreeCamera {
  107094. private static _TmpMatrix;
  107095. /**
  107096. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107097. * @param name the name of the camera
  107098. * @param scene the scene to add the camera to
  107099. */
  107100. constructor(name: string, scene: Scene);
  107101. private _updateNumberOfRigCameras;
  107102. /** @hidden */
  107103. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107104. /**
  107105. * Updates the cameras position from the current pose information of the XR session
  107106. * @param xrSessionManager the session containing pose information
  107107. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107108. */
  107109. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107110. }
  107111. }
  107112. declare module BABYLON {
  107113. /**
  107114. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107115. */
  107116. export class WebXRManagedOutputCanvas implements IDisposable {
  107117. private helper;
  107118. private _canvas;
  107119. /**
  107120. * xrpresent context of the canvas which can be used to display/mirror xr content
  107121. */
  107122. canvasContext: WebGLRenderingContext;
  107123. /**
  107124. * xr layer for the canvas
  107125. */
  107126. xrLayer: Nullable<XRWebGLLayer>;
  107127. /**
  107128. * Initializes the xr layer for the session
  107129. * @param xrSession xr session
  107130. * @returns a promise that will resolve once the XR Layer has been created
  107131. */
  107132. initializeXRLayerAsync(xrSession: any): any;
  107133. /**
  107134. * Initializes the canvas to be added/removed upon entering/exiting xr
  107135. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107136. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107137. */
  107138. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107139. /**
  107140. * Disposes of the object
  107141. */
  107142. dispose(): void;
  107143. private _setManagedOutputCanvas;
  107144. private _addCanvas;
  107145. private _removeCanvas;
  107146. }
  107147. }
  107148. declare module BABYLON {
  107149. /**
  107150. * States of the webXR experience
  107151. */
  107152. export enum WebXRState {
  107153. /**
  107154. * Transitioning to being in XR mode
  107155. */
  107156. ENTERING_XR = 0,
  107157. /**
  107158. * Transitioning to non XR mode
  107159. */
  107160. EXITING_XR = 1,
  107161. /**
  107162. * In XR mode and presenting
  107163. */
  107164. IN_XR = 2,
  107165. /**
  107166. * Not entered XR mode
  107167. */
  107168. NOT_IN_XR = 3
  107169. }
  107170. /**
  107171. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107172. * @see https://doc.babylonjs.com/how_to/webxr
  107173. */
  107174. export class WebXRExperienceHelper implements IDisposable {
  107175. private scene;
  107176. /**
  107177. * 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
  107178. */
  107179. container: AbstractMesh;
  107180. /**
  107181. * Camera used to render xr content
  107182. */
  107183. camera: WebXRCamera;
  107184. /**
  107185. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107186. */
  107187. state: WebXRState;
  107188. private _setState;
  107189. private static _TmpVector;
  107190. /**
  107191. * Fires when the state of the experience helper has changed
  107192. */
  107193. onStateChangedObservable: Observable<WebXRState>;
  107194. /** Session manager used to keep track of xr session */
  107195. sessionManager: WebXRSessionManager;
  107196. private _nonVRCamera;
  107197. private _originalSceneAutoClear;
  107198. private _supported;
  107199. /**
  107200. * Creates the experience helper
  107201. * @param scene the scene to attach the experience helper to
  107202. * @returns a promise for the experience helper
  107203. */
  107204. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107205. /**
  107206. * Creates a WebXRExperienceHelper
  107207. * @param scene The scene the helper should be created in
  107208. */
  107209. private constructor();
  107210. /**
  107211. * Exits XR mode and returns the scene to its original state
  107212. * @returns promise that resolves after xr mode has exited
  107213. */
  107214. exitXRAsync(): Promise<unknown>;
  107215. /**
  107216. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107217. * @param sessionCreationOptions options for the XR session
  107218. * @param referenceSpaceType frame of reference of the XR session
  107219. * @param outputCanvas the output canvas that will be used to enter XR mode
  107220. * @returns promise that resolves after xr mode has entered
  107221. */
  107222. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107223. /**
  107224. * Updates the global position of the camera by moving the camera's container
  107225. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107226. * @param position The desired global position of the camera
  107227. */
  107228. setPositionOfCameraUsingContainer(position: Vector3): void;
  107229. /**
  107230. * Rotates the xr camera by rotating the camera's container around the camera's position
  107231. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107232. * @param rotation the desired quaternion rotation to apply to the camera
  107233. */
  107234. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107235. /**
  107236. * Disposes of the experience helper
  107237. */
  107238. dispose(): void;
  107239. }
  107240. }
  107241. declare module BABYLON {
  107242. /**
  107243. * Button which can be used to enter a different mode of XR
  107244. */
  107245. export class WebXREnterExitUIButton {
  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. * Creates a WebXREnterExitUIButton
  107254. * @param element button element
  107255. * @param sessionMode XR initialization session mode
  107256. * @param referenceSpaceType the type of reference space to be used
  107257. */
  107258. constructor(
  107259. /** button element */
  107260. element: HTMLElement,
  107261. /** XR initialization options for the button */
  107262. sessionMode: XRSessionMode,
  107263. /** Reference space type */
  107264. referenceSpaceType: XRReferenceSpaceType);
  107265. /**
  107266. * Overwritable function which can be used to update the button's visuals when the state changes
  107267. * @param activeButton the current active button in the UI
  107268. */
  107269. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107270. }
  107271. /**
  107272. * Options to create the webXR UI
  107273. */
  107274. export class WebXREnterExitUIOptions {
  107275. /**
  107276. * Context to enter xr with
  107277. */
  107278. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107279. /**
  107280. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107281. */
  107282. customButtons?: Array<WebXREnterExitUIButton>;
  107283. }
  107284. /**
  107285. * UI to allow the user to enter/exit XR mode
  107286. */
  107287. export class WebXREnterExitUI implements IDisposable {
  107288. private scene;
  107289. private _overlay;
  107290. private _buttons;
  107291. private _activeButton;
  107292. /**
  107293. * Fired every time the active button is changed.
  107294. *
  107295. * When xr is entered via a button that launches xr that button will be the callback parameter
  107296. *
  107297. * When exiting xr the callback parameter will be null)
  107298. */
  107299. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107300. /**
  107301. * Creates UI to allow the user to enter/exit XR mode
  107302. * @param scene the scene to add the ui to
  107303. * @param helper the xr experience helper to enter/exit xr with
  107304. * @param options options to configure the UI
  107305. * @returns the created ui
  107306. */
  107307. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107308. private constructor();
  107309. private _updateButtons;
  107310. /**
  107311. * Disposes of the object
  107312. */
  107313. dispose(): void;
  107314. }
  107315. }
  107316. declare module BABYLON {
  107317. /**
  107318. * Represents an XR input
  107319. */
  107320. export class WebXRController {
  107321. private scene;
  107322. /** The underlying input source for the controller */
  107323. inputSource: XRInputSource;
  107324. private parentContainer;
  107325. /**
  107326. * 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
  107327. */
  107328. grip?: AbstractMesh;
  107329. /**
  107330. * Pointer which can be used to select objects or attach a visible laser to
  107331. */
  107332. pointer: AbstractMesh;
  107333. /**
  107334. * Event that fires when the controller is removed/disposed
  107335. */
  107336. onDisposeObservable: Observable<{}>;
  107337. private _tmpMatrix;
  107338. private _tmpQuaternion;
  107339. private _tmpVector;
  107340. /**
  107341. * Creates the controller
  107342. * @see https://doc.babylonjs.com/how_to/webxr
  107343. * @param scene the scene which the controller should be associated to
  107344. * @param inputSource the underlying input source for the controller
  107345. * @param parentContainer parent that the controller meshes should be children of
  107346. */
  107347. constructor(scene: Scene,
  107348. /** The underlying input source for the controller */
  107349. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107350. /**
  107351. * Updates the controller pose based on the given XRFrame
  107352. * @param xrFrame xr frame to update the pose with
  107353. * @param referenceSpace reference space to use
  107354. */
  107355. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107356. /**
  107357. * Gets a world space ray coming from the controller
  107358. * @param result the resulting ray
  107359. */
  107360. getWorldPointerRayToRef(result: Ray): void;
  107361. /**
  107362. * Disposes of the object
  107363. */
  107364. dispose(): void;
  107365. }
  107366. }
  107367. declare module BABYLON {
  107368. /**
  107369. * XR input used to track XR inputs such as controllers/rays
  107370. */
  107371. export class WebXRInput implements IDisposable {
  107372. /**
  107373. * Base experience the input listens to
  107374. */
  107375. baseExperience: WebXRExperienceHelper;
  107376. /**
  107377. * XR controllers being tracked
  107378. */
  107379. controllers: Array<WebXRController>;
  107380. private _frameObserver;
  107381. private _stateObserver;
  107382. /**
  107383. * Event when a controller has been connected/added
  107384. */
  107385. onControllerAddedObservable: Observable<WebXRController>;
  107386. /**
  107387. * Event when a controller has been removed/disconnected
  107388. */
  107389. onControllerRemovedObservable: Observable<WebXRController>;
  107390. /**
  107391. * Initializes the WebXRInput
  107392. * @param baseExperience experience helper which the input should be created for
  107393. */
  107394. constructor(
  107395. /**
  107396. * Base experience the input listens to
  107397. */
  107398. baseExperience: WebXRExperienceHelper);
  107399. private _onInputSourcesChange;
  107400. private _addAndRemoveControllers;
  107401. /**
  107402. * Disposes of the object
  107403. */
  107404. dispose(): void;
  107405. }
  107406. }
  107407. declare module BABYLON {
  107408. /**
  107409. * Enables teleportation
  107410. */
  107411. export class WebXRControllerTeleportation {
  107412. private _teleportationFillColor;
  107413. private _teleportationBorderColor;
  107414. private _tmpRay;
  107415. private _tmpVector;
  107416. /**
  107417. * Creates a WebXRControllerTeleportation
  107418. * @param input input manager to add teleportation to
  107419. * @param floorMeshes floormeshes which can be teleported to
  107420. */
  107421. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107422. }
  107423. }
  107424. declare module BABYLON {
  107425. /**
  107426. * Handles pointer input automatically for the pointer of XR controllers
  107427. */
  107428. export class WebXRControllerPointerSelection {
  107429. private static _idCounter;
  107430. private _tmpRay;
  107431. /**
  107432. * Creates a WebXRControllerPointerSelection
  107433. * @param input input manager to setup pointer selection
  107434. */
  107435. constructor(input: WebXRInput);
  107436. private _convertNormalToDirectionOfRay;
  107437. private _updatePointerDistance;
  107438. }
  107439. }
  107440. declare module BABYLON {
  107441. /**
  107442. * Class used to represent data loading progression
  107443. */
  107444. export class SceneLoaderProgressEvent {
  107445. /** defines if data length to load can be evaluated */
  107446. readonly lengthComputable: boolean;
  107447. /** defines the loaded data length */
  107448. readonly loaded: number;
  107449. /** defines the data length to load */
  107450. readonly total: number;
  107451. /**
  107452. * Create a new progress event
  107453. * @param lengthComputable defines if data length to load can be evaluated
  107454. * @param loaded defines the loaded data length
  107455. * @param total defines the data length to load
  107456. */
  107457. constructor(
  107458. /** defines if data length to load can be evaluated */
  107459. lengthComputable: boolean,
  107460. /** defines the loaded data length */
  107461. loaded: number,
  107462. /** defines the data length to load */
  107463. total: number);
  107464. /**
  107465. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107466. * @param event defines the source event
  107467. * @returns a new SceneLoaderProgressEvent
  107468. */
  107469. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107470. }
  107471. /**
  107472. * Interface used by SceneLoader plugins to define supported file extensions
  107473. */
  107474. export interface ISceneLoaderPluginExtensions {
  107475. /**
  107476. * Defines the list of supported extensions
  107477. */
  107478. [extension: string]: {
  107479. isBinary: boolean;
  107480. };
  107481. }
  107482. /**
  107483. * Interface used by SceneLoader plugin factory
  107484. */
  107485. export interface ISceneLoaderPluginFactory {
  107486. /**
  107487. * Defines the name of the factory
  107488. */
  107489. name: string;
  107490. /**
  107491. * Function called to create a new plugin
  107492. * @return the new plugin
  107493. */
  107494. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107495. /**
  107496. * Boolean indicating if the plugin can direct load specific data
  107497. */
  107498. canDirectLoad?: (data: string) => boolean;
  107499. }
  107500. /**
  107501. * Interface used to define a SceneLoader plugin
  107502. */
  107503. export interface ISceneLoaderPlugin {
  107504. /**
  107505. * The friendly name of this plugin.
  107506. */
  107507. name: string;
  107508. /**
  107509. * The file extensions supported by this plugin.
  107510. */
  107511. extensions: string | ISceneLoaderPluginExtensions;
  107512. /**
  107513. * Import meshes into a scene.
  107514. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107515. * @param scene The scene to import into
  107516. * @param data The data to import
  107517. * @param rootUrl The root url for scene and resources
  107518. * @param meshes The meshes array to import into
  107519. * @param particleSystems The particle systems array to import into
  107520. * @param skeletons The skeletons array to import into
  107521. * @param onError The callback when import fails
  107522. * @returns True if successful or false otherwise
  107523. */
  107524. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107525. /**
  107526. * Load into a scene.
  107527. * @param scene The scene to load into
  107528. * @param data The data to import
  107529. * @param rootUrl The root url for scene and resources
  107530. * @param onError The callback when import fails
  107531. * @returns true if successful or false otherwise
  107532. */
  107533. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107534. /**
  107535. * The callback that returns true if the data can be directly loaded.
  107536. */
  107537. canDirectLoad?: (data: string) => boolean;
  107538. /**
  107539. * The callback that allows custom handling of the root url based on the response url.
  107540. */
  107541. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107542. /**
  107543. * Load into an asset container.
  107544. * @param scene The scene to load into
  107545. * @param data The data to import
  107546. * @param rootUrl The root url for scene and resources
  107547. * @param onError The callback when import fails
  107548. * @returns The loaded asset container
  107549. */
  107550. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107551. }
  107552. /**
  107553. * Interface used to define an async SceneLoader plugin
  107554. */
  107555. export interface ISceneLoaderPluginAsync {
  107556. /**
  107557. * The friendly name of this plugin.
  107558. */
  107559. name: string;
  107560. /**
  107561. * The file extensions supported by this plugin.
  107562. */
  107563. extensions: string | ISceneLoaderPluginExtensions;
  107564. /**
  107565. * Import meshes into a scene.
  107566. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107567. * @param scene The scene to import into
  107568. * @param data The data to import
  107569. * @param rootUrl The root url for scene and resources
  107570. * @param onProgress The callback when the load progresses
  107571. * @param fileName Defines the name of the file to load
  107572. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107573. */
  107574. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107575. meshes: AbstractMesh[];
  107576. particleSystems: IParticleSystem[];
  107577. skeletons: Skeleton[];
  107578. animationGroups: AnimationGroup[];
  107579. }>;
  107580. /**
  107581. * Load into a scene.
  107582. * @param scene The scene to load into
  107583. * @param data The data to import
  107584. * @param rootUrl The root url for scene and resources
  107585. * @param onProgress The callback when the load progresses
  107586. * @param fileName Defines the name of the file to load
  107587. * @returns Nothing
  107588. */
  107589. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107590. /**
  107591. * The callback that returns true if the data can be directly loaded.
  107592. */
  107593. canDirectLoad?: (data: string) => boolean;
  107594. /**
  107595. * The callback that allows custom handling of the root url based on the response url.
  107596. */
  107597. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107598. /**
  107599. * Load into an asset container.
  107600. * @param scene The scene to load into
  107601. * @param data The data to import
  107602. * @param rootUrl The root url for scene and resources
  107603. * @param onProgress The callback when the load progresses
  107604. * @param fileName Defines the name of the file to load
  107605. * @returns The loaded asset container
  107606. */
  107607. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107608. }
  107609. /**
  107610. * Class used to load scene from various file formats using registered plugins
  107611. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107612. */
  107613. export class SceneLoader {
  107614. /**
  107615. * No logging while loading
  107616. */
  107617. static readonly NO_LOGGING: number;
  107618. /**
  107619. * Minimal logging while loading
  107620. */
  107621. static readonly MINIMAL_LOGGING: number;
  107622. /**
  107623. * Summary logging while loading
  107624. */
  107625. static readonly SUMMARY_LOGGING: number;
  107626. /**
  107627. * Detailled logging while loading
  107628. */
  107629. static readonly DETAILED_LOGGING: number;
  107630. /**
  107631. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107632. */
  107633. static ForceFullSceneLoadingForIncremental: boolean;
  107634. /**
  107635. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107636. */
  107637. static ShowLoadingScreen: boolean;
  107638. /**
  107639. * Defines the current logging level (while loading the scene)
  107640. * @ignorenaming
  107641. */
  107642. static loggingLevel: number;
  107643. /**
  107644. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107645. */
  107646. static CleanBoneMatrixWeights: boolean;
  107647. /**
  107648. * Event raised when a plugin is used to load a scene
  107649. */
  107650. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107651. private static _registeredPlugins;
  107652. private static _getDefaultPlugin;
  107653. private static _getPluginForExtension;
  107654. private static _getPluginForDirectLoad;
  107655. private static _getPluginForFilename;
  107656. private static _getDirectLoad;
  107657. private static _loadData;
  107658. private static _getFileInfo;
  107659. /**
  107660. * Gets a plugin that can load the given extension
  107661. * @param extension defines the extension to load
  107662. * @returns a plugin or null if none works
  107663. */
  107664. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107665. /**
  107666. * Gets a boolean indicating that the given extension can be loaded
  107667. * @param extension defines the extension to load
  107668. * @returns true if the extension is supported
  107669. */
  107670. static IsPluginForExtensionAvailable(extension: string): boolean;
  107671. /**
  107672. * Adds a new plugin to the list of registered plugins
  107673. * @param plugin defines the plugin to add
  107674. */
  107675. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  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 onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107683. * @param onProgress a callback with a progress event for each file being loaded
  107684. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107685. * @param pluginExtension the extension used to determine the plugin
  107686. * @returns The loaded plugin
  107687. */
  107688. 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>;
  107689. /**
  107690. * Import meshes into a scene
  107691. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107692. * @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)
  107693. * @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)
  107694. * @param scene the instance of BABYLON.Scene to append to
  107695. * @param onProgress a callback with a progress event for each file being loaded
  107696. * @param pluginExtension the extension used to determine the plugin
  107697. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107698. */
  107699. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107700. meshes: AbstractMesh[];
  107701. particleSystems: IParticleSystem[];
  107702. skeletons: Skeleton[];
  107703. animationGroups: AnimationGroup[];
  107704. }>;
  107705. /**
  107706. * Load a scene
  107707. * @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)
  107708. * @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)
  107709. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107710. * @param onSuccess a callback with the scene when import succeeds
  107711. * @param onProgress a callback with a progress event for each file being loaded
  107712. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107713. * @param pluginExtension the extension used to determine the plugin
  107714. * @returns The loaded plugin
  107715. */
  107716. 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>;
  107717. /**
  107718. * Load a scene
  107719. * @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)
  107720. * @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)
  107721. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107722. * @param onProgress a callback with a progress event for each file being loaded
  107723. * @param pluginExtension the extension used to determine the plugin
  107724. * @returns The loaded scene
  107725. */
  107726. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107727. /**
  107728. * Append a scene
  107729. * @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)
  107730. * @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)
  107731. * @param scene is the instance of BABYLON.Scene to append to
  107732. * @param onSuccess a callback with the scene when import succeeds
  107733. * @param onProgress a callback with a progress event for each file being loaded
  107734. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107735. * @param pluginExtension the extension used to determine the plugin
  107736. * @returns The loaded plugin
  107737. */
  107738. 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>;
  107739. /**
  107740. * Append a scene
  107741. * @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)
  107742. * @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)
  107743. * @param scene is the instance of BABYLON.Scene to append to
  107744. * @param onProgress a callback with a progress event for each file being loaded
  107745. * @param pluginExtension the extension used to determine the plugin
  107746. * @returns The given scene
  107747. */
  107748. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107749. /**
  107750. * Load a scene into an asset container
  107751. * @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)
  107752. * @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)
  107753. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107754. * @param onSuccess a callback with the scene when import succeeds
  107755. * @param onProgress a callback with a progress event for each file being loaded
  107756. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107757. * @param pluginExtension the extension used to determine the plugin
  107758. * @returns The loaded plugin
  107759. */
  107760. 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>;
  107761. /**
  107762. * Load a scene into an asset container
  107763. * @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)
  107764. * @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)
  107765. * @param scene is the instance of Scene to append to
  107766. * @param onProgress a callback with a progress event for each file being loaded
  107767. * @param pluginExtension the extension used to determine the plugin
  107768. * @returns The loaded asset container
  107769. */
  107770. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107771. }
  107772. }
  107773. declare module BABYLON {
  107774. /**
  107775. * Generic Controller
  107776. */
  107777. export class GenericController extends WebVRController {
  107778. /**
  107779. * Base Url for the controller model.
  107780. */
  107781. static readonly MODEL_BASE_URL: string;
  107782. /**
  107783. * File name for the controller model.
  107784. */
  107785. static readonly MODEL_FILENAME: string;
  107786. /**
  107787. * Creates a new GenericController from a gamepad
  107788. * @param vrGamepad the gamepad that the controller should be created from
  107789. */
  107790. constructor(vrGamepad: any);
  107791. /**
  107792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107793. * @param scene scene in which to add meshes
  107794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107795. */
  107796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107797. /**
  107798. * Called once for each button that changed state since the last frame
  107799. * @param buttonIdx Which button index changed
  107800. * @param state New state of the button
  107801. * @param changes Which properties on the state changed since last frame
  107802. */
  107803. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107804. }
  107805. }
  107806. declare module BABYLON {
  107807. /**
  107808. * Defines the WindowsMotionController object that the state of the windows motion controller
  107809. */
  107810. export class WindowsMotionController extends WebVRController {
  107811. /**
  107812. * The base url used to load the left and right controller models
  107813. */
  107814. static MODEL_BASE_URL: string;
  107815. /**
  107816. * The name of the left controller model file
  107817. */
  107818. static MODEL_LEFT_FILENAME: string;
  107819. /**
  107820. * The name of the right controller model file
  107821. */
  107822. static MODEL_RIGHT_FILENAME: string;
  107823. /**
  107824. * The controller name prefix for this controller type
  107825. */
  107826. static readonly GAMEPAD_ID_PREFIX: string;
  107827. /**
  107828. * The controller id pattern for this controller type
  107829. */
  107830. private static readonly GAMEPAD_ID_PATTERN;
  107831. private _loadedMeshInfo;
  107832. private readonly _mapping;
  107833. /**
  107834. * Fired when the trackpad on this controller is clicked
  107835. */
  107836. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107837. /**
  107838. * Fired when the trackpad on this controller is modified
  107839. */
  107840. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107841. /**
  107842. * The current x and y values of this controller's trackpad
  107843. */
  107844. trackpad: StickValues;
  107845. /**
  107846. * Creates a new WindowsMotionController from a gamepad
  107847. * @param vrGamepad the gamepad that the controller should be created from
  107848. */
  107849. constructor(vrGamepad: any);
  107850. /**
  107851. * Fired when the trigger on this controller is modified
  107852. */
  107853. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107854. /**
  107855. * Fired when the menu button on this controller is modified
  107856. */
  107857. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107858. /**
  107859. * Fired when the grip button on this controller is modified
  107860. */
  107861. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107862. /**
  107863. * Fired when the thumbstick button on this controller is modified
  107864. */
  107865. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107866. /**
  107867. * Fired when the touchpad button on this controller is modified
  107868. */
  107869. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107870. /**
  107871. * Fired when the touchpad values on this controller are modified
  107872. */
  107873. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107874. private _updateTrackpad;
  107875. /**
  107876. * Called once per frame by the engine.
  107877. */
  107878. update(): void;
  107879. /**
  107880. * Called once for each button that changed state since the last frame
  107881. * @param buttonIdx Which button index changed
  107882. * @param state New state of the button
  107883. * @param changes Which properties on the state changed since last frame
  107884. */
  107885. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107886. /**
  107887. * Moves the buttons on the controller mesh based on their current state
  107888. * @param buttonName the name of the button to move
  107889. * @param buttonValue the value of the button which determines the buttons new position
  107890. */
  107891. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107892. /**
  107893. * Moves the axis on the controller mesh based on its current state
  107894. * @param axis the index of the axis
  107895. * @param axisValue the value of the axis which determines the meshes new position
  107896. * @hidden
  107897. */
  107898. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107899. /**
  107900. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107901. * @param scene scene in which to add meshes
  107902. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107903. */
  107904. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107905. /**
  107906. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107907. * can be transformed by button presses and axes values, based on this._mapping.
  107908. *
  107909. * @param scene scene in which the meshes exist
  107910. * @param meshes list of meshes that make up the controller model to process
  107911. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107912. */
  107913. private processModel;
  107914. private createMeshInfo;
  107915. /**
  107916. * Gets the ray of the controller in the direction the controller is pointing
  107917. * @param length the length the resulting ray should be
  107918. * @returns a ray in the direction the controller is pointing
  107919. */
  107920. getForwardRay(length?: number): Ray;
  107921. /**
  107922. * Disposes of the controller
  107923. */
  107924. dispose(): void;
  107925. }
  107926. }
  107927. declare module BABYLON {
  107928. /**
  107929. * Oculus Touch Controller
  107930. */
  107931. export class OculusTouchController extends WebVRController {
  107932. /**
  107933. * Base Url for the controller model.
  107934. */
  107935. static MODEL_BASE_URL: string;
  107936. /**
  107937. * File name for the left controller model.
  107938. */
  107939. static MODEL_LEFT_FILENAME: string;
  107940. /**
  107941. * File name for the right controller model.
  107942. */
  107943. static MODEL_RIGHT_FILENAME: string;
  107944. /**
  107945. * Base Url for the Quest controller model.
  107946. */
  107947. static QUEST_MODEL_BASE_URL: string;
  107948. /**
  107949. * @hidden
  107950. * If the controllers are running on a device that needs the updated Quest controller models
  107951. */
  107952. static _IsQuest: boolean;
  107953. /**
  107954. * Fired when the secondary trigger on this controller is modified
  107955. */
  107956. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107957. /**
  107958. * Fired when the thumb rest on this controller is modified
  107959. */
  107960. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107961. /**
  107962. * Creates a new OculusTouchController from a gamepad
  107963. * @param vrGamepad the gamepad that the controller should be created from
  107964. */
  107965. constructor(vrGamepad: any);
  107966. /**
  107967. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107968. * @param scene scene in which to add meshes
  107969. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107970. */
  107971. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107972. /**
  107973. * Fired when the A button on this controller is modified
  107974. */
  107975. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107976. /**
  107977. * Fired when the B button on this controller is modified
  107978. */
  107979. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107980. /**
  107981. * Fired when the X button on this controller is modified
  107982. */
  107983. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107984. /**
  107985. * Fired when the Y button on this controller is modified
  107986. */
  107987. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107988. /**
  107989. * Called once for each button that changed state since the last frame
  107990. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107991. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107992. * 2) secondary trigger (same)
  107993. * 3) A (right) X (left), touch, pressed = value
  107994. * 4) B / Y
  107995. * 5) thumb rest
  107996. * @param buttonIdx Which button index changed
  107997. * @param state New state of the button
  107998. * @param changes Which properties on the state changed since last frame
  107999. */
  108000. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108001. }
  108002. }
  108003. declare module BABYLON {
  108004. /**
  108005. * Vive Controller
  108006. */
  108007. export class ViveController extends WebVRController {
  108008. /**
  108009. * Base Url for the controller model.
  108010. */
  108011. static MODEL_BASE_URL: string;
  108012. /**
  108013. * File name for the controller model.
  108014. */
  108015. static MODEL_FILENAME: string;
  108016. /**
  108017. * Creates a new ViveController from a gamepad
  108018. * @param vrGamepad the gamepad that the controller should be created from
  108019. */
  108020. constructor(vrGamepad: any);
  108021. /**
  108022. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108023. * @param scene scene in which to add meshes
  108024. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108025. */
  108026. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108027. /**
  108028. * Fired when the left button on this controller is modified
  108029. */
  108030. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108031. /**
  108032. * Fired when the right button on this controller is modified
  108033. */
  108034. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108035. /**
  108036. * Fired when the menu button on this controller is modified
  108037. */
  108038. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108039. /**
  108040. * Called once for each button that changed state since the last frame
  108041. * Vive mapping:
  108042. * 0: touchpad
  108043. * 1: trigger
  108044. * 2: left AND right buttons
  108045. * 3: menu button
  108046. * @param buttonIdx Which button index changed
  108047. * @param state New state of the button
  108048. * @param changes Which properties on the state changed since last frame
  108049. */
  108050. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108051. }
  108052. }
  108053. declare module BABYLON {
  108054. /**
  108055. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108056. */
  108057. export class WebXRControllerModelLoader {
  108058. /**
  108059. * Creates the WebXRControllerModelLoader
  108060. * @param input xr input that creates the controllers
  108061. */
  108062. constructor(input: WebXRInput);
  108063. }
  108064. }
  108065. declare module BABYLON {
  108066. /**
  108067. * Contains an array of blocks representing the octree
  108068. */
  108069. export interface IOctreeContainer<T> {
  108070. /**
  108071. * Blocks within the octree
  108072. */
  108073. blocks: Array<OctreeBlock<T>>;
  108074. }
  108075. /**
  108076. * Class used to store a cell in an octree
  108077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108078. */
  108079. export class OctreeBlock<T> {
  108080. /**
  108081. * Gets the content of the current block
  108082. */
  108083. entries: T[];
  108084. /**
  108085. * Gets the list of block children
  108086. */
  108087. blocks: Array<OctreeBlock<T>>;
  108088. private _depth;
  108089. private _maxDepth;
  108090. private _capacity;
  108091. private _minPoint;
  108092. private _maxPoint;
  108093. private _boundingVectors;
  108094. private _creationFunc;
  108095. /**
  108096. * Creates a new block
  108097. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108098. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108099. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108100. * @param depth defines the current depth of this block in the octree
  108101. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108102. * @param creationFunc defines a callback to call when an element is added to the block
  108103. */
  108104. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108105. /**
  108106. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108107. */
  108108. readonly capacity: number;
  108109. /**
  108110. * Gets the minimum vector (in world space) of the block's bounding box
  108111. */
  108112. readonly minPoint: Vector3;
  108113. /**
  108114. * Gets the maximum vector (in world space) of the block's bounding box
  108115. */
  108116. readonly maxPoint: Vector3;
  108117. /**
  108118. * Add a new element to this block
  108119. * @param entry defines the element to add
  108120. */
  108121. addEntry(entry: T): void;
  108122. /**
  108123. * Remove an element from this block
  108124. * @param entry defines the element to remove
  108125. */
  108126. removeEntry(entry: T): void;
  108127. /**
  108128. * Add an array of elements to this block
  108129. * @param entries defines the array of elements to add
  108130. */
  108131. addEntries(entries: T[]): void;
  108132. /**
  108133. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108134. * @param frustumPlanes defines the frustum planes to test
  108135. * @param selection defines the array to store current content if selection is positive
  108136. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108137. */
  108138. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108139. /**
  108140. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108141. * @param sphereCenter defines the bounding sphere center
  108142. * @param sphereRadius defines the bounding sphere radius
  108143. * @param selection defines the array to store current content if selection is positive
  108144. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108145. */
  108146. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108147. /**
  108148. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108149. * @param ray defines the ray to test with
  108150. * @param selection defines the array to store current content if selection is positive
  108151. */
  108152. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108153. /**
  108154. * Subdivide the content into child blocks (this block will then be empty)
  108155. */
  108156. createInnerBlocks(): void;
  108157. /**
  108158. * @hidden
  108159. */
  108160. 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;
  108161. }
  108162. }
  108163. declare module BABYLON {
  108164. /**
  108165. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108166. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108167. */
  108168. export class Octree<T> {
  108169. /** 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.) */
  108170. maxDepth: number;
  108171. /**
  108172. * Blocks within the octree containing objects
  108173. */
  108174. blocks: Array<OctreeBlock<T>>;
  108175. /**
  108176. * Content stored in the octree
  108177. */
  108178. dynamicContent: T[];
  108179. private _maxBlockCapacity;
  108180. private _selectionContent;
  108181. private _creationFunc;
  108182. /**
  108183. * Creates a octree
  108184. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108185. * @param creationFunc function to be used to instatiate the octree
  108186. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108187. * @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.)
  108188. */
  108189. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108190. /** 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.) */
  108191. maxDepth?: number);
  108192. /**
  108193. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108194. * @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);
  108195. * @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);
  108196. * @param entries meshes to be added to the octree blocks
  108197. */
  108198. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108199. /**
  108200. * Adds a mesh to the octree
  108201. * @param entry Mesh to add to the octree
  108202. */
  108203. addMesh(entry: T): void;
  108204. /**
  108205. * Remove an element from the octree
  108206. * @param entry defines the element to remove
  108207. */
  108208. removeMesh(entry: T): void;
  108209. /**
  108210. * Selects an array of meshes within the frustum
  108211. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108212. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108213. * @returns array of meshes within the frustum
  108214. */
  108215. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108216. /**
  108217. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108218. * @param sphereCenter defines the bounding sphere center
  108219. * @param sphereRadius defines the bounding sphere radius
  108220. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108221. * @returns an array of objects that intersect the sphere
  108222. */
  108223. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108224. /**
  108225. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108226. * @param ray defines the ray to test with
  108227. * @returns array of intersected objects
  108228. */
  108229. intersectsRay(ray: Ray): SmartArray<T>;
  108230. /**
  108231. * Adds a mesh into the octree block if it intersects the block
  108232. */
  108233. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108234. /**
  108235. * Adds a submesh into the octree block if it intersects the block
  108236. */
  108237. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108238. }
  108239. }
  108240. declare module BABYLON {
  108241. interface Scene {
  108242. /**
  108243. * @hidden
  108244. * Backing Filed
  108245. */
  108246. _selectionOctree: Octree<AbstractMesh>;
  108247. /**
  108248. * Gets the octree used to boost mesh selection (picking)
  108249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108250. */
  108251. selectionOctree: Octree<AbstractMesh>;
  108252. /**
  108253. * Creates or updates the octree used to boost selection (picking)
  108254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108255. * @param maxCapacity defines the maximum capacity per leaf
  108256. * @param maxDepth defines the maximum depth of the octree
  108257. * @returns an octree of AbstractMesh
  108258. */
  108259. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108260. }
  108261. interface AbstractMesh {
  108262. /**
  108263. * @hidden
  108264. * Backing Field
  108265. */
  108266. _submeshesOctree: Octree<SubMesh>;
  108267. /**
  108268. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108269. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108270. * @param maxCapacity defines the maximum size of each block (64 by default)
  108271. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108272. * @returns the new octree
  108273. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108275. */
  108276. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108277. }
  108278. /**
  108279. * Defines the octree scene component responsible to manage any octrees
  108280. * in a given scene.
  108281. */
  108282. export class OctreeSceneComponent {
  108283. /**
  108284. * The component name help to identify the component in the list of scene components.
  108285. */
  108286. readonly name: string;
  108287. /**
  108288. * The scene the component belongs to.
  108289. */
  108290. scene: Scene;
  108291. /**
  108292. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108293. */
  108294. readonly checksIsEnabled: boolean;
  108295. /**
  108296. * Creates a new instance of the component for the given scene
  108297. * @param scene Defines the scene to register the component in
  108298. */
  108299. constructor(scene: Scene);
  108300. /**
  108301. * Registers the component in a given scene
  108302. */
  108303. register(): void;
  108304. /**
  108305. * Return the list of active meshes
  108306. * @returns the list of active meshes
  108307. */
  108308. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108309. /**
  108310. * Return the list of active sub meshes
  108311. * @param mesh The mesh to get the candidates sub meshes from
  108312. * @returns the list of active sub meshes
  108313. */
  108314. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108315. private _tempRay;
  108316. /**
  108317. * Return the list of sub meshes intersecting with a given local ray
  108318. * @param mesh defines the mesh to find the submesh for
  108319. * @param localRay defines the ray in local space
  108320. * @returns the list of intersecting sub meshes
  108321. */
  108322. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108323. /**
  108324. * Return the list of sub meshes colliding with a collider
  108325. * @param mesh defines the mesh to find the submesh for
  108326. * @param collider defines the collider to evaluate the collision against
  108327. * @returns the list of colliding sub meshes
  108328. */
  108329. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108330. /**
  108331. * Rebuilds the elements related to this component in case of
  108332. * context lost for instance.
  108333. */
  108334. rebuild(): void;
  108335. /**
  108336. * Disposes the component and the associated ressources.
  108337. */
  108338. dispose(): void;
  108339. }
  108340. }
  108341. declare module BABYLON {
  108342. /**
  108343. * Renders a layer on top of an existing scene
  108344. */
  108345. export class UtilityLayerRenderer implements IDisposable {
  108346. /** the original scene that will be rendered on top of */
  108347. originalScene: Scene;
  108348. private _pointerCaptures;
  108349. private _lastPointerEvents;
  108350. private static _DefaultUtilityLayer;
  108351. private static _DefaultKeepDepthUtilityLayer;
  108352. private _sharedGizmoLight;
  108353. private _renderCamera;
  108354. /**
  108355. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108356. * @returns the camera that is used when rendering the utility layer
  108357. */
  108358. getRenderCamera(): Nullable<Camera>;
  108359. /**
  108360. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108361. * @param cam the camera that should be used when rendering the utility layer
  108362. */
  108363. setRenderCamera(cam: Nullable<Camera>): void;
  108364. /**
  108365. * @hidden
  108366. * Light which used by gizmos to get light shading
  108367. */
  108368. _getSharedGizmoLight(): HemisphericLight;
  108369. /**
  108370. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108371. */
  108372. pickUtilitySceneFirst: boolean;
  108373. /**
  108374. * 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)
  108375. */
  108376. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108377. /**
  108378. * 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)
  108379. */
  108380. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108381. /**
  108382. * The scene that is rendered on top of the original scene
  108383. */
  108384. utilityLayerScene: Scene;
  108385. /**
  108386. * If the utility layer should automatically be rendered on top of existing scene
  108387. */
  108388. shouldRender: boolean;
  108389. /**
  108390. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108391. */
  108392. onlyCheckPointerDownEvents: boolean;
  108393. /**
  108394. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108395. */
  108396. processAllEvents: boolean;
  108397. /**
  108398. * Observable raised when the pointer move from the utility layer scene to the main scene
  108399. */
  108400. onPointerOutObservable: Observable<number>;
  108401. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108402. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108403. private _afterRenderObserver;
  108404. private _sceneDisposeObserver;
  108405. private _originalPointerObserver;
  108406. /**
  108407. * Instantiates a UtilityLayerRenderer
  108408. * @param originalScene the original scene that will be rendered on top of
  108409. * @param handleEvents boolean indicating if the utility layer should handle events
  108410. */
  108411. constructor(
  108412. /** the original scene that will be rendered on top of */
  108413. originalScene: Scene, handleEvents?: boolean);
  108414. private _notifyObservers;
  108415. /**
  108416. * Renders the utility layers scene on top of the original scene
  108417. */
  108418. render(): void;
  108419. /**
  108420. * Disposes of the renderer
  108421. */
  108422. dispose(): void;
  108423. private _updateCamera;
  108424. }
  108425. }
  108426. declare module BABYLON {
  108427. /**
  108428. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108429. */
  108430. export class Gizmo implements IDisposable {
  108431. /** The utility layer the gizmo will be added to */
  108432. gizmoLayer: UtilityLayerRenderer;
  108433. /**
  108434. * The root mesh of the gizmo
  108435. */
  108436. _rootMesh: Mesh;
  108437. private _attachedMesh;
  108438. /**
  108439. * Ratio for the scale of the gizmo (Default: 1)
  108440. */
  108441. scaleRatio: number;
  108442. /**
  108443. * If a custom mesh has been set (Default: false)
  108444. */
  108445. protected _customMeshSet: boolean;
  108446. /**
  108447. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108448. * * When set, interactions will be enabled
  108449. */
  108450. attachedMesh: Nullable<AbstractMesh>;
  108451. /**
  108452. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108453. * @param mesh The mesh to replace the default mesh of the gizmo
  108454. */
  108455. setCustomMesh(mesh: Mesh): void;
  108456. /**
  108457. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108458. */
  108459. updateGizmoRotationToMatchAttachedMesh: boolean;
  108460. /**
  108461. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108462. */
  108463. updateGizmoPositionToMatchAttachedMesh: boolean;
  108464. /**
  108465. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108466. */
  108467. updateScale: boolean;
  108468. protected _interactionsEnabled: boolean;
  108469. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108470. private _beforeRenderObserver;
  108471. private _tempVector;
  108472. /**
  108473. * Creates a gizmo
  108474. * @param gizmoLayer The utility layer the gizmo will be added to
  108475. */
  108476. constructor(
  108477. /** The utility layer the gizmo will be added to */
  108478. gizmoLayer?: UtilityLayerRenderer);
  108479. /**
  108480. * Updates the gizmo to match the attached mesh's position/rotation
  108481. */
  108482. protected _update(): void;
  108483. /**
  108484. * Disposes of the gizmo
  108485. */
  108486. dispose(): void;
  108487. }
  108488. }
  108489. declare module BABYLON {
  108490. /**
  108491. * Single plane drag gizmo
  108492. */
  108493. export class PlaneDragGizmo extends Gizmo {
  108494. /**
  108495. * Drag behavior responsible for the gizmos dragging interactions
  108496. */
  108497. dragBehavior: PointerDragBehavior;
  108498. private _pointerObserver;
  108499. /**
  108500. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108501. */
  108502. snapDistance: number;
  108503. /**
  108504. * Event that fires each time the gizmo snaps to a new location.
  108505. * * snapDistance is the the change in distance
  108506. */
  108507. onSnapObservable: Observable<{
  108508. snapDistance: number;
  108509. }>;
  108510. private _plane;
  108511. private _coloredMaterial;
  108512. private _hoverMaterial;
  108513. private _isEnabled;
  108514. private _parent;
  108515. /** @hidden */
  108516. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108517. /** @hidden */
  108518. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108519. /**
  108520. * Creates a PlaneDragGizmo
  108521. * @param gizmoLayer The utility layer the gizmo will be added to
  108522. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108523. * @param color The color of the gizmo
  108524. */
  108525. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108526. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108527. /**
  108528. * If the gizmo is enabled
  108529. */
  108530. isEnabled: boolean;
  108531. /**
  108532. * Disposes of the gizmo
  108533. */
  108534. dispose(): void;
  108535. }
  108536. }
  108537. declare module BABYLON {
  108538. /**
  108539. * Gizmo that enables dragging a mesh along 3 axis
  108540. */
  108541. export class PositionGizmo extends Gizmo {
  108542. /**
  108543. * Internal gizmo used for interactions on the x axis
  108544. */
  108545. xGizmo: AxisDragGizmo;
  108546. /**
  108547. * Internal gizmo used for interactions on the y axis
  108548. */
  108549. yGizmo: AxisDragGizmo;
  108550. /**
  108551. * Internal gizmo used for interactions on the z axis
  108552. */
  108553. zGizmo: AxisDragGizmo;
  108554. /**
  108555. * Internal gizmo used for interactions on the yz plane
  108556. */
  108557. xPlaneGizmo: PlaneDragGizmo;
  108558. /**
  108559. * Internal gizmo used for interactions on the xz plane
  108560. */
  108561. yPlaneGizmo: PlaneDragGizmo;
  108562. /**
  108563. * Internal gizmo used for interactions on the xy plane
  108564. */
  108565. zPlaneGizmo: PlaneDragGizmo;
  108566. /**
  108567. * private variables
  108568. */
  108569. private _meshAttached;
  108570. private _updateGizmoRotationToMatchAttachedMesh;
  108571. private _snapDistance;
  108572. private _scaleRatio;
  108573. /** Fires an event when any of it's sub gizmos are dragged */
  108574. onDragStartObservable: Observable<unknown>;
  108575. /** Fires an event when any of it's sub gizmos are released from dragging */
  108576. onDragEndObservable: Observable<unknown>;
  108577. /**
  108578. * If set to true, planar drag is enabled
  108579. */
  108580. private _planarGizmoEnabled;
  108581. attachedMesh: Nullable<AbstractMesh>;
  108582. /**
  108583. * Creates a PositionGizmo
  108584. * @param gizmoLayer The utility layer the gizmo will be added to
  108585. */
  108586. constructor(gizmoLayer?: UtilityLayerRenderer);
  108587. /**
  108588. * If the planar drag gizmo is enabled
  108589. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108590. */
  108591. planarGizmoEnabled: boolean;
  108592. updateGizmoRotationToMatchAttachedMesh: boolean;
  108593. /**
  108594. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108595. */
  108596. snapDistance: number;
  108597. /**
  108598. * Ratio for the scale of the gizmo (Default: 1)
  108599. */
  108600. scaleRatio: number;
  108601. /**
  108602. * Disposes of the gizmo
  108603. */
  108604. dispose(): void;
  108605. /**
  108606. * CustomMeshes are not supported by this gizmo
  108607. * @param mesh The mesh to replace the default mesh of the gizmo
  108608. */
  108609. setCustomMesh(mesh: Mesh): void;
  108610. }
  108611. }
  108612. declare module BABYLON {
  108613. /**
  108614. * Single axis drag gizmo
  108615. */
  108616. export class AxisDragGizmo extends Gizmo {
  108617. /**
  108618. * Drag behavior responsible for the gizmos dragging interactions
  108619. */
  108620. dragBehavior: PointerDragBehavior;
  108621. private _pointerObserver;
  108622. /**
  108623. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108624. */
  108625. snapDistance: number;
  108626. /**
  108627. * Event that fires each time the gizmo snaps to a new location.
  108628. * * snapDistance is the the change in distance
  108629. */
  108630. onSnapObservable: Observable<{
  108631. snapDistance: number;
  108632. }>;
  108633. private _isEnabled;
  108634. private _parent;
  108635. private _arrow;
  108636. private _coloredMaterial;
  108637. private _hoverMaterial;
  108638. /** @hidden */
  108639. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108640. /** @hidden */
  108641. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108642. /**
  108643. * Creates an AxisDragGizmo
  108644. * @param gizmoLayer The utility layer the gizmo will be added to
  108645. * @param dragAxis The axis which the gizmo will be able to drag on
  108646. * @param color The color of the gizmo
  108647. */
  108648. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108649. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108650. /**
  108651. * If the gizmo is enabled
  108652. */
  108653. isEnabled: boolean;
  108654. /**
  108655. * Disposes of the gizmo
  108656. */
  108657. dispose(): void;
  108658. }
  108659. }
  108660. declare module BABYLON.Debug {
  108661. /**
  108662. * The Axes viewer will show 3 axes in a specific point in space
  108663. */
  108664. export class AxesViewer {
  108665. private _xAxis;
  108666. private _yAxis;
  108667. private _zAxis;
  108668. private _scaleLinesFactor;
  108669. private _instanced;
  108670. /**
  108671. * Gets the hosting scene
  108672. */
  108673. scene: Scene;
  108674. /**
  108675. * Gets or sets a number used to scale line length
  108676. */
  108677. scaleLines: number;
  108678. /** Gets the node hierarchy used to render x-axis */
  108679. readonly xAxis: TransformNode;
  108680. /** Gets the node hierarchy used to render y-axis */
  108681. readonly yAxis: TransformNode;
  108682. /** Gets the node hierarchy used to render z-axis */
  108683. readonly zAxis: TransformNode;
  108684. /**
  108685. * Creates a new AxesViewer
  108686. * @param scene defines the hosting scene
  108687. * @param scaleLines defines a number used to scale line length (1 by default)
  108688. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108689. * @param xAxis defines the node hierarchy used to render the x-axis
  108690. * @param yAxis defines the node hierarchy used to render the y-axis
  108691. * @param zAxis defines the node hierarchy used to render the z-axis
  108692. */
  108693. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108694. /**
  108695. * Force the viewer to update
  108696. * @param position defines the position of the viewer
  108697. * @param xaxis defines the x axis of the viewer
  108698. * @param yaxis defines the y axis of the viewer
  108699. * @param zaxis defines the z axis of the viewer
  108700. */
  108701. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108702. /**
  108703. * Creates an instance of this axes viewer.
  108704. * @returns a new axes viewer with instanced meshes
  108705. */
  108706. createInstance(): AxesViewer;
  108707. /** Releases resources */
  108708. dispose(): void;
  108709. private static _SetRenderingGroupId;
  108710. }
  108711. }
  108712. declare module BABYLON.Debug {
  108713. /**
  108714. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108715. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108716. */
  108717. export class BoneAxesViewer extends AxesViewer {
  108718. /**
  108719. * Gets or sets the target mesh where to display the axes viewer
  108720. */
  108721. mesh: Nullable<Mesh>;
  108722. /**
  108723. * Gets or sets the target bone where to display the axes viewer
  108724. */
  108725. bone: Nullable<Bone>;
  108726. /** Gets current position */
  108727. pos: Vector3;
  108728. /** Gets direction of X axis */
  108729. xaxis: Vector3;
  108730. /** Gets direction of Y axis */
  108731. yaxis: Vector3;
  108732. /** Gets direction of Z axis */
  108733. zaxis: Vector3;
  108734. /**
  108735. * Creates a new BoneAxesViewer
  108736. * @param scene defines the hosting scene
  108737. * @param bone defines the target bone
  108738. * @param mesh defines the target mesh
  108739. * @param scaleLines defines a scaling factor for line length (1 by default)
  108740. */
  108741. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108742. /**
  108743. * Force the viewer to update
  108744. */
  108745. update(): void;
  108746. /** Releases resources */
  108747. dispose(): void;
  108748. }
  108749. }
  108750. declare module BABYLON {
  108751. /**
  108752. * Interface used to define scene explorer extensibility option
  108753. */
  108754. export interface IExplorerExtensibilityOption {
  108755. /**
  108756. * Define the option label
  108757. */
  108758. label: string;
  108759. /**
  108760. * Defines the action to execute on click
  108761. */
  108762. action: (entity: any) => void;
  108763. }
  108764. /**
  108765. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108766. */
  108767. export interface IExplorerExtensibilityGroup {
  108768. /**
  108769. * Defines a predicate to test if a given type mut be extended
  108770. */
  108771. predicate: (entity: any) => boolean;
  108772. /**
  108773. * Gets the list of options added to a type
  108774. */
  108775. entries: IExplorerExtensibilityOption[];
  108776. }
  108777. /**
  108778. * Interface used to define the options to use to create the Inspector
  108779. */
  108780. export interface IInspectorOptions {
  108781. /**
  108782. * Display in overlay mode (default: false)
  108783. */
  108784. overlay?: boolean;
  108785. /**
  108786. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108787. */
  108788. globalRoot?: HTMLElement;
  108789. /**
  108790. * Display the Scene explorer
  108791. */
  108792. showExplorer?: boolean;
  108793. /**
  108794. * Display the property inspector
  108795. */
  108796. showInspector?: boolean;
  108797. /**
  108798. * Display in embed mode (both panes on the right)
  108799. */
  108800. embedMode?: boolean;
  108801. /**
  108802. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108803. */
  108804. handleResize?: boolean;
  108805. /**
  108806. * Allow the panes to popup (default: true)
  108807. */
  108808. enablePopup?: boolean;
  108809. /**
  108810. * Allow the panes to be closed by users (default: true)
  108811. */
  108812. enableClose?: boolean;
  108813. /**
  108814. * Optional list of extensibility entries
  108815. */
  108816. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108817. /**
  108818. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108819. */
  108820. inspectorURL?: string;
  108821. }
  108822. interface Scene {
  108823. /**
  108824. * @hidden
  108825. * Backing field
  108826. */
  108827. _debugLayer: DebugLayer;
  108828. /**
  108829. * Gets the debug layer (aka Inspector) associated with the scene
  108830. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108831. */
  108832. debugLayer: DebugLayer;
  108833. }
  108834. /**
  108835. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108836. * what is happening in your scene
  108837. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108838. */
  108839. export class DebugLayer {
  108840. /**
  108841. * Define the url to get the inspector script from.
  108842. * By default it uses the babylonjs CDN.
  108843. * @ignoreNaming
  108844. */
  108845. static InspectorURL: string;
  108846. private _scene;
  108847. private BJSINSPECTOR;
  108848. private _onPropertyChangedObservable?;
  108849. /**
  108850. * Observable triggered when a property is changed through the inspector.
  108851. */
  108852. readonly onPropertyChangedObservable: any;
  108853. /**
  108854. * Instantiates a new debug layer.
  108855. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108856. * what is happening in your scene
  108857. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108858. * @param scene Defines the scene to inspect
  108859. */
  108860. constructor(scene: Scene);
  108861. /** Creates the inspector window. */
  108862. private _createInspector;
  108863. /**
  108864. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108865. * @param entity defines the entity to select
  108866. * @param lineContainerTitle defines the specific block to highlight
  108867. */
  108868. select(entity: any, lineContainerTitle?: string): void;
  108869. /** Get the inspector from bundle or global */
  108870. private _getGlobalInspector;
  108871. /**
  108872. * Get if the inspector is visible or not.
  108873. * @returns true if visible otherwise, false
  108874. */
  108875. isVisible(): boolean;
  108876. /**
  108877. * Hide the inspector and close its window.
  108878. */
  108879. hide(): void;
  108880. /**
  108881. * Launch the debugLayer.
  108882. * @param config Define the configuration of the inspector
  108883. * @return a promise fulfilled when the debug layer is visible
  108884. */
  108885. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108886. }
  108887. }
  108888. declare module BABYLON {
  108889. /**
  108890. * Class containing static functions to help procedurally build meshes
  108891. */
  108892. export class BoxBuilder {
  108893. /**
  108894. * Creates a box mesh
  108895. * * The parameter `size` sets the size (float) of each box side (default 1)
  108896. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108897. * * 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)
  108898. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108902. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108903. * @param name defines the name of the mesh
  108904. * @param options defines the options used to create the mesh
  108905. * @param scene defines the hosting scene
  108906. * @returns the box mesh
  108907. */
  108908. static CreateBox(name: string, options: {
  108909. size?: number;
  108910. width?: number;
  108911. height?: number;
  108912. depth?: number;
  108913. faceUV?: Vector4[];
  108914. faceColors?: Color4[];
  108915. sideOrientation?: number;
  108916. frontUVs?: Vector4;
  108917. backUVs?: Vector4;
  108918. wrap?: boolean;
  108919. topBaseAt?: number;
  108920. bottomBaseAt?: number;
  108921. updatable?: boolean;
  108922. }, scene?: Nullable<Scene>): Mesh;
  108923. }
  108924. }
  108925. declare module BABYLON {
  108926. /**
  108927. * Class containing static functions to help procedurally build meshes
  108928. */
  108929. export class SphereBuilder {
  108930. /**
  108931. * Creates a sphere mesh
  108932. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108933. * * 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`)
  108934. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108935. * * 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
  108936. * * 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)
  108937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108940. * @param name defines the name of the mesh
  108941. * @param options defines the options used to create the mesh
  108942. * @param scene defines the hosting scene
  108943. * @returns the sphere mesh
  108944. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108945. */
  108946. static CreateSphere(name: string, options: {
  108947. segments?: number;
  108948. diameter?: number;
  108949. diameterX?: number;
  108950. diameterY?: number;
  108951. diameterZ?: number;
  108952. arc?: number;
  108953. slice?: number;
  108954. sideOrientation?: number;
  108955. frontUVs?: Vector4;
  108956. backUVs?: Vector4;
  108957. updatable?: boolean;
  108958. }, scene?: Nullable<Scene>): Mesh;
  108959. }
  108960. }
  108961. declare module BABYLON.Debug {
  108962. /**
  108963. * Used to show the physics impostor around the specific mesh
  108964. */
  108965. export class PhysicsViewer {
  108966. /** @hidden */
  108967. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108968. /** @hidden */
  108969. protected _meshes: Array<Nullable<AbstractMesh>>;
  108970. /** @hidden */
  108971. protected _scene: Nullable<Scene>;
  108972. /** @hidden */
  108973. protected _numMeshes: number;
  108974. /** @hidden */
  108975. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108976. private _renderFunction;
  108977. private _utilityLayer;
  108978. private _debugBoxMesh;
  108979. private _debugSphereMesh;
  108980. private _debugCylinderMesh;
  108981. private _debugMaterial;
  108982. private _debugMeshMeshes;
  108983. /**
  108984. * Creates a new PhysicsViewer
  108985. * @param scene defines the hosting scene
  108986. */
  108987. constructor(scene: Scene);
  108988. /** @hidden */
  108989. protected _updateDebugMeshes(): void;
  108990. /**
  108991. * Renders a specified physic impostor
  108992. * @param impostor defines the impostor to render
  108993. * @param targetMesh defines the mesh represented by the impostor
  108994. * @returns the new debug mesh used to render the impostor
  108995. */
  108996. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108997. /**
  108998. * Hides a specified physic impostor
  108999. * @param impostor defines the impostor to hide
  109000. */
  109001. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109002. private _getDebugMaterial;
  109003. private _getDebugBoxMesh;
  109004. private _getDebugSphereMesh;
  109005. private _getDebugCylinderMesh;
  109006. private _getDebugMeshMesh;
  109007. private _getDebugMesh;
  109008. /** Releases all resources */
  109009. dispose(): void;
  109010. }
  109011. }
  109012. declare module BABYLON {
  109013. /**
  109014. * Class containing static functions to help procedurally build meshes
  109015. */
  109016. export class LinesBuilder {
  109017. /**
  109018. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109019. * * 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
  109020. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109021. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109022. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109023. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109025. * * 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
  109026. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109029. * @param name defines the name of the new line system
  109030. * @param options defines the options used to create the line system
  109031. * @param scene defines the hosting scene
  109032. * @returns a new line system mesh
  109033. */
  109034. static CreateLineSystem(name: string, options: {
  109035. lines: Vector3[][];
  109036. updatable?: boolean;
  109037. instance?: Nullable<LinesMesh>;
  109038. colors?: Nullable<Color4[][]>;
  109039. useVertexAlpha?: boolean;
  109040. }, scene: Nullable<Scene>): LinesMesh;
  109041. /**
  109042. * Creates a line mesh
  109043. * 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
  109044. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109045. * * The parameter `points` is an array successive Vector3
  109046. * * 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
  109047. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109048. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109049. * * When updating an instance, remember that only point positions can change, not the number of points
  109050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109052. * @param name defines the name of the new line system
  109053. * @param options defines the options used to create the line system
  109054. * @param scene defines the hosting scene
  109055. * @returns a new line mesh
  109056. */
  109057. static CreateLines(name: string, options: {
  109058. points: Vector3[];
  109059. updatable?: boolean;
  109060. instance?: Nullable<LinesMesh>;
  109061. colors?: Color4[];
  109062. useVertexAlpha?: boolean;
  109063. }, scene?: Nullable<Scene>): LinesMesh;
  109064. /**
  109065. * Creates a dashed line mesh
  109066. * * 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
  109067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109068. * * The parameter `points` is an array successive Vector3
  109069. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109070. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109071. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109072. * * 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
  109073. * * When updating an instance, remember that only point positions can change, not the number of points
  109074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109075. * @param name defines the name of the mesh
  109076. * @param options defines the options used to create the mesh
  109077. * @param scene defines the hosting scene
  109078. * @returns the dashed line mesh
  109079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109080. */
  109081. static CreateDashedLines(name: string, options: {
  109082. points: Vector3[];
  109083. dashSize?: number;
  109084. gapSize?: number;
  109085. dashNb?: number;
  109086. updatable?: boolean;
  109087. instance?: LinesMesh;
  109088. }, scene?: Nullable<Scene>): LinesMesh;
  109089. }
  109090. }
  109091. declare module BABYLON {
  109092. /**
  109093. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109094. * in order to better appreciate the issue one might have.
  109095. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109096. */
  109097. export class RayHelper {
  109098. /**
  109099. * Defines the ray we are currently tryin to visualize.
  109100. */
  109101. ray: Nullable<Ray>;
  109102. private _renderPoints;
  109103. private _renderLine;
  109104. private _renderFunction;
  109105. private _scene;
  109106. private _updateToMeshFunction;
  109107. private _attachedToMesh;
  109108. private _meshSpaceDirection;
  109109. private _meshSpaceOrigin;
  109110. /**
  109111. * Helper function to create a colored helper in a scene in one line.
  109112. * @param ray Defines the ray we are currently tryin to visualize
  109113. * @param scene Defines the scene the ray is used in
  109114. * @param color Defines the color we want to see the ray in
  109115. * @returns The newly created ray helper.
  109116. */
  109117. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109118. /**
  109119. * Instantiate a new ray helper.
  109120. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109121. * in order to better appreciate the issue one might have.
  109122. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109123. * @param ray Defines the ray we are currently tryin to visualize
  109124. */
  109125. constructor(ray: Ray);
  109126. /**
  109127. * Shows the ray we are willing to debug.
  109128. * @param scene Defines the scene the ray needs to be rendered in
  109129. * @param color Defines the color the ray needs to be rendered in
  109130. */
  109131. show(scene: Scene, color?: Color3): void;
  109132. /**
  109133. * Hides the ray we are debugging.
  109134. */
  109135. hide(): void;
  109136. private _render;
  109137. /**
  109138. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109139. * @param mesh Defines the mesh we want the helper attached to
  109140. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109141. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109142. * @param length Defines the length of the ray
  109143. */
  109144. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109145. /**
  109146. * Detach the ray helper from the mesh it has previously been attached to.
  109147. */
  109148. detachFromMesh(): void;
  109149. private _updateToMesh;
  109150. /**
  109151. * Dispose the helper and release its associated resources.
  109152. */
  109153. dispose(): void;
  109154. }
  109155. }
  109156. declare module BABYLON.Debug {
  109157. /**
  109158. * Class used to render a debug view of a given skeleton
  109159. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109160. */
  109161. export class SkeletonViewer {
  109162. /** defines the skeleton to render */
  109163. skeleton: Skeleton;
  109164. /** defines the mesh attached to the skeleton */
  109165. mesh: AbstractMesh;
  109166. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109167. autoUpdateBonesMatrices: boolean;
  109168. /** defines the rendering group id to use with the viewer */
  109169. renderingGroupId: number;
  109170. /** Gets or sets the color used to render the skeleton */
  109171. color: Color3;
  109172. private _scene;
  109173. private _debugLines;
  109174. private _debugMesh;
  109175. private _isEnabled;
  109176. private _renderFunction;
  109177. private _utilityLayer;
  109178. /**
  109179. * Returns the mesh used to render the bones
  109180. */
  109181. readonly debugMesh: Nullable<LinesMesh>;
  109182. /**
  109183. * Creates a new SkeletonViewer
  109184. * @param skeleton defines the skeleton to render
  109185. * @param mesh defines the mesh attached to the skeleton
  109186. * @param scene defines the hosting scene
  109187. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109188. * @param renderingGroupId defines the rendering group id to use with the viewer
  109189. */
  109190. constructor(
  109191. /** defines the skeleton to render */
  109192. skeleton: Skeleton,
  109193. /** defines the mesh attached to the skeleton */
  109194. mesh: AbstractMesh, scene: Scene,
  109195. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109196. autoUpdateBonesMatrices?: boolean,
  109197. /** defines the rendering group id to use with the viewer */
  109198. renderingGroupId?: number);
  109199. /** Gets or sets a boolean indicating if the viewer is enabled */
  109200. isEnabled: boolean;
  109201. private _getBonePosition;
  109202. private _getLinesForBonesWithLength;
  109203. private _getLinesForBonesNoLength;
  109204. /** Update the viewer to sync with current skeleton state */
  109205. update(): void;
  109206. /** Release associated resources */
  109207. dispose(): void;
  109208. }
  109209. }
  109210. declare module BABYLON {
  109211. /**
  109212. * Options to create the null engine
  109213. */
  109214. export class NullEngineOptions {
  109215. /**
  109216. * Render width (Default: 512)
  109217. */
  109218. renderWidth: number;
  109219. /**
  109220. * Render height (Default: 256)
  109221. */
  109222. renderHeight: number;
  109223. /**
  109224. * Texture size (Default: 512)
  109225. */
  109226. textureSize: number;
  109227. /**
  109228. * If delta time between frames should be constant
  109229. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109230. */
  109231. deterministicLockstep: boolean;
  109232. /**
  109233. * Maximum about of steps between frames (Default: 4)
  109234. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109235. */
  109236. lockstepMaxSteps: number;
  109237. }
  109238. /**
  109239. * The null engine class provides support for headless version of babylon.js.
  109240. * This can be used in server side scenario or for testing purposes
  109241. */
  109242. export class NullEngine extends Engine {
  109243. private _options;
  109244. /**
  109245. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109246. */
  109247. isDeterministicLockStep(): boolean;
  109248. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109249. getLockstepMaxSteps(): number;
  109250. /**
  109251. * Sets hardware scaling, used to save performance if needed
  109252. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109253. */
  109254. getHardwareScalingLevel(): number;
  109255. constructor(options?: NullEngineOptions);
  109256. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109257. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109258. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109259. getRenderWidth(useScreen?: boolean): number;
  109260. getRenderHeight(useScreen?: boolean): number;
  109261. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109262. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109263. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109264. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109265. bindSamplers(effect: Effect): void;
  109266. enableEffect(effect: Effect): void;
  109267. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109268. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109269. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109270. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109271. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109272. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109273. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109274. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109275. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109276. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109277. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109278. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109279. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109280. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109281. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109282. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109283. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109284. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109285. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109286. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109287. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109289. bindBuffers(vertexBuffers: {
  109290. [key: string]: VertexBuffer;
  109291. }, indexBuffer: DataBuffer, effect: Effect): void;
  109292. wipeCaches(bruteForce?: boolean): void;
  109293. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109294. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109295. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109296. /** @hidden */
  109297. _createTexture(): WebGLTexture;
  109298. /** @hidden */
  109299. _releaseTexture(texture: InternalTexture): void;
  109300. 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;
  109301. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109302. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109303. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109304. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109305. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109306. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109307. areAllEffectsReady(): boolean;
  109308. /**
  109309. * @hidden
  109310. * Get the current error code of the webGL context
  109311. * @returns the error code
  109312. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109313. */
  109314. getError(): number;
  109315. /** @hidden */
  109316. _getUnpackAlignement(): number;
  109317. /** @hidden */
  109318. _unpackFlipY(value: boolean): void;
  109319. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109320. /**
  109321. * Updates a dynamic vertex buffer.
  109322. * @param vertexBuffer the vertex buffer to update
  109323. * @param data the data used to update the vertex buffer
  109324. * @param byteOffset the byte offset of the data (optional)
  109325. * @param byteLength the byte length of the data (optional)
  109326. */
  109327. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109328. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109329. /** @hidden */
  109330. _bindTexture(channel: number, texture: InternalTexture): void;
  109331. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109332. releaseEffects(): void;
  109333. displayLoadingUI(): void;
  109334. hideLoadingUI(): void;
  109335. /** @hidden */
  109336. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109337. /** @hidden */
  109338. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109339. /** @hidden */
  109340. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109341. /** @hidden */
  109342. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109343. }
  109344. }
  109345. declare module BABYLON {
  109346. /** @hidden */
  109347. export class _OcclusionDataStorage {
  109348. /** @hidden */
  109349. occlusionInternalRetryCounter: number;
  109350. /** @hidden */
  109351. isOcclusionQueryInProgress: boolean;
  109352. /** @hidden */
  109353. isOccluded: boolean;
  109354. /** @hidden */
  109355. occlusionRetryCount: number;
  109356. /** @hidden */
  109357. occlusionType: number;
  109358. /** @hidden */
  109359. occlusionQueryAlgorithmType: number;
  109360. }
  109361. interface Engine {
  109362. /**
  109363. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109364. * @return the new query
  109365. */
  109366. createQuery(): WebGLQuery;
  109367. /**
  109368. * Delete and release a webGL query
  109369. * @param query defines the query to delete
  109370. * @return the current engine
  109371. */
  109372. deleteQuery(query: WebGLQuery): Engine;
  109373. /**
  109374. * Check if a given query has resolved and got its value
  109375. * @param query defines the query to check
  109376. * @returns true if the query got its value
  109377. */
  109378. isQueryResultAvailable(query: WebGLQuery): boolean;
  109379. /**
  109380. * Gets the value of a given query
  109381. * @param query defines the query to check
  109382. * @returns the value of the query
  109383. */
  109384. getQueryResult(query: WebGLQuery): number;
  109385. /**
  109386. * Initiates an occlusion query
  109387. * @param algorithmType defines the algorithm to use
  109388. * @param query defines the query to use
  109389. * @returns the current engine
  109390. * @see http://doc.babylonjs.com/features/occlusionquery
  109391. */
  109392. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109393. /**
  109394. * Ends an occlusion query
  109395. * @see http://doc.babylonjs.com/features/occlusionquery
  109396. * @param algorithmType defines the algorithm to use
  109397. * @returns the current engine
  109398. */
  109399. endOcclusionQuery(algorithmType: number): Engine;
  109400. /**
  109401. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109402. * Please note that only one query can be issued at a time
  109403. * @returns a time token used to track the time span
  109404. */
  109405. startTimeQuery(): Nullable<_TimeToken>;
  109406. /**
  109407. * Ends a time query
  109408. * @param token defines the token used to measure the time span
  109409. * @returns the time spent (in ns)
  109410. */
  109411. endTimeQuery(token: _TimeToken): int;
  109412. /** @hidden */
  109413. _currentNonTimestampToken: Nullable<_TimeToken>;
  109414. /** @hidden */
  109415. _createTimeQuery(): WebGLQuery;
  109416. /** @hidden */
  109417. _deleteTimeQuery(query: WebGLQuery): void;
  109418. /** @hidden */
  109419. _getGlAlgorithmType(algorithmType: number): number;
  109420. /** @hidden */
  109421. _getTimeQueryResult(query: WebGLQuery): any;
  109422. /** @hidden */
  109423. _getTimeQueryAvailability(query: WebGLQuery): any;
  109424. }
  109425. interface AbstractMesh {
  109426. /**
  109427. * Backing filed
  109428. * @hidden
  109429. */
  109430. __occlusionDataStorage: _OcclusionDataStorage;
  109431. /**
  109432. * Access property
  109433. * @hidden
  109434. */
  109435. _occlusionDataStorage: _OcclusionDataStorage;
  109436. /**
  109437. * 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.
  109438. * The default value is -1 which means don't break the query and wait till the result
  109439. * @see http://doc.babylonjs.com/features/occlusionquery
  109440. */
  109441. occlusionRetryCount: number;
  109442. /**
  109443. * 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:
  109444. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109445. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109446. * * 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.
  109447. * @see http://doc.babylonjs.com/features/occlusionquery
  109448. */
  109449. occlusionType: number;
  109450. /**
  109451. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109452. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109453. * * 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.
  109454. * @see http://doc.babylonjs.com/features/occlusionquery
  109455. */
  109456. occlusionQueryAlgorithmType: number;
  109457. /**
  109458. * 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
  109459. * @see http://doc.babylonjs.com/features/occlusionquery
  109460. */
  109461. isOccluded: boolean;
  109462. /**
  109463. * Flag to check the progress status of the query
  109464. * @see http://doc.babylonjs.com/features/occlusionquery
  109465. */
  109466. isOcclusionQueryInProgress: boolean;
  109467. }
  109468. }
  109469. declare module BABYLON {
  109470. /** @hidden */
  109471. export var _forceTransformFeedbackToBundle: boolean;
  109472. interface Engine {
  109473. /**
  109474. * Creates a webGL transform feedback object
  109475. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109476. * @returns the webGL transform feedback object
  109477. */
  109478. createTransformFeedback(): WebGLTransformFeedback;
  109479. /**
  109480. * Delete a webGL transform feedback object
  109481. * @param value defines the webGL transform feedback object to delete
  109482. */
  109483. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109484. /**
  109485. * Bind a webGL transform feedback object to the webgl context
  109486. * @param value defines the webGL transform feedback object to bind
  109487. */
  109488. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109489. /**
  109490. * Begins a transform feedback operation
  109491. * @param usePoints defines if points or triangles must be used
  109492. */
  109493. beginTransformFeedback(usePoints: boolean): void;
  109494. /**
  109495. * Ends a transform feedback operation
  109496. */
  109497. endTransformFeedback(): void;
  109498. /**
  109499. * Specify the varyings to use with transform feedback
  109500. * @param program defines the associated webGL program
  109501. * @param value defines the list of strings representing the varying names
  109502. */
  109503. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109504. /**
  109505. * Bind a webGL buffer for a transform feedback operation
  109506. * @param value defines the webGL buffer to bind
  109507. */
  109508. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109509. }
  109510. }
  109511. declare module BABYLON {
  109512. /**
  109513. * Creation options of the multi render target texture.
  109514. */
  109515. export interface IMultiRenderTargetOptions {
  109516. /**
  109517. * Define if the texture needs to create mip maps after render.
  109518. */
  109519. generateMipMaps?: boolean;
  109520. /**
  109521. * Define the types of all the draw buffers we want to create
  109522. */
  109523. types?: number[];
  109524. /**
  109525. * Define the sampling modes of all the draw buffers we want to create
  109526. */
  109527. samplingModes?: number[];
  109528. /**
  109529. * Define if a depth buffer is required
  109530. */
  109531. generateDepthBuffer?: boolean;
  109532. /**
  109533. * Define if a stencil buffer is required
  109534. */
  109535. generateStencilBuffer?: boolean;
  109536. /**
  109537. * Define if a depth texture is required instead of a depth buffer
  109538. */
  109539. generateDepthTexture?: boolean;
  109540. /**
  109541. * Define the number of desired draw buffers
  109542. */
  109543. textureCount?: number;
  109544. /**
  109545. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109546. */
  109547. doNotChangeAspectRatio?: boolean;
  109548. /**
  109549. * Define the default type of the buffers we are creating
  109550. */
  109551. defaultType?: number;
  109552. }
  109553. /**
  109554. * A multi render target, like a render target provides the ability to render to a texture.
  109555. * Unlike the render target, it can render to several draw buffers in one draw.
  109556. * This is specially interesting in deferred rendering or for any effects requiring more than
  109557. * just one color from a single pass.
  109558. */
  109559. export class MultiRenderTarget extends RenderTargetTexture {
  109560. private _internalTextures;
  109561. private _textures;
  109562. private _multiRenderTargetOptions;
  109563. /**
  109564. * Get if draw buffers are currently supported by the used hardware and browser.
  109565. */
  109566. readonly isSupported: boolean;
  109567. /**
  109568. * Get the list of textures generated by the multi render target.
  109569. */
  109570. readonly textures: Texture[];
  109571. /**
  109572. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109573. */
  109574. readonly depthTexture: Texture;
  109575. /**
  109576. * Set the wrapping mode on U of all the textures we are rendering to.
  109577. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109578. */
  109579. wrapU: number;
  109580. /**
  109581. * Set the wrapping mode on V of all the textures we are rendering to.
  109582. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109583. */
  109584. wrapV: number;
  109585. /**
  109586. * Instantiate a new multi render target texture.
  109587. * A multi render target, like a render target provides the ability to render to a texture.
  109588. * Unlike the render target, it can render to several draw buffers in one draw.
  109589. * This is specially interesting in deferred rendering or for any effects requiring more than
  109590. * just one color from a single pass.
  109591. * @param name Define the name of the texture
  109592. * @param size Define the size of the buffers to render to
  109593. * @param count Define the number of target we are rendering into
  109594. * @param scene Define the scene the texture belongs to
  109595. * @param options Define the options used to create the multi render target
  109596. */
  109597. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109598. /** @hidden */
  109599. _rebuild(): void;
  109600. private _createInternalTextures;
  109601. private _createTextures;
  109602. /**
  109603. * Define the number of samples used if MSAA is enabled.
  109604. */
  109605. samples: number;
  109606. /**
  109607. * Resize all the textures in the multi render target.
  109608. * Be carrefull as it will recreate all the data in the new texture.
  109609. * @param size Define the new size
  109610. */
  109611. resize(size: any): void;
  109612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109613. /**
  109614. * Dispose the render targets and their associated resources
  109615. */
  109616. dispose(): void;
  109617. /**
  109618. * Release all the underlying texture used as draw buffers.
  109619. */
  109620. releaseInternalTextures(): void;
  109621. }
  109622. }
  109623. declare module BABYLON {
  109624. interface Engine {
  109625. /**
  109626. * Unbind a list of render target textures from the webGL context
  109627. * This is used only when drawBuffer extension or webGL2 are active
  109628. * @param textures defines the render target textures to unbind
  109629. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109630. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109631. */
  109632. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109633. /**
  109634. * Create a multi render target texture
  109635. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109636. * @param size defines the size of the texture
  109637. * @param options defines the creation options
  109638. * @returns the cube texture as an InternalTexture
  109639. */
  109640. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109641. /**
  109642. * Update the sample count for a given multiple render target texture
  109643. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109644. * @param textures defines the textures to update
  109645. * @param samples defines the sample count to set
  109646. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109647. */
  109648. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109649. }
  109650. }
  109651. declare module BABYLON {
  109652. /** @hidden */
  109653. export var rgbdEncodePixelShader: {
  109654. name: string;
  109655. shader: string;
  109656. };
  109657. }
  109658. declare module BABYLON {
  109659. /** @hidden */
  109660. export var rgbdDecodePixelShader: {
  109661. name: string;
  109662. shader: string;
  109663. };
  109664. }
  109665. declare module BABYLON {
  109666. /**
  109667. * Raw texture data and descriptor sufficient for WebGL texture upload
  109668. */
  109669. export interface EnvironmentTextureInfo {
  109670. /**
  109671. * Version of the environment map
  109672. */
  109673. version: number;
  109674. /**
  109675. * Width of image
  109676. */
  109677. width: number;
  109678. /**
  109679. * Irradiance information stored in the file.
  109680. */
  109681. irradiance: any;
  109682. /**
  109683. * Specular information stored in the file.
  109684. */
  109685. specular: any;
  109686. }
  109687. /**
  109688. * Defines One Image in the file. It requires only the position in the file
  109689. * as well as the length.
  109690. */
  109691. interface BufferImageData {
  109692. /**
  109693. * Length of the image data.
  109694. */
  109695. length: number;
  109696. /**
  109697. * Position of the data from the null terminator delimiting the end of the JSON.
  109698. */
  109699. position: number;
  109700. }
  109701. /**
  109702. * Defines the specular data enclosed in the file.
  109703. * This corresponds to the version 1 of the data.
  109704. */
  109705. export interface EnvironmentTextureSpecularInfoV1 {
  109706. /**
  109707. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109708. */
  109709. specularDataPosition?: number;
  109710. /**
  109711. * This contains all the images data needed to reconstruct the cubemap.
  109712. */
  109713. mipmaps: Array<BufferImageData>;
  109714. /**
  109715. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109716. */
  109717. lodGenerationScale: number;
  109718. }
  109719. /**
  109720. * Sets of helpers addressing the serialization and deserialization of environment texture
  109721. * stored in a BabylonJS env file.
  109722. * Those files are usually stored as .env files.
  109723. */
  109724. export class EnvironmentTextureTools {
  109725. /**
  109726. * Magic number identifying the env file.
  109727. */
  109728. private static _MagicBytes;
  109729. /**
  109730. * Gets the environment info from an env file.
  109731. * @param data The array buffer containing the .env bytes.
  109732. * @returns the environment file info (the json header) if successfully parsed.
  109733. */
  109734. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109735. /**
  109736. * Creates an environment texture from a loaded cube texture.
  109737. * @param texture defines the cube texture to convert in env file
  109738. * @return a promise containing the environment data if succesfull.
  109739. */
  109740. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109741. /**
  109742. * Creates a JSON representation of the spherical data.
  109743. * @param texture defines the texture containing the polynomials
  109744. * @return the JSON representation of the spherical info
  109745. */
  109746. private static _CreateEnvTextureIrradiance;
  109747. /**
  109748. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109749. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109750. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109751. * @return the views described by info providing access to the underlying buffer
  109752. */
  109753. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109754. /**
  109755. * Uploads the texture info contained in the env file to the GPU.
  109756. * @param texture defines the internal texture to upload to
  109757. * @param arrayBuffer defines the buffer cotaining the data to load
  109758. * @param info defines the texture info retrieved through the GetEnvInfo method
  109759. * @returns a promise
  109760. */
  109761. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109762. /**
  109763. * Uploads the levels of image data to the GPU.
  109764. * @param texture defines the internal texture to upload to
  109765. * @param imageData defines the array buffer views of image data [mipmap][face]
  109766. * @returns a promise
  109767. */
  109768. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109769. /**
  109770. * Uploads spherical polynomials information to the texture.
  109771. * @param texture defines the texture we are trying to upload the information to
  109772. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109773. */
  109774. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109775. /** @hidden */
  109776. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109777. }
  109778. }
  109779. declare module BABYLON {
  109780. /**
  109781. * Contains position and normal vectors for a vertex
  109782. */
  109783. export class PositionNormalVertex {
  109784. /** the position of the vertex (defaut: 0,0,0) */
  109785. position: Vector3;
  109786. /** the normal of the vertex (defaut: 0,1,0) */
  109787. normal: Vector3;
  109788. /**
  109789. * Creates a PositionNormalVertex
  109790. * @param position the position of the vertex (defaut: 0,0,0)
  109791. * @param normal the normal of the vertex (defaut: 0,1,0)
  109792. */
  109793. constructor(
  109794. /** the position of the vertex (defaut: 0,0,0) */
  109795. position?: Vector3,
  109796. /** the normal of the vertex (defaut: 0,1,0) */
  109797. normal?: Vector3);
  109798. /**
  109799. * Clones the PositionNormalVertex
  109800. * @returns the cloned PositionNormalVertex
  109801. */
  109802. clone(): PositionNormalVertex;
  109803. }
  109804. /**
  109805. * Contains position, normal and uv vectors for a vertex
  109806. */
  109807. export class PositionNormalTextureVertex {
  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. * Creates a PositionNormalTextureVertex
  109816. * @param position the position of the vertex (defaut: 0,0,0)
  109817. * @param normal the normal of the vertex (defaut: 0,1,0)
  109818. * @param uv the uv of the vertex (default: 0,0)
  109819. */
  109820. constructor(
  109821. /** the position of the vertex (defaut: 0,0,0) */
  109822. position?: Vector3,
  109823. /** the normal of the vertex (defaut: 0,1,0) */
  109824. normal?: Vector3,
  109825. /** the uv of the vertex (default: 0,0) */
  109826. uv?: Vector2);
  109827. /**
  109828. * Clones the PositionNormalTextureVertex
  109829. * @returns the cloned PositionNormalTextureVertex
  109830. */
  109831. clone(): PositionNormalTextureVertex;
  109832. }
  109833. }
  109834. declare module BABYLON {
  109835. /** @hidden */
  109836. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109837. private _genericAttributeLocation;
  109838. private _varyingLocationCount;
  109839. private _varyingLocationMap;
  109840. private _replacements;
  109841. private _textureCount;
  109842. private _uniforms;
  109843. lineProcessor(line: string): string;
  109844. attributeProcessor(attribute: string): string;
  109845. varyingProcessor(varying: string, isFragment: boolean): string;
  109846. uniformProcessor(uniform: string): string;
  109847. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109848. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109849. }
  109850. }
  109851. declare module BABYLON {
  109852. /**
  109853. * Container for accessors for natively-stored mesh data buffers.
  109854. */
  109855. class NativeDataBuffer extends DataBuffer {
  109856. /**
  109857. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109858. */
  109859. nativeIndexBuffer?: any;
  109860. /**
  109861. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109862. */
  109863. nativeVertexBuffer?: any;
  109864. }
  109865. /** @hidden */
  109866. export class NativeEngine extends Engine {
  109867. private readonly _native;
  109868. getHardwareScalingLevel(): number;
  109869. constructor();
  109870. /**
  109871. * Can be used to override the current requestAnimationFrame requester.
  109872. * @hidden
  109873. */
  109874. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109875. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109876. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109877. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109878. recordVertexArrayObject(vertexBuffers: {
  109879. [key: string]: VertexBuffer;
  109880. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109881. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109882. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109883. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109884. /**
  109885. * Draw a list of indexed primitives
  109886. * @param fillMode defines the primitive to use
  109887. * @param indexStart defines the starting index
  109888. * @param indexCount defines the number of index to draw
  109889. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109890. */
  109891. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109892. /**
  109893. * Draw a list of unindexed primitives
  109894. * @param fillMode defines the primitive to use
  109895. * @param verticesStart defines the index of first vertex to draw
  109896. * @param verticesCount defines the count of vertices to draw
  109897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109898. */
  109899. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109900. createPipelineContext(): IPipelineContext;
  109901. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109902. /** @hidden */
  109903. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109904. /** @hidden */
  109905. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109906. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109907. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109908. protected _setProgram(program: WebGLProgram): void;
  109909. _releaseEffect(effect: Effect): void;
  109910. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109911. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109912. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109913. bindSamplers(effect: Effect): void;
  109914. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109915. getRenderWidth(useScreen?: boolean): number;
  109916. getRenderHeight(useScreen?: boolean): number;
  109917. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109918. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109919. /**
  109920. * Set the z offset to apply to current rendering
  109921. * @param value defines the offset to apply
  109922. */
  109923. setZOffset(value: number): void;
  109924. /**
  109925. * Gets the current value of the zOffset
  109926. * @returns the current zOffset state
  109927. */
  109928. getZOffset(): number;
  109929. /**
  109930. * Enable or disable depth buffering
  109931. * @param enable defines the state to set
  109932. */
  109933. setDepthBuffer(enable: boolean): void;
  109934. /**
  109935. * Gets a boolean indicating if depth writing is enabled
  109936. * @returns the current depth writing state
  109937. */
  109938. getDepthWrite(): boolean;
  109939. /**
  109940. * Enable or disable depth writing
  109941. * @param enable defines the state to set
  109942. */
  109943. setDepthWrite(enable: boolean): void;
  109944. /**
  109945. * Enable or disable color writing
  109946. * @param enable defines the state to set
  109947. */
  109948. setColorWrite(enable: boolean): void;
  109949. /**
  109950. * Gets a boolean indicating if color writing is enabled
  109951. * @returns the current color writing state
  109952. */
  109953. getColorWrite(): boolean;
  109954. /**
  109955. * Sets alpha constants used by some alpha blending modes
  109956. * @param r defines the red component
  109957. * @param g defines the green component
  109958. * @param b defines the blue component
  109959. * @param a defines the alpha component
  109960. */
  109961. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109962. /**
  109963. * Sets the current alpha mode
  109964. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109965. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109967. */
  109968. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109969. /**
  109970. * Gets the current alpha mode
  109971. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109972. * @returns the current alpha mode
  109973. */
  109974. getAlphaMode(): number;
  109975. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109976. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109977. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109978. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109979. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109980. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109981. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109982. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109983. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109984. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109985. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109986. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109987. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109988. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109989. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109990. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109991. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109992. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109993. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109994. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109995. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109996. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109997. wipeCaches(bruteForce?: boolean): void;
  109998. _createTexture(): WebGLTexture;
  109999. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  110000. /**
  110001. * Usually called from BABYLON.Texture.ts.
  110002. * Passed information to create a WebGLTexture
  110003. * @param urlArg defines a value which contains one of the following:
  110004. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110005. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110006. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110007. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110008. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110009. * @param scene needed for loading to the correct scene
  110010. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110011. * @param onLoad optional callback to be called upon successful completion
  110012. * @param onError optional callback to be called upon failure
  110013. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110014. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110015. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110016. * @param forcedExtension defines the extension to use to pick the right loader
  110017. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110018. */
  110019. 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;
  110020. /**
  110021. * Creates a cube texture
  110022. * @param rootUrl defines the url where the files to load is located
  110023. * @param scene defines the current scene
  110024. * @param files defines the list of files to load (1 per face)
  110025. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110026. * @param onLoad defines an optional callback raised when the texture is loaded
  110027. * @param onError defines an optional callback raised if there is an issue to load the texture
  110028. * @param format defines the format of the data
  110029. * @param forcedExtension defines the extension to use to pick the right loader
  110030. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110031. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110032. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110033. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110034. * @returns the cube texture as an InternalTexture
  110035. */
  110036. 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;
  110037. private _getSamplingFilter;
  110038. private static _GetNativeTextureFormat;
  110039. createRenderTargetTexture(size: number | {
  110040. width: number;
  110041. height: number;
  110042. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110043. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110044. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110045. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110046. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110047. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110048. /**
  110049. * Updates a dynamic vertex buffer.
  110050. * @param vertexBuffer the vertex buffer to update
  110051. * @param data the data used to update the vertex buffer
  110052. * @param byteOffset the byte offset of the data (optional)
  110053. * @param byteLength the byte length of the data (optional)
  110054. */
  110055. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110056. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110057. private _updateAnisotropicLevel;
  110058. private _getAddressMode;
  110059. /** @hidden */
  110060. _bindTexture(channel: number, texture: InternalTexture): void;
  110061. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110062. releaseEffects(): void;
  110063. /** @hidden */
  110064. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110065. /** @hidden */
  110066. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110067. /** @hidden */
  110068. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110069. /** @hidden */
  110070. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110071. }
  110072. }
  110073. declare module BABYLON {
  110074. /**
  110075. * Gather the list of clipboard event types as constants.
  110076. */
  110077. export class ClipboardEventTypes {
  110078. /**
  110079. * The clipboard event is fired when a copy command is active (pressed).
  110080. */
  110081. static readonly COPY: number;
  110082. /**
  110083. * The clipboard event is fired when a cut command is active (pressed).
  110084. */
  110085. static readonly CUT: number;
  110086. /**
  110087. * The clipboard event is fired when a paste command is active (pressed).
  110088. */
  110089. static readonly PASTE: number;
  110090. }
  110091. /**
  110092. * This class is used to store clipboard related info for the onClipboardObservable event.
  110093. */
  110094. export class ClipboardInfo {
  110095. /**
  110096. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110097. */
  110098. type: number;
  110099. /**
  110100. * Defines the related dom event
  110101. */
  110102. event: ClipboardEvent;
  110103. /**
  110104. *Creates an instance of ClipboardInfo.
  110105. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110106. * @param event Defines the related dom event
  110107. */
  110108. constructor(
  110109. /**
  110110. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110111. */
  110112. type: number,
  110113. /**
  110114. * Defines the related dom event
  110115. */
  110116. event: ClipboardEvent);
  110117. /**
  110118. * Get the clipboard event's type from the keycode.
  110119. * @param keyCode Defines the keyCode for the current keyboard event.
  110120. * @return {number}
  110121. */
  110122. static GetTypeFromCharacter(keyCode: number): number;
  110123. }
  110124. }
  110125. declare module BABYLON {
  110126. /**
  110127. * Google Daydream controller
  110128. */
  110129. export class DaydreamController extends WebVRController {
  110130. /**
  110131. * Base Url for the controller model.
  110132. */
  110133. static MODEL_BASE_URL: string;
  110134. /**
  110135. * File name for the controller model.
  110136. */
  110137. static MODEL_FILENAME: string;
  110138. /**
  110139. * Gamepad Id prefix used to identify Daydream Controller.
  110140. */
  110141. static readonly GAMEPAD_ID_PREFIX: string;
  110142. /**
  110143. * Creates a new DaydreamController from a gamepad
  110144. * @param vrGamepad the gamepad that the controller should be created from
  110145. */
  110146. constructor(vrGamepad: any);
  110147. /**
  110148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110149. * @param scene scene in which to add meshes
  110150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110151. */
  110152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110153. /**
  110154. * Called once for each button that changed state since the last frame
  110155. * @param buttonIdx Which button index changed
  110156. * @param state New state of the button
  110157. * @param changes Which properties on the state changed since last frame
  110158. */
  110159. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110160. }
  110161. }
  110162. declare module BABYLON {
  110163. /**
  110164. * Gear VR Controller
  110165. */
  110166. export class GearVRController extends WebVRController {
  110167. /**
  110168. * Base Url for the controller model.
  110169. */
  110170. static MODEL_BASE_URL: string;
  110171. /**
  110172. * File name for the controller model.
  110173. */
  110174. static MODEL_FILENAME: string;
  110175. /**
  110176. * Gamepad Id prefix used to identify this controller.
  110177. */
  110178. static readonly GAMEPAD_ID_PREFIX: string;
  110179. private readonly _buttonIndexToObservableNameMap;
  110180. /**
  110181. * Creates a new GearVRController from a gamepad
  110182. * @param vrGamepad the gamepad that the controller should be created from
  110183. */
  110184. constructor(vrGamepad: any);
  110185. /**
  110186. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110187. * @param scene scene in which to add meshes
  110188. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110189. */
  110190. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110191. /**
  110192. * Called once for each button that changed state since the last frame
  110193. * @param buttonIdx Which button index changed
  110194. * @param state New state of the button
  110195. * @param changes Which properties on the state changed since last frame
  110196. */
  110197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110198. }
  110199. }
  110200. declare module BABYLON {
  110201. /**
  110202. * Class containing static functions to help procedurally build meshes
  110203. */
  110204. export class PolyhedronBuilder {
  110205. /**
  110206. * Creates a polyhedron mesh
  110207. * * 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
  110208. * * The parameter `size` (positive float, default 1) sets the polygon size
  110209. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110210. * * 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`
  110211. * * 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
  110212. * * 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)`)
  110213. * * 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
  110214. * * 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
  110215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110218. * @param name defines the name of the mesh
  110219. * @param options defines the options used to create the mesh
  110220. * @param scene defines the hosting scene
  110221. * @returns the polyhedron mesh
  110222. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110223. */
  110224. static CreatePolyhedron(name: string, options: {
  110225. type?: number;
  110226. size?: number;
  110227. sizeX?: number;
  110228. sizeY?: number;
  110229. sizeZ?: number;
  110230. custom?: any;
  110231. faceUV?: Vector4[];
  110232. faceColors?: Color4[];
  110233. flat?: boolean;
  110234. updatable?: boolean;
  110235. sideOrientation?: number;
  110236. frontUVs?: Vector4;
  110237. backUVs?: Vector4;
  110238. }, scene?: Nullable<Scene>): Mesh;
  110239. }
  110240. }
  110241. declare module BABYLON {
  110242. /**
  110243. * Gizmo that enables scaling a mesh along 3 axis
  110244. */
  110245. export class ScaleGizmo extends Gizmo {
  110246. /**
  110247. * Internal gizmo used for interactions on the x axis
  110248. */
  110249. xGizmo: AxisScaleGizmo;
  110250. /**
  110251. * Internal gizmo used for interactions on the y axis
  110252. */
  110253. yGizmo: AxisScaleGizmo;
  110254. /**
  110255. * Internal gizmo used for interactions on the z axis
  110256. */
  110257. zGizmo: AxisScaleGizmo;
  110258. /**
  110259. * Internal gizmo used to scale all axis equally
  110260. */
  110261. uniformScaleGizmo: AxisScaleGizmo;
  110262. private _meshAttached;
  110263. private _updateGizmoRotationToMatchAttachedMesh;
  110264. private _snapDistance;
  110265. private _scaleRatio;
  110266. private _uniformScalingMesh;
  110267. private _octahedron;
  110268. /** Fires an event when any of it's sub gizmos are dragged */
  110269. onDragStartObservable: Observable<unknown>;
  110270. /** Fires an event when any of it's sub gizmos are released from dragging */
  110271. onDragEndObservable: Observable<unknown>;
  110272. attachedMesh: Nullable<AbstractMesh>;
  110273. /**
  110274. * Creates a ScaleGizmo
  110275. * @param gizmoLayer The utility layer the gizmo will be added to
  110276. */
  110277. constructor(gizmoLayer?: UtilityLayerRenderer);
  110278. updateGizmoRotationToMatchAttachedMesh: boolean;
  110279. /**
  110280. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110281. */
  110282. snapDistance: number;
  110283. /**
  110284. * Ratio for the scale of the gizmo (Default: 1)
  110285. */
  110286. scaleRatio: number;
  110287. /**
  110288. * Disposes of the gizmo
  110289. */
  110290. dispose(): void;
  110291. }
  110292. }
  110293. declare module BABYLON {
  110294. /**
  110295. * Single axis scale gizmo
  110296. */
  110297. export class AxisScaleGizmo extends Gizmo {
  110298. /**
  110299. * Drag behavior responsible for the gizmos dragging interactions
  110300. */
  110301. dragBehavior: PointerDragBehavior;
  110302. private _pointerObserver;
  110303. /**
  110304. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110305. */
  110306. snapDistance: number;
  110307. /**
  110308. * Event that fires each time the gizmo snaps to a new location.
  110309. * * snapDistance is the the change in distance
  110310. */
  110311. onSnapObservable: Observable<{
  110312. snapDistance: number;
  110313. }>;
  110314. /**
  110315. * If the scaling operation should be done on all axis (default: false)
  110316. */
  110317. uniformScaling: boolean;
  110318. private _isEnabled;
  110319. private _parent;
  110320. private _arrow;
  110321. private _coloredMaterial;
  110322. private _hoverMaterial;
  110323. /**
  110324. * Creates an AxisScaleGizmo
  110325. * @param gizmoLayer The utility layer the gizmo will be added to
  110326. * @param dragAxis The axis which the gizmo will be able to scale on
  110327. * @param color The color of the gizmo
  110328. */
  110329. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110330. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110331. /**
  110332. * If the gizmo is enabled
  110333. */
  110334. isEnabled: boolean;
  110335. /**
  110336. * Disposes of the gizmo
  110337. */
  110338. dispose(): void;
  110339. /**
  110340. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110341. * @param mesh The mesh to replace the default mesh of the gizmo
  110342. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110343. */
  110344. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110345. }
  110346. }
  110347. declare module BABYLON {
  110348. /**
  110349. * Bounding box gizmo
  110350. */
  110351. export class BoundingBoxGizmo extends Gizmo {
  110352. private _lineBoundingBox;
  110353. private _rotateSpheresParent;
  110354. private _scaleBoxesParent;
  110355. private _boundingDimensions;
  110356. private _renderObserver;
  110357. private _pointerObserver;
  110358. private _scaleDragSpeed;
  110359. private _tmpQuaternion;
  110360. private _tmpVector;
  110361. private _tmpRotationMatrix;
  110362. /**
  110363. * 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)
  110364. */
  110365. ignoreChildren: boolean;
  110366. /**
  110367. * 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)
  110368. */
  110369. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110370. /**
  110371. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110372. */
  110373. rotationSphereSize: number;
  110374. /**
  110375. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110376. */
  110377. scaleBoxSize: number;
  110378. /**
  110379. * 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)
  110380. */
  110381. fixedDragMeshScreenSize: boolean;
  110382. /**
  110383. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110384. */
  110385. fixedDragMeshScreenSizeDistanceFactor: number;
  110386. /**
  110387. * Fired when a rotation sphere or scale box is dragged
  110388. */
  110389. onDragStartObservable: Observable<{}>;
  110390. /**
  110391. * Fired when a scale box is dragged
  110392. */
  110393. onScaleBoxDragObservable: Observable<{}>;
  110394. /**
  110395. * Fired when a scale box drag is ended
  110396. */
  110397. onScaleBoxDragEndObservable: Observable<{}>;
  110398. /**
  110399. * Fired when a rotation sphere is dragged
  110400. */
  110401. onRotationSphereDragObservable: Observable<{}>;
  110402. /**
  110403. * Fired when a rotation sphere drag is ended
  110404. */
  110405. onRotationSphereDragEndObservable: Observable<{}>;
  110406. /**
  110407. * 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)
  110408. */
  110409. scalePivot: Nullable<Vector3>;
  110410. /**
  110411. * Mesh used as a pivot to rotate the attached mesh
  110412. */
  110413. private _anchorMesh;
  110414. private _existingMeshScale;
  110415. private _dragMesh;
  110416. private pointerDragBehavior;
  110417. private coloredMaterial;
  110418. private hoverColoredMaterial;
  110419. /**
  110420. * Sets the color of the bounding box gizmo
  110421. * @param color the color to set
  110422. */
  110423. setColor(color: Color3): void;
  110424. /**
  110425. * Creates an BoundingBoxGizmo
  110426. * @param gizmoLayer The utility layer the gizmo will be added to
  110427. * @param color The color of the gizmo
  110428. */
  110429. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110430. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110431. private _selectNode;
  110432. /**
  110433. * Updates the bounding box information for the Gizmo
  110434. */
  110435. updateBoundingBox(): void;
  110436. private _updateRotationSpheres;
  110437. private _updateScaleBoxes;
  110438. /**
  110439. * Enables rotation on the specified axis and disables rotation on the others
  110440. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110441. */
  110442. setEnabledRotationAxis(axis: string): void;
  110443. /**
  110444. * Enables/disables scaling
  110445. * @param enable if scaling should be enabled
  110446. */
  110447. setEnabledScaling(enable: boolean): void;
  110448. private _updateDummy;
  110449. /**
  110450. * Enables a pointer drag behavior on the bounding box of the gizmo
  110451. */
  110452. enableDragBehavior(): void;
  110453. /**
  110454. * Disposes of the gizmo
  110455. */
  110456. dispose(): void;
  110457. /**
  110458. * 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)
  110459. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110460. * @returns the bounding box mesh with the passed in mesh as a child
  110461. */
  110462. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110463. /**
  110464. * CustomMeshes are not supported by this gizmo
  110465. * @param mesh The mesh to replace the default mesh of the gizmo
  110466. */
  110467. setCustomMesh(mesh: Mesh): void;
  110468. }
  110469. }
  110470. declare module BABYLON {
  110471. /**
  110472. * Single plane rotation gizmo
  110473. */
  110474. export class PlaneRotationGizmo extends Gizmo {
  110475. /**
  110476. * Drag behavior responsible for the gizmos dragging interactions
  110477. */
  110478. dragBehavior: PointerDragBehavior;
  110479. private _pointerObserver;
  110480. /**
  110481. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110482. */
  110483. snapDistance: number;
  110484. /**
  110485. * Event that fires each time the gizmo snaps to a new location.
  110486. * * snapDistance is the the change in distance
  110487. */
  110488. onSnapObservable: Observable<{
  110489. snapDistance: number;
  110490. }>;
  110491. private _isEnabled;
  110492. private _parent;
  110493. /**
  110494. * Creates a PlaneRotationGizmo
  110495. * @param gizmoLayer The utility layer the gizmo will be added to
  110496. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110497. * @param color The color of the gizmo
  110498. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110499. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110500. */
  110501. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110502. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110503. /**
  110504. * If the gizmo is enabled
  110505. */
  110506. isEnabled: boolean;
  110507. /**
  110508. * Disposes of the gizmo
  110509. */
  110510. dispose(): void;
  110511. }
  110512. }
  110513. declare module BABYLON {
  110514. /**
  110515. * Gizmo that enables rotating a mesh along 3 axis
  110516. */
  110517. export class RotationGizmo extends Gizmo {
  110518. /**
  110519. * Internal gizmo used for interactions on the x axis
  110520. */
  110521. xGizmo: PlaneRotationGizmo;
  110522. /**
  110523. * Internal gizmo used for interactions on the y axis
  110524. */
  110525. yGizmo: PlaneRotationGizmo;
  110526. /**
  110527. * Internal gizmo used for interactions on the z axis
  110528. */
  110529. zGizmo: PlaneRotationGizmo;
  110530. /** Fires an event when any of it's sub gizmos are dragged */
  110531. onDragStartObservable: Observable<unknown>;
  110532. /** Fires an event when any of it's sub gizmos are released from dragging */
  110533. onDragEndObservable: Observable<unknown>;
  110534. private _meshAttached;
  110535. attachedMesh: Nullable<AbstractMesh>;
  110536. /**
  110537. * Creates a RotationGizmo
  110538. * @param gizmoLayer The utility layer the gizmo will be added to
  110539. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110540. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110541. */
  110542. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110543. updateGizmoRotationToMatchAttachedMesh: boolean;
  110544. /**
  110545. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110546. */
  110547. snapDistance: number;
  110548. /**
  110549. * Ratio for the scale of the gizmo (Default: 1)
  110550. */
  110551. scaleRatio: number;
  110552. /**
  110553. * Disposes of the gizmo
  110554. */
  110555. dispose(): void;
  110556. /**
  110557. * CustomMeshes are not supported by this gizmo
  110558. * @param mesh The mesh to replace the default mesh of the gizmo
  110559. */
  110560. setCustomMesh(mesh: Mesh): void;
  110561. }
  110562. }
  110563. declare module BABYLON {
  110564. /**
  110565. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110566. */
  110567. export class GizmoManager implements IDisposable {
  110568. private scene;
  110569. /**
  110570. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110571. */
  110572. gizmos: {
  110573. positionGizmo: Nullable<PositionGizmo>;
  110574. rotationGizmo: Nullable<RotationGizmo>;
  110575. scaleGizmo: Nullable<ScaleGizmo>;
  110576. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110577. };
  110578. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110579. clearGizmoOnEmptyPointerEvent: boolean;
  110580. /** Fires an event when the manager is attached to a mesh */
  110581. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110582. private _gizmosEnabled;
  110583. private _pointerObserver;
  110584. private _attachedMesh;
  110585. private _boundingBoxColor;
  110586. private _defaultUtilityLayer;
  110587. private _defaultKeepDepthUtilityLayer;
  110588. /**
  110589. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110590. */
  110591. boundingBoxDragBehavior: SixDofDragBehavior;
  110592. /**
  110593. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110594. */
  110595. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110596. /**
  110597. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110598. */
  110599. usePointerToAttachGizmos: boolean;
  110600. /**
  110601. * Utility layer that the bounding box gizmo belongs to
  110602. */
  110603. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110604. /**
  110605. * Utility layer that all gizmos besides bounding box belong to
  110606. */
  110607. readonly utilityLayer: UtilityLayerRenderer;
  110608. /**
  110609. * Instatiates a gizmo manager
  110610. * @param scene the scene to overlay the gizmos on top of
  110611. */
  110612. constructor(scene: Scene);
  110613. /**
  110614. * Attaches a set of gizmos to the specified mesh
  110615. * @param mesh The mesh the gizmo's should be attached to
  110616. */
  110617. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110618. /**
  110619. * If the position gizmo is enabled
  110620. */
  110621. positionGizmoEnabled: boolean;
  110622. /**
  110623. * If the rotation gizmo is enabled
  110624. */
  110625. rotationGizmoEnabled: boolean;
  110626. /**
  110627. * If the scale gizmo is enabled
  110628. */
  110629. scaleGizmoEnabled: boolean;
  110630. /**
  110631. * If the boundingBox gizmo is enabled
  110632. */
  110633. boundingBoxGizmoEnabled: boolean;
  110634. /**
  110635. * Disposes of the gizmo manager
  110636. */
  110637. dispose(): void;
  110638. }
  110639. }
  110640. declare module BABYLON {
  110641. /**
  110642. * A directional light is defined by a direction (what a surprise!).
  110643. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110644. * 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.
  110645. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110646. */
  110647. export class DirectionalLight extends ShadowLight {
  110648. private _shadowFrustumSize;
  110649. /**
  110650. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110651. */
  110652. /**
  110653. * Specifies a fix frustum size for the shadow generation.
  110654. */
  110655. shadowFrustumSize: number;
  110656. private _shadowOrthoScale;
  110657. /**
  110658. * Gets the shadow projection scale against the optimal computed one.
  110659. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110660. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110661. */
  110662. /**
  110663. * Sets the shadow projection scale against the optimal computed one.
  110664. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110665. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110666. */
  110667. shadowOrthoScale: number;
  110668. /**
  110669. * Automatically compute the projection matrix to best fit (including all the casters)
  110670. * on each frame.
  110671. */
  110672. autoUpdateExtends: boolean;
  110673. private _orthoLeft;
  110674. private _orthoRight;
  110675. private _orthoTop;
  110676. private _orthoBottom;
  110677. /**
  110678. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110679. * The directional light is emitted from everywhere in the given direction.
  110680. * It can cast shadows.
  110681. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110682. * @param name The friendly name of the light
  110683. * @param direction The direction of the light
  110684. * @param scene The scene the light belongs to
  110685. */
  110686. constructor(name: string, direction: Vector3, scene: Scene);
  110687. /**
  110688. * Returns the string "DirectionalLight".
  110689. * @return The class name
  110690. */
  110691. getClassName(): string;
  110692. /**
  110693. * Returns the integer 1.
  110694. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110695. */
  110696. getTypeID(): number;
  110697. /**
  110698. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110699. * Returns the DirectionalLight Shadow projection matrix.
  110700. */
  110701. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110702. /**
  110703. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110704. * Returns the DirectionalLight Shadow projection matrix.
  110705. */
  110706. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110707. /**
  110708. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110709. * Returns the DirectionalLight Shadow projection matrix.
  110710. */
  110711. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110712. protected _buildUniformLayout(): void;
  110713. /**
  110714. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110715. * @param effect The effect to update
  110716. * @param lightIndex The index of the light in the effect to update
  110717. * @returns The directional light
  110718. */
  110719. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110720. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110721. /**
  110722. * Gets the minZ used for shadow according to both the scene and the light.
  110723. *
  110724. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110725. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110726. * @param activeCamera The camera we are returning the min for
  110727. * @returns the depth min z
  110728. */
  110729. getDepthMinZ(activeCamera: Camera): number;
  110730. /**
  110731. * Gets the maxZ used for shadow according to both the scene and the light.
  110732. *
  110733. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110734. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110735. * @param activeCamera The camera we are returning the max for
  110736. * @returns the depth max z
  110737. */
  110738. getDepthMaxZ(activeCamera: Camera): number;
  110739. /**
  110740. * Prepares the list of defines specific to the light type.
  110741. * @param defines the list of defines
  110742. * @param lightIndex defines the index of the light for the effect
  110743. */
  110744. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110745. }
  110746. }
  110747. declare module BABYLON {
  110748. /**
  110749. * Class containing static functions to help procedurally build meshes
  110750. */
  110751. export class HemisphereBuilder {
  110752. /**
  110753. * Creates a hemisphere mesh
  110754. * @param name defines the name of the mesh
  110755. * @param options defines the options used to create the mesh
  110756. * @param scene defines the hosting scene
  110757. * @returns the hemisphere mesh
  110758. */
  110759. static CreateHemisphere(name: string, options: {
  110760. segments?: number;
  110761. diameter?: number;
  110762. sideOrientation?: number;
  110763. }, scene: any): Mesh;
  110764. }
  110765. }
  110766. declare module BABYLON {
  110767. /**
  110768. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110769. * These values define a cone of light starting from the position, emitting toward the direction.
  110770. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110771. * and the exponent defines the speed of the decay of the light with distance (reach).
  110772. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110773. */
  110774. export class SpotLight extends ShadowLight {
  110775. private _angle;
  110776. private _innerAngle;
  110777. private _cosHalfAngle;
  110778. private _lightAngleScale;
  110779. private _lightAngleOffset;
  110780. /**
  110781. * Gets the cone angle of the spot light in Radians.
  110782. */
  110783. /**
  110784. * Sets the cone angle of the spot light in Radians.
  110785. */
  110786. angle: number;
  110787. /**
  110788. * Only used in gltf falloff mode, this defines the angle where
  110789. * the directional falloff will start before cutting at angle which could be seen
  110790. * as outer angle.
  110791. */
  110792. /**
  110793. * Only used in gltf falloff mode, this defines the angle where
  110794. * the directional falloff will start before cutting at angle which could be seen
  110795. * as outer angle.
  110796. */
  110797. innerAngle: number;
  110798. private _shadowAngleScale;
  110799. /**
  110800. * Allows scaling the angle of the light for shadow generation only.
  110801. */
  110802. /**
  110803. * Allows scaling the angle of the light for shadow generation only.
  110804. */
  110805. shadowAngleScale: number;
  110806. /**
  110807. * The light decay speed with the distance from the emission spot.
  110808. */
  110809. exponent: number;
  110810. private _projectionTextureMatrix;
  110811. /**
  110812. * Allows reading the projecton texture
  110813. */
  110814. readonly projectionTextureMatrix: Matrix;
  110815. protected _projectionTextureLightNear: number;
  110816. /**
  110817. * Gets the near clip of the Spotlight for texture projection.
  110818. */
  110819. /**
  110820. * Sets the near clip of the Spotlight for texture projection.
  110821. */
  110822. projectionTextureLightNear: number;
  110823. protected _projectionTextureLightFar: number;
  110824. /**
  110825. * Gets the far clip of the Spotlight for texture projection.
  110826. */
  110827. /**
  110828. * Sets the far clip of the Spotlight for texture projection.
  110829. */
  110830. projectionTextureLightFar: number;
  110831. protected _projectionTextureUpDirection: Vector3;
  110832. /**
  110833. * Gets the Up vector of the Spotlight for texture projection.
  110834. */
  110835. /**
  110836. * Sets the Up vector of the Spotlight for texture projection.
  110837. */
  110838. projectionTextureUpDirection: Vector3;
  110839. private _projectionTexture;
  110840. /**
  110841. * Gets the projection texture of the light.
  110842. */
  110843. /**
  110844. * Sets the projection texture of the light.
  110845. */
  110846. projectionTexture: Nullable<BaseTexture>;
  110847. private _projectionTextureViewLightDirty;
  110848. private _projectionTextureProjectionLightDirty;
  110849. private _projectionTextureDirty;
  110850. private _projectionTextureViewTargetVector;
  110851. private _projectionTextureViewLightMatrix;
  110852. private _projectionTextureProjectionLightMatrix;
  110853. private _projectionTextureScalingMatrix;
  110854. /**
  110855. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110856. * It can cast shadows.
  110857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110858. * @param name The light friendly name
  110859. * @param position The position of the spot light in the scene
  110860. * @param direction The direction of the light in the scene
  110861. * @param angle The cone angle of the light in Radians
  110862. * @param exponent The light decay speed with the distance from the emission spot
  110863. * @param scene The scene the lights belongs to
  110864. */
  110865. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110866. /**
  110867. * Returns the string "SpotLight".
  110868. * @returns the class name
  110869. */
  110870. getClassName(): string;
  110871. /**
  110872. * Returns the integer 2.
  110873. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110874. */
  110875. getTypeID(): number;
  110876. /**
  110877. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110878. */
  110879. protected _setDirection(value: Vector3): void;
  110880. /**
  110881. * Overrides the position setter to recompute the projection texture view light Matrix.
  110882. */
  110883. protected _setPosition(value: Vector3): void;
  110884. /**
  110885. * 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.
  110886. * Returns the SpotLight.
  110887. */
  110888. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110889. protected _computeProjectionTextureViewLightMatrix(): void;
  110890. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110891. /**
  110892. * Main function for light texture projection matrix computing.
  110893. */
  110894. protected _computeProjectionTextureMatrix(): void;
  110895. protected _buildUniformLayout(): void;
  110896. private _computeAngleValues;
  110897. /**
  110898. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110899. * @param effect The effect to update
  110900. * @param lightIndex The index of the light in the effect to update
  110901. * @returns The spot light
  110902. */
  110903. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110904. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110905. /**
  110906. * Disposes the light and the associated resources.
  110907. */
  110908. dispose(): void;
  110909. /**
  110910. * Prepares the list of defines specific to the light type.
  110911. * @param defines the list of defines
  110912. * @param lightIndex defines the index of the light for the effect
  110913. */
  110914. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110915. }
  110916. }
  110917. declare module BABYLON {
  110918. /**
  110919. * Gizmo that enables viewing a light
  110920. */
  110921. export class LightGizmo extends Gizmo {
  110922. private _lightMesh;
  110923. private _material;
  110924. private cachedPosition;
  110925. private cachedForward;
  110926. /**
  110927. * Creates a LightGizmo
  110928. * @param gizmoLayer The utility layer the gizmo will be added to
  110929. */
  110930. constructor(gizmoLayer?: UtilityLayerRenderer);
  110931. private _light;
  110932. /**
  110933. * The light that the gizmo is attached to
  110934. */
  110935. light: Nullable<Light>;
  110936. /**
  110937. * Gets the material used to render the light gizmo
  110938. */
  110939. readonly material: StandardMaterial;
  110940. /**
  110941. * @hidden
  110942. * Updates the gizmo to match the attached mesh's position/rotation
  110943. */
  110944. protected _update(): void;
  110945. private static _Scale;
  110946. /**
  110947. * Creates the lines for a light mesh
  110948. */
  110949. private static _createLightLines;
  110950. /**
  110951. * Disposes of the light gizmo
  110952. */
  110953. dispose(): void;
  110954. private static _CreateHemisphericLightMesh;
  110955. private static _CreatePointLightMesh;
  110956. private static _CreateSpotLightMesh;
  110957. private static _CreateDirectionalLightMesh;
  110958. }
  110959. }
  110960. declare module BABYLON {
  110961. /** @hidden */
  110962. export var backgroundFragmentDeclaration: {
  110963. name: string;
  110964. shader: string;
  110965. };
  110966. }
  110967. declare module BABYLON {
  110968. /** @hidden */
  110969. export var backgroundUboDeclaration: {
  110970. name: string;
  110971. shader: string;
  110972. };
  110973. }
  110974. declare module BABYLON {
  110975. /** @hidden */
  110976. export var backgroundPixelShader: {
  110977. name: string;
  110978. shader: string;
  110979. };
  110980. }
  110981. declare module BABYLON {
  110982. /** @hidden */
  110983. export var backgroundVertexDeclaration: {
  110984. name: string;
  110985. shader: string;
  110986. };
  110987. }
  110988. declare module BABYLON {
  110989. /** @hidden */
  110990. export var backgroundVertexShader: {
  110991. name: string;
  110992. shader: string;
  110993. };
  110994. }
  110995. declare module BABYLON {
  110996. /**
  110997. * Background material used to create an efficient environement around your scene.
  110998. */
  110999. export class BackgroundMaterial extends PushMaterial {
  111000. /**
  111001. * Standard reflectance value at parallel view angle.
  111002. */
  111003. static StandardReflectance0: number;
  111004. /**
  111005. * Standard reflectance value at grazing angle.
  111006. */
  111007. static StandardReflectance90: number;
  111008. protected _primaryColor: Color3;
  111009. /**
  111010. * Key light Color (multiply against the environement texture)
  111011. */
  111012. primaryColor: Color3;
  111013. protected __perceptualColor: Nullable<Color3>;
  111014. /**
  111015. * Experimental Internal Use Only.
  111016. *
  111017. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111018. * This acts as a helper to set the primary color to a more "human friendly" value.
  111019. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111020. * output color as close as possible from the chosen value.
  111021. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111022. * part of lighting setup.)
  111023. */
  111024. _perceptualColor: Nullable<Color3>;
  111025. protected _primaryColorShadowLevel: float;
  111026. /**
  111027. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111028. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111029. */
  111030. primaryColorShadowLevel: float;
  111031. protected _primaryColorHighlightLevel: float;
  111032. /**
  111033. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111034. * The primary color is used at the level chosen to define what the white area would look.
  111035. */
  111036. primaryColorHighlightLevel: float;
  111037. protected _reflectionTexture: Nullable<BaseTexture>;
  111038. /**
  111039. * Reflection Texture used in the material.
  111040. * Should be author in a specific way for the best result (refer to the documentation).
  111041. */
  111042. reflectionTexture: Nullable<BaseTexture>;
  111043. protected _reflectionBlur: float;
  111044. /**
  111045. * Reflection Texture level of blur.
  111046. *
  111047. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111048. * texture twice.
  111049. */
  111050. reflectionBlur: float;
  111051. protected _diffuseTexture: Nullable<BaseTexture>;
  111052. /**
  111053. * Diffuse Texture used in the material.
  111054. * Should be author in a specific way for the best result (refer to the documentation).
  111055. */
  111056. diffuseTexture: Nullable<BaseTexture>;
  111057. protected _shadowLights: Nullable<IShadowLight[]>;
  111058. /**
  111059. * Specify the list of lights casting shadow on the material.
  111060. * All scene shadow lights will be included if null.
  111061. */
  111062. shadowLights: Nullable<IShadowLight[]>;
  111063. protected _shadowLevel: float;
  111064. /**
  111065. * Helps adjusting the shadow to a softer level if required.
  111066. * 0 means black shadows and 1 means no shadows.
  111067. */
  111068. shadowLevel: float;
  111069. protected _sceneCenter: Vector3;
  111070. /**
  111071. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111072. * It is usually zero but might be interesting to modify according to your setup.
  111073. */
  111074. sceneCenter: Vector3;
  111075. protected _opacityFresnel: boolean;
  111076. /**
  111077. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111078. * This helps ensuring a nice transition when the camera goes under the ground.
  111079. */
  111080. opacityFresnel: boolean;
  111081. protected _reflectionFresnel: boolean;
  111082. /**
  111083. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111084. * This helps adding a mirror texture on the ground.
  111085. */
  111086. reflectionFresnel: boolean;
  111087. protected _reflectionFalloffDistance: number;
  111088. /**
  111089. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111090. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111091. */
  111092. reflectionFalloffDistance: number;
  111093. protected _reflectionAmount: number;
  111094. /**
  111095. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111096. */
  111097. reflectionAmount: number;
  111098. protected _reflectionReflectance0: number;
  111099. /**
  111100. * This specifies the weight of the reflection at grazing angle.
  111101. */
  111102. reflectionReflectance0: number;
  111103. protected _reflectionReflectance90: number;
  111104. /**
  111105. * This specifies the weight of the reflection at a perpendicular point of view.
  111106. */
  111107. reflectionReflectance90: number;
  111108. /**
  111109. * Sets the reflection reflectance fresnel values according to the default standard
  111110. * empirically know to work well :-)
  111111. */
  111112. reflectionStandardFresnelWeight: number;
  111113. protected _useRGBColor: boolean;
  111114. /**
  111115. * Helps to directly use the maps channels instead of their level.
  111116. */
  111117. useRGBColor: boolean;
  111118. protected _enableNoise: boolean;
  111119. /**
  111120. * This helps reducing the banding effect that could occur on the background.
  111121. */
  111122. enableNoise: boolean;
  111123. /**
  111124. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111125. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111126. * Recommended to be keep at 1.0 except for special cases.
  111127. */
  111128. fovMultiplier: number;
  111129. private _fovMultiplier;
  111130. /**
  111131. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111132. */
  111133. useEquirectangularFOV: boolean;
  111134. private _maxSimultaneousLights;
  111135. /**
  111136. * Number of Simultaneous lights allowed on the material.
  111137. */
  111138. maxSimultaneousLights: int;
  111139. /**
  111140. * Default configuration related to image processing available in the Background Material.
  111141. */
  111142. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111143. /**
  111144. * Keep track of the image processing observer to allow dispose and replace.
  111145. */
  111146. private _imageProcessingObserver;
  111147. /**
  111148. * Attaches a new image processing configuration to the PBR Material.
  111149. * @param configuration (if null the scene configuration will be use)
  111150. */
  111151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111152. /**
  111153. * Gets the image processing configuration used either in this material.
  111154. */
  111155. /**
  111156. * Sets the Default image processing configuration used either in the this material.
  111157. *
  111158. * If sets to null, the scene one is in use.
  111159. */
  111160. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111161. /**
  111162. * Gets wether the color curves effect is enabled.
  111163. */
  111164. /**
  111165. * Sets wether the color curves effect is enabled.
  111166. */
  111167. cameraColorCurvesEnabled: boolean;
  111168. /**
  111169. * Gets wether the color grading effect is enabled.
  111170. */
  111171. /**
  111172. * Gets wether the color grading effect is enabled.
  111173. */
  111174. cameraColorGradingEnabled: boolean;
  111175. /**
  111176. * Gets wether tonemapping is enabled or not.
  111177. */
  111178. /**
  111179. * Sets wether tonemapping is enabled or not
  111180. */
  111181. cameraToneMappingEnabled: boolean;
  111182. /**
  111183. * The camera exposure used on this material.
  111184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111185. * This corresponds to a photographic exposure.
  111186. */
  111187. /**
  111188. * The camera exposure used on this material.
  111189. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111190. * This corresponds to a photographic exposure.
  111191. */
  111192. cameraExposure: float;
  111193. /**
  111194. * Gets The camera contrast used on this material.
  111195. */
  111196. /**
  111197. * Sets The camera contrast used on this material.
  111198. */
  111199. cameraContrast: float;
  111200. /**
  111201. * Gets the Color Grading 2D Lookup Texture.
  111202. */
  111203. /**
  111204. * Sets the Color Grading 2D Lookup Texture.
  111205. */
  111206. cameraColorGradingTexture: Nullable<BaseTexture>;
  111207. /**
  111208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111210. * 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;
  111211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111212. */
  111213. /**
  111214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111216. * 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;
  111217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111218. */
  111219. cameraColorCurves: Nullable<ColorCurves>;
  111220. /**
  111221. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111222. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111223. */
  111224. switchToBGR: boolean;
  111225. private _renderTargets;
  111226. private _reflectionControls;
  111227. private _white;
  111228. private _primaryShadowColor;
  111229. private _primaryHighlightColor;
  111230. /**
  111231. * Instantiates a Background Material in the given scene
  111232. * @param name The friendly name of the material
  111233. * @param scene The scene to add the material to
  111234. */
  111235. constructor(name: string, scene: Scene);
  111236. /**
  111237. * Gets a boolean indicating that current material needs to register RTT
  111238. */
  111239. readonly hasRenderTargetTextures: boolean;
  111240. /**
  111241. * The entire material has been created in order to prevent overdraw.
  111242. * @returns false
  111243. */
  111244. needAlphaTesting(): boolean;
  111245. /**
  111246. * The entire material has been created in order to prevent overdraw.
  111247. * @returns true if blending is enable
  111248. */
  111249. needAlphaBlending(): boolean;
  111250. /**
  111251. * Checks wether the material is ready to be rendered for a given mesh.
  111252. * @param mesh The mesh to render
  111253. * @param subMesh The submesh to check against
  111254. * @param useInstances Specify wether or not the material is used with instances
  111255. * @returns true if all the dependencies are ready (Textures, Effects...)
  111256. */
  111257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111258. /**
  111259. * Compute the primary color according to the chosen perceptual color.
  111260. */
  111261. private _computePrimaryColorFromPerceptualColor;
  111262. /**
  111263. * Compute the highlights and shadow colors according to their chosen levels.
  111264. */
  111265. private _computePrimaryColors;
  111266. /**
  111267. * Build the uniform buffer used in the material.
  111268. */
  111269. buildUniformLayout(): void;
  111270. /**
  111271. * Unbind the material.
  111272. */
  111273. unbind(): void;
  111274. /**
  111275. * Bind only the world matrix to the material.
  111276. * @param world The world matrix to bind.
  111277. */
  111278. bindOnlyWorldMatrix(world: Matrix): void;
  111279. /**
  111280. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111281. * @param world The world matrix to bind.
  111282. * @param subMesh The submesh to bind for.
  111283. */
  111284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111285. /**
  111286. * Checks to see if a texture is used in the material.
  111287. * @param texture - Base texture to use.
  111288. * @returns - Boolean specifying if a texture is used in the material.
  111289. */
  111290. hasTexture(texture: BaseTexture): boolean;
  111291. /**
  111292. * Dispose the material.
  111293. * @param forceDisposeEffect Force disposal of the associated effect.
  111294. * @param forceDisposeTextures Force disposal of the associated textures.
  111295. */
  111296. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111297. /**
  111298. * Clones the material.
  111299. * @param name The cloned name.
  111300. * @returns The cloned material.
  111301. */
  111302. clone(name: string): BackgroundMaterial;
  111303. /**
  111304. * Serializes the current material to its JSON representation.
  111305. * @returns The JSON representation.
  111306. */
  111307. serialize(): any;
  111308. /**
  111309. * Gets the class name of the material
  111310. * @returns "BackgroundMaterial"
  111311. */
  111312. getClassName(): string;
  111313. /**
  111314. * Parse a JSON input to create back a background material.
  111315. * @param source The JSON data to parse
  111316. * @param scene The scene to create the parsed material in
  111317. * @param rootUrl The root url of the assets the material depends upon
  111318. * @returns the instantiated BackgroundMaterial.
  111319. */
  111320. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111321. }
  111322. }
  111323. declare module BABYLON {
  111324. /**
  111325. * Represents the different options available during the creation of
  111326. * a Environment helper.
  111327. *
  111328. * This can control the default ground, skybox and image processing setup of your scene.
  111329. */
  111330. export interface IEnvironmentHelperOptions {
  111331. /**
  111332. * Specifies wether or not to create a ground.
  111333. * True by default.
  111334. */
  111335. createGround: boolean;
  111336. /**
  111337. * Specifies the ground size.
  111338. * 15 by default.
  111339. */
  111340. groundSize: number;
  111341. /**
  111342. * The texture used on the ground for the main color.
  111343. * Comes from the BabylonJS CDN by default.
  111344. *
  111345. * Remarks: Can be either a texture or a url.
  111346. */
  111347. groundTexture: string | BaseTexture;
  111348. /**
  111349. * The color mixed in the ground texture by default.
  111350. * BabylonJS clearColor by default.
  111351. */
  111352. groundColor: Color3;
  111353. /**
  111354. * Specifies the ground opacity.
  111355. * 1 by default.
  111356. */
  111357. groundOpacity: number;
  111358. /**
  111359. * Enables the ground to receive shadows.
  111360. * True by default.
  111361. */
  111362. enableGroundShadow: boolean;
  111363. /**
  111364. * Helps preventing the shadow to be fully black on the ground.
  111365. * 0.5 by default.
  111366. */
  111367. groundShadowLevel: number;
  111368. /**
  111369. * Creates a mirror texture attach to the ground.
  111370. * false by default.
  111371. */
  111372. enableGroundMirror: boolean;
  111373. /**
  111374. * Specifies the ground mirror size ratio.
  111375. * 0.3 by default as the default kernel is 64.
  111376. */
  111377. groundMirrorSizeRatio: number;
  111378. /**
  111379. * Specifies the ground mirror blur kernel size.
  111380. * 64 by default.
  111381. */
  111382. groundMirrorBlurKernel: number;
  111383. /**
  111384. * Specifies the ground mirror visibility amount.
  111385. * 1 by default
  111386. */
  111387. groundMirrorAmount: number;
  111388. /**
  111389. * Specifies the ground mirror reflectance weight.
  111390. * This uses the standard weight of the background material to setup the fresnel effect
  111391. * of the mirror.
  111392. * 1 by default.
  111393. */
  111394. groundMirrorFresnelWeight: number;
  111395. /**
  111396. * Specifies the ground mirror Falloff distance.
  111397. * This can helps reducing the size of the reflection.
  111398. * 0 by Default.
  111399. */
  111400. groundMirrorFallOffDistance: number;
  111401. /**
  111402. * Specifies the ground mirror texture type.
  111403. * Unsigned Int by Default.
  111404. */
  111405. groundMirrorTextureType: number;
  111406. /**
  111407. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111408. * the shown objects.
  111409. */
  111410. groundYBias: number;
  111411. /**
  111412. * Specifies wether or not to create a skybox.
  111413. * True by default.
  111414. */
  111415. createSkybox: boolean;
  111416. /**
  111417. * Specifies the skybox size.
  111418. * 20 by default.
  111419. */
  111420. skyboxSize: number;
  111421. /**
  111422. * The texture used on the skybox for the main color.
  111423. * Comes from the BabylonJS CDN by default.
  111424. *
  111425. * Remarks: Can be either a texture or a url.
  111426. */
  111427. skyboxTexture: string | BaseTexture;
  111428. /**
  111429. * The color mixed in the skybox texture by default.
  111430. * BabylonJS clearColor by default.
  111431. */
  111432. skyboxColor: Color3;
  111433. /**
  111434. * The background rotation around the Y axis of the scene.
  111435. * This helps aligning the key lights of your scene with the background.
  111436. * 0 by default.
  111437. */
  111438. backgroundYRotation: number;
  111439. /**
  111440. * Compute automatically the size of the elements to best fit with the scene.
  111441. */
  111442. sizeAuto: boolean;
  111443. /**
  111444. * Default position of the rootMesh if autoSize is not true.
  111445. */
  111446. rootPosition: Vector3;
  111447. /**
  111448. * Sets up the image processing in the scene.
  111449. * true by default.
  111450. */
  111451. setupImageProcessing: boolean;
  111452. /**
  111453. * The texture used as your environment texture in the scene.
  111454. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111455. *
  111456. * Remarks: Can be either a texture or a url.
  111457. */
  111458. environmentTexture: string | BaseTexture;
  111459. /**
  111460. * The value of the exposure to apply to the scene.
  111461. * 0.6 by default if setupImageProcessing is true.
  111462. */
  111463. cameraExposure: number;
  111464. /**
  111465. * The value of the contrast to apply to the scene.
  111466. * 1.6 by default if setupImageProcessing is true.
  111467. */
  111468. cameraContrast: number;
  111469. /**
  111470. * Specifies wether or not tonemapping should be enabled in the scene.
  111471. * true by default if setupImageProcessing is true.
  111472. */
  111473. toneMappingEnabled: boolean;
  111474. }
  111475. /**
  111476. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111477. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111478. * It also helps with the default setup of your imageProcessing configuration.
  111479. */
  111480. export class EnvironmentHelper {
  111481. /**
  111482. * Default ground texture URL.
  111483. */
  111484. private static _groundTextureCDNUrl;
  111485. /**
  111486. * Default skybox texture URL.
  111487. */
  111488. private static _skyboxTextureCDNUrl;
  111489. /**
  111490. * Default environment texture URL.
  111491. */
  111492. private static _environmentTextureCDNUrl;
  111493. /**
  111494. * Creates the default options for the helper.
  111495. */
  111496. private static _getDefaultOptions;
  111497. private _rootMesh;
  111498. /**
  111499. * Gets the root mesh created by the helper.
  111500. */
  111501. readonly rootMesh: Mesh;
  111502. private _skybox;
  111503. /**
  111504. * Gets the skybox created by the helper.
  111505. */
  111506. readonly skybox: Nullable<Mesh>;
  111507. private _skyboxTexture;
  111508. /**
  111509. * Gets the skybox texture created by the helper.
  111510. */
  111511. readonly skyboxTexture: Nullable<BaseTexture>;
  111512. private _skyboxMaterial;
  111513. /**
  111514. * Gets the skybox material created by the helper.
  111515. */
  111516. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111517. private _ground;
  111518. /**
  111519. * Gets the ground mesh created by the helper.
  111520. */
  111521. readonly ground: Nullable<Mesh>;
  111522. private _groundTexture;
  111523. /**
  111524. * Gets the ground texture created by the helper.
  111525. */
  111526. readonly groundTexture: Nullable<BaseTexture>;
  111527. private _groundMirror;
  111528. /**
  111529. * Gets the ground mirror created by the helper.
  111530. */
  111531. readonly groundMirror: Nullable<MirrorTexture>;
  111532. /**
  111533. * Gets the ground mirror render list to helps pushing the meshes
  111534. * you wish in the ground reflection.
  111535. */
  111536. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111537. private _groundMaterial;
  111538. /**
  111539. * Gets the ground material created by the helper.
  111540. */
  111541. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111542. /**
  111543. * Stores the creation options.
  111544. */
  111545. private readonly _scene;
  111546. private _options;
  111547. /**
  111548. * This observable will be notified with any error during the creation of the environment,
  111549. * mainly texture creation errors.
  111550. */
  111551. onErrorObservable: Observable<{
  111552. message?: string;
  111553. exception?: any;
  111554. }>;
  111555. /**
  111556. * constructor
  111557. * @param options Defines the options we want to customize the helper
  111558. * @param scene The scene to add the material to
  111559. */
  111560. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111561. /**
  111562. * Updates the background according to the new options
  111563. * @param options
  111564. */
  111565. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111566. /**
  111567. * Sets the primary color of all the available elements.
  111568. * @param color the main color to affect to the ground and the background
  111569. */
  111570. setMainColor(color: Color3): void;
  111571. /**
  111572. * Setup the image processing according to the specified options.
  111573. */
  111574. private _setupImageProcessing;
  111575. /**
  111576. * Setup the environment texture according to the specified options.
  111577. */
  111578. private _setupEnvironmentTexture;
  111579. /**
  111580. * Setup the background according to the specified options.
  111581. */
  111582. private _setupBackground;
  111583. /**
  111584. * Get the scene sizes according to the setup.
  111585. */
  111586. private _getSceneSize;
  111587. /**
  111588. * Setup the ground according to the specified options.
  111589. */
  111590. private _setupGround;
  111591. /**
  111592. * Setup the ground material according to the specified options.
  111593. */
  111594. private _setupGroundMaterial;
  111595. /**
  111596. * Setup the ground diffuse texture according to the specified options.
  111597. */
  111598. private _setupGroundDiffuseTexture;
  111599. /**
  111600. * Setup the ground mirror texture according to the specified options.
  111601. */
  111602. private _setupGroundMirrorTexture;
  111603. /**
  111604. * Setup the ground to receive the mirror texture.
  111605. */
  111606. private _setupMirrorInGroundMaterial;
  111607. /**
  111608. * Setup the skybox according to the specified options.
  111609. */
  111610. private _setupSkybox;
  111611. /**
  111612. * Setup the skybox material according to the specified options.
  111613. */
  111614. private _setupSkyboxMaterial;
  111615. /**
  111616. * Setup the skybox reflection texture according to the specified options.
  111617. */
  111618. private _setupSkyboxReflectionTexture;
  111619. private _errorHandler;
  111620. /**
  111621. * Dispose all the elements created by the Helper.
  111622. */
  111623. dispose(): void;
  111624. }
  111625. }
  111626. declare module BABYLON {
  111627. /**
  111628. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111629. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111630. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111631. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111632. */
  111633. export class PhotoDome extends TransformNode {
  111634. /**
  111635. * Define the image as a Monoscopic panoramic 360 image.
  111636. */
  111637. static readonly MODE_MONOSCOPIC: number;
  111638. /**
  111639. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111640. */
  111641. static readonly MODE_TOPBOTTOM: number;
  111642. /**
  111643. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111644. */
  111645. static readonly MODE_SIDEBYSIDE: number;
  111646. private _useDirectMapping;
  111647. /**
  111648. * The texture being displayed on the sphere
  111649. */
  111650. protected _photoTexture: Texture;
  111651. /**
  111652. * Gets or sets the texture being displayed on the sphere
  111653. */
  111654. photoTexture: Texture;
  111655. /**
  111656. * Observable raised when an error occured while loading the 360 image
  111657. */
  111658. onLoadErrorObservable: Observable<string>;
  111659. /**
  111660. * The skybox material
  111661. */
  111662. protected _material: BackgroundMaterial;
  111663. /**
  111664. * The surface used for the skybox
  111665. */
  111666. protected _mesh: Mesh;
  111667. /**
  111668. * Gets the mesh used for the skybox.
  111669. */
  111670. readonly mesh: Mesh;
  111671. /**
  111672. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111673. * Also see the options.resolution property.
  111674. */
  111675. fovMultiplier: number;
  111676. private _imageMode;
  111677. /**
  111678. * Gets or set the current video mode for the video. It can be:
  111679. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111680. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111681. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111682. */
  111683. imageMode: number;
  111684. /**
  111685. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111686. * @param name Element's name, child elements will append suffixes for their own names.
  111687. * @param urlsOfPhoto defines the url of the photo to display
  111688. * @param options defines an object containing optional or exposed sub element properties
  111689. * @param onError defines a callback called when an error occured while loading the texture
  111690. */
  111691. constructor(name: string, urlOfPhoto: string, options: {
  111692. resolution?: number;
  111693. size?: number;
  111694. useDirectMapping?: boolean;
  111695. faceForward?: boolean;
  111696. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111697. private _onBeforeCameraRenderObserver;
  111698. private _changeImageMode;
  111699. /**
  111700. * Releases resources associated with this node.
  111701. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111702. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111703. */
  111704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111705. }
  111706. }
  111707. declare module BABYLON {
  111708. /**
  111709. * Class used to host RGBD texture specific utilities
  111710. */
  111711. export class RGBDTextureTools {
  111712. /**
  111713. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111714. * @param texture the texture to expand.
  111715. */
  111716. static ExpandRGBDTexture(texture: Texture): void;
  111717. }
  111718. }
  111719. declare module BABYLON {
  111720. /**
  111721. * Class used to host texture specific utilities
  111722. */
  111723. export class BRDFTextureTools {
  111724. /**
  111725. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111726. * @param scene defines the hosting scene
  111727. * @returns the environment BRDF texture
  111728. */
  111729. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111730. private static _environmentBRDFBase64Texture;
  111731. }
  111732. }
  111733. declare module BABYLON {
  111734. /**
  111735. * @hidden
  111736. */
  111737. export interface IMaterialClearCoatDefines {
  111738. CLEARCOAT: boolean;
  111739. CLEARCOAT_DEFAULTIOR: boolean;
  111740. CLEARCOAT_TEXTURE: boolean;
  111741. CLEARCOAT_TEXTUREDIRECTUV: number;
  111742. CLEARCOAT_BUMP: boolean;
  111743. CLEARCOAT_BUMPDIRECTUV: number;
  111744. CLEARCOAT_TINT: boolean;
  111745. CLEARCOAT_TINT_TEXTURE: boolean;
  111746. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111747. /** @hidden */
  111748. _areTexturesDirty: boolean;
  111749. }
  111750. /**
  111751. * Define the code related to the clear coat parameters of the pbr material.
  111752. */
  111753. export class PBRClearCoatConfiguration {
  111754. /**
  111755. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111756. * The default fits with a polyurethane material.
  111757. */
  111758. private static readonly _DefaultIndexOfRefraction;
  111759. private _isEnabled;
  111760. /**
  111761. * Defines if the clear coat is enabled in the material.
  111762. */
  111763. isEnabled: boolean;
  111764. /**
  111765. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111766. */
  111767. intensity: number;
  111768. /**
  111769. * Defines the clear coat layer roughness.
  111770. */
  111771. roughness: number;
  111772. private _indexOfRefraction;
  111773. /**
  111774. * Defines the index of refraction of the clear coat.
  111775. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111776. * The default fits with a polyurethane material.
  111777. * Changing the default value is more performance intensive.
  111778. */
  111779. indexOfRefraction: number;
  111780. private _texture;
  111781. /**
  111782. * Stores the clear coat values in a texture.
  111783. */
  111784. texture: Nullable<BaseTexture>;
  111785. private _bumpTexture;
  111786. /**
  111787. * Define the clear coat specific bump texture.
  111788. */
  111789. bumpTexture: Nullable<BaseTexture>;
  111790. private _isTintEnabled;
  111791. /**
  111792. * Defines if the clear coat tint is enabled in the material.
  111793. */
  111794. isTintEnabled: boolean;
  111795. /**
  111796. * Defines the clear coat tint of the material.
  111797. * This is only use if tint is enabled
  111798. */
  111799. tintColor: Color3;
  111800. /**
  111801. * Defines the distance at which the tint color should be found in the
  111802. * clear coat media.
  111803. * This is only use if tint is enabled
  111804. */
  111805. tintColorAtDistance: number;
  111806. /**
  111807. * Defines the clear coat layer thickness.
  111808. * This is only use if tint is enabled
  111809. */
  111810. tintThickness: number;
  111811. private _tintTexture;
  111812. /**
  111813. * Stores the clear tint values in a texture.
  111814. * rgb is tint
  111815. * a is a thickness factor
  111816. */
  111817. tintTexture: Nullable<BaseTexture>;
  111818. /** @hidden */
  111819. private _internalMarkAllSubMeshesAsTexturesDirty;
  111820. /** @hidden */
  111821. _markAllSubMeshesAsTexturesDirty(): void;
  111822. /**
  111823. * Instantiate a new istance of clear coat configuration.
  111824. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111825. */
  111826. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111827. /**
  111828. * Gets wehter the submesh is ready to be used or not.
  111829. * @param defines the list of "defines" to update.
  111830. * @param scene defines the scene the material belongs to.
  111831. * @param engine defines the engine the material belongs to.
  111832. * @param disableBumpMap defines wether the material disables bump or not.
  111833. * @returns - boolean indicating that the submesh is ready or not.
  111834. */
  111835. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111836. /**
  111837. * Checks to see if a texture is used in the material.
  111838. * @param defines the list of "defines" to update.
  111839. * @param scene defines the scene to the material belongs to.
  111840. */
  111841. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111842. /**
  111843. * Binds the material data.
  111844. * @param uniformBuffer defines the Uniform buffer to fill in.
  111845. * @param scene defines the scene the material belongs to.
  111846. * @param engine defines the engine the material belongs to.
  111847. * @param disableBumpMap defines wether the material disables bump or not.
  111848. * @param isFrozen defines wether the material is frozen or not.
  111849. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111850. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111851. */
  111852. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111853. /**
  111854. * Checks to see if a texture is used in the material.
  111855. * @param texture - Base texture to use.
  111856. * @returns - Boolean specifying if a texture is used in the material.
  111857. */
  111858. hasTexture(texture: BaseTexture): boolean;
  111859. /**
  111860. * Returns an array of the actively used textures.
  111861. * @param activeTextures Array of BaseTextures
  111862. */
  111863. getActiveTextures(activeTextures: BaseTexture[]): void;
  111864. /**
  111865. * Returns the animatable textures.
  111866. * @param animatables Array of animatable textures.
  111867. */
  111868. getAnimatables(animatables: IAnimatable[]): void;
  111869. /**
  111870. * Disposes the resources of the material.
  111871. * @param forceDisposeTextures - Forces the disposal of all textures.
  111872. */
  111873. dispose(forceDisposeTextures?: boolean): void;
  111874. /**
  111875. * Get the current class name of the texture useful for serialization or dynamic coding.
  111876. * @returns "PBRClearCoatConfiguration"
  111877. */
  111878. getClassName(): string;
  111879. /**
  111880. * Add fallbacks to the effect fallbacks list.
  111881. * @param defines defines the Base texture to use.
  111882. * @param fallbacks defines the current fallback list.
  111883. * @param currentRank defines the current fallback rank.
  111884. * @returns the new fallback rank.
  111885. */
  111886. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111887. /**
  111888. * Add the required uniforms to the current list.
  111889. * @param uniforms defines the current uniform list.
  111890. */
  111891. static AddUniforms(uniforms: string[]): void;
  111892. /**
  111893. * Add the required samplers to the current list.
  111894. * @param samplers defines the current sampler list.
  111895. */
  111896. static AddSamplers(samplers: string[]): void;
  111897. /**
  111898. * Add the required uniforms to the current buffer.
  111899. * @param uniformBuffer defines the current uniform buffer.
  111900. */
  111901. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111902. /**
  111903. * Makes a duplicate of the current configuration into another one.
  111904. * @param clearCoatConfiguration define the config where to copy the info
  111905. */
  111906. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111907. /**
  111908. * Serializes this clear coat configuration.
  111909. * @returns - An object with the serialized config.
  111910. */
  111911. serialize(): any;
  111912. /**
  111913. * Parses a anisotropy Configuration from a serialized object.
  111914. * @param source - Serialized object.
  111915. * @param scene Defines the scene we are parsing for
  111916. * @param rootUrl Defines the rootUrl to load from
  111917. */
  111918. parse(source: any, scene: Scene, rootUrl: string): void;
  111919. }
  111920. }
  111921. declare module BABYLON {
  111922. /**
  111923. * @hidden
  111924. */
  111925. export interface IMaterialAnisotropicDefines {
  111926. ANISOTROPIC: boolean;
  111927. ANISOTROPIC_TEXTURE: boolean;
  111928. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111929. MAINUV1: boolean;
  111930. _areTexturesDirty: boolean;
  111931. _needUVs: boolean;
  111932. }
  111933. /**
  111934. * Define the code related to the anisotropic parameters of the pbr material.
  111935. */
  111936. export class PBRAnisotropicConfiguration {
  111937. private _isEnabled;
  111938. /**
  111939. * Defines if the anisotropy is enabled in the material.
  111940. */
  111941. isEnabled: boolean;
  111942. /**
  111943. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111944. */
  111945. intensity: number;
  111946. /**
  111947. * Defines if the effect is along the tangents, bitangents or in between.
  111948. * By default, the effect is "strectching" the highlights along the tangents.
  111949. */
  111950. direction: Vector2;
  111951. private _texture;
  111952. /**
  111953. * Stores the anisotropy values in a texture.
  111954. * rg is direction (like normal from -1 to 1)
  111955. * b is a intensity
  111956. */
  111957. texture: Nullable<BaseTexture>;
  111958. /** @hidden */
  111959. private _internalMarkAllSubMeshesAsTexturesDirty;
  111960. /** @hidden */
  111961. _markAllSubMeshesAsTexturesDirty(): void;
  111962. /**
  111963. * Instantiate a new istance of anisotropy configuration.
  111964. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111965. */
  111966. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111967. /**
  111968. * Specifies that the submesh is ready to be used.
  111969. * @param defines the list of "defines" to update.
  111970. * @param scene defines the scene the material belongs to.
  111971. * @returns - boolean indicating that the submesh is ready or not.
  111972. */
  111973. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111974. /**
  111975. * Checks to see if a texture is used in the material.
  111976. * @param defines the list of "defines" to update.
  111977. * @param mesh the mesh we are preparing the defines for.
  111978. * @param scene defines the scene the material belongs to.
  111979. */
  111980. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111981. /**
  111982. * Binds the material data.
  111983. * @param uniformBuffer defines the Uniform buffer to fill in.
  111984. * @param scene defines the scene the material belongs to.
  111985. * @param isFrozen defines wether the material is frozen or not.
  111986. */
  111987. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111988. /**
  111989. * Checks to see if a texture is used in the material.
  111990. * @param texture - Base texture to use.
  111991. * @returns - Boolean specifying if a texture is used in the material.
  111992. */
  111993. hasTexture(texture: BaseTexture): boolean;
  111994. /**
  111995. * Returns an array of the actively used textures.
  111996. * @param activeTextures Array of BaseTextures
  111997. */
  111998. getActiveTextures(activeTextures: BaseTexture[]): void;
  111999. /**
  112000. * Returns the animatable textures.
  112001. * @param animatables Array of animatable textures.
  112002. */
  112003. getAnimatables(animatables: IAnimatable[]): void;
  112004. /**
  112005. * Disposes the resources of the material.
  112006. * @param forceDisposeTextures - Forces the disposal of all textures.
  112007. */
  112008. dispose(forceDisposeTextures?: boolean): void;
  112009. /**
  112010. * Get the current class name of the texture useful for serialization or dynamic coding.
  112011. * @returns "PBRAnisotropicConfiguration"
  112012. */
  112013. getClassName(): string;
  112014. /**
  112015. * Add fallbacks to the effect fallbacks list.
  112016. * @param defines defines the Base texture to use.
  112017. * @param fallbacks defines the current fallback list.
  112018. * @param currentRank defines the current fallback rank.
  112019. * @returns the new fallback rank.
  112020. */
  112021. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112022. /**
  112023. * Add the required uniforms to the current list.
  112024. * @param uniforms defines the current uniform list.
  112025. */
  112026. static AddUniforms(uniforms: string[]): void;
  112027. /**
  112028. * Add the required uniforms to the current buffer.
  112029. * @param uniformBuffer defines the current uniform buffer.
  112030. */
  112031. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112032. /**
  112033. * Add the required samplers to the current list.
  112034. * @param samplers defines the current sampler list.
  112035. */
  112036. static AddSamplers(samplers: string[]): void;
  112037. /**
  112038. * Makes a duplicate of the current configuration into another one.
  112039. * @param anisotropicConfiguration define the config where to copy the info
  112040. */
  112041. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112042. /**
  112043. * Serializes this anisotropy configuration.
  112044. * @returns - An object with the serialized config.
  112045. */
  112046. serialize(): any;
  112047. /**
  112048. * Parses a anisotropy Configuration from a serialized object.
  112049. * @param source - Serialized object.
  112050. * @param scene Defines the scene we are parsing for
  112051. * @param rootUrl Defines the rootUrl to load from
  112052. */
  112053. parse(source: any, scene: Scene, rootUrl: string): void;
  112054. }
  112055. }
  112056. declare module BABYLON {
  112057. /**
  112058. * @hidden
  112059. */
  112060. export interface IMaterialBRDFDefines {
  112061. BRDF_V_HEIGHT_CORRELATED: boolean;
  112062. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112063. SPHERICAL_HARMONICS: boolean;
  112064. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112065. /** @hidden */
  112066. _areMiscDirty: boolean;
  112067. }
  112068. /**
  112069. * Define the code related to the BRDF parameters of the pbr material.
  112070. */
  112071. export class PBRBRDFConfiguration {
  112072. /**
  112073. * Default value used for the energy conservation.
  112074. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112075. */
  112076. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112077. /**
  112078. * Default value used for the Smith Visibility Height Correlated mode.
  112079. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112080. */
  112081. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112082. /**
  112083. * Default value used for the IBL diffuse part.
  112084. * This can help switching back to the polynomials mode globally which is a tiny bit
  112085. * less GPU intensive at the drawback of a lower quality.
  112086. */
  112087. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112088. /**
  112089. * Default value used for activating energy conservation for the specular workflow.
  112090. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112091. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112092. */
  112093. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112094. private _useEnergyConservation;
  112095. /**
  112096. * Defines if the material uses energy conservation.
  112097. */
  112098. useEnergyConservation: boolean;
  112099. private _useSmithVisibilityHeightCorrelated;
  112100. /**
  112101. * LEGACY Mode set to false
  112102. * Defines if the material uses height smith correlated visibility term.
  112103. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112104. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112105. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112106. * Not relying on height correlated will also disable energy conservation.
  112107. */
  112108. useSmithVisibilityHeightCorrelated: boolean;
  112109. private _useSphericalHarmonics;
  112110. /**
  112111. * LEGACY Mode set to false
  112112. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112113. * diffuse part of the IBL.
  112114. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112115. * to the ground truth.
  112116. */
  112117. useSphericalHarmonics: boolean;
  112118. private _useSpecularGlossinessInputEnergyConservation;
  112119. /**
  112120. * Defines if the material uses energy conservation, when the specular workflow is active.
  112121. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112122. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112123. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112124. */
  112125. useSpecularGlossinessInputEnergyConservation: boolean;
  112126. /** @hidden */
  112127. private _internalMarkAllSubMeshesAsMiscDirty;
  112128. /** @hidden */
  112129. _markAllSubMeshesAsMiscDirty(): void;
  112130. /**
  112131. * Instantiate a new istance of clear coat configuration.
  112132. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112133. */
  112134. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112135. /**
  112136. * Checks to see if a texture is used in the material.
  112137. * @param defines the list of "defines" to update.
  112138. */
  112139. prepareDefines(defines: IMaterialBRDFDefines): void;
  112140. /**
  112141. * Get the current class name of the texture useful for serialization or dynamic coding.
  112142. * @returns "PBRClearCoatConfiguration"
  112143. */
  112144. getClassName(): string;
  112145. /**
  112146. * Makes a duplicate of the current configuration into another one.
  112147. * @param brdfConfiguration define the config where to copy the info
  112148. */
  112149. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112150. /**
  112151. * Serializes this BRDF configuration.
  112152. * @returns - An object with the serialized config.
  112153. */
  112154. serialize(): any;
  112155. /**
  112156. * Parses a anisotropy Configuration from a serialized object.
  112157. * @param source - Serialized object.
  112158. * @param scene Defines the scene we are parsing for
  112159. * @param rootUrl Defines the rootUrl to load from
  112160. */
  112161. parse(source: any, scene: Scene, rootUrl: string): void;
  112162. }
  112163. }
  112164. declare module BABYLON {
  112165. /**
  112166. * @hidden
  112167. */
  112168. export interface IMaterialSheenDefines {
  112169. SHEEN: boolean;
  112170. SHEEN_TEXTURE: boolean;
  112171. SHEEN_TEXTUREDIRECTUV: number;
  112172. SHEEN_LINKWITHALBEDO: boolean;
  112173. /** @hidden */
  112174. _areTexturesDirty: boolean;
  112175. }
  112176. /**
  112177. * Define the code related to the Sheen parameters of the pbr material.
  112178. */
  112179. export class PBRSheenConfiguration {
  112180. private _isEnabled;
  112181. /**
  112182. * Defines if the material uses sheen.
  112183. */
  112184. isEnabled: boolean;
  112185. private _linkSheenWithAlbedo;
  112186. /**
  112187. * Defines if the sheen is linked to the sheen color.
  112188. */
  112189. linkSheenWithAlbedo: boolean;
  112190. /**
  112191. * Defines the sheen intensity.
  112192. */
  112193. intensity: number;
  112194. /**
  112195. * Defines the sheen color.
  112196. */
  112197. color: Color3;
  112198. private _texture;
  112199. /**
  112200. * Stores the sheen tint values in a texture.
  112201. * rgb is tint
  112202. * a is a intensity
  112203. */
  112204. texture: Nullable<BaseTexture>;
  112205. /** @hidden */
  112206. private _internalMarkAllSubMeshesAsTexturesDirty;
  112207. /** @hidden */
  112208. _markAllSubMeshesAsTexturesDirty(): void;
  112209. /**
  112210. * Instantiate a new istance of clear coat configuration.
  112211. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112212. */
  112213. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112214. /**
  112215. * Specifies that the submesh is ready to be used.
  112216. * @param defines the list of "defines" to update.
  112217. * @param scene defines the scene the material belongs to.
  112218. * @returns - boolean indicating that the submesh is ready or not.
  112219. */
  112220. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112221. /**
  112222. * Checks to see if a texture is used in the material.
  112223. * @param defines the list of "defines" to update.
  112224. * @param scene defines the scene the material belongs to.
  112225. */
  112226. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112227. /**
  112228. * Binds the material data.
  112229. * @param uniformBuffer defines the Uniform buffer to fill in.
  112230. * @param scene defines the scene the material belongs to.
  112231. * @param isFrozen defines wether the material is frozen or not.
  112232. */
  112233. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112234. /**
  112235. * Checks to see if a texture is used in the material.
  112236. * @param texture - Base texture to use.
  112237. * @returns - Boolean specifying if a texture is used in the material.
  112238. */
  112239. hasTexture(texture: BaseTexture): boolean;
  112240. /**
  112241. * Returns an array of the actively used textures.
  112242. * @param activeTextures Array of BaseTextures
  112243. */
  112244. getActiveTextures(activeTextures: BaseTexture[]): void;
  112245. /**
  112246. * Returns the animatable textures.
  112247. * @param animatables Array of animatable textures.
  112248. */
  112249. getAnimatables(animatables: IAnimatable[]): void;
  112250. /**
  112251. * Disposes the resources of the material.
  112252. * @param forceDisposeTextures - Forces the disposal of all textures.
  112253. */
  112254. dispose(forceDisposeTextures?: boolean): void;
  112255. /**
  112256. * Get the current class name of the texture useful for serialization or dynamic coding.
  112257. * @returns "PBRSheenConfiguration"
  112258. */
  112259. getClassName(): string;
  112260. /**
  112261. * Add fallbacks to the effect fallbacks list.
  112262. * @param defines defines the Base texture to use.
  112263. * @param fallbacks defines the current fallback list.
  112264. * @param currentRank defines the current fallback rank.
  112265. * @returns the new fallback rank.
  112266. */
  112267. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112268. /**
  112269. * Add the required uniforms to the current list.
  112270. * @param uniforms defines the current uniform list.
  112271. */
  112272. static AddUniforms(uniforms: string[]): void;
  112273. /**
  112274. * Add the required uniforms to the current buffer.
  112275. * @param uniformBuffer defines the current uniform buffer.
  112276. */
  112277. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112278. /**
  112279. * Add the required samplers to the current list.
  112280. * @param samplers defines the current sampler list.
  112281. */
  112282. static AddSamplers(samplers: string[]): void;
  112283. /**
  112284. * Makes a duplicate of the current configuration into another one.
  112285. * @param sheenConfiguration define the config where to copy the info
  112286. */
  112287. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112288. /**
  112289. * Serializes this BRDF configuration.
  112290. * @returns - An object with the serialized config.
  112291. */
  112292. serialize(): any;
  112293. /**
  112294. * Parses a anisotropy Configuration from a serialized object.
  112295. * @param source - Serialized object.
  112296. * @param scene Defines the scene we are parsing for
  112297. * @param rootUrl Defines the rootUrl to load from
  112298. */
  112299. parse(source: any, scene: Scene, rootUrl: string): void;
  112300. }
  112301. }
  112302. declare module BABYLON {
  112303. /**
  112304. * @hidden
  112305. */
  112306. export interface IMaterialSubSurfaceDefines {
  112307. SUBSURFACE: boolean;
  112308. SS_REFRACTION: boolean;
  112309. SS_TRANSLUCENCY: boolean;
  112310. SS_SCATERRING: boolean;
  112311. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112312. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112313. SS_REFRACTIONMAP_3D: boolean;
  112314. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112315. SS_LODINREFRACTIONALPHA: boolean;
  112316. SS_GAMMAREFRACTION: boolean;
  112317. SS_RGBDREFRACTION: boolean;
  112318. SS_LINEARSPECULARREFRACTION: boolean;
  112319. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112320. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112321. /** @hidden */
  112322. _areTexturesDirty: boolean;
  112323. }
  112324. /**
  112325. * Define the code related to the sub surface parameters of the pbr material.
  112326. */
  112327. export class PBRSubSurfaceConfiguration {
  112328. private _isRefractionEnabled;
  112329. /**
  112330. * Defines if the refraction is enabled in the material.
  112331. */
  112332. isRefractionEnabled: boolean;
  112333. private _isTranslucencyEnabled;
  112334. /**
  112335. * Defines if the translucency is enabled in the material.
  112336. */
  112337. isTranslucencyEnabled: boolean;
  112338. private _isScatteringEnabled;
  112339. /**
  112340. * Defines the refraction intensity of the material.
  112341. * The refraction when enabled replaces the Diffuse part of the material.
  112342. * The intensity helps transitionning between diffuse and refraction.
  112343. */
  112344. refractionIntensity: number;
  112345. /**
  112346. * Defines the translucency intensity of the material.
  112347. * When translucency has been enabled, this defines how much of the "translucency"
  112348. * is addded to the diffuse part of the material.
  112349. */
  112350. translucencyIntensity: number;
  112351. /**
  112352. * Defines the scattering intensity of the material.
  112353. * When scattering has been enabled, this defines how much of the "scattered light"
  112354. * is addded to the diffuse part of the material.
  112355. */
  112356. scatteringIntensity: number;
  112357. private _thicknessTexture;
  112358. /**
  112359. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112360. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112361. * 0 would mean minimumThickness
  112362. * 1 would mean maximumThickness
  112363. * The other channels might be use as a mask to vary the different effects intensity.
  112364. */
  112365. thicknessTexture: Nullable<BaseTexture>;
  112366. private _refractionTexture;
  112367. /**
  112368. * Defines the texture to use for refraction.
  112369. */
  112370. refractionTexture: Nullable<BaseTexture>;
  112371. private _indexOfRefraction;
  112372. /**
  112373. * Defines the index of refraction used in the material.
  112374. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112375. */
  112376. indexOfRefraction: number;
  112377. private _invertRefractionY;
  112378. /**
  112379. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112380. */
  112381. invertRefractionY: boolean;
  112382. private _linkRefractionWithTransparency;
  112383. /**
  112384. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112385. * Materials half opaque for instance using refraction could benefit from this control.
  112386. */
  112387. linkRefractionWithTransparency: boolean;
  112388. /**
  112389. * Defines the minimum thickness stored in the thickness map.
  112390. * If no thickness map is defined, this value will be used to simulate thickness.
  112391. */
  112392. minimumThickness: number;
  112393. /**
  112394. * Defines the maximum thickness stored in the thickness map.
  112395. */
  112396. maximumThickness: number;
  112397. /**
  112398. * Defines the volume tint of the material.
  112399. * This is used for both translucency and scattering.
  112400. */
  112401. tintColor: Color3;
  112402. /**
  112403. * Defines the distance at which the tint color should be found in the media.
  112404. * This is used for refraction only.
  112405. */
  112406. tintColorAtDistance: number;
  112407. /**
  112408. * Defines how far each channel transmit through the media.
  112409. * It is defined as a color to simplify it selection.
  112410. */
  112411. diffusionDistance: Color3;
  112412. private _useMaskFromThicknessTexture;
  112413. /**
  112414. * Stores the intensity of the different subsurface effects in the thickness texture.
  112415. * * the green channel is the translucency intensity.
  112416. * * the blue channel is the scattering intensity.
  112417. * * the alpha channel is the refraction intensity.
  112418. */
  112419. useMaskFromThicknessTexture: boolean;
  112420. /** @hidden */
  112421. private _internalMarkAllSubMeshesAsTexturesDirty;
  112422. /** @hidden */
  112423. _markAllSubMeshesAsTexturesDirty(): void;
  112424. /**
  112425. * Instantiate a new istance of sub surface configuration.
  112426. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112427. */
  112428. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112429. /**
  112430. * Gets wehter the submesh is ready to be used or not.
  112431. * @param defines the list of "defines" to update.
  112432. * @param scene defines the scene the material belongs to.
  112433. * @returns - boolean indicating that the submesh is ready or not.
  112434. */
  112435. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112436. /**
  112437. * Checks to see if a texture is used in the material.
  112438. * @param defines the list of "defines" to update.
  112439. * @param scene defines the scene to the material belongs to.
  112440. */
  112441. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112442. /**
  112443. * Binds the material data.
  112444. * @param uniformBuffer defines the Uniform buffer to fill in.
  112445. * @param scene defines the scene the material belongs to.
  112446. * @param engine defines the engine the material belongs to.
  112447. * @param isFrozen defines wether the material is frozen or not.
  112448. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112449. */
  112450. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112451. /**
  112452. * Unbinds the material from the mesh.
  112453. * @param activeEffect defines the effect that should be unbound from.
  112454. * @returns true if unbound, otherwise false
  112455. */
  112456. unbind(activeEffect: Effect): boolean;
  112457. /**
  112458. * Returns the texture used for refraction or null if none is used.
  112459. * @param scene defines the scene the material belongs to.
  112460. * @returns - Refraction texture if present. If no refraction texture and refraction
  112461. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112462. */
  112463. private _getRefractionTexture;
  112464. /**
  112465. * Returns true if alpha blending should be disabled.
  112466. */
  112467. readonly disableAlphaBlending: boolean;
  112468. /**
  112469. * Fills the list of render target textures.
  112470. * @param renderTargets the list of render targets to update
  112471. */
  112472. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112473. /**
  112474. * Checks to see if a texture is used in the material.
  112475. * @param texture - Base texture to use.
  112476. * @returns - Boolean specifying if a texture is used in the material.
  112477. */
  112478. hasTexture(texture: BaseTexture): boolean;
  112479. /**
  112480. * Gets a boolean indicating that current material needs to register RTT
  112481. * @returns true if this uses a render target otherwise false.
  112482. */
  112483. hasRenderTargetTextures(): boolean;
  112484. /**
  112485. * Returns an array of the actively used textures.
  112486. * @param activeTextures Array of BaseTextures
  112487. */
  112488. getActiveTextures(activeTextures: BaseTexture[]): void;
  112489. /**
  112490. * Returns the animatable textures.
  112491. * @param animatables Array of animatable textures.
  112492. */
  112493. getAnimatables(animatables: IAnimatable[]): void;
  112494. /**
  112495. * Disposes the resources of the material.
  112496. * @param forceDisposeTextures - Forces the disposal of all textures.
  112497. */
  112498. dispose(forceDisposeTextures?: boolean): void;
  112499. /**
  112500. * Get the current class name of the texture useful for serialization or dynamic coding.
  112501. * @returns "PBRSubSurfaceConfiguration"
  112502. */
  112503. getClassName(): string;
  112504. /**
  112505. * Add fallbacks to the effect fallbacks list.
  112506. * @param defines defines the Base texture to use.
  112507. * @param fallbacks defines the current fallback list.
  112508. * @param currentRank defines the current fallback rank.
  112509. * @returns the new fallback rank.
  112510. */
  112511. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112512. /**
  112513. * Add the required uniforms to the current list.
  112514. * @param uniforms defines the current uniform list.
  112515. */
  112516. static AddUniforms(uniforms: string[]): void;
  112517. /**
  112518. * Add the required samplers to the current list.
  112519. * @param samplers defines the current sampler list.
  112520. */
  112521. static AddSamplers(samplers: string[]): void;
  112522. /**
  112523. * Add the required uniforms to the current buffer.
  112524. * @param uniformBuffer defines the current uniform buffer.
  112525. */
  112526. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112527. /**
  112528. * Makes a duplicate of the current configuration into another one.
  112529. * @param configuration define the config where to copy the info
  112530. */
  112531. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112532. /**
  112533. * Serializes this Sub Surface configuration.
  112534. * @returns - An object with the serialized config.
  112535. */
  112536. serialize(): any;
  112537. /**
  112538. * Parses a anisotropy Configuration from a serialized object.
  112539. * @param source - Serialized object.
  112540. * @param scene Defines the scene we are parsing for
  112541. * @param rootUrl Defines the rootUrl to load from
  112542. */
  112543. parse(source: any, scene: Scene, rootUrl: string): void;
  112544. }
  112545. }
  112546. declare module BABYLON {
  112547. /** @hidden */
  112548. export var pbrFragmentDeclaration: {
  112549. name: string;
  112550. shader: string;
  112551. };
  112552. }
  112553. declare module BABYLON {
  112554. /** @hidden */
  112555. export var pbrUboDeclaration: {
  112556. name: string;
  112557. shader: string;
  112558. };
  112559. }
  112560. declare module BABYLON {
  112561. /** @hidden */
  112562. export var pbrFragmentExtraDeclaration: {
  112563. name: string;
  112564. shader: string;
  112565. };
  112566. }
  112567. declare module BABYLON {
  112568. /** @hidden */
  112569. export var pbrFragmentSamplersDeclaration: {
  112570. name: string;
  112571. shader: string;
  112572. };
  112573. }
  112574. declare module BABYLON {
  112575. /** @hidden */
  112576. export var pbrHelperFunctions: {
  112577. name: string;
  112578. shader: string;
  112579. };
  112580. }
  112581. declare module BABYLON {
  112582. /** @hidden */
  112583. export var harmonicsFunctions: {
  112584. name: string;
  112585. shader: string;
  112586. };
  112587. }
  112588. declare module BABYLON {
  112589. /** @hidden */
  112590. export var pbrDirectLightingSetupFunctions: {
  112591. name: string;
  112592. shader: string;
  112593. };
  112594. }
  112595. declare module BABYLON {
  112596. /** @hidden */
  112597. export var pbrDirectLightingFalloffFunctions: {
  112598. name: string;
  112599. shader: string;
  112600. };
  112601. }
  112602. declare module BABYLON {
  112603. /** @hidden */
  112604. export var pbrBRDFFunctions: {
  112605. name: string;
  112606. shader: string;
  112607. };
  112608. }
  112609. declare module BABYLON {
  112610. /** @hidden */
  112611. export var pbrDirectLightingFunctions: {
  112612. name: string;
  112613. shader: string;
  112614. };
  112615. }
  112616. declare module BABYLON {
  112617. /** @hidden */
  112618. export var pbrIBLFunctions: {
  112619. name: string;
  112620. shader: string;
  112621. };
  112622. }
  112623. declare module BABYLON {
  112624. /** @hidden */
  112625. export var pbrDebug: {
  112626. name: string;
  112627. shader: string;
  112628. };
  112629. }
  112630. declare module BABYLON {
  112631. /** @hidden */
  112632. export var pbrPixelShader: {
  112633. name: string;
  112634. shader: string;
  112635. };
  112636. }
  112637. declare module BABYLON {
  112638. /** @hidden */
  112639. export var pbrVertexDeclaration: {
  112640. name: string;
  112641. shader: string;
  112642. };
  112643. }
  112644. declare module BABYLON {
  112645. /** @hidden */
  112646. export var pbrVertexShader: {
  112647. name: string;
  112648. shader: string;
  112649. };
  112650. }
  112651. declare module BABYLON {
  112652. /**
  112653. * Manages the defines for the PBR Material.
  112654. * @hidden
  112655. */
  112656. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112657. PBR: boolean;
  112658. MAINUV1: boolean;
  112659. MAINUV2: boolean;
  112660. UV1: boolean;
  112661. UV2: boolean;
  112662. ALBEDO: boolean;
  112663. ALBEDODIRECTUV: number;
  112664. VERTEXCOLOR: boolean;
  112665. AMBIENT: boolean;
  112666. AMBIENTDIRECTUV: number;
  112667. AMBIENTINGRAYSCALE: boolean;
  112668. OPACITY: boolean;
  112669. VERTEXALPHA: boolean;
  112670. OPACITYDIRECTUV: number;
  112671. OPACITYRGB: boolean;
  112672. ALPHATEST: boolean;
  112673. DEPTHPREPASS: boolean;
  112674. ALPHABLEND: boolean;
  112675. ALPHAFROMALBEDO: boolean;
  112676. ALPHATESTVALUE: string;
  112677. SPECULAROVERALPHA: boolean;
  112678. RADIANCEOVERALPHA: boolean;
  112679. ALPHAFRESNEL: boolean;
  112680. LINEARALPHAFRESNEL: boolean;
  112681. PREMULTIPLYALPHA: boolean;
  112682. EMISSIVE: boolean;
  112683. EMISSIVEDIRECTUV: number;
  112684. REFLECTIVITY: boolean;
  112685. REFLECTIVITYDIRECTUV: number;
  112686. SPECULARTERM: boolean;
  112687. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112688. MICROSURFACEAUTOMATIC: boolean;
  112689. LODBASEDMICROSFURACE: boolean;
  112690. MICROSURFACEMAP: boolean;
  112691. MICROSURFACEMAPDIRECTUV: number;
  112692. METALLICWORKFLOW: boolean;
  112693. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112694. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112695. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112696. AOSTOREINMETALMAPRED: boolean;
  112697. ENVIRONMENTBRDF: boolean;
  112698. ENVIRONMENTBRDF_RGBD: boolean;
  112699. NORMAL: boolean;
  112700. TANGENT: boolean;
  112701. BUMP: boolean;
  112702. BUMPDIRECTUV: number;
  112703. OBJECTSPACE_NORMALMAP: boolean;
  112704. PARALLAX: boolean;
  112705. PARALLAXOCCLUSION: boolean;
  112706. NORMALXYSCALE: boolean;
  112707. LIGHTMAP: boolean;
  112708. LIGHTMAPDIRECTUV: number;
  112709. USELIGHTMAPASSHADOWMAP: boolean;
  112710. GAMMALIGHTMAP: boolean;
  112711. RGBDLIGHTMAP: boolean;
  112712. REFLECTION: boolean;
  112713. REFLECTIONMAP_3D: boolean;
  112714. REFLECTIONMAP_SPHERICAL: boolean;
  112715. REFLECTIONMAP_PLANAR: boolean;
  112716. REFLECTIONMAP_CUBIC: boolean;
  112717. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112718. REFLECTIONMAP_PROJECTION: boolean;
  112719. REFLECTIONMAP_SKYBOX: boolean;
  112720. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112721. REFLECTIONMAP_EXPLICIT: boolean;
  112722. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112723. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112724. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112725. INVERTCUBICMAP: boolean;
  112726. USESPHERICALFROMREFLECTIONMAP: boolean;
  112727. USEIRRADIANCEMAP: boolean;
  112728. SPHERICAL_HARMONICS: boolean;
  112729. USESPHERICALINVERTEX: boolean;
  112730. REFLECTIONMAP_OPPOSITEZ: boolean;
  112731. LODINREFLECTIONALPHA: boolean;
  112732. GAMMAREFLECTION: boolean;
  112733. RGBDREFLECTION: boolean;
  112734. LINEARSPECULARREFLECTION: boolean;
  112735. RADIANCEOCCLUSION: boolean;
  112736. HORIZONOCCLUSION: boolean;
  112737. INSTANCES: boolean;
  112738. NUM_BONE_INFLUENCERS: number;
  112739. BonesPerMesh: number;
  112740. BONETEXTURE: boolean;
  112741. NONUNIFORMSCALING: boolean;
  112742. MORPHTARGETS: boolean;
  112743. MORPHTARGETS_NORMAL: boolean;
  112744. MORPHTARGETS_TANGENT: boolean;
  112745. MORPHTARGETS_UV: boolean;
  112746. NUM_MORPH_INFLUENCERS: number;
  112747. IMAGEPROCESSING: boolean;
  112748. VIGNETTE: boolean;
  112749. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112750. VIGNETTEBLENDMODEOPAQUE: boolean;
  112751. TONEMAPPING: boolean;
  112752. TONEMAPPING_ACES: boolean;
  112753. CONTRAST: boolean;
  112754. COLORCURVES: boolean;
  112755. COLORGRADING: boolean;
  112756. COLORGRADING3D: boolean;
  112757. SAMPLER3DGREENDEPTH: boolean;
  112758. SAMPLER3DBGRMAP: boolean;
  112759. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112760. EXPOSURE: boolean;
  112761. MULTIVIEW: boolean;
  112762. USEPHYSICALLIGHTFALLOFF: boolean;
  112763. USEGLTFLIGHTFALLOFF: boolean;
  112764. TWOSIDEDLIGHTING: boolean;
  112765. SHADOWFLOAT: boolean;
  112766. CLIPPLANE: boolean;
  112767. CLIPPLANE2: boolean;
  112768. CLIPPLANE3: boolean;
  112769. CLIPPLANE4: boolean;
  112770. POINTSIZE: boolean;
  112771. FOG: boolean;
  112772. LOGARITHMICDEPTH: boolean;
  112773. FORCENORMALFORWARD: boolean;
  112774. SPECULARAA: boolean;
  112775. CLEARCOAT: boolean;
  112776. CLEARCOAT_DEFAULTIOR: boolean;
  112777. CLEARCOAT_TEXTURE: boolean;
  112778. CLEARCOAT_TEXTUREDIRECTUV: number;
  112779. CLEARCOAT_BUMP: boolean;
  112780. CLEARCOAT_BUMPDIRECTUV: number;
  112781. CLEARCOAT_TINT: boolean;
  112782. CLEARCOAT_TINT_TEXTURE: boolean;
  112783. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112784. ANISOTROPIC: boolean;
  112785. ANISOTROPIC_TEXTURE: boolean;
  112786. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112787. BRDF_V_HEIGHT_CORRELATED: boolean;
  112788. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112789. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112790. SHEEN: boolean;
  112791. SHEEN_TEXTURE: boolean;
  112792. SHEEN_TEXTUREDIRECTUV: number;
  112793. SHEEN_LINKWITHALBEDO: boolean;
  112794. SUBSURFACE: boolean;
  112795. SS_REFRACTION: boolean;
  112796. SS_TRANSLUCENCY: boolean;
  112797. SS_SCATERRING: boolean;
  112798. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112799. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112800. SS_REFRACTIONMAP_3D: boolean;
  112801. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112802. SS_LODINREFRACTIONALPHA: boolean;
  112803. SS_GAMMAREFRACTION: boolean;
  112804. SS_RGBDREFRACTION: boolean;
  112805. SS_LINEARSPECULARREFRACTION: boolean;
  112806. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112807. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112808. UNLIT: boolean;
  112809. DEBUGMODE: number;
  112810. /**
  112811. * Initializes the PBR Material defines.
  112812. */
  112813. constructor();
  112814. /**
  112815. * Resets the PBR Material defines.
  112816. */
  112817. reset(): void;
  112818. }
  112819. /**
  112820. * The Physically based material base class of BJS.
  112821. *
  112822. * This offers the main features of a standard PBR material.
  112823. * For more information, please refer to the documentation :
  112824. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112825. */
  112826. export abstract class PBRBaseMaterial extends PushMaterial {
  112827. /**
  112828. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112829. */
  112830. static readonly PBRMATERIAL_OPAQUE: number;
  112831. /**
  112832. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112833. */
  112834. static readonly PBRMATERIAL_ALPHATEST: number;
  112835. /**
  112836. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112837. */
  112838. static readonly PBRMATERIAL_ALPHABLEND: number;
  112839. /**
  112840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112841. * They are also discarded below the alpha cutoff threshold to improve performances.
  112842. */
  112843. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112844. /**
  112845. * Defines the default value of how much AO map is occluding the analytical lights
  112846. * (point spot...).
  112847. */
  112848. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112849. /**
  112850. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112851. */
  112852. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112853. /**
  112854. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112855. * to enhance interoperability with other engines.
  112856. */
  112857. static readonly LIGHTFALLOFF_GLTF: number;
  112858. /**
  112859. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112860. * to enhance interoperability with other materials.
  112861. */
  112862. static readonly LIGHTFALLOFF_STANDARD: number;
  112863. /**
  112864. * Intensity of the direct lights e.g. the four lights available in your scene.
  112865. * This impacts both the direct diffuse and specular highlights.
  112866. */
  112867. protected _directIntensity: number;
  112868. /**
  112869. * Intensity of the emissive part of the material.
  112870. * This helps controlling the emissive effect without modifying the emissive color.
  112871. */
  112872. protected _emissiveIntensity: number;
  112873. /**
  112874. * Intensity of the environment e.g. how much the environment will light the object
  112875. * either through harmonics for rough material or through the refelction for shiny ones.
  112876. */
  112877. protected _environmentIntensity: number;
  112878. /**
  112879. * This is a special control allowing the reduction of the specular highlights coming from the
  112880. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112881. */
  112882. protected _specularIntensity: number;
  112883. /**
  112884. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112885. */
  112886. private _lightingInfos;
  112887. /**
  112888. * Debug Control allowing disabling the bump map on this material.
  112889. */
  112890. protected _disableBumpMap: boolean;
  112891. /**
  112892. * AKA Diffuse Texture in standard nomenclature.
  112893. */
  112894. protected _albedoTexture: Nullable<BaseTexture>;
  112895. /**
  112896. * AKA Occlusion Texture in other nomenclature.
  112897. */
  112898. protected _ambientTexture: Nullable<BaseTexture>;
  112899. /**
  112900. * AKA Occlusion Texture Intensity in other nomenclature.
  112901. */
  112902. protected _ambientTextureStrength: number;
  112903. /**
  112904. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112905. * 1 means it completely occludes it
  112906. * 0 mean it has no impact
  112907. */
  112908. protected _ambientTextureImpactOnAnalyticalLights: number;
  112909. /**
  112910. * Stores the alpha values in a texture.
  112911. */
  112912. protected _opacityTexture: Nullable<BaseTexture>;
  112913. /**
  112914. * Stores the reflection values in a texture.
  112915. */
  112916. protected _reflectionTexture: Nullable<BaseTexture>;
  112917. /**
  112918. * Stores the emissive values in a texture.
  112919. */
  112920. protected _emissiveTexture: Nullable<BaseTexture>;
  112921. /**
  112922. * AKA Specular texture in other nomenclature.
  112923. */
  112924. protected _reflectivityTexture: Nullable<BaseTexture>;
  112925. /**
  112926. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112927. */
  112928. protected _metallicTexture: Nullable<BaseTexture>;
  112929. /**
  112930. * Specifies the metallic scalar of the metallic/roughness workflow.
  112931. * Can also be used to scale the metalness values of the metallic texture.
  112932. */
  112933. protected _metallic: Nullable<number>;
  112934. /**
  112935. * Specifies the roughness scalar of the metallic/roughness workflow.
  112936. * Can also be used to scale the roughness values of the metallic texture.
  112937. */
  112938. protected _roughness: Nullable<number>;
  112939. /**
  112940. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112941. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112942. */
  112943. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112944. /**
  112945. * Stores surface normal data used to displace a mesh in a texture.
  112946. */
  112947. protected _bumpTexture: Nullable<BaseTexture>;
  112948. /**
  112949. * Stores the pre-calculated light information of a mesh in a texture.
  112950. */
  112951. protected _lightmapTexture: Nullable<BaseTexture>;
  112952. /**
  112953. * The color of a material in ambient lighting.
  112954. */
  112955. protected _ambientColor: Color3;
  112956. /**
  112957. * AKA Diffuse Color in other nomenclature.
  112958. */
  112959. protected _albedoColor: Color3;
  112960. /**
  112961. * AKA Specular Color in other nomenclature.
  112962. */
  112963. protected _reflectivityColor: Color3;
  112964. /**
  112965. * The color applied when light is reflected from a material.
  112966. */
  112967. protected _reflectionColor: Color3;
  112968. /**
  112969. * The color applied when light is emitted from a material.
  112970. */
  112971. protected _emissiveColor: Color3;
  112972. /**
  112973. * AKA Glossiness in other nomenclature.
  112974. */
  112975. protected _microSurface: number;
  112976. /**
  112977. * Specifies that the material will use the light map as a show map.
  112978. */
  112979. protected _useLightmapAsShadowmap: boolean;
  112980. /**
  112981. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112982. * makes the reflect vector face the model (under horizon).
  112983. */
  112984. protected _useHorizonOcclusion: boolean;
  112985. /**
  112986. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112987. * too much the area relying on ambient texture to define their ambient occlusion.
  112988. */
  112989. protected _useRadianceOcclusion: boolean;
  112990. /**
  112991. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112992. */
  112993. protected _useAlphaFromAlbedoTexture: boolean;
  112994. /**
  112995. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112996. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112997. */
  112998. protected _useSpecularOverAlpha: boolean;
  112999. /**
  113000. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113001. */
  113002. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113003. /**
  113004. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113005. */
  113006. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  113007. /**
  113008. * Specifies if the metallic texture contains the roughness information in its green channel.
  113009. */
  113010. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113011. /**
  113012. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113013. */
  113014. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113015. /**
  113016. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113017. */
  113018. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113019. /**
  113020. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113021. */
  113022. protected _useAmbientInGrayScale: boolean;
  113023. /**
  113024. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113025. * The material will try to infer what glossiness each pixel should be.
  113026. */
  113027. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113028. /**
  113029. * Defines the falloff type used in this material.
  113030. * It by default is Physical.
  113031. */
  113032. protected _lightFalloff: number;
  113033. /**
  113034. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113035. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113036. */
  113037. protected _useRadianceOverAlpha: boolean;
  113038. /**
  113039. * Allows using an object space normal map (instead of tangent space).
  113040. */
  113041. protected _useObjectSpaceNormalMap: boolean;
  113042. /**
  113043. * Allows using the bump map in parallax mode.
  113044. */
  113045. protected _useParallax: boolean;
  113046. /**
  113047. * Allows using the bump map in parallax occlusion mode.
  113048. */
  113049. protected _useParallaxOcclusion: boolean;
  113050. /**
  113051. * Controls the scale bias of the parallax mode.
  113052. */
  113053. protected _parallaxScaleBias: number;
  113054. /**
  113055. * If sets to true, disables all the lights affecting the material.
  113056. */
  113057. protected _disableLighting: boolean;
  113058. /**
  113059. * Number of Simultaneous lights allowed on the material.
  113060. */
  113061. protected _maxSimultaneousLights: number;
  113062. /**
  113063. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113064. */
  113065. protected _invertNormalMapX: boolean;
  113066. /**
  113067. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113068. */
  113069. protected _invertNormalMapY: boolean;
  113070. /**
  113071. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113072. */
  113073. protected _twoSidedLighting: boolean;
  113074. /**
  113075. * Defines the alpha limits in alpha test mode.
  113076. */
  113077. protected _alphaCutOff: number;
  113078. /**
  113079. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113080. */
  113081. protected _forceAlphaTest: boolean;
  113082. /**
  113083. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113084. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113085. */
  113086. protected _useAlphaFresnel: boolean;
  113087. /**
  113088. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113089. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113090. */
  113091. protected _useLinearAlphaFresnel: boolean;
  113092. /**
  113093. * The transparency mode of the material.
  113094. */
  113095. protected _transparencyMode: Nullable<number>;
  113096. /**
  113097. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113098. * from cos thetav and roughness:
  113099. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113100. */
  113101. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113102. /**
  113103. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113104. */
  113105. protected _forceIrradianceInFragment: boolean;
  113106. /**
  113107. * Force normal to face away from face.
  113108. */
  113109. protected _forceNormalForward: boolean;
  113110. /**
  113111. * Enables specular anti aliasing in the PBR shader.
  113112. * It will both interacts on the Geometry for analytical and IBL lighting.
  113113. * It also prefilter the roughness map based on the bump values.
  113114. */
  113115. protected _enableSpecularAntiAliasing: boolean;
  113116. /**
  113117. * Default configuration related to image processing available in the PBR Material.
  113118. */
  113119. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113120. /**
  113121. * Keep track of the image processing observer to allow dispose and replace.
  113122. */
  113123. private _imageProcessingObserver;
  113124. /**
  113125. * Attaches a new image processing configuration to the PBR Material.
  113126. * @param configuration
  113127. */
  113128. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113129. /**
  113130. * Stores the available render targets.
  113131. */
  113132. private _renderTargets;
  113133. /**
  113134. * Sets the global ambient color for the material used in lighting calculations.
  113135. */
  113136. private _globalAmbientColor;
  113137. /**
  113138. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113139. */
  113140. private _useLogarithmicDepth;
  113141. /**
  113142. * If set to true, no lighting calculations will be applied.
  113143. */
  113144. private _unlit;
  113145. private _debugMode;
  113146. /**
  113147. * @hidden
  113148. * This is reserved for the inspector.
  113149. * Defines the material debug mode.
  113150. * It helps seeing only some components of the material while troubleshooting.
  113151. */
  113152. debugMode: number;
  113153. /**
  113154. * @hidden
  113155. * This is reserved for the inspector.
  113156. * Specify from where on screen the debug mode should start.
  113157. * The value goes from -1 (full screen) to 1 (not visible)
  113158. * It helps with side by side comparison against the final render
  113159. * This defaults to -1
  113160. */
  113161. private debugLimit;
  113162. /**
  113163. * @hidden
  113164. * This is reserved for the inspector.
  113165. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113166. * You can use the factor to better multiply the final value.
  113167. */
  113168. private debugFactor;
  113169. /**
  113170. * Defines the clear coat layer parameters for the material.
  113171. */
  113172. readonly clearCoat: PBRClearCoatConfiguration;
  113173. /**
  113174. * Defines the anisotropic parameters for the material.
  113175. */
  113176. readonly anisotropy: PBRAnisotropicConfiguration;
  113177. /**
  113178. * Defines the BRDF parameters for the material.
  113179. */
  113180. readonly brdf: PBRBRDFConfiguration;
  113181. /**
  113182. * Defines the Sheen parameters for the material.
  113183. */
  113184. readonly sheen: PBRSheenConfiguration;
  113185. /**
  113186. * Defines the SubSurface parameters for the material.
  113187. */
  113188. readonly subSurface: PBRSubSurfaceConfiguration;
  113189. /**
  113190. * Custom callback helping to override the default shader used in the material.
  113191. */
  113192. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113193. protected _rebuildInParallel: boolean;
  113194. /**
  113195. * Instantiates a new PBRMaterial instance.
  113196. *
  113197. * @param name The material name
  113198. * @param scene The scene the material will be use in.
  113199. */
  113200. constructor(name: string, scene: Scene);
  113201. /**
  113202. * Gets a boolean indicating that current material needs to register RTT
  113203. */
  113204. readonly hasRenderTargetTextures: boolean;
  113205. /**
  113206. * Gets the name of the material class.
  113207. */
  113208. getClassName(): string;
  113209. /**
  113210. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113211. */
  113212. /**
  113213. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113214. */
  113215. useLogarithmicDepth: boolean;
  113216. /**
  113217. * Gets the current transparency mode.
  113218. */
  113219. /**
  113220. * Sets the transparency mode of the material.
  113221. *
  113222. * | Value | Type | Description |
  113223. * | ----- | ----------------------------------- | ----------- |
  113224. * | 0 | OPAQUE | |
  113225. * | 1 | ALPHATEST | |
  113226. * | 2 | ALPHABLEND | |
  113227. * | 3 | ALPHATESTANDBLEND | |
  113228. *
  113229. */
  113230. transparencyMode: Nullable<number>;
  113231. /**
  113232. * Returns true if alpha blending should be disabled.
  113233. */
  113234. private readonly _disableAlphaBlending;
  113235. /**
  113236. * Specifies whether or not this material should be rendered in alpha blend mode.
  113237. */
  113238. needAlphaBlending(): boolean;
  113239. /**
  113240. * Specifies if the mesh will require alpha blending.
  113241. * @param mesh - BJS mesh.
  113242. */
  113243. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113244. /**
  113245. * Specifies whether or not this material should be rendered in alpha test mode.
  113246. */
  113247. needAlphaTesting(): boolean;
  113248. /**
  113249. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113250. */
  113251. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113252. /**
  113253. * Gets the texture used for the alpha test.
  113254. */
  113255. getAlphaTestTexture(): Nullable<BaseTexture>;
  113256. /**
  113257. * Specifies that the submesh is ready to be used.
  113258. * @param mesh - BJS mesh.
  113259. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113260. * @param useInstances - Specifies that instances should be used.
  113261. * @returns - boolean indicating that the submesh is ready or not.
  113262. */
  113263. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113264. /**
  113265. * Specifies if the material uses metallic roughness workflow.
  113266. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113267. */
  113268. isMetallicWorkflow(): boolean;
  113269. private _prepareEffect;
  113270. private _prepareDefines;
  113271. /**
  113272. * Force shader compilation
  113273. */
  113274. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113275. clipPlane: boolean;
  113276. }>): void;
  113277. /**
  113278. * Initializes the uniform buffer layout for the shader.
  113279. */
  113280. buildUniformLayout(): void;
  113281. /**
  113282. * Unbinds the material from the mesh
  113283. */
  113284. unbind(): void;
  113285. /**
  113286. * Binds the submesh data.
  113287. * @param world - The world matrix.
  113288. * @param mesh - The BJS mesh.
  113289. * @param subMesh - A submesh of the BJS mesh.
  113290. */
  113291. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113292. /**
  113293. * Returns the animatable textures.
  113294. * @returns - Array of animatable textures.
  113295. */
  113296. getAnimatables(): IAnimatable[];
  113297. /**
  113298. * Returns the texture used for reflections.
  113299. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113300. */
  113301. private _getReflectionTexture;
  113302. /**
  113303. * Returns an array of the actively used textures.
  113304. * @returns - Array of BaseTextures
  113305. */
  113306. getActiveTextures(): BaseTexture[];
  113307. /**
  113308. * Checks to see if a texture is used in the material.
  113309. * @param texture - Base texture to use.
  113310. * @returns - Boolean specifying if a texture is used in the material.
  113311. */
  113312. hasTexture(texture: BaseTexture): boolean;
  113313. /**
  113314. * Disposes the resources of the material.
  113315. * @param forceDisposeEffect - Forces the disposal of effects.
  113316. * @param forceDisposeTextures - Forces the disposal of all textures.
  113317. */
  113318. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113319. }
  113320. }
  113321. declare module BABYLON {
  113322. /**
  113323. * The Physically based material of BJS.
  113324. *
  113325. * This offers the main features of a standard PBR material.
  113326. * For more information, please refer to the documentation :
  113327. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113328. */
  113329. export class PBRMaterial extends PBRBaseMaterial {
  113330. /**
  113331. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113332. */
  113333. static readonly PBRMATERIAL_OPAQUE: number;
  113334. /**
  113335. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113336. */
  113337. static readonly PBRMATERIAL_ALPHATEST: number;
  113338. /**
  113339. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113340. */
  113341. static readonly PBRMATERIAL_ALPHABLEND: number;
  113342. /**
  113343. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113344. * They are also discarded below the alpha cutoff threshold to improve performances.
  113345. */
  113346. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113347. /**
  113348. * Defines the default value of how much AO map is occluding the analytical lights
  113349. * (point spot...).
  113350. */
  113351. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113352. /**
  113353. * Intensity of the direct lights e.g. the four lights available in your scene.
  113354. * This impacts both the direct diffuse and specular highlights.
  113355. */
  113356. directIntensity: number;
  113357. /**
  113358. * Intensity of the emissive part of the material.
  113359. * This helps controlling the emissive effect without modifying the emissive color.
  113360. */
  113361. emissiveIntensity: number;
  113362. /**
  113363. * Intensity of the environment e.g. how much the environment will light the object
  113364. * either through harmonics for rough material or through the refelction for shiny ones.
  113365. */
  113366. environmentIntensity: number;
  113367. /**
  113368. * This is a special control allowing the reduction of the specular highlights coming from the
  113369. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113370. */
  113371. specularIntensity: number;
  113372. /**
  113373. * Debug Control allowing disabling the bump map on this material.
  113374. */
  113375. disableBumpMap: boolean;
  113376. /**
  113377. * AKA Diffuse Texture in standard nomenclature.
  113378. */
  113379. albedoTexture: BaseTexture;
  113380. /**
  113381. * AKA Occlusion Texture in other nomenclature.
  113382. */
  113383. ambientTexture: BaseTexture;
  113384. /**
  113385. * AKA Occlusion Texture Intensity in other nomenclature.
  113386. */
  113387. ambientTextureStrength: number;
  113388. /**
  113389. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113390. * 1 means it completely occludes it
  113391. * 0 mean it has no impact
  113392. */
  113393. ambientTextureImpactOnAnalyticalLights: number;
  113394. /**
  113395. * Stores the alpha values in a texture.
  113396. */
  113397. opacityTexture: BaseTexture;
  113398. /**
  113399. * Stores the reflection values in a texture.
  113400. */
  113401. reflectionTexture: Nullable<BaseTexture>;
  113402. /**
  113403. * Stores the emissive values in a texture.
  113404. */
  113405. emissiveTexture: BaseTexture;
  113406. /**
  113407. * AKA Specular texture in other nomenclature.
  113408. */
  113409. reflectivityTexture: BaseTexture;
  113410. /**
  113411. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113412. */
  113413. metallicTexture: BaseTexture;
  113414. /**
  113415. * Specifies the metallic scalar of the metallic/roughness workflow.
  113416. * Can also be used to scale the metalness values of the metallic texture.
  113417. */
  113418. metallic: Nullable<number>;
  113419. /**
  113420. * Specifies the roughness scalar of the metallic/roughness workflow.
  113421. * Can also be used to scale the roughness values of the metallic texture.
  113422. */
  113423. roughness: Nullable<number>;
  113424. /**
  113425. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113426. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113427. */
  113428. microSurfaceTexture: BaseTexture;
  113429. /**
  113430. * Stores surface normal data used to displace a mesh in a texture.
  113431. */
  113432. bumpTexture: BaseTexture;
  113433. /**
  113434. * Stores the pre-calculated light information of a mesh in a texture.
  113435. */
  113436. lightmapTexture: BaseTexture;
  113437. /**
  113438. * Stores the refracted light information in a texture.
  113439. */
  113440. refractionTexture: Nullable<BaseTexture>;
  113441. /**
  113442. * The color of a material in ambient lighting.
  113443. */
  113444. ambientColor: Color3;
  113445. /**
  113446. * AKA Diffuse Color in other nomenclature.
  113447. */
  113448. albedoColor: Color3;
  113449. /**
  113450. * AKA Specular Color in other nomenclature.
  113451. */
  113452. reflectivityColor: Color3;
  113453. /**
  113454. * The color reflected from the material.
  113455. */
  113456. reflectionColor: Color3;
  113457. /**
  113458. * The color emitted from the material.
  113459. */
  113460. emissiveColor: Color3;
  113461. /**
  113462. * AKA Glossiness in other nomenclature.
  113463. */
  113464. microSurface: number;
  113465. /**
  113466. * source material index of refraction (IOR)' / 'destination material IOR.
  113467. */
  113468. indexOfRefraction: number;
  113469. /**
  113470. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113471. */
  113472. invertRefractionY: boolean;
  113473. /**
  113474. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113475. * Materials half opaque for instance using refraction could benefit from this control.
  113476. */
  113477. linkRefractionWithTransparency: boolean;
  113478. /**
  113479. * If true, the light map contains occlusion information instead of lighting info.
  113480. */
  113481. useLightmapAsShadowmap: boolean;
  113482. /**
  113483. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113484. */
  113485. useAlphaFromAlbedoTexture: boolean;
  113486. /**
  113487. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113488. */
  113489. forceAlphaTest: boolean;
  113490. /**
  113491. * Defines the alpha limits in alpha test mode.
  113492. */
  113493. alphaCutOff: number;
  113494. /**
  113495. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113496. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113497. */
  113498. useSpecularOverAlpha: boolean;
  113499. /**
  113500. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113501. */
  113502. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113503. /**
  113504. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113505. */
  113506. useRoughnessFromMetallicTextureAlpha: boolean;
  113507. /**
  113508. * Specifies if the metallic texture contains the roughness information in its green channel.
  113509. */
  113510. useRoughnessFromMetallicTextureGreen: boolean;
  113511. /**
  113512. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113513. */
  113514. useMetallnessFromMetallicTextureBlue: boolean;
  113515. /**
  113516. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113517. */
  113518. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113519. /**
  113520. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113521. */
  113522. useAmbientInGrayScale: boolean;
  113523. /**
  113524. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113525. * The material will try to infer what glossiness each pixel should be.
  113526. */
  113527. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113528. /**
  113529. * BJS is using an harcoded light falloff based on a manually sets up range.
  113530. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113531. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113532. */
  113533. /**
  113534. * BJS is using an harcoded light falloff based on a manually sets up range.
  113535. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113536. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113537. */
  113538. usePhysicalLightFalloff: boolean;
  113539. /**
  113540. * In order to support the falloff compatibility with gltf, a special mode has been added
  113541. * to reproduce the gltf light falloff.
  113542. */
  113543. /**
  113544. * In order to support the falloff compatibility with gltf, a special mode has been added
  113545. * to reproduce the gltf light falloff.
  113546. */
  113547. useGLTFLightFalloff: boolean;
  113548. /**
  113549. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113550. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113551. */
  113552. useRadianceOverAlpha: boolean;
  113553. /**
  113554. * Allows using an object space normal map (instead of tangent space).
  113555. */
  113556. useObjectSpaceNormalMap: boolean;
  113557. /**
  113558. * Allows using the bump map in parallax mode.
  113559. */
  113560. useParallax: boolean;
  113561. /**
  113562. * Allows using the bump map in parallax occlusion mode.
  113563. */
  113564. useParallaxOcclusion: boolean;
  113565. /**
  113566. * Controls the scale bias of the parallax mode.
  113567. */
  113568. parallaxScaleBias: number;
  113569. /**
  113570. * If sets to true, disables all the lights affecting the material.
  113571. */
  113572. disableLighting: boolean;
  113573. /**
  113574. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113575. */
  113576. forceIrradianceInFragment: boolean;
  113577. /**
  113578. * Number of Simultaneous lights allowed on the material.
  113579. */
  113580. maxSimultaneousLights: number;
  113581. /**
  113582. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113583. */
  113584. invertNormalMapX: boolean;
  113585. /**
  113586. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113587. */
  113588. invertNormalMapY: boolean;
  113589. /**
  113590. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113591. */
  113592. twoSidedLighting: boolean;
  113593. /**
  113594. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113595. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113596. */
  113597. useAlphaFresnel: boolean;
  113598. /**
  113599. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113600. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113601. */
  113602. useLinearAlphaFresnel: boolean;
  113603. /**
  113604. * Let user defines the brdf lookup texture used for IBL.
  113605. * A default 8bit version is embedded but you could point at :
  113606. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113607. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113608. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113609. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113610. */
  113611. environmentBRDFTexture: Nullable<BaseTexture>;
  113612. /**
  113613. * Force normal to face away from face.
  113614. */
  113615. forceNormalForward: boolean;
  113616. /**
  113617. * Enables specular anti aliasing in the PBR shader.
  113618. * It will both interacts on the Geometry for analytical and IBL lighting.
  113619. * It also prefilter the roughness map based on the bump values.
  113620. */
  113621. enableSpecularAntiAliasing: boolean;
  113622. /**
  113623. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113624. * makes the reflect vector face the model (under horizon).
  113625. */
  113626. useHorizonOcclusion: boolean;
  113627. /**
  113628. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113629. * too much the area relying on ambient texture to define their ambient occlusion.
  113630. */
  113631. useRadianceOcclusion: boolean;
  113632. /**
  113633. * If set to true, no lighting calculations will be applied.
  113634. */
  113635. unlit: boolean;
  113636. /**
  113637. * Gets the image processing configuration used either in this material.
  113638. */
  113639. /**
  113640. * Sets the Default image processing configuration used either in the this material.
  113641. *
  113642. * If sets to null, the scene one is in use.
  113643. */
  113644. imageProcessingConfiguration: ImageProcessingConfiguration;
  113645. /**
  113646. * Gets wether the color curves effect is enabled.
  113647. */
  113648. /**
  113649. * Sets wether the color curves effect is enabled.
  113650. */
  113651. cameraColorCurvesEnabled: boolean;
  113652. /**
  113653. * Gets wether the color grading effect is enabled.
  113654. */
  113655. /**
  113656. * Gets wether the color grading effect is enabled.
  113657. */
  113658. cameraColorGradingEnabled: boolean;
  113659. /**
  113660. * Gets wether tonemapping is enabled or not.
  113661. */
  113662. /**
  113663. * Sets wether tonemapping is enabled or not
  113664. */
  113665. cameraToneMappingEnabled: boolean;
  113666. /**
  113667. * The camera exposure used on this material.
  113668. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113669. * This corresponds to a photographic exposure.
  113670. */
  113671. /**
  113672. * The camera exposure used on this material.
  113673. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113674. * This corresponds to a photographic exposure.
  113675. */
  113676. cameraExposure: number;
  113677. /**
  113678. * Gets The camera contrast used on this material.
  113679. */
  113680. /**
  113681. * Sets The camera contrast used on this material.
  113682. */
  113683. cameraContrast: number;
  113684. /**
  113685. * Gets the Color Grading 2D Lookup Texture.
  113686. */
  113687. /**
  113688. * Sets the Color Grading 2D Lookup Texture.
  113689. */
  113690. cameraColorGradingTexture: Nullable<BaseTexture>;
  113691. /**
  113692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113694. * 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;
  113695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113696. */
  113697. /**
  113698. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113699. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113700. * 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;
  113701. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113702. */
  113703. cameraColorCurves: Nullable<ColorCurves>;
  113704. /**
  113705. * Instantiates a new PBRMaterial instance.
  113706. *
  113707. * @param name The material name
  113708. * @param scene The scene the material will be use in.
  113709. */
  113710. constructor(name: string, scene: Scene);
  113711. /**
  113712. * Returns the name of this material class.
  113713. */
  113714. getClassName(): string;
  113715. /**
  113716. * Makes a duplicate of the current material.
  113717. * @param name - name to use for the new material.
  113718. */
  113719. clone(name: string): PBRMaterial;
  113720. /**
  113721. * Serializes this PBR Material.
  113722. * @returns - An object with the serialized material.
  113723. */
  113724. serialize(): any;
  113725. /**
  113726. * Parses a PBR Material from a serialized object.
  113727. * @param source - Serialized object.
  113728. * @param scene - BJS scene instance.
  113729. * @param rootUrl - url for the scene object
  113730. * @returns - PBRMaterial
  113731. */
  113732. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113733. }
  113734. }
  113735. declare module BABYLON {
  113736. /**
  113737. * Direct draw surface info
  113738. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113739. */
  113740. export interface DDSInfo {
  113741. /**
  113742. * Width of the texture
  113743. */
  113744. width: number;
  113745. /**
  113746. * Width of the texture
  113747. */
  113748. height: number;
  113749. /**
  113750. * Number of Mipmaps for the texture
  113751. * @see https://en.wikipedia.org/wiki/Mipmap
  113752. */
  113753. mipmapCount: number;
  113754. /**
  113755. * If the textures format is a known fourCC format
  113756. * @see https://www.fourcc.org/
  113757. */
  113758. isFourCC: boolean;
  113759. /**
  113760. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113761. */
  113762. isRGB: boolean;
  113763. /**
  113764. * If the texture is a lumincance format
  113765. */
  113766. isLuminance: boolean;
  113767. /**
  113768. * If this is a cube texture
  113769. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113770. */
  113771. isCube: boolean;
  113772. /**
  113773. * If the texture is a compressed format eg. FOURCC_DXT1
  113774. */
  113775. isCompressed: boolean;
  113776. /**
  113777. * The dxgiFormat of the texture
  113778. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113779. */
  113780. dxgiFormat: number;
  113781. /**
  113782. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113783. */
  113784. textureType: number;
  113785. /**
  113786. * Sphericle polynomial created for the dds texture
  113787. */
  113788. sphericalPolynomial?: SphericalPolynomial;
  113789. }
  113790. /**
  113791. * Class used to provide DDS decompression tools
  113792. */
  113793. export class DDSTools {
  113794. /**
  113795. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113796. */
  113797. static StoreLODInAlphaChannel: boolean;
  113798. /**
  113799. * Gets DDS information from an array buffer
  113800. * @param arrayBuffer defines the array buffer to read data from
  113801. * @returns the DDS information
  113802. */
  113803. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113804. private static _FloatView;
  113805. private static _Int32View;
  113806. private static _ToHalfFloat;
  113807. private static _FromHalfFloat;
  113808. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113809. private static _GetHalfFloatRGBAArrayBuffer;
  113810. private static _GetFloatRGBAArrayBuffer;
  113811. private static _GetFloatAsUIntRGBAArrayBuffer;
  113812. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113813. private static _GetRGBAArrayBuffer;
  113814. private static _ExtractLongWordOrder;
  113815. private static _GetRGBArrayBuffer;
  113816. private static _GetLuminanceArrayBuffer;
  113817. /**
  113818. * Uploads DDS Levels to a Babylon Texture
  113819. * @hidden
  113820. */
  113821. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113822. }
  113823. interface Engine {
  113824. /**
  113825. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113826. * @param rootUrl defines the url where the file to load is located
  113827. * @param scene defines the current scene
  113828. * @param lodScale defines scale to apply to the mip map selection
  113829. * @param lodOffset defines offset to apply to the mip map selection
  113830. * @param onLoad defines an optional callback raised when the texture is loaded
  113831. * @param onError defines an optional callback raised if there is an issue to load the texture
  113832. * @param format defines the format of the data
  113833. * @param forcedExtension defines the extension to use to pick the right loader
  113834. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113835. * @returns the cube texture as an InternalTexture
  113836. */
  113837. 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;
  113838. }
  113839. }
  113840. declare module BABYLON {
  113841. /**
  113842. * Implementation of the DDS Texture Loader.
  113843. * @hidden
  113844. */
  113845. export class _DDSTextureLoader implements IInternalTextureLoader {
  113846. /**
  113847. * Defines wether the loader supports cascade loading the different faces.
  113848. */
  113849. readonly supportCascades: boolean;
  113850. /**
  113851. * This returns if the loader support the current file information.
  113852. * @param extension defines the file extension of the file being loaded
  113853. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113854. * @param fallback defines the fallback internal texture if any
  113855. * @param isBase64 defines whether the texture is encoded as a base64
  113856. * @param isBuffer defines whether the texture data are stored as a buffer
  113857. * @returns true if the loader can load the specified file
  113858. */
  113859. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113860. /**
  113861. * Transform the url before loading if required.
  113862. * @param rootUrl the url of the texture
  113863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113864. * @returns the transformed texture
  113865. */
  113866. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113867. /**
  113868. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113869. * @param rootUrl the url of the texture
  113870. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113871. * @returns the fallback texture
  113872. */
  113873. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113874. /**
  113875. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113876. * @param data contains the texture data
  113877. * @param texture defines the BabylonJS internal texture
  113878. * @param createPolynomials will be true if polynomials have been requested
  113879. * @param onLoad defines the callback to trigger once the texture is ready
  113880. * @param onError defines the callback to trigger in case of error
  113881. */
  113882. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113883. /**
  113884. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113885. * @param data contains the texture data
  113886. * @param texture defines the BabylonJS internal texture
  113887. * @param callback defines the method to call once ready to upload
  113888. */
  113889. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113890. }
  113891. }
  113892. declare module BABYLON {
  113893. /**
  113894. * Implementation of the ENV Texture Loader.
  113895. * @hidden
  113896. */
  113897. export class _ENVTextureLoader implements IInternalTextureLoader {
  113898. /**
  113899. * Defines wether the loader supports cascade loading the different faces.
  113900. */
  113901. readonly supportCascades: boolean;
  113902. /**
  113903. * This returns if the loader support the current file information.
  113904. * @param extension defines the file extension of the file being loaded
  113905. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113906. * @param fallback defines the fallback internal texture if any
  113907. * @param isBase64 defines whether the texture is encoded as a base64
  113908. * @param isBuffer defines whether the texture data are stored as a buffer
  113909. * @returns true if the loader can load the specified file
  113910. */
  113911. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113912. /**
  113913. * Transform the url before loading if required.
  113914. * @param rootUrl the url of the texture
  113915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113916. * @returns the transformed texture
  113917. */
  113918. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113919. /**
  113920. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113921. * @param rootUrl the url of the texture
  113922. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113923. * @returns the fallback texture
  113924. */
  113925. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113926. /**
  113927. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113928. * @param data contains the texture data
  113929. * @param texture defines the BabylonJS internal texture
  113930. * @param createPolynomials will be true if polynomials have been requested
  113931. * @param onLoad defines the callback to trigger once the texture is ready
  113932. * @param onError defines the callback to trigger in case of error
  113933. */
  113934. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113935. /**
  113936. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113937. * @param data contains the texture data
  113938. * @param texture defines the BabylonJS internal texture
  113939. * @param callback defines the method to call once ready to upload
  113940. */
  113941. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113942. }
  113943. }
  113944. declare module BABYLON {
  113945. /**
  113946. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113947. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113948. */
  113949. export class KhronosTextureContainer {
  113950. /** contents of the KTX container file */
  113951. arrayBuffer: any;
  113952. private static HEADER_LEN;
  113953. private static COMPRESSED_2D;
  113954. private static COMPRESSED_3D;
  113955. private static TEX_2D;
  113956. private static TEX_3D;
  113957. /**
  113958. * Gets the openGL type
  113959. */
  113960. glType: number;
  113961. /**
  113962. * Gets the openGL type size
  113963. */
  113964. glTypeSize: number;
  113965. /**
  113966. * Gets the openGL format
  113967. */
  113968. glFormat: number;
  113969. /**
  113970. * Gets the openGL internal format
  113971. */
  113972. glInternalFormat: number;
  113973. /**
  113974. * Gets the base internal format
  113975. */
  113976. glBaseInternalFormat: number;
  113977. /**
  113978. * Gets image width in pixel
  113979. */
  113980. pixelWidth: number;
  113981. /**
  113982. * Gets image height in pixel
  113983. */
  113984. pixelHeight: number;
  113985. /**
  113986. * Gets image depth in pixels
  113987. */
  113988. pixelDepth: number;
  113989. /**
  113990. * Gets the number of array elements
  113991. */
  113992. numberOfArrayElements: number;
  113993. /**
  113994. * Gets the number of faces
  113995. */
  113996. numberOfFaces: number;
  113997. /**
  113998. * Gets the number of mipmap levels
  113999. */
  114000. numberOfMipmapLevels: number;
  114001. /**
  114002. * Gets the bytes of key value data
  114003. */
  114004. bytesOfKeyValueData: number;
  114005. /**
  114006. * Gets the load type
  114007. */
  114008. loadType: number;
  114009. /**
  114010. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114011. */
  114012. isInvalid: boolean;
  114013. /**
  114014. * Creates a new KhronosTextureContainer
  114015. * @param arrayBuffer contents of the KTX container file
  114016. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114017. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114018. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114019. */
  114020. constructor(
  114021. /** contents of the KTX container file */
  114022. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114023. /**
  114024. * Uploads KTX content to a Babylon Texture.
  114025. * It is assumed that the texture has already been created & is currently bound
  114026. * @hidden
  114027. */
  114028. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114029. private _upload2DCompressedLevels;
  114030. }
  114031. }
  114032. declare module BABYLON {
  114033. /**
  114034. * Implementation of the KTX Texture Loader.
  114035. * @hidden
  114036. */
  114037. export class _KTXTextureLoader implements IInternalTextureLoader {
  114038. /**
  114039. * Defines wether the loader supports cascade loading the different faces.
  114040. */
  114041. readonly supportCascades: boolean;
  114042. /**
  114043. * This returns if the loader support the current file information.
  114044. * @param extension defines the file extension of the file being loaded
  114045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114046. * @param fallback defines the fallback internal texture if any
  114047. * @param isBase64 defines whether the texture is encoded as a base64
  114048. * @param isBuffer defines whether the texture data are stored as a buffer
  114049. * @returns true if the loader can load the specified file
  114050. */
  114051. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114052. /**
  114053. * Transform the url before loading if required.
  114054. * @param rootUrl the url of the texture
  114055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114056. * @returns the transformed texture
  114057. */
  114058. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114059. /**
  114060. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114061. * @param rootUrl the url of the texture
  114062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114063. * @returns the fallback texture
  114064. */
  114065. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114066. /**
  114067. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114068. * @param data contains the texture data
  114069. * @param texture defines the BabylonJS internal texture
  114070. * @param createPolynomials will be true if polynomials have been requested
  114071. * @param onLoad defines the callback to trigger once the texture is ready
  114072. * @param onError defines the callback to trigger in case of error
  114073. */
  114074. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114075. /**
  114076. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114077. * @param data contains the texture data
  114078. * @param texture defines the BabylonJS internal texture
  114079. * @param callback defines the method to call once ready to upload
  114080. */
  114081. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114082. }
  114083. }
  114084. declare module BABYLON {
  114085. /**
  114086. * Options for the default xr helper
  114087. */
  114088. export class WebXRDefaultExperienceOptions {
  114089. /**
  114090. * Floor meshes that should be used for teleporting
  114091. */
  114092. floorMeshes: Array<AbstractMesh>;
  114093. }
  114094. /**
  114095. * Default experience which provides a similar setup to the previous webVRExperience
  114096. */
  114097. export class WebXRDefaultExperience {
  114098. /**
  114099. * Base experience
  114100. */
  114101. baseExperience: WebXRExperienceHelper;
  114102. /**
  114103. * Input experience extension
  114104. */
  114105. input: WebXRInput;
  114106. /**
  114107. * Loads the controller models
  114108. */
  114109. controllerModelLoader: WebXRControllerModelLoader;
  114110. /**
  114111. * Enables laser pointer and selection
  114112. */
  114113. pointerSelection: WebXRControllerPointerSelection;
  114114. /**
  114115. * Enables teleportation
  114116. */
  114117. teleportation: WebXRControllerTeleportation;
  114118. /**
  114119. * Enables ui for enetering/exiting xr
  114120. */
  114121. enterExitUI: WebXREnterExitUI;
  114122. /**
  114123. * Default output canvas xr should render to
  114124. */
  114125. outputCanvas: WebXRManagedOutputCanvas;
  114126. /**
  114127. * Creates the default xr experience
  114128. * @param scene scene
  114129. * @param options options for basic configuration
  114130. * @returns resulting WebXRDefaultExperience
  114131. */
  114132. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114133. private constructor();
  114134. /**
  114135. * DIsposes of the experience helper
  114136. */
  114137. dispose(): void;
  114138. }
  114139. }
  114140. declare module BABYLON {
  114141. /** @hidden */
  114142. export var _forceSceneHelpersToBundle: boolean;
  114143. interface Scene {
  114144. /**
  114145. * Creates a default light for the scene.
  114146. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114147. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114148. */
  114149. createDefaultLight(replace?: boolean): void;
  114150. /**
  114151. * Creates a default camera for the scene.
  114152. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114153. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114154. * @param replace has default false, when true replaces the active camera in the scene
  114155. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114156. */
  114157. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114158. /**
  114159. * Creates a default camera and a default light.
  114160. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114161. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114162. * @param replace has the default false, when true replaces the active camera/light in the scene
  114163. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114164. */
  114165. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114166. /**
  114167. * Creates a new sky box
  114168. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114169. * @param environmentTexture defines the texture to use as environment texture
  114170. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114171. * @param scale defines the overall scale of the skybox
  114172. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114173. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114174. * @returns a new mesh holding the sky box
  114175. */
  114176. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114177. /**
  114178. * Creates a new environment
  114179. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114180. * @param options defines the options you can use to configure the environment
  114181. * @returns the new EnvironmentHelper
  114182. */
  114183. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114184. /**
  114185. * Creates a new VREXperienceHelper
  114186. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114187. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114188. * @returns a new VREXperienceHelper
  114189. */
  114190. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114191. /**
  114192. * Creates a new WebXRDefaultExperience
  114193. * @see http://doc.babylonjs.com/how_to/webxr
  114194. * @param options experience options
  114195. * @returns a promise for a new WebXRDefaultExperience
  114196. */
  114197. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114198. }
  114199. }
  114200. declare module BABYLON {
  114201. /**
  114202. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114203. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114204. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114205. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114206. */
  114207. export class VideoDome extends TransformNode {
  114208. /**
  114209. * Define the video source as a Monoscopic panoramic 360 video.
  114210. */
  114211. static readonly MODE_MONOSCOPIC: number;
  114212. /**
  114213. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114214. */
  114215. static readonly MODE_TOPBOTTOM: number;
  114216. /**
  114217. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114218. */
  114219. static readonly MODE_SIDEBYSIDE: number;
  114220. private _halfDome;
  114221. private _useDirectMapping;
  114222. /**
  114223. * The video texture being displayed on the sphere
  114224. */
  114225. protected _videoTexture: VideoTexture;
  114226. /**
  114227. * Gets the video texture being displayed on the sphere
  114228. */
  114229. readonly videoTexture: VideoTexture;
  114230. /**
  114231. * The skybox material
  114232. */
  114233. protected _material: BackgroundMaterial;
  114234. /**
  114235. * The surface used for the skybox
  114236. */
  114237. protected _mesh: Mesh;
  114238. /**
  114239. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114240. */
  114241. private _halfDomeMask;
  114242. /**
  114243. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114244. * Also see the options.resolution property.
  114245. */
  114246. fovMultiplier: number;
  114247. private _videoMode;
  114248. /**
  114249. * Gets or set the current video mode for the video. It can be:
  114250. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114251. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114252. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114253. */
  114254. videoMode: number;
  114255. /**
  114256. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114257. *
  114258. */
  114259. /**
  114260. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114261. */
  114262. halfDome: boolean;
  114263. /**
  114264. * Oberserver used in Stereoscopic VR Mode.
  114265. */
  114266. private _onBeforeCameraRenderObserver;
  114267. /**
  114268. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114269. * @param name Element's name, child elements will append suffixes for their own names.
  114270. * @param urlsOrVideo defines the url(s) or the video element to use
  114271. * @param options An object containing optional or exposed sub element properties
  114272. */
  114273. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114274. resolution?: number;
  114275. clickToPlay?: boolean;
  114276. autoPlay?: boolean;
  114277. loop?: boolean;
  114278. size?: number;
  114279. poster?: string;
  114280. faceForward?: boolean;
  114281. useDirectMapping?: boolean;
  114282. halfDomeMode?: boolean;
  114283. }, scene: Scene);
  114284. private _changeVideoMode;
  114285. /**
  114286. * Releases resources associated with this node.
  114287. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114288. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114289. */
  114290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114291. }
  114292. }
  114293. declare module BABYLON {
  114294. /**
  114295. * This class can be used to get instrumentation data from a Babylon engine
  114296. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114297. */
  114298. export class EngineInstrumentation implements IDisposable {
  114299. /**
  114300. * Define the instrumented engine.
  114301. */
  114302. engine: Engine;
  114303. private _captureGPUFrameTime;
  114304. private _gpuFrameTimeToken;
  114305. private _gpuFrameTime;
  114306. private _captureShaderCompilationTime;
  114307. private _shaderCompilationTime;
  114308. private _onBeginFrameObserver;
  114309. private _onEndFrameObserver;
  114310. private _onBeforeShaderCompilationObserver;
  114311. private _onAfterShaderCompilationObserver;
  114312. /**
  114313. * Gets the perf counter used for GPU frame time
  114314. */
  114315. readonly gpuFrameTimeCounter: PerfCounter;
  114316. /**
  114317. * Gets the GPU frame time capture status
  114318. */
  114319. /**
  114320. * Enable or disable the GPU frame time capture
  114321. */
  114322. captureGPUFrameTime: boolean;
  114323. /**
  114324. * Gets the perf counter used for shader compilation time
  114325. */
  114326. readonly shaderCompilationTimeCounter: PerfCounter;
  114327. /**
  114328. * Gets the shader compilation time capture status
  114329. */
  114330. /**
  114331. * Enable or disable the shader compilation time capture
  114332. */
  114333. captureShaderCompilationTime: boolean;
  114334. /**
  114335. * Instantiates a new engine instrumentation.
  114336. * This class can be used to get instrumentation data from a Babylon engine
  114337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114338. * @param engine Defines the engine to instrument
  114339. */
  114340. constructor(
  114341. /**
  114342. * Define the instrumented engine.
  114343. */
  114344. engine: Engine);
  114345. /**
  114346. * Dispose and release associated resources.
  114347. */
  114348. dispose(): void;
  114349. }
  114350. }
  114351. declare module BABYLON {
  114352. /**
  114353. * This class can be used to get instrumentation data from a Babylon engine
  114354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114355. */
  114356. export class SceneInstrumentation implements IDisposable {
  114357. /**
  114358. * Defines the scene to instrument
  114359. */
  114360. scene: Scene;
  114361. private _captureActiveMeshesEvaluationTime;
  114362. private _activeMeshesEvaluationTime;
  114363. private _captureRenderTargetsRenderTime;
  114364. private _renderTargetsRenderTime;
  114365. private _captureFrameTime;
  114366. private _frameTime;
  114367. private _captureRenderTime;
  114368. private _renderTime;
  114369. private _captureInterFrameTime;
  114370. private _interFrameTime;
  114371. private _captureParticlesRenderTime;
  114372. private _particlesRenderTime;
  114373. private _captureSpritesRenderTime;
  114374. private _spritesRenderTime;
  114375. private _capturePhysicsTime;
  114376. private _physicsTime;
  114377. private _captureAnimationsTime;
  114378. private _animationsTime;
  114379. private _captureCameraRenderTime;
  114380. private _cameraRenderTime;
  114381. private _onBeforeActiveMeshesEvaluationObserver;
  114382. private _onAfterActiveMeshesEvaluationObserver;
  114383. private _onBeforeRenderTargetsRenderObserver;
  114384. private _onAfterRenderTargetsRenderObserver;
  114385. private _onAfterRenderObserver;
  114386. private _onBeforeDrawPhaseObserver;
  114387. private _onAfterDrawPhaseObserver;
  114388. private _onBeforeAnimationsObserver;
  114389. private _onBeforeParticlesRenderingObserver;
  114390. private _onAfterParticlesRenderingObserver;
  114391. private _onBeforeSpritesRenderingObserver;
  114392. private _onAfterSpritesRenderingObserver;
  114393. private _onBeforePhysicsObserver;
  114394. private _onAfterPhysicsObserver;
  114395. private _onAfterAnimationsObserver;
  114396. private _onBeforeCameraRenderObserver;
  114397. private _onAfterCameraRenderObserver;
  114398. /**
  114399. * Gets the perf counter used for active meshes evaluation time
  114400. */
  114401. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114402. /**
  114403. * Gets the active meshes evaluation time capture status
  114404. */
  114405. /**
  114406. * Enable or disable the active meshes evaluation time capture
  114407. */
  114408. captureActiveMeshesEvaluationTime: boolean;
  114409. /**
  114410. * Gets the perf counter used for render targets render time
  114411. */
  114412. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114413. /**
  114414. * Gets the render targets render time capture status
  114415. */
  114416. /**
  114417. * Enable or disable the render targets render time capture
  114418. */
  114419. captureRenderTargetsRenderTime: boolean;
  114420. /**
  114421. * Gets the perf counter used for particles render time
  114422. */
  114423. readonly particlesRenderTimeCounter: PerfCounter;
  114424. /**
  114425. * Gets the particles render time capture status
  114426. */
  114427. /**
  114428. * Enable or disable the particles render time capture
  114429. */
  114430. captureParticlesRenderTime: boolean;
  114431. /**
  114432. * Gets the perf counter used for sprites render time
  114433. */
  114434. readonly spritesRenderTimeCounter: PerfCounter;
  114435. /**
  114436. * Gets the sprites render time capture status
  114437. */
  114438. /**
  114439. * Enable or disable the sprites render time capture
  114440. */
  114441. captureSpritesRenderTime: boolean;
  114442. /**
  114443. * Gets the perf counter used for physics time
  114444. */
  114445. readonly physicsTimeCounter: PerfCounter;
  114446. /**
  114447. * Gets the physics time capture status
  114448. */
  114449. /**
  114450. * Enable or disable the physics time capture
  114451. */
  114452. capturePhysicsTime: boolean;
  114453. /**
  114454. * Gets the perf counter used for animations time
  114455. */
  114456. readonly animationsTimeCounter: PerfCounter;
  114457. /**
  114458. * Gets the animations time capture status
  114459. */
  114460. /**
  114461. * Enable or disable the animations time capture
  114462. */
  114463. captureAnimationsTime: boolean;
  114464. /**
  114465. * Gets the perf counter used for frame time capture
  114466. */
  114467. readonly frameTimeCounter: PerfCounter;
  114468. /**
  114469. * Gets the frame time capture status
  114470. */
  114471. /**
  114472. * Enable or disable the frame time capture
  114473. */
  114474. captureFrameTime: boolean;
  114475. /**
  114476. * Gets the perf counter used for inter-frames time capture
  114477. */
  114478. readonly interFrameTimeCounter: PerfCounter;
  114479. /**
  114480. * Gets the inter-frames time capture status
  114481. */
  114482. /**
  114483. * Enable or disable the inter-frames time capture
  114484. */
  114485. captureInterFrameTime: boolean;
  114486. /**
  114487. * Gets the perf counter used for render time capture
  114488. */
  114489. readonly renderTimeCounter: PerfCounter;
  114490. /**
  114491. * Gets the render time capture status
  114492. */
  114493. /**
  114494. * Enable or disable the render time capture
  114495. */
  114496. captureRenderTime: boolean;
  114497. /**
  114498. * Gets the perf counter used for camera render time capture
  114499. */
  114500. readonly cameraRenderTimeCounter: PerfCounter;
  114501. /**
  114502. * Gets the camera render time capture status
  114503. */
  114504. /**
  114505. * Enable or disable the camera render time capture
  114506. */
  114507. captureCameraRenderTime: boolean;
  114508. /**
  114509. * Gets the perf counter used for draw calls
  114510. */
  114511. readonly drawCallsCounter: PerfCounter;
  114512. /**
  114513. * Instantiates a new scene instrumentation.
  114514. * This class can be used to get instrumentation data from a Babylon engine
  114515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114516. * @param scene Defines the scene to instrument
  114517. */
  114518. constructor(
  114519. /**
  114520. * Defines the scene to instrument
  114521. */
  114522. scene: Scene);
  114523. /**
  114524. * Dispose and release associated resources.
  114525. */
  114526. dispose(): void;
  114527. }
  114528. }
  114529. declare module BABYLON {
  114530. /** @hidden */
  114531. export var glowMapGenerationPixelShader: {
  114532. name: string;
  114533. shader: string;
  114534. };
  114535. }
  114536. declare module BABYLON {
  114537. /** @hidden */
  114538. export var glowMapGenerationVertexShader: {
  114539. name: string;
  114540. shader: string;
  114541. };
  114542. }
  114543. declare module BABYLON {
  114544. /**
  114545. * Effect layer options. This helps customizing the behaviour
  114546. * of the effect layer.
  114547. */
  114548. export interface IEffectLayerOptions {
  114549. /**
  114550. * Multiplication factor apply to the canvas size to compute the render target size
  114551. * used to generated the objects (the smaller the faster).
  114552. */
  114553. mainTextureRatio: number;
  114554. /**
  114555. * Enforces a fixed size texture to ensure effect stability across devices.
  114556. */
  114557. mainTextureFixedSize?: number;
  114558. /**
  114559. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114560. */
  114561. alphaBlendingMode: number;
  114562. /**
  114563. * The camera attached to the layer.
  114564. */
  114565. camera: Nullable<Camera>;
  114566. /**
  114567. * The rendering group to draw the layer in.
  114568. */
  114569. renderingGroupId: number;
  114570. }
  114571. /**
  114572. * The effect layer Helps adding post process effect blended with the main pass.
  114573. *
  114574. * This can be for instance use to generate glow or higlight effects on the scene.
  114575. *
  114576. * The effect layer class can not be used directly and is intented to inherited from to be
  114577. * customized per effects.
  114578. */
  114579. export abstract class EffectLayer {
  114580. private _vertexBuffers;
  114581. private _indexBuffer;
  114582. private _cachedDefines;
  114583. private _effectLayerMapGenerationEffect;
  114584. private _effectLayerOptions;
  114585. private _mergeEffect;
  114586. protected _scene: Scene;
  114587. protected _engine: Engine;
  114588. protected _maxSize: number;
  114589. protected _mainTextureDesiredSize: ISize;
  114590. protected _mainTexture: RenderTargetTexture;
  114591. protected _shouldRender: boolean;
  114592. protected _postProcesses: PostProcess[];
  114593. protected _textures: BaseTexture[];
  114594. protected _emissiveTextureAndColor: {
  114595. texture: Nullable<BaseTexture>;
  114596. color: Color4;
  114597. };
  114598. /**
  114599. * The name of the layer
  114600. */
  114601. name: string;
  114602. /**
  114603. * The clear color of the texture used to generate the glow map.
  114604. */
  114605. neutralColor: Color4;
  114606. /**
  114607. * Specifies wether the highlight layer is enabled or not.
  114608. */
  114609. isEnabled: boolean;
  114610. /**
  114611. * Gets the camera attached to the layer.
  114612. */
  114613. readonly camera: Nullable<Camera>;
  114614. /**
  114615. * Gets the rendering group id the layer should render in.
  114616. */
  114617. renderingGroupId: number;
  114618. /**
  114619. * An event triggered when the effect layer has been disposed.
  114620. */
  114621. onDisposeObservable: Observable<EffectLayer>;
  114622. /**
  114623. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114624. */
  114625. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114626. /**
  114627. * An event triggered when the generated texture is being merged in the scene.
  114628. */
  114629. onBeforeComposeObservable: Observable<EffectLayer>;
  114630. /**
  114631. * An event triggered when the generated texture has been merged in the scene.
  114632. */
  114633. onAfterComposeObservable: Observable<EffectLayer>;
  114634. /**
  114635. * An event triggered when the efffect layer changes its size.
  114636. */
  114637. onSizeChangedObservable: Observable<EffectLayer>;
  114638. /** @hidden */
  114639. static _SceneComponentInitialization: (scene: Scene) => void;
  114640. /**
  114641. * Instantiates a new effect Layer and references it in the scene.
  114642. * @param name The name of the layer
  114643. * @param scene The scene to use the layer in
  114644. */
  114645. constructor(
  114646. /** The Friendly of the effect in the scene */
  114647. name: string, scene: Scene);
  114648. /**
  114649. * Get the effect name of the layer.
  114650. * @return The effect name
  114651. */
  114652. abstract getEffectName(): string;
  114653. /**
  114654. * Checks for the readiness of the element composing the layer.
  114655. * @param subMesh the mesh to check for
  114656. * @param useInstances specify wether or not to use instances to render the mesh
  114657. * @return true if ready otherwise, false
  114658. */
  114659. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114660. /**
  114661. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114662. * @returns true if the effect requires stencil during the main canvas render pass.
  114663. */
  114664. abstract needStencil(): boolean;
  114665. /**
  114666. * Create the merge effect. This is the shader use to blit the information back
  114667. * to the main canvas at the end of the scene rendering.
  114668. * @returns The effect containing the shader used to merge the effect on the main canvas
  114669. */
  114670. protected abstract _createMergeEffect(): Effect;
  114671. /**
  114672. * Creates the render target textures and post processes used in the effect layer.
  114673. */
  114674. protected abstract _createTextureAndPostProcesses(): void;
  114675. /**
  114676. * Implementation specific of rendering the generating effect on the main canvas.
  114677. * @param effect The effect used to render through
  114678. */
  114679. protected abstract _internalRender(effect: Effect): void;
  114680. /**
  114681. * Sets the required values for both the emissive texture and and the main color.
  114682. */
  114683. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114684. /**
  114685. * Free any resources and references associated to a mesh.
  114686. * Internal use
  114687. * @param mesh The mesh to free.
  114688. */
  114689. abstract _disposeMesh(mesh: Mesh): void;
  114690. /**
  114691. * Serializes this layer (Glow or Highlight for example)
  114692. * @returns a serialized layer object
  114693. */
  114694. abstract serialize?(): any;
  114695. /**
  114696. * Initializes the effect layer with the required options.
  114697. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114698. */
  114699. protected _init(options: Partial<IEffectLayerOptions>): void;
  114700. /**
  114701. * Generates the index buffer of the full screen quad blending to the main canvas.
  114702. */
  114703. private _generateIndexBuffer;
  114704. /**
  114705. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114706. */
  114707. private _generateVertexBuffer;
  114708. /**
  114709. * Sets the main texture desired size which is the closest power of two
  114710. * of the engine canvas size.
  114711. */
  114712. private _setMainTextureSize;
  114713. /**
  114714. * Creates the main texture for the effect layer.
  114715. */
  114716. protected _createMainTexture(): void;
  114717. /**
  114718. * Adds specific effects defines.
  114719. * @param defines The defines to add specifics to.
  114720. */
  114721. protected _addCustomEffectDefines(defines: string[]): void;
  114722. /**
  114723. * Checks for the readiness of the element composing the layer.
  114724. * @param subMesh the mesh to check for
  114725. * @param useInstances specify wether or not to use instances to render the mesh
  114726. * @param emissiveTexture the associated emissive texture used to generate the glow
  114727. * @return true if ready otherwise, false
  114728. */
  114729. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114730. /**
  114731. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114732. */
  114733. render(): void;
  114734. /**
  114735. * Determine if a given mesh will be used in the current effect.
  114736. * @param mesh mesh to test
  114737. * @returns true if the mesh will be used
  114738. */
  114739. hasMesh(mesh: AbstractMesh): boolean;
  114740. /**
  114741. * Returns true if the layer contains information to display, otherwise false.
  114742. * @returns true if the glow layer should be rendered
  114743. */
  114744. shouldRender(): 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 _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114751. /**
  114752. * Returns true if the mesh can be rendered, otherwise false.
  114753. * @param mesh The mesh to render
  114754. * @param material The material used on the mesh
  114755. * @returns true if it can be rendered otherwise false
  114756. */
  114757. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114758. /**
  114759. * Returns true if the mesh should render, otherwise false.
  114760. * @param mesh The mesh to render
  114761. * @returns true if it should render otherwise false
  114762. */
  114763. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114764. /**
  114765. * Renders the submesh passed in parameter to the generation map.
  114766. */
  114767. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114768. /**
  114769. * Rebuild the required buffers.
  114770. * @hidden Internal use only.
  114771. */
  114772. _rebuild(): void;
  114773. /**
  114774. * Dispose only the render target textures and post process.
  114775. */
  114776. private _disposeTextureAndPostProcesses;
  114777. /**
  114778. * Dispose the highlight layer and free resources.
  114779. */
  114780. dispose(): void;
  114781. /**
  114782. * Gets the class name of the effect layer
  114783. * @returns the string with the class name of the effect layer
  114784. */
  114785. getClassName(): string;
  114786. /**
  114787. * Creates an effect layer from parsed effect layer data
  114788. * @param parsedEffectLayer defines effect layer data
  114789. * @param scene defines the current scene
  114790. * @param rootUrl defines the root URL containing the effect layer information
  114791. * @returns a parsed effect Layer
  114792. */
  114793. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114794. }
  114795. }
  114796. declare module BABYLON {
  114797. interface AbstractScene {
  114798. /**
  114799. * The list of effect layers (highlights/glow) added to the scene
  114800. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114801. * @see http://doc.babylonjs.com/how_to/glow_layer
  114802. */
  114803. effectLayers: Array<EffectLayer>;
  114804. /**
  114805. * Removes the given effect layer from this scene.
  114806. * @param toRemove defines the effect layer to remove
  114807. * @returns the index of the removed effect layer
  114808. */
  114809. removeEffectLayer(toRemove: EffectLayer): number;
  114810. /**
  114811. * Adds the given effect layer to this scene
  114812. * @param newEffectLayer defines the effect layer to add
  114813. */
  114814. addEffectLayer(newEffectLayer: EffectLayer): void;
  114815. }
  114816. /**
  114817. * Defines the layer scene component responsible to manage any effect layers
  114818. * in a given scene.
  114819. */
  114820. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114821. /**
  114822. * The component name helpfull to identify the component in the list of scene components.
  114823. */
  114824. readonly name: string;
  114825. /**
  114826. * The scene the component belongs to.
  114827. */
  114828. scene: Scene;
  114829. private _engine;
  114830. private _renderEffects;
  114831. private _needStencil;
  114832. private _previousStencilState;
  114833. /**
  114834. * Creates a new instance of the component for the given scene
  114835. * @param scene Defines the scene to register the component in
  114836. */
  114837. constructor(scene: Scene);
  114838. /**
  114839. * Registers the component in a given scene
  114840. */
  114841. register(): void;
  114842. /**
  114843. * Rebuilds the elements related to this component in case of
  114844. * context lost for instance.
  114845. */
  114846. rebuild(): void;
  114847. /**
  114848. * Serializes the component data to the specified json object
  114849. * @param serializationObject The object to serialize to
  114850. */
  114851. serialize(serializationObject: any): void;
  114852. /**
  114853. * Adds all the elements from the container to the scene
  114854. * @param container the container holding the elements
  114855. */
  114856. addFromContainer(container: AbstractScene): void;
  114857. /**
  114858. * Removes all the elements in the container from the scene
  114859. * @param container contains the elements to remove
  114860. * @param dispose if the removed element should be disposed (default: false)
  114861. */
  114862. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114863. /**
  114864. * Disposes the component and the associated ressources.
  114865. */
  114866. dispose(): void;
  114867. private _isReadyForMesh;
  114868. private _renderMainTexture;
  114869. private _setStencil;
  114870. private _setStencilBack;
  114871. private _draw;
  114872. private _drawCamera;
  114873. private _drawRenderingGroup;
  114874. }
  114875. }
  114876. declare module BABYLON {
  114877. /** @hidden */
  114878. export var glowMapMergePixelShader: {
  114879. name: string;
  114880. shader: string;
  114881. };
  114882. }
  114883. declare module BABYLON {
  114884. /** @hidden */
  114885. export var glowMapMergeVertexShader: {
  114886. name: string;
  114887. shader: string;
  114888. };
  114889. }
  114890. declare module BABYLON {
  114891. interface AbstractScene {
  114892. /**
  114893. * Return a the first highlight layer of the scene with a given name.
  114894. * @param name The name of the highlight layer to look for.
  114895. * @return The highlight layer if found otherwise null.
  114896. */
  114897. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114898. }
  114899. /**
  114900. * Glow layer options. This helps customizing the behaviour
  114901. * of the glow layer.
  114902. */
  114903. export interface IGlowLayerOptions {
  114904. /**
  114905. * Multiplication factor apply to the canvas size to compute the render target size
  114906. * used to generated the glowing objects (the smaller the faster).
  114907. */
  114908. mainTextureRatio: number;
  114909. /**
  114910. * Enforces a fixed size texture to ensure resize independant blur.
  114911. */
  114912. mainTextureFixedSize?: number;
  114913. /**
  114914. * How big is the kernel of the blur texture.
  114915. */
  114916. blurKernelSize: number;
  114917. /**
  114918. * The camera attached to the layer.
  114919. */
  114920. camera: Nullable<Camera>;
  114921. /**
  114922. * Enable MSAA by chosing the number of samples.
  114923. */
  114924. mainTextureSamples?: number;
  114925. /**
  114926. * The rendering group to draw the layer in.
  114927. */
  114928. renderingGroupId: number;
  114929. }
  114930. /**
  114931. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114932. *
  114933. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114934. * glowy meshes to your scene.
  114935. *
  114936. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114937. */
  114938. export class GlowLayer extends EffectLayer {
  114939. /**
  114940. * Effect Name of the layer.
  114941. */
  114942. static readonly EffectName: string;
  114943. /**
  114944. * The default blur kernel size used for the glow.
  114945. */
  114946. static DefaultBlurKernelSize: number;
  114947. /**
  114948. * The default texture size ratio used for the glow.
  114949. */
  114950. static DefaultTextureRatio: number;
  114951. /**
  114952. * Sets the kernel size of the blur.
  114953. */
  114954. /**
  114955. * Gets the kernel size of the blur.
  114956. */
  114957. blurKernelSize: number;
  114958. /**
  114959. * Sets the glow intensity.
  114960. */
  114961. /**
  114962. * Gets the glow intensity.
  114963. */
  114964. intensity: number;
  114965. private _options;
  114966. private _intensity;
  114967. private _horizontalBlurPostprocess1;
  114968. private _verticalBlurPostprocess1;
  114969. private _horizontalBlurPostprocess2;
  114970. private _verticalBlurPostprocess2;
  114971. private _blurTexture1;
  114972. private _blurTexture2;
  114973. private _postProcesses1;
  114974. private _postProcesses2;
  114975. private _includedOnlyMeshes;
  114976. private _excludedMeshes;
  114977. /**
  114978. * Callback used to let the user override the color selection on a per mesh basis
  114979. */
  114980. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114981. /**
  114982. * Callback used to let the user override the texture selection on a per mesh basis
  114983. */
  114984. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114985. /**
  114986. * Instantiates a new glow Layer and references it to the scene.
  114987. * @param name The name of the layer
  114988. * @param scene The scene to use the layer in
  114989. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114990. */
  114991. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114992. /**
  114993. * Get the effect name of the layer.
  114994. * @return The effect name
  114995. */
  114996. getEffectName(): string;
  114997. /**
  114998. * Create the merge effect. This is the shader use to blit the information back
  114999. * to the main canvas at the end of the scene rendering.
  115000. */
  115001. protected _createMergeEffect(): Effect;
  115002. /**
  115003. * Creates the render target textures and post processes used in the glow layer.
  115004. */
  115005. protected _createTextureAndPostProcesses(): void;
  115006. /**
  115007. * Checks for the readiness of the element composing the layer.
  115008. * @param subMesh the mesh to check for
  115009. * @param useInstances specify wether or not to use instances to render the mesh
  115010. * @param emissiveTexture the associated emissive texture used to generate the glow
  115011. * @return true if ready otherwise, false
  115012. */
  115013. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115014. /**
  115015. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115016. */
  115017. needStencil(): boolean;
  115018. /**
  115019. * Returns true if the mesh can be rendered, otherwise false.
  115020. * @param mesh The mesh to render
  115021. * @param material The material used on the mesh
  115022. * @returns true if it can be rendered otherwise false
  115023. */
  115024. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115025. /**
  115026. * Implementation specific of rendering the generating effect on the main canvas.
  115027. * @param effect The effect used to render through
  115028. */
  115029. protected _internalRender(effect: Effect): void;
  115030. /**
  115031. * Sets the required values for both the emissive texture and and the main color.
  115032. */
  115033. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115034. /**
  115035. * Returns true if the mesh should render, otherwise false.
  115036. * @param mesh The mesh to render
  115037. * @returns true if it should render otherwise false
  115038. */
  115039. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115040. /**
  115041. * Adds specific effects defines.
  115042. * @param defines The defines to add specifics to.
  115043. */
  115044. protected _addCustomEffectDefines(defines: string[]): void;
  115045. /**
  115046. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115047. * @param mesh The mesh to exclude from the glow layer
  115048. */
  115049. addExcludedMesh(mesh: Mesh): void;
  115050. /**
  115051. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115052. * @param mesh The mesh to remove
  115053. */
  115054. removeExcludedMesh(mesh: Mesh): void;
  115055. /**
  115056. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115057. * @param mesh The mesh to include in the glow layer
  115058. */
  115059. addIncludedOnlyMesh(mesh: Mesh): void;
  115060. /**
  115061. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115062. * @param mesh The mesh to remove
  115063. */
  115064. removeIncludedOnlyMesh(mesh: Mesh): void;
  115065. /**
  115066. * Determine if a given mesh will be used in the glow layer
  115067. * @param mesh The mesh to test
  115068. * @returns true if the mesh will be highlighted by the current glow layer
  115069. */
  115070. hasMesh(mesh: AbstractMesh): boolean;
  115071. /**
  115072. * Free any resources and references associated to a mesh.
  115073. * Internal use
  115074. * @param mesh The mesh to free.
  115075. * @hidden
  115076. */
  115077. _disposeMesh(mesh: Mesh): void;
  115078. /**
  115079. * Gets the class name of the effect layer
  115080. * @returns the string with the class name of the effect layer
  115081. */
  115082. getClassName(): string;
  115083. /**
  115084. * Serializes this glow layer
  115085. * @returns a serialized glow layer object
  115086. */
  115087. serialize(): any;
  115088. /**
  115089. * Creates a Glow Layer from parsed glow layer data
  115090. * @param parsedGlowLayer defines glow layer data
  115091. * @param scene defines the current scene
  115092. * @param rootUrl defines the root URL containing the glow layer information
  115093. * @returns a parsed Glow Layer
  115094. */
  115095. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115096. }
  115097. }
  115098. declare module BABYLON {
  115099. /** @hidden */
  115100. export var glowBlurPostProcessPixelShader: {
  115101. name: string;
  115102. shader: string;
  115103. };
  115104. }
  115105. declare module BABYLON {
  115106. interface AbstractScene {
  115107. /**
  115108. * Return a the first highlight layer of the scene with a given name.
  115109. * @param name The name of the highlight layer to look for.
  115110. * @return The highlight layer if found otherwise null.
  115111. */
  115112. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115113. }
  115114. /**
  115115. * Highlight layer options. This helps customizing the behaviour
  115116. * of the highlight layer.
  115117. */
  115118. export interface IHighlightLayerOptions {
  115119. /**
  115120. * Multiplication factor apply to the canvas size to compute the render target size
  115121. * used to generated the glowing objects (the smaller the faster).
  115122. */
  115123. mainTextureRatio: number;
  115124. /**
  115125. * Enforces a fixed size texture to ensure resize independant blur.
  115126. */
  115127. mainTextureFixedSize?: number;
  115128. /**
  115129. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115130. * of the picture to blur (the smaller the faster).
  115131. */
  115132. blurTextureSizeRatio: number;
  115133. /**
  115134. * How big in texel of the blur texture is the vertical blur.
  115135. */
  115136. blurVerticalSize: number;
  115137. /**
  115138. * How big in texel of the blur texture is the horizontal blur.
  115139. */
  115140. blurHorizontalSize: number;
  115141. /**
  115142. * Alpha blending mode used to apply the blur. Default is combine.
  115143. */
  115144. alphaBlendingMode: number;
  115145. /**
  115146. * The camera attached to the layer.
  115147. */
  115148. camera: Nullable<Camera>;
  115149. /**
  115150. * Should we display highlight as a solid stroke?
  115151. */
  115152. isStroke?: boolean;
  115153. /**
  115154. * The rendering group to draw the layer in.
  115155. */
  115156. renderingGroupId: number;
  115157. }
  115158. /**
  115159. * The highlight layer Helps adding a glow effect around a mesh.
  115160. *
  115161. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115162. * glowy meshes to your scene.
  115163. *
  115164. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115165. */
  115166. export class HighlightLayer extends EffectLayer {
  115167. name: string;
  115168. /**
  115169. * Effect Name of the highlight layer.
  115170. */
  115171. static readonly EffectName: string;
  115172. /**
  115173. * The neutral color used during the preparation of the glow effect.
  115174. * This is black by default as the blend operation is a blend operation.
  115175. */
  115176. static NeutralColor: Color4;
  115177. /**
  115178. * Stencil value used for glowing meshes.
  115179. */
  115180. static GlowingMeshStencilReference: number;
  115181. /**
  115182. * Stencil value used for the other meshes in the scene.
  115183. */
  115184. static NormalMeshStencilReference: number;
  115185. /**
  115186. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115187. */
  115188. innerGlow: boolean;
  115189. /**
  115190. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115191. */
  115192. outerGlow: boolean;
  115193. /**
  115194. * Specifies the horizontal size of the blur.
  115195. */
  115196. /**
  115197. * Gets the horizontal size of the blur.
  115198. */
  115199. blurHorizontalSize: number;
  115200. /**
  115201. * Specifies the vertical size of the blur.
  115202. */
  115203. /**
  115204. * Gets the vertical size of the blur.
  115205. */
  115206. blurVerticalSize: number;
  115207. /**
  115208. * An event triggered when the highlight layer is being blurred.
  115209. */
  115210. onBeforeBlurObservable: Observable<HighlightLayer>;
  115211. /**
  115212. * An event triggered when the highlight layer has been blurred.
  115213. */
  115214. onAfterBlurObservable: Observable<HighlightLayer>;
  115215. private _instanceGlowingMeshStencilReference;
  115216. private _options;
  115217. private _downSamplePostprocess;
  115218. private _horizontalBlurPostprocess;
  115219. private _verticalBlurPostprocess;
  115220. private _blurTexture;
  115221. private _meshes;
  115222. private _excludedMeshes;
  115223. /**
  115224. * Instantiates a new highlight Layer and references it to the scene..
  115225. * @param name The name of the layer
  115226. * @param scene The scene to use the layer in
  115227. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115228. */
  115229. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115230. /**
  115231. * Get the effect name of the layer.
  115232. * @return The effect name
  115233. */
  115234. getEffectName(): string;
  115235. /**
  115236. * Create the merge effect. This is the shader use to blit the information back
  115237. * to the main canvas at the end of the scene rendering.
  115238. */
  115239. protected _createMergeEffect(): Effect;
  115240. /**
  115241. * Creates the render target textures and post processes used in the highlight layer.
  115242. */
  115243. protected _createTextureAndPostProcesses(): void;
  115244. /**
  115245. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115246. */
  115247. needStencil(): boolean;
  115248. /**
  115249. * Checks for the readiness of the element composing the layer.
  115250. * @param subMesh the mesh to check for
  115251. * @param useInstances specify wether or not to use instances to render the mesh
  115252. * @param emissiveTexture the associated emissive texture used to generate the glow
  115253. * @return true if ready otherwise, false
  115254. */
  115255. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115256. /**
  115257. * Implementation specific of rendering the generating effect on the main canvas.
  115258. * @param effect The effect used to render through
  115259. */
  115260. protected _internalRender(effect: Effect): void;
  115261. /**
  115262. * Returns true if the layer contains information to display, otherwise false.
  115263. */
  115264. shouldRender(): boolean;
  115265. /**
  115266. * Returns true if the mesh should render, otherwise false.
  115267. * @param mesh The mesh to render
  115268. * @returns true if it should render otherwise false
  115269. */
  115270. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115271. /**
  115272. * Sets the required values for both the emissive texture and and the main color.
  115273. */
  115274. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115275. /**
  115276. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115277. * @param mesh The mesh to exclude from the highlight layer
  115278. */
  115279. addExcludedMesh(mesh: Mesh): void;
  115280. /**
  115281. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115282. * @param mesh The mesh to highlight
  115283. */
  115284. removeExcludedMesh(mesh: Mesh): void;
  115285. /**
  115286. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115287. * @param mesh mesh to test
  115288. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115289. */
  115290. hasMesh(mesh: AbstractMesh): boolean;
  115291. /**
  115292. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115293. * @param mesh The mesh to highlight
  115294. * @param color The color of the highlight
  115295. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115296. */
  115297. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115298. /**
  115299. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115300. * @param mesh The mesh to highlight
  115301. */
  115302. removeMesh(mesh: Mesh): void;
  115303. /**
  115304. * Force the stencil to the normal expected value for none glowing parts
  115305. */
  115306. private _defaultStencilReference;
  115307. /**
  115308. * Free any resources and references associated to a mesh.
  115309. * Internal use
  115310. * @param mesh The mesh to free.
  115311. * @hidden
  115312. */
  115313. _disposeMesh(mesh: Mesh): void;
  115314. /**
  115315. * Dispose the highlight layer and free resources.
  115316. */
  115317. dispose(): void;
  115318. /**
  115319. * Gets the class name of the effect layer
  115320. * @returns the string with the class name of the effect layer
  115321. */
  115322. getClassName(): string;
  115323. /**
  115324. * Serializes this Highlight layer
  115325. * @returns a serialized Highlight layer object
  115326. */
  115327. serialize(): any;
  115328. /**
  115329. * Creates a Highlight layer from parsed Highlight layer data
  115330. * @param parsedHightlightLayer defines the Highlight layer data
  115331. * @param scene defines the current scene
  115332. * @param rootUrl defines the root URL containing the Highlight layer information
  115333. * @returns a parsed Highlight layer
  115334. */
  115335. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115336. }
  115337. }
  115338. declare module BABYLON {
  115339. interface AbstractScene {
  115340. /**
  115341. * The list of layers (background and foreground) of the scene
  115342. */
  115343. layers: Array<Layer>;
  115344. }
  115345. /**
  115346. * Defines the layer scene component responsible to manage any layers
  115347. * in a given scene.
  115348. */
  115349. export class LayerSceneComponent implements ISceneComponent {
  115350. /**
  115351. * The component name helpfull to identify the component in the list of scene components.
  115352. */
  115353. readonly name: string;
  115354. /**
  115355. * The scene the component belongs to.
  115356. */
  115357. scene: Scene;
  115358. private _engine;
  115359. /**
  115360. * Creates a new instance of the component for the given scene
  115361. * @param scene Defines the scene to register the component in
  115362. */
  115363. constructor(scene: Scene);
  115364. /**
  115365. * Registers the component in a given scene
  115366. */
  115367. register(): void;
  115368. /**
  115369. * Rebuilds the elements related to this component in case of
  115370. * context lost for instance.
  115371. */
  115372. rebuild(): void;
  115373. /**
  115374. * Disposes the component and the associated ressources.
  115375. */
  115376. dispose(): void;
  115377. private _draw;
  115378. private _drawCameraPredicate;
  115379. private _drawCameraBackground;
  115380. private _drawCameraForeground;
  115381. private _drawRenderTargetPredicate;
  115382. private _drawRenderTargetBackground;
  115383. private _drawRenderTargetForeground;
  115384. /**
  115385. * Adds all the elements from the container to the scene
  115386. * @param container the container holding the elements
  115387. */
  115388. addFromContainer(container: AbstractScene): void;
  115389. /**
  115390. * Removes all the elements in the container from the scene
  115391. * @param container contains the elements to remove
  115392. * @param dispose if the removed element should be disposed (default: false)
  115393. */
  115394. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115395. }
  115396. }
  115397. declare module BABYLON {
  115398. /** @hidden */
  115399. export var layerPixelShader: {
  115400. name: string;
  115401. shader: string;
  115402. };
  115403. }
  115404. declare module BABYLON {
  115405. /** @hidden */
  115406. export var layerVertexShader: {
  115407. name: string;
  115408. shader: string;
  115409. };
  115410. }
  115411. declare module BABYLON {
  115412. /**
  115413. * This represents a full screen 2d layer.
  115414. * This can be useful to display a picture in the background of your scene for instance.
  115415. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115416. */
  115417. export class Layer {
  115418. /**
  115419. * Define the name of the layer.
  115420. */
  115421. name: string;
  115422. /**
  115423. * Define the texture the layer should display.
  115424. */
  115425. texture: Nullable<Texture>;
  115426. /**
  115427. * Is the layer in background or foreground.
  115428. */
  115429. isBackground: boolean;
  115430. /**
  115431. * Define the color of the layer (instead of texture).
  115432. */
  115433. color: Color4;
  115434. /**
  115435. * Define the scale of the layer in order to zoom in out of the texture.
  115436. */
  115437. scale: Vector2;
  115438. /**
  115439. * Define an offset for the layer in order to shift the texture.
  115440. */
  115441. offset: Vector2;
  115442. /**
  115443. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115444. */
  115445. alphaBlendingMode: number;
  115446. /**
  115447. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115448. * Alpha test will not mix with the background color in case of transparency.
  115449. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115450. */
  115451. alphaTest: boolean;
  115452. /**
  115453. * Define a mask to restrict the layer to only some of the scene cameras.
  115454. */
  115455. layerMask: number;
  115456. /**
  115457. * Define the list of render target the layer is visible into.
  115458. */
  115459. renderTargetTextures: RenderTargetTexture[];
  115460. /**
  115461. * Define if the layer is only used in renderTarget or if it also
  115462. * renders in the main frame buffer of the canvas.
  115463. */
  115464. renderOnlyInRenderTargetTextures: boolean;
  115465. private _scene;
  115466. private _vertexBuffers;
  115467. private _indexBuffer;
  115468. private _effect;
  115469. private _alphaTestEffect;
  115470. /**
  115471. * An event triggered when the layer is disposed.
  115472. */
  115473. onDisposeObservable: Observable<Layer>;
  115474. private _onDisposeObserver;
  115475. /**
  115476. * Back compatibility with callback before the onDisposeObservable existed.
  115477. * The set callback will be triggered when the layer has been disposed.
  115478. */
  115479. onDispose: () => void;
  115480. /**
  115481. * An event triggered before rendering the scene
  115482. */
  115483. onBeforeRenderObservable: Observable<Layer>;
  115484. private _onBeforeRenderObserver;
  115485. /**
  115486. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115487. * The set callback will be triggered just before rendering the layer.
  115488. */
  115489. onBeforeRender: () => void;
  115490. /**
  115491. * An event triggered after rendering the scene
  115492. */
  115493. onAfterRenderObservable: Observable<Layer>;
  115494. private _onAfterRenderObserver;
  115495. /**
  115496. * Back compatibility with callback before the onAfterRenderObservable existed.
  115497. * The set callback will be triggered just after rendering the layer.
  115498. */
  115499. onAfterRender: () => void;
  115500. /**
  115501. * Instantiates a new layer.
  115502. * This represents a full screen 2d layer.
  115503. * This can be useful to display a picture in the background of your scene for instance.
  115504. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115505. * @param name Define the name of the layer in the scene
  115506. * @param imgUrl Define the url of the texture to display in the layer
  115507. * @param scene Define the scene the layer belongs to
  115508. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115509. * @param color Defines a color for the layer
  115510. */
  115511. constructor(
  115512. /**
  115513. * Define the name of the layer.
  115514. */
  115515. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115516. private _createIndexBuffer;
  115517. /** @hidden */
  115518. _rebuild(): void;
  115519. /**
  115520. * Renders the layer in the scene.
  115521. */
  115522. render(): void;
  115523. /**
  115524. * Disposes and releases the associated ressources.
  115525. */
  115526. dispose(): void;
  115527. }
  115528. }
  115529. declare module BABYLON {
  115530. /** @hidden */
  115531. export var lensFlarePixelShader: {
  115532. name: string;
  115533. shader: string;
  115534. };
  115535. }
  115536. declare module BABYLON {
  115537. /** @hidden */
  115538. export var lensFlareVertexShader: {
  115539. name: string;
  115540. shader: string;
  115541. };
  115542. }
  115543. declare module BABYLON {
  115544. /**
  115545. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115546. * It is usually composed of several `lensFlare`.
  115547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115548. */
  115549. export class LensFlareSystem {
  115550. /**
  115551. * Define the name of the lens flare system
  115552. */
  115553. name: string;
  115554. /**
  115555. * List of lens flares used in this system.
  115556. */
  115557. lensFlares: LensFlare[];
  115558. /**
  115559. * Define a limit from the border the lens flare can be visible.
  115560. */
  115561. borderLimit: number;
  115562. /**
  115563. * Define a viewport border we do not want to see the lens flare in.
  115564. */
  115565. viewportBorder: number;
  115566. /**
  115567. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115568. */
  115569. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115570. /**
  115571. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115572. */
  115573. layerMask: number;
  115574. /**
  115575. * Define the id of the lens flare system in the scene.
  115576. * (equal to name by default)
  115577. */
  115578. id: string;
  115579. private _scene;
  115580. private _emitter;
  115581. private _vertexBuffers;
  115582. private _indexBuffer;
  115583. private _effect;
  115584. private _positionX;
  115585. private _positionY;
  115586. private _isEnabled;
  115587. /** @hidden */
  115588. static _SceneComponentInitialization: (scene: Scene) => void;
  115589. /**
  115590. * Instantiates a lens flare system.
  115591. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115592. * It is usually composed of several `lensFlare`.
  115593. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115594. * @param name Define the name of the lens flare system in the scene
  115595. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115596. * @param scene Define the scene the lens flare system belongs to
  115597. */
  115598. constructor(
  115599. /**
  115600. * Define the name of the lens flare system
  115601. */
  115602. name: string, emitter: any, scene: Scene);
  115603. /**
  115604. * Define if the lens flare system is enabled.
  115605. */
  115606. isEnabled: boolean;
  115607. /**
  115608. * Get the scene the effects belongs to.
  115609. * @returns the scene holding the lens flare system
  115610. */
  115611. getScene(): Scene;
  115612. /**
  115613. * Get the emitter of the lens flare system.
  115614. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115615. * @returns the emitter of the lens flare system
  115616. */
  115617. getEmitter(): any;
  115618. /**
  115619. * Set the emitter of the lens flare system.
  115620. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115621. * @param newEmitter Define the new emitter of the system
  115622. */
  115623. setEmitter(newEmitter: any): void;
  115624. /**
  115625. * Get the lens flare system emitter position.
  115626. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115627. * @returns the position
  115628. */
  115629. getEmitterPosition(): Vector3;
  115630. /**
  115631. * @hidden
  115632. */
  115633. computeEffectivePosition(globalViewport: Viewport): boolean;
  115634. /** @hidden */
  115635. _isVisible(): boolean;
  115636. /**
  115637. * @hidden
  115638. */
  115639. render(): boolean;
  115640. /**
  115641. * Dispose and release the lens flare with its associated resources.
  115642. */
  115643. dispose(): void;
  115644. /**
  115645. * Parse a lens flare system from a JSON repressentation
  115646. * @param parsedLensFlareSystem Define the JSON to parse
  115647. * @param scene Define the scene the parsed system should be instantiated in
  115648. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115649. * @returns the parsed system
  115650. */
  115651. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115652. /**
  115653. * Serialize the current Lens Flare System into a JSON representation.
  115654. * @returns the serialized JSON
  115655. */
  115656. serialize(): any;
  115657. }
  115658. }
  115659. declare module BABYLON {
  115660. /**
  115661. * This represents one of the lens effect in a `lensFlareSystem`.
  115662. * It controls one of the indiviual texture used in the effect.
  115663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115664. */
  115665. export class LensFlare {
  115666. /**
  115667. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115668. */
  115669. size: number;
  115670. /**
  115671. * 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.
  115672. */
  115673. position: number;
  115674. /**
  115675. * Define the lens color.
  115676. */
  115677. color: Color3;
  115678. /**
  115679. * Define the lens texture.
  115680. */
  115681. texture: Nullable<Texture>;
  115682. /**
  115683. * Define the alpha mode to render this particular lens.
  115684. */
  115685. alphaMode: number;
  115686. private _system;
  115687. /**
  115688. * Creates 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 (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. * @returns The newly created Lens Flare
  115698. */
  115699. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115700. /**
  115701. * Instantiates a new Lens Flare.
  115702. * This represents one of the lens effect in a `lensFlareSystem`.
  115703. * It controls one of the indiviual texture used in the effect.
  115704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115705. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115706. * @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.
  115707. * @param color Define the lens color
  115708. * @param imgUrl Define the lens texture url
  115709. * @param system Define the `lensFlareSystem` this flare is part of
  115710. */
  115711. constructor(
  115712. /**
  115713. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115714. */
  115715. size: number,
  115716. /**
  115717. * 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.
  115718. */
  115719. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115720. /**
  115721. * Dispose and release the lens flare with its associated resources.
  115722. */
  115723. dispose(): void;
  115724. }
  115725. }
  115726. declare module BABYLON {
  115727. interface AbstractScene {
  115728. /**
  115729. * The list of lens flare system added to the scene
  115730. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115731. */
  115732. lensFlareSystems: Array<LensFlareSystem>;
  115733. /**
  115734. * Removes the given lens flare system from this scene.
  115735. * @param toRemove The lens flare system to remove
  115736. * @returns The index of the removed lens flare system
  115737. */
  115738. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115739. /**
  115740. * Adds the given lens flare system to this scene
  115741. * @param newLensFlareSystem The lens flare system to add
  115742. */
  115743. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115744. /**
  115745. * Gets a lens flare system using its name
  115746. * @param name defines the name to look for
  115747. * @returns the lens flare system or null if not found
  115748. */
  115749. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115750. /**
  115751. * Gets a lens flare system using its id
  115752. * @param id defines the id to look for
  115753. * @returns the lens flare system or null if not found
  115754. */
  115755. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115756. }
  115757. /**
  115758. * Defines the lens flare scene component responsible to manage any lens flares
  115759. * in a given scene.
  115760. */
  115761. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115762. /**
  115763. * The component name helpfull to identify the component in the list of scene components.
  115764. */
  115765. readonly name: string;
  115766. /**
  115767. * The scene the component belongs to.
  115768. */
  115769. scene: Scene;
  115770. /**
  115771. * Creates a new instance of the component for the given scene
  115772. * @param scene Defines the scene to register the component in
  115773. */
  115774. constructor(scene: Scene);
  115775. /**
  115776. * Registers the component in a given scene
  115777. */
  115778. register(): void;
  115779. /**
  115780. * Rebuilds the elements related to this component in case of
  115781. * context lost for instance.
  115782. */
  115783. rebuild(): void;
  115784. /**
  115785. * Adds all the elements from the container to the scene
  115786. * @param container the container holding the elements
  115787. */
  115788. addFromContainer(container: AbstractScene): void;
  115789. /**
  115790. * Removes all the elements in the container from the scene
  115791. * @param container contains the elements to remove
  115792. * @param dispose if the removed element should be disposed (default: false)
  115793. */
  115794. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115795. /**
  115796. * Serializes the component data to the specified json object
  115797. * @param serializationObject The object to serialize to
  115798. */
  115799. serialize(serializationObject: any): void;
  115800. /**
  115801. * Disposes the component and the associated ressources.
  115802. */
  115803. dispose(): void;
  115804. private _draw;
  115805. }
  115806. }
  115807. declare module BABYLON {
  115808. /**
  115809. * Defines the shadow generator component responsible to manage any shadow generators
  115810. * in a given scene.
  115811. */
  115812. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115813. /**
  115814. * The component name helpfull to identify the component in the list of scene components.
  115815. */
  115816. readonly name: string;
  115817. /**
  115818. * The scene the component belongs to.
  115819. */
  115820. scene: Scene;
  115821. /**
  115822. * Creates a new instance of the component for the given scene
  115823. * @param scene Defines the scene to register the component in
  115824. */
  115825. constructor(scene: Scene);
  115826. /**
  115827. * Registers the component in a given scene
  115828. */
  115829. register(): void;
  115830. /**
  115831. * Rebuilds the elements related to this component in case of
  115832. * context lost for instance.
  115833. */
  115834. rebuild(): void;
  115835. /**
  115836. * Serializes the component data to the specified json object
  115837. * @param serializationObject The object to serialize to
  115838. */
  115839. serialize(serializationObject: any): void;
  115840. /**
  115841. * Adds all the elements from the container to the scene
  115842. * @param container the container holding the elements
  115843. */
  115844. addFromContainer(container: AbstractScene): void;
  115845. /**
  115846. * Removes all the elements in the container from the scene
  115847. * @param container contains the elements to remove
  115848. * @param dispose if the removed element should be disposed (default: false)
  115849. */
  115850. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115851. /**
  115852. * Rebuilds the elements related to this component in case of
  115853. * context lost for instance.
  115854. */
  115855. dispose(): void;
  115856. private _gatherRenderTargets;
  115857. }
  115858. }
  115859. declare module BABYLON {
  115860. /**
  115861. * A point light is a light defined by an unique point in world space.
  115862. * The light is emitted in every direction from this point.
  115863. * A good example of a point light is a standard light bulb.
  115864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115865. */
  115866. export class PointLight extends ShadowLight {
  115867. private _shadowAngle;
  115868. /**
  115869. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115870. * This specifies what angle the shadow will use to be created.
  115871. *
  115872. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115873. */
  115874. /**
  115875. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115876. * This specifies what angle the shadow will use to be created.
  115877. *
  115878. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115879. */
  115880. shadowAngle: number;
  115881. /**
  115882. * Gets the direction if it has been set.
  115883. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115884. */
  115885. /**
  115886. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115887. */
  115888. direction: Vector3;
  115889. /**
  115890. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115891. * A PointLight emits the light in every direction.
  115892. * It can cast shadows.
  115893. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115894. * ```javascript
  115895. * var pointLight = new PointLight("pl", camera.position, scene);
  115896. * ```
  115897. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115898. * @param name The light friendly name
  115899. * @param position The position of the point light in the scene
  115900. * @param scene The scene the lights belongs to
  115901. */
  115902. constructor(name: string, position: Vector3, scene: Scene);
  115903. /**
  115904. * Returns the string "PointLight"
  115905. * @returns the class name
  115906. */
  115907. getClassName(): string;
  115908. /**
  115909. * Returns the integer 0.
  115910. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115911. */
  115912. getTypeID(): number;
  115913. /**
  115914. * Specifies wether or not the shadowmap should be a cube texture.
  115915. * @returns true if the shadowmap needs to be a cube texture.
  115916. */
  115917. needCube(): boolean;
  115918. /**
  115919. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115922. */
  115923. getShadowDirection(faceIndex?: number): Vector3;
  115924. /**
  115925. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115926. * - fov = PI / 2
  115927. * - aspect ratio : 1.0
  115928. * - z-near and far equal to the active camera minZ and maxZ.
  115929. * Returns the PointLight.
  115930. */
  115931. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115932. protected _buildUniformLayout(): void;
  115933. /**
  115934. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115935. * @param effect The effect to update
  115936. * @param lightIndex The index of the light in the effect to update
  115937. * @returns The point light
  115938. */
  115939. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115940. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115941. /**
  115942. * Prepares the list of defines specific to the light type.
  115943. * @param defines the list of defines
  115944. * @param lightIndex defines the index of the light for the effect
  115945. */
  115946. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115947. }
  115948. }
  115949. declare module BABYLON {
  115950. /**
  115951. * Header information of HDR texture files.
  115952. */
  115953. export interface HDRInfo {
  115954. /**
  115955. * The height of the texture in pixels.
  115956. */
  115957. height: number;
  115958. /**
  115959. * The width of the texture in pixels.
  115960. */
  115961. width: number;
  115962. /**
  115963. * The index of the beginning of the data in the binary file.
  115964. */
  115965. dataPosition: number;
  115966. }
  115967. /**
  115968. * This groups tools to convert HDR texture to native colors array.
  115969. */
  115970. export class HDRTools {
  115971. private static Ldexp;
  115972. private static Rgbe2float;
  115973. private static readStringLine;
  115974. /**
  115975. * Reads header information from an RGBE texture stored in a native array.
  115976. * More information on this format are available here:
  115977. * https://en.wikipedia.org/wiki/RGBE_image_format
  115978. *
  115979. * @param uint8array The binary file stored in native array.
  115980. * @return The header information.
  115981. */
  115982. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115983. /**
  115984. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115985. * This RGBE texture needs to store the information as a panorama.
  115986. *
  115987. * More information on this format are available here:
  115988. * https://en.wikipedia.org/wiki/RGBE_image_format
  115989. *
  115990. * @param buffer The binary file stored in an array buffer.
  115991. * @param size The expected size of the extracted cubemap.
  115992. * @return The Cube Map information.
  115993. */
  115994. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115995. /**
  115996. * Returns the pixels data extracted from an RGBE texture.
  115997. * This pixels will be stored left to right up to down in the R G B order in one array.
  115998. *
  115999. * More information on this format are available here:
  116000. * https://en.wikipedia.org/wiki/RGBE_image_format
  116001. *
  116002. * @param uint8array The binary file stored in an array buffer.
  116003. * @param hdrInfo The header information of the file.
  116004. * @return The pixels data in RGB right to left up to down order.
  116005. */
  116006. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  116007. private static RGBE_ReadPixels_RLE;
  116008. }
  116009. }
  116010. declare module BABYLON {
  116011. /**
  116012. * This represents a texture coming from an HDR input.
  116013. *
  116014. * The only supported format is currently panorama picture stored in RGBE format.
  116015. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116016. */
  116017. export class HDRCubeTexture extends BaseTexture {
  116018. private static _facesMapping;
  116019. private _generateHarmonics;
  116020. private _noMipmap;
  116021. private _textureMatrix;
  116022. private _size;
  116023. private _onLoad;
  116024. private _onError;
  116025. /**
  116026. * The texture URL.
  116027. */
  116028. url: string;
  116029. /**
  116030. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116031. */
  116032. coordinatesMode: number;
  116033. protected _isBlocking: boolean;
  116034. /**
  116035. * Sets wether or not the texture is blocking during loading.
  116036. */
  116037. /**
  116038. * Gets wether or not the texture is blocking during loading.
  116039. */
  116040. isBlocking: boolean;
  116041. protected _rotationY: number;
  116042. /**
  116043. * Sets texture matrix rotation angle around Y axis in radians.
  116044. */
  116045. /**
  116046. * Gets texture matrix rotation angle around Y axis radians.
  116047. */
  116048. rotationY: number;
  116049. /**
  116050. * Gets or sets the center of the bounding box associated with the cube texture
  116051. * It must define where the camera used to render the texture was set
  116052. */
  116053. boundingBoxPosition: Vector3;
  116054. private _boundingBoxSize;
  116055. /**
  116056. * Gets or sets the size of the bounding box associated with the cube texture
  116057. * When defined, the cubemap will switch to local mode
  116058. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116059. * @example https://www.babylonjs-playground.com/#RNASML
  116060. */
  116061. boundingBoxSize: Vector3;
  116062. /**
  116063. * Instantiates an HDRTexture from the following parameters.
  116064. *
  116065. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116066. * @param scene The scene the texture will be used in
  116067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116068. * @param noMipmap Forces to not generate the mipmap if true
  116069. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116070. * @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)
  116071. * @param reserved Reserved flag for internal use.
  116072. */
  116073. 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>);
  116074. /**
  116075. * Get the current class name of the texture useful for serialization or dynamic coding.
  116076. * @returns "HDRCubeTexture"
  116077. */
  116078. getClassName(): string;
  116079. /**
  116080. * Occurs when the file is raw .hdr file.
  116081. */
  116082. private loadTexture;
  116083. clone(): HDRCubeTexture;
  116084. delayLoad(): void;
  116085. /**
  116086. * Get the texture reflection matrix used to rotate/transform the reflection.
  116087. * @returns the reflection matrix
  116088. */
  116089. getReflectionTextureMatrix(): Matrix;
  116090. /**
  116091. * Set the texture reflection matrix used to rotate/transform the reflection.
  116092. * @param value Define the reflection matrix to set
  116093. */
  116094. setReflectionTextureMatrix(value: Matrix): void;
  116095. /**
  116096. * Parses a JSON representation of an HDR Texture in order to create the texture
  116097. * @param parsedTexture Define the JSON representation
  116098. * @param scene Define the scene the texture should be created in
  116099. * @param rootUrl Define the root url in case we need to load relative dependencies
  116100. * @returns the newly created texture after parsing
  116101. */
  116102. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116103. serialize(): any;
  116104. }
  116105. }
  116106. declare module BABYLON {
  116107. /**
  116108. * Class used to control physics engine
  116109. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116110. */
  116111. export class PhysicsEngine implements IPhysicsEngine {
  116112. private _physicsPlugin;
  116113. /**
  116114. * Global value used to control the smallest number supported by the simulation
  116115. */
  116116. static Epsilon: number;
  116117. private _impostors;
  116118. private _joints;
  116119. /**
  116120. * Gets the gravity vector used by the simulation
  116121. */
  116122. gravity: Vector3;
  116123. /**
  116124. * Factory used to create the default physics plugin.
  116125. * @returns The default physics plugin
  116126. */
  116127. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116128. /**
  116129. * Creates a new Physics Engine
  116130. * @param gravity defines the gravity vector used by the simulation
  116131. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116132. */
  116133. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116134. /**
  116135. * Sets the gravity vector used by the simulation
  116136. * @param gravity defines the gravity vector to use
  116137. */
  116138. setGravity(gravity: Vector3): void;
  116139. /**
  116140. * Set the time step of the physics engine.
  116141. * Default is 1/60.
  116142. * To slow it down, enter 1/600 for example.
  116143. * To speed it up, 1/30
  116144. * @param newTimeStep defines the new timestep to apply to this world.
  116145. */
  116146. setTimeStep(newTimeStep?: number): void;
  116147. /**
  116148. * Get the time step of the physics engine.
  116149. * @returns the current time step
  116150. */
  116151. getTimeStep(): number;
  116152. /**
  116153. * Release all resources
  116154. */
  116155. dispose(): void;
  116156. /**
  116157. * Gets the name of the current physics plugin
  116158. * @returns the name of the plugin
  116159. */
  116160. getPhysicsPluginName(): string;
  116161. /**
  116162. * Adding a new impostor for the impostor tracking.
  116163. * This will be done by the impostor itself.
  116164. * @param impostor the impostor to add
  116165. */
  116166. addImpostor(impostor: PhysicsImpostor): void;
  116167. /**
  116168. * Remove an impostor from the engine.
  116169. * This impostor and its mesh will not longer be updated by the physics engine.
  116170. * @param impostor the impostor to remove
  116171. */
  116172. removeImpostor(impostor: PhysicsImpostor): void;
  116173. /**
  116174. * Add a joint to the physics engine
  116175. * @param mainImpostor defines the main impostor to which the joint is added.
  116176. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116177. * @param joint defines the joint that will connect both impostors.
  116178. */
  116179. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116180. /**
  116181. * Removes a joint from the simulation
  116182. * @param mainImpostor defines the impostor used with the joint
  116183. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116184. * @param joint defines the joint to remove
  116185. */
  116186. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116187. /**
  116188. * Called by the scene. No need to call it.
  116189. * @param delta defines the timespam between frames
  116190. */
  116191. _step(delta: number): void;
  116192. /**
  116193. * Gets the current plugin used to run the simulation
  116194. * @returns current plugin
  116195. */
  116196. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116197. /**
  116198. * Gets the list of physic impostors
  116199. * @returns an array of PhysicsImpostor
  116200. */
  116201. getImpostors(): Array<PhysicsImpostor>;
  116202. /**
  116203. * Gets the impostor for a physics enabled object
  116204. * @param object defines the object impersonated by the impostor
  116205. * @returns the PhysicsImpostor or null if not found
  116206. */
  116207. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116208. /**
  116209. * Gets the impostor for a physics body object
  116210. * @param body defines physics body used by the impostor
  116211. * @returns the PhysicsImpostor or null if not found
  116212. */
  116213. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116214. /**
  116215. * Does a raycast in the physics world
  116216. * @param from when should the ray start?
  116217. * @param to when should the ray end?
  116218. * @returns PhysicsRaycastResult
  116219. */
  116220. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116221. }
  116222. }
  116223. declare module BABYLON {
  116224. /** @hidden */
  116225. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116226. private _useDeltaForWorldStep;
  116227. world: any;
  116228. name: string;
  116229. private _physicsMaterials;
  116230. private _fixedTimeStep;
  116231. private _cannonRaycastResult;
  116232. private _raycastResult;
  116233. private _physicsBodysToRemoveAfterStep;
  116234. BJSCANNON: any;
  116235. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116236. setGravity(gravity: Vector3): void;
  116237. setTimeStep(timeStep: number): void;
  116238. getTimeStep(): number;
  116239. executeStep(delta: number): void;
  116240. private _removeMarkedPhysicsBodiesFromWorld;
  116241. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116242. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116243. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116244. private _processChildMeshes;
  116245. removePhysicsBody(impostor: PhysicsImpostor): void;
  116246. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116247. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116248. private _addMaterial;
  116249. private _checkWithEpsilon;
  116250. private _createShape;
  116251. private _createHeightmap;
  116252. private _minus90X;
  116253. private _plus90X;
  116254. private _tmpPosition;
  116255. private _tmpDeltaPosition;
  116256. private _tmpUnityRotation;
  116257. private _updatePhysicsBodyTransformation;
  116258. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116259. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116260. isSupported(): boolean;
  116261. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116262. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116263. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116264. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116265. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116266. getBodyMass(impostor: PhysicsImpostor): number;
  116267. getBodyFriction(impostor: PhysicsImpostor): number;
  116268. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116269. getBodyRestitution(impostor: PhysicsImpostor): number;
  116270. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116271. sleepBody(impostor: PhysicsImpostor): void;
  116272. wakeUpBody(impostor: PhysicsImpostor): void;
  116273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116274. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116275. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116276. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116277. getRadius(impostor: PhysicsImpostor): number;
  116278. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116279. dispose(): void;
  116280. private _extendNamespace;
  116281. /**
  116282. * Does a raycast in the physics world
  116283. * @param from when should the ray start?
  116284. * @param to when should the ray end?
  116285. * @returns PhysicsRaycastResult
  116286. */
  116287. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116288. }
  116289. }
  116290. declare module BABYLON {
  116291. /** @hidden */
  116292. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116293. world: any;
  116294. name: string;
  116295. BJSOIMO: any;
  116296. private _raycastResult;
  116297. constructor(iterations?: number, oimoInjection?: any);
  116298. setGravity(gravity: Vector3): void;
  116299. setTimeStep(timeStep: number): void;
  116300. getTimeStep(): number;
  116301. private _tmpImpostorsArray;
  116302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116303. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116304. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116306. private _tmpPositionVector;
  116307. removePhysicsBody(impostor: PhysicsImpostor): void;
  116308. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116309. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116310. isSupported(): boolean;
  116311. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116312. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116316. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116318. getBodyMass(impostor: PhysicsImpostor): number;
  116319. getBodyFriction(impostor: PhysicsImpostor): number;
  116320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116321. getBodyRestitution(impostor: PhysicsImpostor): number;
  116322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116323. sleepBody(impostor: PhysicsImpostor): void;
  116324. wakeUpBody(impostor: PhysicsImpostor): void;
  116325. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116326. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116327. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116328. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116329. getRadius(impostor: PhysicsImpostor): number;
  116330. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116331. dispose(): void;
  116332. /**
  116333. * Does a raycast in the physics world
  116334. * @param from when should the ray start?
  116335. * @param to when should the ray end?
  116336. * @returns PhysicsRaycastResult
  116337. */
  116338. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116339. }
  116340. }
  116341. declare module BABYLON {
  116342. /**
  116343. * Class containing static functions to help procedurally build meshes
  116344. */
  116345. export class RibbonBuilder {
  116346. /**
  116347. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116348. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116349. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116350. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116351. * * 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
  116352. * * 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
  116353. * * 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
  116354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116357. * * 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
  116358. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116359. * * 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
  116360. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116362. * @param name defines the name of the mesh
  116363. * @param options defines the options used to create the mesh
  116364. * @param scene defines the hosting scene
  116365. * @returns the ribbon mesh
  116366. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116368. */
  116369. static CreateRibbon(name: string, options: {
  116370. pathArray: Vector3[][];
  116371. closeArray?: boolean;
  116372. closePath?: boolean;
  116373. offset?: number;
  116374. updatable?: boolean;
  116375. sideOrientation?: number;
  116376. frontUVs?: Vector4;
  116377. backUVs?: Vector4;
  116378. instance?: Mesh;
  116379. invertUV?: boolean;
  116380. uvs?: Vector2[];
  116381. colors?: Color4[];
  116382. }, scene?: Nullable<Scene>): Mesh;
  116383. }
  116384. }
  116385. declare module BABYLON {
  116386. /**
  116387. * Class containing static functions to help procedurally build meshes
  116388. */
  116389. export class ShapeBuilder {
  116390. /**
  116391. * 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.
  116392. * * 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.
  116393. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116394. * * 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.
  116395. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116396. * * 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
  116397. * * 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
  116398. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116403. * @param name defines the name of the mesh
  116404. * @param options defines the options used to create the mesh
  116405. * @param scene defines the hosting scene
  116406. * @returns the extruded shape mesh
  116407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116409. */
  116410. static ExtrudeShape(name: string, options: {
  116411. shape: Vector3[];
  116412. path: Vector3[];
  116413. scale?: number;
  116414. rotation?: number;
  116415. cap?: number;
  116416. updatable?: boolean;
  116417. sideOrientation?: number;
  116418. frontUVs?: Vector4;
  116419. backUVs?: Vector4;
  116420. instance?: Mesh;
  116421. invertUV?: boolean;
  116422. }, scene?: Nullable<Scene>): Mesh;
  116423. /**
  116424. * Creates an custom extruded shape mesh.
  116425. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116426. * * 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.
  116427. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116428. * * 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
  116429. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116430. * * 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
  116431. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116432. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116433. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116434. * * 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
  116435. * * 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
  116436. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116441. * @param name defines the name of the mesh
  116442. * @param options defines the options used to create the mesh
  116443. * @param scene defines the hosting scene
  116444. * @returns the custom extruded shape mesh
  116445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116448. */
  116449. static ExtrudeShapeCustom(name: string, options: {
  116450. shape: Vector3[];
  116451. path: Vector3[];
  116452. scaleFunction?: any;
  116453. rotationFunction?: any;
  116454. ribbonCloseArray?: boolean;
  116455. ribbonClosePath?: boolean;
  116456. cap?: number;
  116457. updatable?: boolean;
  116458. sideOrientation?: number;
  116459. frontUVs?: Vector4;
  116460. backUVs?: Vector4;
  116461. instance?: Mesh;
  116462. invertUV?: boolean;
  116463. }, scene?: Nullable<Scene>): Mesh;
  116464. private static _ExtrudeShapeGeneric;
  116465. }
  116466. }
  116467. declare module BABYLON {
  116468. /**
  116469. * AmmoJS Physics plugin
  116470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116471. * @see https://github.com/kripken/ammo.js/
  116472. */
  116473. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116474. private _useDeltaForWorldStep;
  116475. /**
  116476. * Reference to the Ammo library
  116477. */
  116478. bjsAMMO: any;
  116479. /**
  116480. * Created ammoJS world which physics bodies are added to
  116481. */
  116482. world: any;
  116483. /**
  116484. * Name of the plugin
  116485. */
  116486. name: string;
  116487. private _timeStep;
  116488. private _fixedTimeStep;
  116489. private _maxSteps;
  116490. private _tmpQuaternion;
  116491. private _tmpAmmoTransform;
  116492. private _tmpAmmoQuaternion;
  116493. private _tmpAmmoConcreteContactResultCallback;
  116494. private _collisionConfiguration;
  116495. private _dispatcher;
  116496. private _overlappingPairCache;
  116497. private _solver;
  116498. private _softBodySolver;
  116499. private _tmpAmmoVectorA;
  116500. private _tmpAmmoVectorB;
  116501. private _tmpAmmoVectorC;
  116502. private _tmpAmmoVectorD;
  116503. private _tmpContactCallbackResult;
  116504. private _tmpAmmoVectorRCA;
  116505. private _tmpAmmoVectorRCB;
  116506. private _raycastResult;
  116507. private static readonly DISABLE_COLLISION_FLAG;
  116508. private static readonly KINEMATIC_FLAG;
  116509. private static readonly DISABLE_DEACTIVATION_FLAG;
  116510. /**
  116511. * Initializes the ammoJS plugin
  116512. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116513. * @param ammoInjection can be used to inject your own ammo reference
  116514. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116515. */
  116516. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116517. /**
  116518. * Sets the gravity of the physics world (m/(s^2))
  116519. * @param gravity Gravity to set
  116520. */
  116521. setGravity(gravity: Vector3): void;
  116522. /**
  116523. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116524. * @param timeStep timestep to use in seconds
  116525. */
  116526. setTimeStep(timeStep: number): void;
  116527. /**
  116528. * 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)
  116529. * @param fixedTimeStep fixedTimeStep to use in seconds
  116530. */
  116531. setFixedTimeStep(fixedTimeStep: number): void;
  116532. /**
  116533. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116534. * @param maxSteps the maximum number of steps by the physics engine per frame
  116535. */
  116536. setMaxSteps(maxSteps: number): void;
  116537. /**
  116538. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116539. * @returns the current timestep in seconds
  116540. */
  116541. getTimeStep(): number;
  116542. private _isImpostorInContact;
  116543. private _isImpostorPairInContact;
  116544. private _stepSimulation;
  116545. /**
  116546. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116547. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116548. * After the step the babylon meshes are set to the position of the physics imposters
  116549. * @param delta amount of time to step forward
  116550. * @param impostors array of imposters to update before/after the step
  116551. */
  116552. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116553. /**
  116554. * Update babylon mesh to match physics world object
  116555. * @param impostor imposter to match
  116556. */
  116557. private _afterSoftStep;
  116558. /**
  116559. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116560. * @param impostor imposter to match
  116561. */
  116562. private _ropeStep;
  116563. /**
  116564. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116565. * @param impostor imposter to match
  116566. */
  116567. private _softbodyOrClothStep;
  116568. private _tmpVector;
  116569. private _tmpMatrix;
  116570. /**
  116571. * Applies an impulse on the imposter
  116572. * @param impostor imposter to apply impulse to
  116573. * @param force amount of force to be applied to the imposter
  116574. * @param contactPoint the location to apply the impulse on the imposter
  116575. */
  116576. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116577. /**
  116578. * Applies a force on the imposter
  116579. * @param impostor imposter to apply force
  116580. * @param force amount of force to be applied to the imposter
  116581. * @param contactPoint the location to apply the force on the imposter
  116582. */
  116583. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116584. /**
  116585. * Creates a physics body using the plugin
  116586. * @param impostor the imposter to create the physics body on
  116587. */
  116588. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116589. /**
  116590. * Removes the physics body from the imposter and disposes of the body's memory
  116591. * @param impostor imposter to remove the physics body from
  116592. */
  116593. removePhysicsBody(impostor: PhysicsImpostor): void;
  116594. /**
  116595. * Generates a joint
  116596. * @param impostorJoint the imposter joint to create the joint with
  116597. */
  116598. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116599. /**
  116600. * Removes a joint
  116601. * @param impostorJoint the imposter joint to remove the joint from
  116602. */
  116603. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116604. private _addMeshVerts;
  116605. /**
  116606. * Initialise the soft body vertices to match its object's (mesh) vertices
  116607. * Softbody vertices (nodes) are in world space and to match this
  116608. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116609. * @param impostor to create the softbody for
  116610. */
  116611. private _softVertexData;
  116612. /**
  116613. * Create an impostor's soft body
  116614. * @param impostor to create the softbody for
  116615. */
  116616. private _createSoftbody;
  116617. /**
  116618. * Create cloth for an impostor
  116619. * @param impostor to create the softbody for
  116620. */
  116621. private _createCloth;
  116622. /**
  116623. * Create rope for an impostor
  116624. * @param impostor to create the softbody for
  116625. */
  116626. private _createRope;
  116627. private _addHullVerts;
  116628. private _createShape;
  116629. /**
  116630. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116631. * @param impostor imposter containing the physics body and babylon object
  116632. */
  116633. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116634. /**
  116635. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116636. * @param impostor imposter containing the physics body and babylon object
  116637. * @param newPosition new position
  116638. * @param newRotation new rotation
  116639. */
  116640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116641. /**
  116642. * If this plugin is supported
  116643. * @returns true if its supported
  116644. */
  116645. isSupported(): boolean;
  116646. /**
  116647. * Sets the linear velocity of the physics body
  116648. * @param impostor imposter to set the velocity on
  116649. * @param velocity velocity to set
  116650. */
  116651. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116652. /**
  116653. * Sets the angular velocity of the physics body
  116654. * @param impostor imposter to set the velocity on
  116655. * @param velocity velocity to set
  116656. */
  116657. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116658. /**
  116659. * gets the linear velocity
  116660. * @param impostor imposter to get linear velocity from
  116661. * @returns linear velocity
  116662. */
  116663. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116664. /**
  116665. * gets the angular velocity
  116666. * @param impostor imposter to get angular velocity from
  116667. * @returns angular velocity
  116668. */
  116669. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116670. /**
  116671. * Sets the mass of physics body
  116672. * @param impostor imposter to set the mass on
  116673. * @param mass mass to set
  116674. */
  116675. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116676. /**
  116677. * Gets the mass of the physics body
  116678. * @param impostor imposter to get the mass from
  116679. * @returns mass
  116680. */
  116681. getBodyMass(impostor: PhysicsImpostor): number;
  116682. /**
  116683. * Gets friction of the impostor
  116684. * @param impostor impostor to get friction from
  116685. * @returns friction value
  116686. */
  116687. getBodyFriction(impostor: PhysicsImpostor): number;
  116688. /**
  116689. * Sets friction of the impostor
  116690. * @param impostor impostor to set friction on
  116691. * @param friction friction value
  116692. */
  116693. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116694. /**
  116695. * Gets restitution of the impostor
  116696. * @param impostor impostor to get restitution from
  116697. * @returns restitution value
  116698. */
  116699. getBodyRestitution(impostor: PhysicsImpostor): number;
  116700. /**
  116701. * Sets resitution of the impostor
  116702. * @param impostor impostor to set resitution on
  116703. * @param restitution resitution value
  116704. */
  116705. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116706. /**
  116707. * Gets pressure inside the impostor
  116708. * @param impostor impostor to get pressure from
  116709. * @returns pressure value
  116710. */
  116711. getBodyPressure(impostor: PhysicsImpostor): number;
  116712. /**
  116713. * Sets pressure inside a soft body impostor
  116714. * Cloth and rope must remain 0 pressure
  116715. * @param impostor impostor to set pressure on
  116716. * @param pressure pressure value
  116717. */
  116718. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116719. /**
  116720. * Gets stiffness of the impostor
  116721. * @param impostor impostor to get stiffness from
  116722. * @returns pressure value
  116723. */
  116724. getBodyStiffness(impostor: PhysicsImpostor): number;
  116725. /**
  116726. * Sets stiffness of the impostor
  116727. * @param impostor impostor to set stiffness on
  116728. * @param stiffness stiffness value from 0 to 1
  116729. */
  116730. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116731. /**
  116732. * Gets velocityIterations of the impostor
  116733. * @param impostor impostor to get velocity iterations from
  116734. * @returns velocityIterations value
  116735. */
  116736. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116737. /**
  116738. * Sets velocityIterations of the impostor
  116739. * @param impostor impostor to set velocity iterations on
  116740. * @param velocityIterations velocityIterations value
  116741. */
  116742. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116743. /**
  116744. * Gets positionIterations of the impostor
  116745. * @param impostor impostor to get position iterations from
  116746. * @returns positionIterations value
  116747. */
  116748. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116749. /**
  116750. * Sets positionIterations of the impostor
  116751. * @param impostor impostor to set position on
  116752. * @param positionIterations positionIterations value
  116753. */
  116754. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116755. /**
  116756. * Append an anchor to a cloth object
  116757. * @param impostor is the cloth impostor to add anchor to
  116758. * @param otherImpostor is the rigid impostor to anchor to
  116759. * @param width ratio across width from 0 to 1
  116760. * @param height ratio up height from 0 to 1
  116761. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116762. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116763. */
  116764. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116765. /**
  116766. * Append an hook to a rope object
  116767. * @param impostor is the rope impostor to add hook to
  116768. * @param otherImpostor is the rigid impostor to hook to
  116769. * @param length ratio along the rope from 0 to 1
  116770. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116771. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116772. */
  116773. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116774. /**
  116775. * Sleeps the physics body and stops it from being active
  116776. * @param impostor impostor to sleep
  116777. */
  116778. sleepBody(impostor: PhysicsImpostor): void;
  116779. /**
  116780. * Activates the physics body
  116781. * @param impostor impostor to activate
  116782. */
  116783. wakeUpBody(impostor: PhysicsImpostor): void;
  116784. /**
  116785. * Updates the distance parameters of the joint
  116786. * @param joint joint to update
  116787. * @param maxDistance maximum distance of the joint
  116788. * @param minDistance minimum distance of the joint
  116789. */
  116790. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116791. /**
  116792. * Sets a motor on the joint
  116793. * @param joint joint to set motor on
  116794. * @param speed speed of the motor
  116795. * @param maxForce maximum force of the motor
  116796. * @param motorIndex index of the motor
  116797. */
  116798. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116799. /**
  116800. * Sets the motors limit
  116801. * @param joint joint to set limit on
  116802. * @param upperLimit upper limit
  116803. * @param lowerLimit lower limit
  116804. */
  116805. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116806. /**
  116807. * Syncs the position and rotation of a mesh with the impostor
  116808. * @param mesh mesh to sync
  116809. * @param impostor impostor to update the mesh with
  116810. */
  116811. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116812. /**
  116813. * Gets the radius of the impostor
  116814. * @param impostor impostor to get radius from
  116815. * @returns the radius
  116816. */
  116817. getRadius(impostor: PhysicsImpostor): number;
  116818. /**
  116819. * Gets the box size of the impostor
  116820. * @param impostor impostor to get box size from
  116821. * @param result the resulting box size
  116822. */
  116823. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116824. /**
  116825. * Disposes of the impostor
  116826. */
  116827. dispose(): void;
  116828. /**
  116829. * Does a raycast in the physics world
  116830. * @param from when should the ray start?
  116831. * @param to when should the ray end?
  116832. * @returns PhysicsRaycastResult
  116833. */
  116834. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116835. }
  116836. }
  116837. declare module BABYLON {
  116838. interface AbstractScene {
  116839. /**
  116840. * The list of reflection probes added to the scene
  116841. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116842. */
  116843. reflectionProbes: Array<ReflectionProbe>;
  116844. /**
  116845. * Removes the given reflection probe from this scene.
  116846. * @param toRemove The reflection probe to remove
  116847. * @returns The index of the removed reflection probe
  116848. */
  116849. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116850. /**
  116851. * Adds the given reflection probe to this scene.
  116852. * @param newReflectionProbe The reflection probe to add
  116853. */
  116854. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116855. }
  116856. /**
  116857. * Class used to generate realtime reflection / refraction cube textures
  116858. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116859. */
  116860. export class ReflectionProbe {
  116861. /** defines the name of the probe */
  116862. name: string;
  116863. private _scene;
  116864. private _renderTargetTexture;
  116865. private _projectionMatrix;
  116866. private _viewMatrix;
  116867. private _target;
  116868. private _add;
  116869. private _attachedMesh;
  116870. private _invertYAxis;
  116871. /** Gets or sets probe position (center of the cube map) */
  116872. position: Vector3;
  116873. /**
  116874. * Creates a new reflection probe
  116875. * @param name defines the name of the probe
  116876. * @param size defines the texture resolution (for each face)
  116877. * @param scene defines the hosting scene
  116878. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116879. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116880. */
  116881. constructor(
  116882. /** defines the name of the probe */
  116883. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116884. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116885. samples: number;
  116886. /** Gets or sets the refresh rate to use (on every frame by default) */
  116887. refreshRate: number;
  116888. /**
  116889. * Gets the hosting scene
  116890. * @returns a Scene
  116891. */
  116892. getScene(): Scene;
  116893. /** Gets the internal CubeTexture used to render to */
  116894. readonly cubeTexture: RenderTargetTexture;
  116895. /** Gets the list of meshes to render */
  116896. readonly renderList: Nullable<AbstractMesh[]>;
  116897. /**
  116898. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116899. * @param mesh defines the mesh to attach to
  116900. */
  116901. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116902. /**
  116903. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116904. * @param renderingGroupId The rendering group id corresponding to its index
  116905. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116906. */
  116907. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116908. /**
  116909. * Clean all associated resources
  116910. */
  116911. dispose(): void;
  116912. /**
  116913. * Converts the reflection probe information to a readable string for debug purpose.
  116914. * @param fullDetails Supports for multiple levels of logging within scene loading
  116915. * @returns the human readable reflection probe info
  116916. */
  116917. toString(fullDetails?: boolean): string;
  116918. /**
  116919. * Get the class name of the relfection probe.
  116920. * @returns "ReflectionProbe"
  116921. */
  116922. getClassName(): string;
  116923. /**
  116924. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116925. * @returns The JSON representation of the texture
  116926. */
  116927. serialize(): any;
  116928. /**
  116929. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116930. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116931. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116932. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116933. * @returns The parsed reflection probe if successful
  116934. */
  116935. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116936. }
  116937. }
  116938. declare module BABYLON {
  116939. /** @hidden */
  116940. export var _BabylonLoaderRegistered: boolean;
  116941. }
  116942. declare module BABYLON {
  116943. /**
  116944. * The Physically based simple base material of BJS.
  116945. *
  116946. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116947. * It is used as the base class for both the specGloss and metalRough conventions.
  116948. */
  116949. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116950. /**
  116951. * Number of Simultaneous lights allowed on the material.
  116952. */
  116953. maxSimultaneousLights: number;
  116954. /**
  116955. * If sets to true, disables all the lights affecting the material.
  116956. */
  116957. disableLighting: boolean;
  116958. /**
  116959. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116960. */
  116961. environmentTexture: BaseTexture;
  116962. /**
  116963. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116964. */
  116965. invertNormalMapX: boolean;
  116966. /**
  116967. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116968. */
  116969. invertNormalMapY: boolean;
  116970. /**
  116971. * Normal map used in the model.
  116972. */
  116973. normalTexture: BaseTexture;
  116974. /**
  116975. * Emissivie color used to self-illuminate the model.
  116976. */
  116977. emissiveColor: Color3;
  116978. /**
  116979. * Emissivie texture used to self-illuminate the model.
  116980. */
  116981. emissiveTexture: BaseTexture;
  116982. /**
  116983. * Occlusion Channel Strenght.
  116984. */
  116985. occlusionStrength: number;
  116986. /**
  116987. * Occlusion Texture of the material (adding extra occlusion effects).
  116988. */
  116989. occlusionTexture: BaseTexture;
  116990. /**
  116991. * Defines the alpha limits in alpha test mode.
  116992. */
  116993. alphaCutOff: number;
  116994. /**
  116995. * Gets the current double sided mode.
  116996. */
  116997. /**
  116998. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116999. */
  117000. doubleSided: boolean;
  117001. /**
  117002. * Stores the pre-calculated light information of a mesh in a texture.
  117003. */
  117004. lightmapTexture: BaseTexture;
  117005. /**
  117006. * If true, the light map contains occlusion information instead of lighting info.
  117007. */
  117008. useLightmapAsShadowmap: boolean;
  117009. /**
  117010. * Instantiates a new PBRMaterial instance.
  117011. *
  117012. * @param name The material name
  117013. * @param scene The scene the material will be use in.
  117014. */
  117015. constructor(name: string, scene: Scene);
  117016. getClassName(): string;
  117017. }
  117018. }
  117019. declare module BABYLON {
  117020. /**
  117021. * The PBR material of BJS following the metal roughness convention.
  117022. *
  117023. * This fits to the PBR convention in the GLTF definition:
  117024. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117025. */
  117026. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117027. /**
  117028. * The base color has two different interpretations depending on the value of metalness.
  117029. * When the material is a metal, the base color is the specific measured reflectance value
  117030. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117031. * of the material.
  117032. */
  117033. baseColor: Color3;
  117034. /**
  117035. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117036. * well as opacity information in the alpha channel.
  117037. */
  117038. baseTexture: BaseTexture;
  117039. /**
  117040. * Specifies the metallic scalar value of the material.
  117041. * Can also be used to scale the metalness values of the metallic texture.
  117042. */
  117043. metallic: number;
  117044. /**
  117045. * Specifies the roughness scalar value of the material.
  117046. * Can also be used to scale the roughness values of the metallic texture.
  117047. */
  117048. roughness: number;
  117049. /**
  117050. * Texture containing both the metallic value in the B channel and the
  117051. * roughness value in the G channel to keep better precision.
  117052. */
  117053. metallicRoughnessTexture: BaseTexture;
  117054. /**
  117055. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117056. *
  117057. * @param name The material name
  117058. * @param scene The scene the material will be use in.
  117059. */
  117060. constructor(name: string, scene: Scene);
  117061. /**
  117062. * Return the currrent class name of the material.
  117063. */
  117064. getClassName(): string;
  117065. /**
  117066. * Makes a duplicate of the current material.
  117067. * @param name - name to use for the new material.
  117068. */
  117069. clone(name: string): PBRMetallicRoughnessMaterial;
  117070. /**
  117071. * Serialize the material to a parsable JSON object.
  117072. */
  117073. serialize(): any;
  117074. /**
  117075. * Parses a JSON object correponding to the serialize function.
  117076. */
  117077. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117078. }
  117079. }
  117080. declare module BABYLON {
  117081. /**
  117082. * The PBR material of BJS following the specular glossiness convention.
  117083. *
  117084. * This fits to the PBR convention in the GLTF definition:
  117085. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117086. */
  117087. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117088. /**
  117089. * Specifies the diffuse color of the material.
  117090. */
  117091. diffuseColor: Color3;
  117092. /**
  117093. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117094. * channel.
  117095. */
  117096. diffuseTexture: BaseTexture;
  117097. /**
  117098. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117099. */
  117100. specularColor: Color3;
  117101. /**
  117102. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117103. */
  117104. glossiness: number;
  117105. /**
  117106. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117107. */
  117108. specularGlossinessTexture: BaseTexture;
  117109. /**
  117110. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117111. *
  117112. * @param name The material name
  117113. * @param scene The scene the material will be use in.
  117114. */
  117115. constructor(name: string, scene: Scene);
  117116. /**
  117117. * Return the currrent class name of the material.
  117118. */
  117119. getClassName(): string;
  117120. /**
  117121. * Makes a duplicate of the current material.
  117122. * @param name - name to use for the new material.
  117123. */
  117124. clone(name: string): PBRSpecularGlossinessMaterial;
  117125. /**
  117126. * Serialize the material to a parsable JSON object.
  117127. */
  117128. serialize(): any;
  117129. /**
  117130. * Parses a JSON object correponding to the serialize function.
  117131. */
  117132. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117133. }
  117134. }
  117135. declare module BABYLON {
  117136. /**
  117137. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117138. * It can help converting any input color in a desired output one. This can then be used to create effects
  117139. * from sepia, black and white to sixties or futuristic rendering...
  117140. *
  117141. * The only supported format is currently 3dl.
  117142. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117143. */
  117144. export class ColorGradingTexture extends BaseTexture {
  117145. /**
  117146. * The current texture matrix. (will always be identity in color grading texture)
  117147. */
  117148. private _textureMatrix;
  117149. /**
  117150. * The texture URL.
  117151. */
  117152. url: string;
  117153. /**
  117154. * Empty line regex stored for GC.
  117155. */
  117156. private static _noneEmptyLineRegex;
  117157. private _engine;
  117158. /**
  117159. * Instantiates a ColorGradingTexture from the following parameters.
  117160. *
  117161. * @param url The location of the color gradind data (currently only supporting 3dl)
  117162. * @param scene The scene the texture will be used in
  117163. */
  117164. constructor(url: string, scene: Scene);
  117165. /**
  117166. * Returns the texture matrix used in most of the material.
  117167. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117168. */
  117169. getTextureMatrix(): Matrix;
  117170. /**
  117171. * Occurs when the file being loaded is a .3dl LUT file.
  117172. */
  117173. private load3dlTexture;
  117174. /**
  117175. * Starts the loading process of the texture.
  117176. */
  117177. private loadTexture;
  117178. /**
  117179. * Clones the color gradind texture.
  117180. */
  117181. clone(): ColorGradingTexture;
  117182. /**
  117183. * Called during delayed load for textures.
  117184. */
  117185. delayLoad(): void;
  117186. /**
  117187. * Parses a color grading texture serialized by Babylon.
  117188. * @param parsedTexture The texture information being parsedTexture
  117189. * @param scene The scene to load the texture in
  117190. * @param rootUrl The root url of the data assets to load
  117191. * @return A color gradind texture
  117192. */
  117193. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117194. /**
  117195. * Serializes the LUT texture to json format.
  117196. */
  117197. serialize(): any;
  117198. }
  117199. }
  117200. declare module BABYLON {
  117201. /**
  117202. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117203. */
  117204. export class EquiRectangularCubeTexture extends BaseTexture {
  117205. /** The six faces of the cube. */
  117206. private static _FacesMapping;
  117207. private _noMipmap;
  117208. private _onLoad;
  117209. private _onError;
  117210. /** The size of the cubemap. */
  117211. private _size;
  117212. /** The buffer of the image. */
  117213. private _buffer;
  117214. /** The width of the input image. */
  117215. private _width;
  117216. /** The height of the input image. */
  117217. private _height;
  117218. /** The URL to the image. */
  117219. url: string;
  117220. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117221. coordinatesMode: number;
  117222. /**
  117223. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117224. * @param url The location of the image
  117225. * @param scene The scene the texture will be used in
  117226. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117227. * @param noMipmap Forces to not generate the mipmap if true
  117228. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117229. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117230. * @param onLoad — defines a callback called when texture is loaded
  117231. * @param onError — defines a callback called if there is an error
  117232. */
  117233. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117234. /**
  117235. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117236. */
  117237. private loadImage;
  117238. /**
  117239. * Convert the image buffer into a cubemap and create a CubeTexture.
  117240. */
  117241. private loadTexture;
  117242. /**
  117243. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117244. * @param buffer The ArrayBuffer that should be converted.
  117245. * @returns The buffer as Float32Array.
  117246. */
  117247. private getFloat32ArrayFromArrayBuffer;
  117248. /**
  117249. * Get the current class name of the texture useful for serialization or dynamic coding.
  117250. * @returns "EquiRectangularCubeTexture"
  117251. */
  117252. getClassName(): string;
  117253. /**
  117254. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117255. * @returns A clone of the current EquiRectangularCubeTexture.
  117256. */
  117257. clone(): EquiRectangularCubeTexture;
  117258. }
  117259. }
  117260. declare module BABYLON {
  117261. /**
  117262. * Based on jsTGALoader - Javascript loader for TGA file
  117263. * By Vincent Thibault
  117264. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117265. */
  117266. export class TGATools {
  117267. private static _TYPE_INDEXED;
  117268. private static _TYPE_RGB;
  117269. private static _TYPE_GREY;
  117270. private static _TYPE_RLE_INDEXED;
  117271. private static _TYPE_RLE_RGB;
  117272. private static _TYPE_RLE_GREY;
  117273. private static _ORIGIN_MASK;
  117274. private static _ORIGIN_SHIFT;
  117275. private static _ORIGIN_BL;
  117276. private static _ORIGIN_BR;
  117277. private static _ORIGIN_UL;
  117278. private static _ORIGIN_UR;
  117279. /**
  117280. * Gets the header of a TGA file
  117281. * @param data defines the TGA data
  117282. * @returns the header
  117283. */
  117284. static GetTGAHeader(data: Uint8Array): any;
  117285. /**
  117286. * Uploads TGA content to a Babylon Texture
  117287. * @hidden
  117288. */
  117289. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117290. /** @hidden */
  117291. 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;
  117292. /** @hidden */
  117293. 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;
  117294. /** @hidden */
  117295. 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;
  117296. /** @hidden */
  117297. 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;
  117298. /** @hidden */
  117299. 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;
  117300. /** @hidden */
  117301. 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;
  117302. }
  117303. }
  117304. declare module BABYLON {
  117305. /**
  117306. * Implementation of the TGA Texture Loader.
  117307. * @hidden
  117308. */
  117309. export class _TGATextureLoader implements IInternalTextureLoader {
  117310. /**
  117311. * Defines wether the loader supports cascade loading the different faces.
  117312. */
  117313. readonly supportCascades: boolean;
  117314. /**
  117315. * This returns if the loader support the current file information.
  117316. * @param extension defines the file extension of the file being loaded
  117317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117318. * @param fallback defines the fallback internal texture if any
  117319. * @param isBase64 defines whether the texture is encoded as a base64
  117320. * @param isBuffer defines whether the texture data are stored as a buffer
  117321. * @returns true if the loader can load the specified file
  117322. */
  117323. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117324. /**
  117325. * Transform the url before loading if required.
  117326. * @param rootUrl the url of the texture
  117327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117328. * @returns the transformed texture
  117329. */
  117330. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117331. /**
  117332. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117333. * @param rootUrl the url of the texture
  117334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117335. * @returns the fallback texture
  117336. */
  117337. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117338. /**
  117339. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117340. * @param data contains the texture data
  117341. * @param texture defines the BabylonJS internal texture
  117342. * @param createPolynomials will be true if polynomials have been requested
  117343. * @param onLoad defines the callback to trigger once the texture is ready
  117344. * @param onError defines the callback to trigger in case of error
  117345. */
  117346. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117347. /**
  117348. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117349. * @param data contains the texture data
  117350. * @param texture defines the BabylonJS internal texture
  117351. * @param callback defines the method to call once ready to upload
  117352. */
  117353. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117354. }
  117355. }
  117356. declare module BABYLON {
  117357. /**
  117358. * Info about the .basis files
  117359. */
  117360. class BasisFileInfo {
  117361. /**
  117362. * If the file has alpha
  117363. */
  117364. hasAlpha: boolean;
  117365. /**
  117366. * Info about each image of the basis file
  117367. */
  117368. images: Array<{
  117369. levels: Array<{
  117370. width: number;
  117371. height: number;
  117372. transcodedPixels: ArrayBufferView;
  117373. }>;
  117374. }>;
  117375. }
  117376. /**
  117377. * Result of transcoding a basis file
  117378. */
  117379. class TranscodeResult {
  117380. /**
  117381. * Info about the .basis file
  117382. */
  117383. fileInfo: BasisFileInfo;
  117384. /**
  117385. * Format to use when loading the file
  117386. */
  117387. format: number;
  117388. }
  117389. /**
  117390. * Configuration options for the Basis transcoder
  117391. */
  117392. export class BasisTranscodeConfiguration {
  117393. /**
  117394. * Supported compression formats used to determine the supported output format of the transcoder
  117395. */
  117396. supportedCompressionFormats?: {
  117397. /**
  117398. * etc1 compression format
  117399. */
  117400. etc1?: boolean;
  117401. /**
  117402. * s3tc compression format
  117403. */
  117404. s3tc?: boolean;
  117405. /**
  117406. * pvrtc compression format
  117407. */
  117408. pvrtc?: boolean;
  117409. /**
  117410. * etc2 compression format
  117411. */
  117412. etc2?: boolean;
  117413. };
  117414. /**
  117415. * If mipmap levels should be loaded for transcoded images (Default: true)
  117416. */
  117417. loadMipmapLevels?: boolean;
  117418. /**
  117419. * Index of a single image to load (Default: all images)
  117420. */
  117421. loadSingleImage?: number;
  117422. }
  117423. /**
  117424. * Used to load .Basis files
  117425. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117426. */
  117427. export class BasisTools {
  117428. private static _IgnoreSupportedFormats;
  117429. /**
  117430. * URL to use when loading the basis transcoder
  117431. */
  117432. static JSModuleURL: string;
  117433. /**
  117434. * URL to use when loading the wasm module for the transcoder
  117435. */
  117436. static WasmModuleURL: string;
  117437. /**
  117438. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117439. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117440. * @returns internal format corresponding to the Basis format
  117441. */
  117442. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117443. private static _WorkerPromise;
  117444. private static _Worker;
  117445. private static _actionId;
  117446. private static _CreateWorkerAsync;
  117447. /**
  117448. * Transcodes a loaded image file to compressed pixel data
  117449. * @param imageData image data to transcode
  117450. * @param config configuration options for the transcoding
  117451. * @returns a promise resulting in the transcoded image
  117452. */
  117453. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117454. /**
  117455. * Loads a texture from the transcode result
  117456. * @param texture texture load to
  117457. * @param transcodeResult the result of transcoding the basis file to load from
  117458. */
  117459. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117460. }
  117461. }
  117462. declare module BABYLON {
  117463. /**
  117464. * Loader for .basis file format
  117465. */
  117466. export class _BasisTextureLoader implements IInternalTextureLoader {
  117467. /**
  117468. * Defines whether the loader supports cascade loading the different faces.
  117469. */
  117470. readonly supportCascades: boolean;
  117471. /**
  117472. * This returns if the loader support the current file information.
  117473. * @param extension defines the file extension of the file being loaded
  117474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117475. * @param fallback defines the fallback internal texture if any
  117476. * @param isBase64 defines whether the texture is encoded as a base64
  117477. * @param isBuffer defines whether the texture data are stored as a buffer
  117478. * @returns true if the loader can load the specified file
  117479. */
  117480. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117481. /**
  117482. * Transform the url before loading if required.
  117483. * @param rootUrl the url of the texture
  117484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117485. * @returns the transformed texture
  117486. */
  117487. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117488. /**
  117489. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117490. * @param rootUrl the url of the texture
  117491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117492. * @returns the fallback texture
  117493. */
  117494. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117495. /**
  117496. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117497. * @param data contains the texture data
  117498. * @param texture defines the BabylonJS internal texture
  117499. * @param createPolynomials will be true if polynomials have been requested
  117500. * @param onLoad defines the callback to trigger once the texture is ready
  117501. * @param onError defines the callback to trigger in case of error
  117502. */
  117503. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117504. /**
  117505. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117506. * @param data contains the texture data
  117507. * @param texture defines the BabylonJS internal texture
  117508. * @param callback defines the method to call once ready to upload
  117509. */
  117510. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117511. }
  117512. }
  117513. declare module BABYLON {
  117514. /**
  117515. * 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.
  117516. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117517. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117518. */
  117519. export class CustomProceduralTexture extends ProceduralTexture {
  117520. private _animate;
  117521. private _time;
  117522. private _config;
  117523. private _texturePath;
  117524. /**
  117525. * Instantiates a new Custom Procedural Texture.
  117526. * 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.
  117527. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117528. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117529. * @param name Define the name of the texture
  117530. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117531. * @param size Define the size of the texture to create
  117532. * @param scene Define the scene the texture belongs to
  117533. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117534. * @param generateMipMaps Define if the texture should creates mip maps or not
  117535. */
  117536. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117537. private _loadJson;
  117538. /**
  117539. * Is the texture ready to be used ? (rendered at least once)
  117540. * @returns true if ready, otherwise, false.
  117541. */
  117542. isReady(): boolean;
  117543. /**
  117544. * Render the texture to its associated render target.
  117545. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117546. */
  117547. render(useCameraPostProcess?: boolean): void;
  117548. /**
  117549. * Update the list of dependant textures samplers in the shader.
  117550. */
  117551. updateTextures(): void;
  117552. /**
  117553. * Update the uniform values of the procedural texture in the shader.
  117554. */
  117555. updateShaderUniforms(): void;
  117556. /**
  117557. * Define if the texture animates or not.
  117558. */
  117559. animate: boolean;
  117560. }
  117561. }
  117562. declare module BABYLON {
  117563. /** @hidden */
  117564. export var noisePixelShader: {
  117565. name: string;
  117566. shader: string;
  117567. };
  117568. }
  117569. declare module BABYLON {
  117570. /**
  117571. * Class used to generate noise procedural textures
  117572. */
  117573. export class NoiseProceduralTexture extends ProceduralTexture {
  117574. private _time;
  117575. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117576. brightness: number;
  117577. /** Defines the number of octaves to process */
  117578. octaves: number;
  117579. /** Defines the level of persistence (0.8 by default) */
  117580. persistence: number;
  117581. /** Gets or sets animation speed factor (default is 1) */
  117582. animationSpeedFactor: number;
  117583. /**
  117584. * Creates a new NoiseProceduralTexture
  117585. * @param name defines the name fo the texture
  117586. * @param size defines the size of the texture (default is 256)
  117587. * @param scene defines the hosting scene
  117588. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117589. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117590. */
  117591. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117592. private _updateShaderUniforms;
  117593. protected _getDefines(): string;
  117594. /** Generate the current state of the procedural texture */
  117595. render(useCameraPostProcess?: boolean): void;
  117596. /**
  117597. * Serializes this noise procedural texture
  117598. * @returns a serialized noise procedural texture object
  117599. */
  117600. serialize(): any;
  117601. /**
  117602. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117603. * @param parsedTexture defines parsed texture data
  117604. * @param scene defines the current scene
  117605. * @param rootUrl defines the root URL containing noise procedural texture information
  117606. * @returns a parsed NoiseProceduralTexture
  117607. */
  117608. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117609. }
  117610. }
  117611. declare module BABYLON {
  117612. /**
  117613. * Raw cube texture where the raw buffers are passed in
  117614. */
  117615. export class RawCubeTexture extends CubeTexture {
  117616. /**
  117617. * Creates a cube texture where the raw buffers are passed in.
  117618. * @param scene defines the scene the texture is attached to
  117619. * @param data defines the array of data to use to create each face
  117620. * @param size defines the size of the textures
  117621. * @param format defines the format of the data
  117622. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117623. * @param generateMipMaps defines if the engine should generate the mip levels
  117624. * @param invertY defines if data must be stored with Y axis inverted
  117625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117626. * @param compression defines the compression used (null by default)
  117627. */
  117628. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117629. /**
  117630. * Updates the raw cube texture.
  117631. * @param data defines the data to store
  117632. * @param format defines the data format
  117633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117634. * @param invertY defines if data must be stored with Y axis inverted
  117635. * @param compression defines the compression used (null by default)
  117636. * @param level defines which level of the texture to update
  117637. */
  117638. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117639. /**
  117640. * Updates a raw cube texture with RGBD encoded data.
  117641. * @param data defines the array of data [mipmap][face] to use to create each face
  117642. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117643. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117644. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117645. * @returns a promsie that resolves when the operation is complete
  117646. */
  117647. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117648. /**
  117649. * Clones the raw cube texture.
  117650. * @return a new cube texture
  117651. */
  117652. clone(): CubeTexture;
  117653. /** @hidden */
  117654. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117655. }
  117656. }
  117657. declare module BABYLON {
  117658. /**
  117659. * Class used to store 3D textures containing user data
  117660. */
  117661. export class RawTexture3D extends Texture {
  117662. /** Gets or sets the texture format to use */
  117663. format: number;
  117664. private _engine;
  117665. /**
  117666. * Create a new RawTexture3D
  117667. * @param data defines the data of the texture
  117668. * @param width defines the width of the texture
  117669. * @param height defines the height of the texture
  117670. * @param depth defines the depth of the texture
  117671. * @param format defines the texture format to use
  117672. * @param scene defines the hosting scene
  117673. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117674. * @param invertY defines if texture must be stored with Y axis inverted
  117675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117676. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117677. */
  117678. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117679. /** Gets or sets the texture format to use */
  117680. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117681. /**
  117682. * Update the texture with new data
  117683. * @param data defines the data to store in the texture
  117684. */
  117685. update(data: ArrayBufferView): void;
  117686. }
  117687. }
  117688. declare module BABYLON {
  117689. /**
  117690. * Creates a refraction texture used by refraction channel of the standard material.
  117691. * It is like a mirror but to see through a material.
  117692. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117693. */
  117694. export class RefractionTexture extends RenderTargetTexture {
  117695. /**
  117696. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117697. * 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.
  117698. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117699. */
  117700. refractionPlane: Plane;
  117701. /**
  117702. * Define how deep under the surface we should see.
  117703. */
  117704. depth: number;
  117705. /**
  117706. * Creates a refraction texture used by refraction channel of the standard material.
  117707. * It is like a mirror but to see through a material.
  117708. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117709. * @param name Define the texture name
  117710. * @param size Define the size of the underlying texture
  117711. * @param scene Define the scene the refraction belongs to
  117712. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117713. */
  117714. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117715. /**
  117716. * Clone the refraction texture.
  117717. * @returns the cloned texture
  117718. */
  117719. clone(): RefractionTexture;
  117720. /**
  117721. * Serialize the texture to a JSON representation you could use in Parse later on
  117722. * @returns the serialized JSON representation
  117723. */
  117724. serialize(): any;
  117725. }
  117726. }
  117727. declare module BABYLON {
  117728. /**
  117729. * Defines the options related to the creation of an HtmlElementTexture
  117730. */
  117731. export interface IHtmlElementTextureOptions {
  117732. /**
  117733. * Defines wether mip maps should be created or not.
  117734. */
  117735. generateMipMaps?: boolean;
  117736. /**
  117737. * Defines the sampling mode of the texture.
  117738. */
  117739. samplingMode?: number;
  117740. /**
  117741. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117742. */
  117743. engine: Nullable<Engine>;
  117744. /**
  117745. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117746. */
  117747. scene: Nullable<Scene>;
  117748. }
  117749. /**
  117750. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117751. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117752. * is automatically managed.
  117753. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117754. * in your application.
  117755. *
  117756. * As the update is not automatic, you need to call them manually.
  117757. */
  117758. export class HtmlElementTexture extends BaseTexture {
  117759. /**
  117760. * The texture URL.
  117761. */
  117762. element: HTMLVideoElement | HTMLCanvasElement;
  117763. private static readonly DefaultOptions;
  117764. private _textureMatrix;
  117765. private _engine;
  117766. private _isVideo;
  117767. private _generateMipMaps;
  117768. private _samplingMode;
  117769. /**
  117770. * Instantiates a HtmlElementTexture from the following parameters.
  117771. *
  117772. * @param name Defines the name of the texture
  117773. * @param element Defines the video or canvas the texture is filled with
  117774. * @param options Defines the other none mandatory texture creation options
  117775. */
  117776. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117777. private _createInternalTexture;
  117778. /**
  117779. * Returns the texture matrix used in most of the material.
  117780. */
  117781. getTextureMatrix(): Matrix;
  117782. /**
  117783. * Updates the content of the texture.
  117784. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117785. */
  117786. update(invertY?: Nullable<boolean>): void;
  117787. }
  117788. }
  117789. declare module BABYLON {
  117790. /**
  117791. * Enum used to define the target of a block
  117792. */
  117793. export enum NodeMaterialBlockTargets {
  117794. /** Vertex shader */
  117795. Vertex = 1,
  117796. /** Fragment shader */
  117797. Fragment = 2,
  117798. /** Neutral */
  117799. Neutral = 4,
  117800. /** Vertex and Fragment */
  117801. VertexAndFragment = 3
  117802. }
  117803. }
  117804. declare module BABYLON {
  117805. /**
  117806. * Defines the kind of connection point for node based material
  117807. */
  117808. export enum NodeMaterialBlockConnectionPointTypes {
  117809. /** Float */
  117810. Float = 1,
  117811. /** Int */
  117812. Int = 2,
  117813. /** Vector2 */
  117814. Vector2 = 4,
  117815. /** Vector3 */
  117816. Vector3 = 8,
  117817. /** Vector4 */
  117818. Vector4 = 16,
  117819. /** Color3 */
  117820. Color3 = 32,
  117821. /** Color4 */
  117822. Color4 = 64,
  117823. /** Matrix */
  117824. Matrix = 128,
  117825. /** Detect type based on connection */
  117826. AutoDetect = 1024,
  117827. /** Output type that will be defined by input type */
  117828. BasedOnInput = 2048
  117829. }
  117830. }
  117831. declare module BABYLON {
  117832. /**
  117833. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117834. */
  117835. export enum NodeMaterialBlockConnectionPointMode {
  117836. /** Value is an uniform */
  117837. Uniform = 0,
  117838. /** Value is a mesh attribute */
  117839. Attribute = 1,
  117840. /** Value is a varying between vertex and fragment shaders */
  117841. Varying = 2,
  117842. /** Mode is undefined */
  117843. Undefined = 3
  117844. }
  117845. }
  117846. declare module BABYLON {
  117847. /**
  117848. * Enum used to define system values e.g. values automatically provided by the system
  117849. */
  117850. export enum NodeMaterialSystemValues {
  117851. /** World */
  117852. World = 1,
  117853. /** View */
  117854. View = 2,
  117855. /** Projection */
  117856. Projection = 3,
  117857. /** ViewProjection */
  117858. ViewProjection = 4,
  117859. /** WorldView */
  117860. WorldView = 5,
  117861. /** WorldViewProjection */
  117862. WorldViewProjection = 6,
  117863. /** CameraPosition */
  117864. CameraPosition = 7,
  117865. /** Fog Color */
  117866. FogColor = 8
  117867. }
  117868. }
  117869. declare module BABYLON {
  117870. /**
  117871. * Root class for all node material optimizers
  117872. */
  117873. export class NodeMaterialOptimizer {
  117874. /**
  117875. * Function used to optimize a NodeMaterial graph
  117876. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117877. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117878. */
  117879. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117880. }
  117881. }
  117882. declare module BABYLON {
  117883. /**
  117884. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117885. */
  117886. export class TransformBlock extends NodeMaterialBlock {
  117887. /**
  117888. * Defines the value to use to complement W value to transform it to a Vector4
  117889. */
  117890. complementW: number;
  117891. /**
  117892. * Defines the value to use to complement z value to transform it to a Vector4
  117893. */
  117894. complementZ: number;
  117895. /**
  117896. * Creates a new TransformBlock
  117897. * @param name defines the block name
  117898. */
  117899. constructor(name: string);
  117900. /**
  117901. * Gets the current class name
  117902. * @returns the class name
  117903. */
  117904. getClassName(): string;
  117905. /**
  117906. * Gets the vector input
  117907. */
  117908. readonly vector: NodeMaterialConnectionPoint;
  117909. /**
  117910. * Gets the output component
  117911. */
  117912. readonly output: NodeMaterialConnectionPoint;
  117913. /**
  117914. * Gets the matrix transform input
  117915. */
  117916. readonly transform: NodeMaterialConnectionPoint;
  117917. protected _buildBlock(state: NodeMaterialBuildState): this;
  117918. serialize(): any;
  117919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117920. protected _dumpPropertiesCode(): string;
  117921. }
  117922. }
  117923. declare module BABYLON {
  117924. /**
  117925. * Block used to output the vertex position
  117926. */
  117927. export class VertexOutputBlock extends NodeMaterialBlock {
  117928. /**
  117929. * Creates a new VertexOutputBlock
  117930. * @param name defines the block name
  117931. */
  117932. constructor(name: string);
  117933. /**
  117934. * Gets the current class name
  117935. * @returns the class name
  117936. */
  117937. getClassName(): string;
  117938. /**
  117939. * Gets the vector input component
  117940. */
  117941. readonly vector: NodeMaterialConnectionPoint;
  117942. protected _buildBlock(state: NodeMaterialBuildState): this;
  117943. }
  117944. }
  117945. declare module BABYLON {
  117946. /**
  117947. * Block used to output the final color
  117948. */
  117949. export class FragmentOutputBlock extends NodeMaterialBlock {
  117950. /**
  117951. * Create a new FragmentOutputBlock
  117952. * @param name defines the block name
  117953. */
  117954. constructor(name: string);
  117955. /**
  117956. * Gets the current class name
  117957. * @returns the class name
  117958. */
  117959. getClassName(): string;
  117960. /**
  117961. * Gets the rgba input component
  117962. */
  117963. readonly rgba: NodeMaterialConnectionPoint;
  117964. /**
  117965. * Gets the rgb input component
  117966. */
  117967. readonly rgb: NodeMaterialConnectionPoint;
  117968. /**
  117969. * Gets the a input component
  117970. */
  117971. readonly a: NodeMaterialConnectionPoint;
  117972. protected _buildBlock(state: NodeMaterialBuildState): this;
  117973. }
  117974. }
  117975. declare module BABYLON {
  117976. /**
  117977. * Block used to read a reflection texture from a sampler
  117978. */
  117979. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117980. private _define3DName;
  117981. private _defineCubicName;
  117982. private _defineExplicitName;
  117983. private _defineProjectionName;
  117984. private _defineLocalCubicName;
  117985. private _defineSphericalName;
  117986. private _definePlanarName;
  117987. private _defineEquirectangularName;
  117988. private _defineMirroredEquirectangularFixedName;
  117989. private _defineEquirectangularFixedName;
  117990. private _defineSkyboxName;
  117991. private _cubeSamplerName;
  117992. private _2DSamplerName;
  117993. private _positionUVWName;
  117994. private _directionWName;
  117995. private _reflectionCoordsName;
  117996. private _reflection2DCoordsName;
  117997. private _reflectionColorName;
  117998. private _reflectionMatrixName;
  117999. /**
  118000. * Gets or sets the texture associated with the node
  118001. */
  118002. texture: Nullable<BaseTexture>;
  118003. /**
  118004. * Create a new TextureBlock
  118005. * @param name defines the block name
  118006. */
  118007. constructor(name: string);
  118008. /**
  118009. * Gets the current class name
  118010. * @returns the class name
  118011. */
  118012. getClassName(): string;
  118013. /**
  118014. * Gets the world position input component
  118015. */
  118016. readonly position: NodeMaterialConnectionPoint;
  118017. /**
  118018. * Gets the world position input component
  118019. */
  118020. readonly worldPosition: NodeMaterialConnectionPoint;
  118021. /**
  118022. * Gets the world normal input component
  118023. */
  118024. readonly worldNormal: NodeMaterialConnectionPoint;
  118025. /**
  118026. * Gets the world input component
  118027. */
  118028. readonly world: NodeMaterialConnectionPoint;
  118029. /**
  118030. * Gets the camera (or eye) position component
  118031. */
  118032. readonly cameraPosition: NodeMaterialConnectionPoint;
  118033. /**
  118034. * Gets the view input component
  118035. */
  118036. readonly view: NodeMaterialConnectionPoint;
  118037. /**
  118038. * Gets the rgb output component
  118039. */
  118040. readonly rgb: NodeMaterialConnectionPoint;
  118041. /**
  118042. * Gets the r output component
  118043. */
  118044. readonly r: NodeMaterialConnectionPoint;
  118045. /**
  118046. * Gets the g output component
  118047. */
  118048. readonly g: NodeMaterialConnectionPoint;
  118049. /**
  118050. * Gets the b output component
  118051. */
  118052. readonly b: NodeMaterialConnectionPoint;
  118053. autoConfigure(material: NodeMaterial): void;
  118054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118055. isReady(): boolean;
  118056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118057. private _injectVertexCode;
  118058. private _writeOutput;
  118059. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118060. serialize(): any;
  118061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118062. }
  118063. }
  118064. declare module BABYLON {
  118065. /**
  118066. * Interface used to configure the node material editor
  118067. */
  118068. export interface INodeMaterialEditorOptions {
  118069. /** Define the URl to load node editor script */
  118070. editorURL?: string;
  118071. }
  118072. /** @hidden */
  118073. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118074. /** BONES */
  118075. NUM_BONE_INFLUENCERS: number;
  118076. BonesPerMesh: number;
  118077. BONETEXTURE: boolean;
  118078. /** MORPH TARGETS */
  118079. MORPHTARGETS: boolean;
  118080. MORPHTARGETS_NORMAL: boolean;
  118081. MORPHTARGETS_TANGENT: boolean;
  118082. MORPHTARGETS_UV: boolean;
  118083. NUM_MORPH_INFLUENCERS: number;
  118084. /** IMAGE PROCESSING */
  118085. IMAGEPROCESSING: boolean;
  118086. VIGNETTE: boolean;
  118087. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118088. VIGNETTEBLENDMODEOPAQUE: boolean;
  118089. TONEMAPPING: boolean;
  118090. TONEMAPPING_ACES: boolean;
  118091. CONTRAST: boolean;
  118092. EXPOSURE: boolean;
  118093. COLORCURVES: boolean;
  118094. COLORGRADING: boolean;
  118095. COLORGRADING3D: boolean;
  118096. SAMPLER3DGREENDEPTH: boolean;
  118097. SAMPLER3DBGRMAP: boolean;
  118098. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118099. /** MISC. */
  118100. BUMPDIRECTUV: number;
  118101. constructor();
  118102. setValue(name: string, value: boolean): void;
  118103. }
  118104. /**
  118105. * Class used to configure NodeMaterial
  118106. */
  118107. export interface INodeMaterialOptions {
  118108. /**
  118109. * Defines if blocks should emit comments
  118110. */
  118111. emitComments: boolean;
  118112. }
  118113. /**
  118114. * Class used to create a node based material built by assembling shader blocks
  118115. */
  118116. export class NodeMaterial extends PushMaterial {
  118117. private static _BuildIdGenerator;
  118118. private _options;
  118119. private _vertexCompilationState;
  118120. private _fragmentCompilationState;
  118121. private _sharedData;
  118122. private _buildId;
  118123. private _buildWasSuccessful;
  118124. private _cachedWorldViewMatrix;
  118125. private _cachedWorldViewProjectionMatrix;
  118126. private _optimizers;
  118127. private _animationFrame;
  118128. /** Define the URl to load node editor script */
  118129. static EditorURL: string;
  118130. private BJSNODEMATERIALEDITOR;
  118131. /** Get the inspector from bundle or global */
  118132. private _getGlobalNodeMaterialEditor;
  118133. /**
  118134. * 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)
  118135. */
  118136. ignoreAlpha: boolean;
  118137. /**
  118138. * Defines the maximum number of lights that can be used in the material
  118139. */
  118140. maxSimultaneousLights: number;
  118141. /**
  118142. * Observable raised when the material is built
  118143. */
  118144. onBuildObservable: Observable<NodeMaterial>;
  118145. /**
  118146. * Gets or sets the root nodes of the material vertex shader
  118147. */
  118148. _vertexOutputNodes: NodeMaterialBlock[];
  118149. /**
  118150. * Gets or sets the root nodes of the material fragment (pixel) shader
  118151. */
  118152. _fragmentOutputNodes: NodeMaterialBlock[];
  118153. /** Gets or sets options to control the node material overall behavior */
  118154. options: INodeMaterialOptions;
  118155. /**
  118156. * Default configuration related to image processing available in the standard Material.
  118157. */
  118158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118159. /**
  118160. * Gets the image processing configuration used either in this material.
  118161. */
  118162. /**
  118163. * Sets the Default image processing configuration used either in the this material.
  118164. *
  118165. * If sets to null, the scene one is in use.
  118166. */
  118167. imageProcessingConfiguration: ImageProcessingConfiguration;
  118168. /**
  118169. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118170. */
  118171. attachedBlocks: NodeMaterialBlock[];
  118172. /**
  118173. * Create a new node based material
  118174. * @param name defines the material name
  118175. * @param scene defines the hosting scene
  118176. * @param options defines creation option
  118177. */
  118178. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118179. /**
  118180. * Gets the current class name of the material e.g. "NodeMaterial"
  118181. * @returns the class name
  118182. */
  118183. getClassName(): string;
  118184. /**
  118185. * Keep track of the image processing observer to allow dispose and replace.
  118186. */
  118187. private _imageProcessingObserver;
  118188. /**
  118189. * Attaches a new image processing configuration to the Standard Material.
  118190. * @param configuration
  118191. */
  118192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118193. /**
  118194. * Get a block by its name
  118195. * @param name defines the name of the block to retrieve
  118196. * @returns the required block or null if not found
  118197. */
  118198. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118199. /**
  118200. * Get a block by its name
  118201. * @param predicate defines the predicate used to find the good candidate
  118202. * @returns the required block or null if not found
  118203. */
  118204. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118205. /**
  118206. * Get an input block by its name
  118207. * @param predicate defines the predicate used to find the good candidate
  118208. * @returns the required input block or null if not found
  118209. */
  118210. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118211. /**
  118212. * Gets the list of input blocks attached to this material
  118213. * @returns an array of InputBlocks
  118214. */
  118215. getInputBlocks(): InputBlock[];
  118216. /**
  118217. * Adds a new optimizer to the list of optimizers
  118218. * @param optimizer defines the optimizers to add
  118219. * @returns the current material
  118220. */
  118221. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118222. /**
  118223. * Remove an optimizer from the list of optimizers
  118224. * @param optimizer defines the optimizers to remove
  118225. * @returns the current material
  118226. */
  118227. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118228. /**
  118229. * Add a new block to the list of output nodes
  118230. * @param node defines the node to add
  118231. * @returns the current material
  118232. */
  118233. addOutputNode(node: NodeMaterialBlock): this;
  118234. /**
  118235. * Remove a block from the list of root nodes
  118236. * @param node defines the node to remove
  118237. * @returns the current material
  118238. */
  118239. removeOutputNode(node: NodeMaterialBlock): this;
  118240. private _addVertexOutputNode;
  118241. private _removeVertexOutputNode;
  118242. private _addFragmentOutputNode;
  118243. private _removeFragmentOutputNode;
  118244. /**
  118245. * Specifies if the material will require alpha blending
  118246. * @returns a boolean specifying if alpha blending is needed
  118247. */
  118248. needAlphaBlending(): boolean;
  118249. /**
  118250. * Specifies if this material should be rendered in alpha test mode
  118251. * @returns a boolean specifying if an alpha test is needed.
  118252. */
  118253. needAlphaTesting(): boolean;
  118254. private _initializeBlock;
  118255. private _resetDualBlocks;
  118256. /**
  118257. * Build the material and generates the inner effect
  118258. * @param verbose defines if the build should log activity
  118259. */
  118260. build(verbose?: boolean): void;
  118261. /**
  118262. * Runs an otpimization phase to try to improve the shader code
  118263. */
  118264. optimize(): void;
  118265. private _prepareDefinesForAttributes;
  118266. /**
  118267. * Get if the submesh is ready to be used and all its information available.
  118268. * Child classes can use it to update shaders
  118269. * @param mesh defines the mesh to check
  118270. * @param subMesh defines which submesh to check
  118271. * @param useInstances specifies that instances should be used
  118272. * @returns a boolean indicating that the submesh is ready or not
  118273. */
  118274. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118275. /**
  118276. * Get a string representing the shaders built by the current node graph
  118277. */
  118278. readonly compiledShaders: string;
  118279. /**
  118280. * Binds the world matrix to the material
  118281. * @param world defines the world transformation matrix
  118282. */
  118283. bindOnlyWorldMatrix(world: Matrix): void;
  118284. /**
  118285. * Binds the submesh to this material by preparing the effect and shader to draw
  118286. * @param world defines the world transformation matrix
  118287. * @param mesh defines the mesh containing the submesh
  118288. * @param subMesh defines the submesh to bind the material to
  118289. */
  118290. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118291. /**
  118292. * Gets the active textures from the material
  118293. * @returns an array of textures
  118294. */
  118295. getActiveTextures(): BaseTexture[];
  118296. /**
  118297. * Gets the list of texture blocks
  118298. * @returns an array of texture blocks
  118299. */
  118300. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118301. /**
  118302. * Specifies if the material uses a texture
  118303. * @param texture defines the texture to check against the material
  118304. * @returns a boolean specifying if the material uses the texture
  118305. */
  118306. hasTexture(texture: BaseTexture): boolean;
  118307. /**
  118308. * Disposes the material
  118309. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118310. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118311. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118312. */
  118313. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118314. /** Creates the node editor window. */
  118315. private _createNodeEditor;
  118316. /**
  118317. * Launch the node material editor
  118318. * @param config Define the configuration of the editor
  118319. * @return a promise fulfilled when the node editor is visible
  118320. */
  118321. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118322. /**
  118323. * Clear the current material
  118324. */
  118325. clear(): void;
  118326. /**
  118327. * Clear the current material and set it to a default state
  118328. */
  118329. setToDefault(): void;
  118330. /**
  118331. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118332. * @param url defines the url to load from
  118333. * @returns a promise that will fullfil when the material is fully loaded
  118334. */
  118335. loadAsync(url: string): Promise<unknown>;
  118336. private _gatherBlocks;
  118337. /**
  118338. * Generate a string containing the code declaration required to create an equivalent of this material
  118339. * @returns a string
  118340. */
  118341. generateCode(): string;
  118342. /**
  118343. * Serializes this material in a JSON representation
  118344. * @returns the serialized material object
  118345. */
  118346. serialize(): any;
  118347. private _restoreConnections;
  118348. /**
  118349. * Clear the current graph and load a new one from a serialization object
  118350. * @param source defines the JSON representation of the material
  118351. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118352. */
  118353. loadFromSerialization(source: any, rootUrl?: string): void;
  118354. /**
  118355. * Creates a node material from parsed material data
  118356. * @param source defines the JSON representation of the material
  118357. * @param scene defines the hosting scene
  118358. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118359. * @returns a new node material
  118360. */
  118361. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118362. /**
  118363. * Creates a new node material set to default basic configuration
  118364. * @param name defines the name of the material
  118365. * @param scene defines the hosting scene
  118366. * @returns a new NodeMaterial
  118367. */
  118368. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118369. }
  118370. }
  118371. declare module BABYLON {
  118372. /**
  118373. * Block used to read a texture from a sampler
  118374. */
  118375. export class TextureBlock extends NodeMaterialBlock {
  118376. private _defineName;
  118377. private _samplerName;
  118378. private _transformedUVName;
  118379. private _textureTransformName;
  118380. private _textureInfoName;
  118381. private _mainUVName;
  118382. private _mainUVDefineName;
  118383. /**
  118384. * Gets or sets the texture associated with the node
  118385. */
  118386. texture: Nullable<Texture>;
  118387. /**
  118388. * Create a new TextureBlock
  118389. * @param name defines the block name
  118390. */
  118391. constructor(name: string);
  118392. /**
  118393. * Gets the current class name
  118394. * @returns the class name
  118395. */
  118396. getClassName(): string;
  118397. /**
  118398. * Gets the uv input component
  118399. */
  118400. readonly uv: NodeMaterialConnectionPoint;
  118401. /**
  118402. * Gets the rgba output component
  118403. */
  118404. readonly rgba: NodeMaterialConnectionPoint;
  118405. /**
  118406. * Gets the rgb output component
  118407. */
  118408. readonly rgb: NodeMaterialConnectionPoint;
  118409. /**
  118410. * Gets the r output component
  118411. */
  118412. readonly r: NodeMaterialConnectionPoint;
  118413. /**
  118414. * Gets the g output component
  118415. */
  118416. readonly g: NodeMaterialConnectionPoint;
  118417. /**
  118418. * Gets the b output component
  118419. */
  118420. readonly b: NodeMaterialConnectionPoint;
  118421. /**
  118422. * Gets the a output component
  118423. */
  118424. readonly a: NodeMaterialConnectionPoint;
  118425. readonly target: NodeMaterialBlockTargets;
  118426. autoConfigure(material: NodeMaterial): void;
  118427. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118429. isReady(): boolean;
  118430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118431. private readonly _isMixed;
  118432. private _injectVertexCode;
  118433. private _writeOutput;
  118434. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118435. protected _dumpPropertiesCode(): string;
  118436. serialize(): any;
  118437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118438. }
  118439. }
  118440. declare module BABYLON {
  118441. /**
  118442. * Class used to store shared data between 2 NodeMaterialBuildState
  118443. */
  118444. export class NodeMaterialBuildStateSharedData {
  118445. /**
  118446. * Gets the list of emitted varyings
  118447. */
  118448. temps: string[];
  118449. /**
  118450. * Gets the list of emitted varyings
  118451. */
  118452. varyings: string[];
  118453. /**
  118454. * Gets the varying declaration string
  118455. */
  118456. varyingDeclaration: string;
  118457. /**
  118458. * Input blocks
  118459. */
  118460. inputBlocks: InputBlock[];
  118461. /**
  118462. * Input blocks
  118463. */
  118464. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118465. /**
  118466. * Bindable blocks (Blocks that need to set data to the effect)
  118467. */
  118468. bindableBlocks: NodeMaterialBlock[];
  118469. /**
  118470. * List of blocks that can provide a compilation fallback
  118471. */
  118472. blocksWithFallbacks: NodeMaterialBlock[];
  118473. /**
  118474. * List of blocks that can provide a define update
  118475. */
  118476. blocksWithDefines: NodeMaterialBlock[];
  118477. /**
  118478. * List of blocks that can provide a repeatable content
  118479. */
  118480. repeatableContentBlocks: NodeMaterialBlock[];
  118481. /**
  118482. * List of blocks that can provide a dynamic list of uniforms
  118483. */
  118484. dynamicUniformBlocks: NodeMaterialBlock[];
  118485. /**
  118486. * List of blocks that can block the isReady function for the material
  118487. */
  118488. blockingBlocks: NodeMaterialBlock[];
  118489. /**
  118490. * Gets the list of animated inputs
  118491. */
  118492. animatedInputs: InputBlock[];
  118493. /**
  118494. * Build Id used to avoid multiple recompilations
  118495. */
  118496. buildId: number;
  118497. /** List of emitted variables */
  118498. variableNames: {
  118499. [key: string]: number;
  118500. };
  118501. /** List of emitted defines */
  118502. defineNames: {
  118503. [key: string]: number;
  118504. };
  118505. /** Should emit comments? */
  118506. emitComments: boolean;
  118507. /** Emit build activity */
  118508. verbose: boolean;
  118509. /** Gets or sets the hosting scene */
  118510. scene: Scene;
  118511. /**
  118512. * Gets the compilation hints emitted at compilation time
  118513. */
  118514. hints: {
  118515. needWorldViewMatrix: boolean;
  118516. needWorldViewProjectionMatrix: boolean;
  118517. needAlphaBlending: boolean;
  118518. needAlphaTesting: boolean;
  118519. };
  118520. /**
  118521. * List of compilation checks
  118522. */
  118523. checks: {
  118524. emitVertex: boolean;
  118525. emitFragment: boolean;
  118526. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118527. };
  118528. /** Creates a new shared data */
  118529. constructor();
  118530. /**
  118531. * Emits console errors and exceptions if there is a failing check
  118532. */
  118533. emitErrors(): void;
  118534. }
  118535. }
  118536. declare module BABYLON {
  118537. /**
  118538. * Class used to store node based material build state
  118539. */
  118540. export class NodeMaterialBuildState {
  118541. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118542. supportUniformBuffers: boolean;
  118543. /**
  118544. * Gets the list of emitted attributes
  118545. */
  118546. attributes: string[];
  118547. /**
  118548. * Gets the list of emitted uniforms
  118549. */
  118550. uniforms: string[];
  118551. /**
  118552. * Gets the list of emitted constants
  118553. */
  118554. constants: string[];
  118555. /**
  118556. * Gets the list of emitted uniform buffers
  118557. */
  118558. uniformBuffers: string[];
  118559. /**
  118560. * Gets the list of emitted samplers
  118561. */
  118562. samplers: string[];
  118563. /**
  118564. * Gets the list of emitted functions
  118565. */
  118566. functions: {
  118567. [key: string]: string;
  118568. };
  118569. /**
  118570. * Gets the list of emitted extensions
  118571. */
  118572. extensions: {
  118573. [key: string]: string;
  118574. };
  118575. /**
  118576. * Gets the target of the compilation state
  118577. */
  118578. target: NodeMaterialBlockTargets;
  118579. /**
  118580. * Gets the list of emitted counters
  118581. */
  118582. counters: {
  118583. [key: string]: number;
  118584. };
  118585. /**
  118586. * Shared data between multiple NodeMaterialBuildState instances
  118587. */
  118588. sharedData: NodeMaterialBuildStateSharedData;
  118589. /** @hidden */
  118590. _vertexState: NodeMaterialBuildState;
  118591. /** @hidden */
  118592. _attributeDeclaration: string;
  118593. /** @hidden */
  118594. _uniformDeclaration: string;
  118595. /** @hidden */
  118596. _constantDeclaration: string;
  118597. /** @hidden */
  118598. _samplerDeclaration: string;
  118599. /** @hidden */
  118600. _varyingTransfer: string;
  118601. private _repeatableContentAnchorIndex;
  118602. /** @hidden */
  118603. _builtCompilationString: string;
  118604. /**
  118605. * Gets the emitted compilation strings
  118606. */
  118607. compilationString: string;
  118608. /**
  118609. * Finalize the compilation strings
  118610. * @param state defines the current compilation state
  118611. */
  118612. finalize(state: NodeMaterialBuildState): void;
  118613. /** @hidden */
  118614. readonly _repeatableContentAnchor: string;
  118615. /** @hidden */
  118616. _getFreeVariableName(prefix: string): string;
  118617. /** @hidden */
  118618. _getFreeDefineName(prefix: string): string;
  118619. /** @hidden */
  118620. _excludeVariableName(name: string): void;
  118621. /** @hidden */
  118622. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118623. /** @hidden */
  118624. _emitExtension(name: string, extension: string): void;
  118625. /** @hidden */
  118626. _emitFunction(name: string, code: string, comments: string): void;
  118627. /** @hidden */
  118628. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118629. replaceStrings?: {
  118630. search: RegExp;
  118631. replace: string;
  118632. }[];
  118633. repeatKey?: string;
  118634. }): string;
  118635. /** @hidden */
  118636. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118637. repeatKey?: string;
  118638. removeAttributes?: boolean;
  118639. removeUniforms?: boolean;
  118640. removeVaryings?: boolean;
  118641. removeIfDef?: boolean;
  118642. replaceStrings?: {
  118643. search: RegExp;
  118644. replace: string;
  118645. }[];
  118646. }, storeKey?: string): void;
  118647. /** @hidden */
  118648. _registerTempVariable(name: string): boolean;
  118649. /** @hidden */
  118650. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118651. /** @hidden */
  118652. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118653. }
  118654. }
  118655. declare module BABYLON {
  118656. /**
  118657. * Defines a block that can be used inside a node based material
  118658. */
  118659. export class NodeMaterialBlock {
  118660. private _buildId;
  118661. private _buildTarget;
  118662. private _target;
  118663. private _isFinalMerger;
  118664. private _isInput;
  118665. /** @hidden */
  118666. _codeVariableName: string;
  118667. /** @hidden */
  118668. _inputs: NodeMaterialConnectionPoint[];
  118669. /** @hidden */
  118670. _outputs: NodeMaterialConnectionPoint[];
  118671. /** @hidden */
  118672. _preparationId: number;
  118673. /**
  118674. * Gets or sets the name of the block
  118675. */
  118676. name: string;
  118677. /**
  118678. * Gets or sets the unique id of the node
  118679. */
  118680. uniqueId: number;
  118681. /**
  118682. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118683. */
  118684. readonly isFinalMerger: boolean;
  118685. /**
  118686. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118687. */
  118688. readonly isInput: boolean;
  118689. /**
  118690. * Gets or sets the build Id
  118691. */
  118692. buildId: number;
  118693. /**
  118694. * Gets or sets the target of the block
  118695. */
  118696. target: NodeMaterialBlockTargets;
  118697. /**
  118698. * Gets the list of input points
  118699. */
  118700. readonly inputs: NodeMaterialConnectionPoint[];
  118701. /** Gets the list of output points */
  118702. readonly outputs: NodeMaterialConnectionPoint[];
  118703. /**
  118704. * Find an input by its name
  118705. * @param name defines the name of the input to look for
  118706. * @returns the input or null if not found
  118707. */
  118708. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118709. /**
  118710. * Find an output by its name
  118711. * @param name defines the name of the outputto look for
  118712. * @returns the output or null if not found
  118713. */
  118714. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118715. /**
  118716. * Creates a new NodeMaterialBlock
  118717. * @param name defines the block name
  118718. * @param target defines the target of that block (Vertex by default)
  118719. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118720. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118721. */
  118722. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118723. /**
  118724. * Initialize the block and prepare the context for build
  118725. * @param state defines the state that will be used for the build
  118726. */
  118727. initialize(state: NodeMaterialBuildState): void;
  118728. /**
  118729. * Bind data to effect. Will only be called for blocks with isBindable === true
  118730. * @param effect defines the effect to bind data to
  118731. * @param nodeMaterial defines the hosting NodeMaterial
  118732. * @param mesh defines the mesh that will be rendered
  118733. */
  118734. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118735. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118736. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118737. protected _writeFloat(value: number): string;
  118738. /**
  118739. * Gets the current class name e.g. "NodeMaterialBlock"
  118740. * @returns the class name
  118741. */
  118742. getClassName(): string;
  118743. /**
  118744. * Register a new input. Must be called inside a block constructor
  118745. * @param name defines the connection point name
  118746. * @param type defines the connection point type
  118747. * @param isOptional defines a boolean indicating that this input can be omitted
  118748. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118749. * @returns the current block
  118750. */
  118751. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118752. /**
  118753. * Register a new output. Must be called inside a block constructor
  118754. * @param name defines the connection point name
  118755. * @param type defines the connection point type
  118756. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118757. * @returns the current block
  118758. */
  118759. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118760. /**
  118761. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118762. * @param forOutput defines an optional connection point to check compatibility with
  118763. * @returns the first available input or null
  118764. */
  118765. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118766. /**
  118767. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118768. * @param forBlock defines an optional block to check compatibility with
  118769. * @returns the first available input or null
  118770. */
  118771. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118772. /**
  118773. * Gets the sibling of the given output
  118774. * @param current defines the current output
  118775. * @returns the next output in the list or null
  118776. */
  118777. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118778. /**
  118779. * Connect current block with another block
  118780. * @param other defines the block to connect with
  118781. * @param options define the various options to help pick the right connections
  118782. * @returns the current block
  118783. */
  118784. connectTo(other: NodeMaterialBlock, options?: {
  118785. input?: string;
  118786. output?: string;
  118787. outputSwizzle?: string;
  118788. }): this | undefined;
  118789. protected _buildBlock(state: NodeMaterialBuildState): void;
  118790. /**
  118791. * Add uniforms, samplers and uniform buffers at compilation time
  118792. * @param state defines the state to update
  118793. * @param nodeMaterial defines the node material requesting the update
  118794. * @param defines defines the material defines to update
  118795. */
  118796. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118797. /**
  118798. * Add potential fallbacks if shader compilation fails
  118799. * @param mesh defines the mesh to be rendered
  118800. * @param fallbacks defines the current prioritized list of fallbacks
  118801. */
  118802. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118803. /**
  118804. * Initialize defines for shader compilation
  118805. * @param mesh defines the mesh to be rendered
  118806. * @param nodeMaterial defines the node material requesting the update
  118807. * @param defines defines the material defines to update
  118808. * @param useInstances specifies that instances should be used
  118809. */
  118810. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118811. /**
  118812. * Update defines for shader compilation
  118813. * @param mesh defines the mesh to be rendered
  118814. * @param nodeMaterial defines the node material requesting the update
  118815. * @param defines defines the material defines to update
  118816. * @param useInstances specifies that instances should be used
  118817. */
  118818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118819. /**
  118820. * Lets the block try to connect some inputs automatically
  118821. * @param material defines the hosting NodeMaterial
  118822. */
  118823. autoConfigure(material: NodeMaterial): void;
  118824. /**
  118825. * Function called when a block is declared as repeatable content generator
  118826. * @param vertexShaderState defines the current compilation state for the vertex shader
  118827. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118828. * @param mesh defines the mesh to be rendered
  118829. * @param defines defines the material defines to update
  118830. */
  118831. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118832. /**
  118833. * Checks if the block is ready
  118834. * @param mesh defines the mesh to be rendered
  118835. * @param nodeMaterial defines the node material requesting the update
  118836. * @param defines defines the material defines to update
  118837. * @param useInstances specifies that instances should be used
  118838. * @returns true if the block is ready
  118839. */
  118840. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118841. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118842. private _processBuild;
  118843. /**
  118844. * Compile the current node and generate the shader code
  118845. * @param state defines the current compilation state (uniforms, samplers, current string)
  118846. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118847. * @returns true if already built
  118848. */
  118849. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118850. protected _inputRename(name: string): string;
  118851. protected _outputRename(name: string): string;
  118852. protected _dumpPropertiesCode(): string;
  118853. /** @hidden */
  118854. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118855. /**
  118856. * Clone the current block to a new identical block
  118857. * @param scene defines the hosting scene
  118858. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118859. * @returns a copy of the current block
  118860. */
  118861. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118862. /**
  118863. * Serializes this block in a JSON representation
  118864. * @returns the serialized block object
  118865. */
  118866. serialize(): any;
  118867. /** @hidden */
  118868. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118869. }
  118870. }
  118871. declare module BABYLON {
  118872. /**
  118873. * Enum defining the type of animations supported by InputBlock
  118874. */
  118875. export enum AnimatedInputBlockTypes {
  118876. /** No animation */
  118877. None = 0,
  118878. /** Time based animation. Will only work for floats */
  118879. Time = 1
  118880. }
  118881. }
  118882. declare module BABYLON {
  118883. /**
  118884. * Block used to expose an input value
  118885. */
  118886. export class InputBlock extends NodeMaterialBlock {
  118887. private _mode;
  118888. private _associatedVariableName;
  118889. private _storedValue;
  118890. private _valueCallback;
  118891. private _type;
  118892. private _animationType;
  118893. /** Gets or set a value used to limit the range of float values */
  118894. min: number;
  118895. /** Gets or set a value used to limit the range of float values */
  118896. max: number;
  118897. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  118898. matrixMode: number;
  118899. /** @hidden */
  118900. _systemValue: Nullable<NodeMaterialSystemValues>;
  118901. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118902. visibleInInspector: boolean;
  118903. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  118904. isConstant: boolean;
  118905. /**
  118906. * Gets or sets the connection point type (default is float)
  118907. */
  118908. readonly type: NodeMaterialBlockConnectionPointTypes;
  118909. /**
  118910. * Creates a new InputBlock
  118911. * @param name defines the block name
  118912. * @param target defines the target of that block (Vertex by default)
  118913. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118914. */
  118915. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118916. /**
  118917. * Gets the output component
  118918. */
  118919. readonly output: NodeMaterialConnectionPoint;
  118920. /**
  118921. * Set the source of this connection point to a vertex attribute
  118922. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118923. * @returns the current connection point
  118924. */
  118925. setAsAttribute(attributeName?: string): InputBlock;
  118926. /**
  118927. * Set the source of this connection point to a system value
  118928. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118929. * @returns the current connection point
  118930. */
  118931. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118932. /**
  118933. * Gets or sets the value of that point.
  118934. * Please note that this value will be ignored if valueCallback is defined
  118935. */
  118936. value: any;
  118937. /**
  118938. * Gets or sets a callback used to get the value of that point.
  118939. * Please note that setting this value will force the connection point to ignore the value property
  118940. */
  118941. valueCallback: () => any;
  118942. /**
  118943. * Gets or sets the associated variable name in the shader
  118944. */
  118945. associatedVariableName: string;
  118946. /** Gets or sets the type of animation applied to the input */
  118947. animationType: AnimatedInputBlockTypes;
  118948. /**
  118949. * Gets a boolean indicating that this connection point not defined yet
  118950. */
  118951. readonly isUndefined: boolean;
  118952. /**
  118953. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118954. * In this case the connection point name must be the name of the uniform to use.
  118955. * Can only be set on inputs
  118956. */
  118957. isUniform: boolean;
  118958. /**
  118959. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118960. * In this case the connection point name must be the name of the attribute to use
  118961. * Can only be set on inputs
  118962. */
  118963. isAttribute: boolean;
  118964. /**
  118965. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118966. * Can only be set on exit points
  118967. */
  118968. isVarying: boolean;
  118969. /**
  118970. * Gets a boolean indicating that the current connection point is a system value
  118971. */
  118972. readonly isSystemValue: boolean;
  118973. /**
  118974. * Gets or sets the current well known value or null if not defined as a system value
  118975. */
  118976. systemValue: Nullable<NodeMaterialSystemValues>;
  118977. /**
  118978. * Gets the current class name
  118979. * @returns the class name
  118980. */
  118981. getClassName(): string;
  118982. /**
  118983. * Animate the input if animationType !== None
  118984. * @param scene defines the rendering scene
  118985. */
  118986. animate(scene: Scene): void;
  118987. private _emitDefine;
  118988. initialize(state: NodeMaterialBuildState): void;
  118989. /**
  118990. * Set the input block to its default value (based on its type)
  118991. */
  118992. setDefaultValue(): void;
  118993. protected _dumpPropertiesCode(): string;
  118994. private _emitConstant;
  118995. private _emit;
  118996. /** @hidden */
  118997. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118998. /** @hidden */
  118999. _transmit(effect: Effect, scene: Scene): void;
  119000. protected _buildBlock(state: NodeMaterialBuildState): void;
  119001. serialize(): any;
  119002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119003. }
  119004. }
  119005. declare module BABYLON {
  119006. /**
  119007. * Defines a connection point for a block
  119008. */
  119009. export class NodeMaterialConnectionPoint {
  119010. /** @hidden */
  119011. _ownerBlock: NodeMaterialBlock;
  119012. /** @hidden */
  119013. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119014. private _endpoints;
  119015. private _associatedVariableName;
  119016. /** @hidden */
  119017. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119018. /** @hidden */
  119019. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119020. private _type;
  119021. /** @hidden */
  119022. _enforceAssociatedVariableName: boolean;
  119023. /**
  119024. * Gets or sets the additional types supported byt this connection point
  119025. */
  119026. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119027. /**
  119028. * Gets or sets the associated variable name in the shader
  119029. */
  119030. associatedVariableName: string;
  119031. /**
  119032. * Gets or sets the connection point type (default is float)
  119033. */
  119034. type: NodeMaterialBlockConnectionPointTypes;
  119035. /**
  119036. * Gets or sets the connection point name
  119037. */
  119038. name: string;
  119039. /**
  119040. * Gets or sets a boolean indicating that this connection point can be omitted
  119041. */
  119042. isOptional: boolean;
  119043. /**
  119044. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119045. */
  119046. define: string;
  119047. /** Gets or sets the target of that connection point */
  119048. target: NodeMaterialBlockTargets;
  119049. /**
  119050. * Gets a boolean indicating that the current point is connected
  119051. */
  119052. readonly isConnected: boolean;
  119053. /**
  119054. * Gets a boolean indicating that the current point is connected to an input block
  119055. */
  119056. readonly isConnectedToInputBlock: boolean;
  119057. /**
  119058. * Gets a the connected input block (if any)
  119059. */
  119060. readonly connectInputBlock: Nullable<InputBlock>;
  119061. /** Get the other side of the connection (if any) */
  119062. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119063. /** Get the block that owns this connection point */
  119064. readonly ownerBlock: NodeMaterialBlock;
  119065. /** Get the block connected on the other side of this connection (if any) */
  119066. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119067. /** Get the block connected on the endpoints of this connection (if any) */
  119068. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119069. /** Gets the list of connected endpoints */
  119070. readonly endpoints: NodeMaterialConnectionPoint[];
  119071. /** Gets a boolean indicating if that output point is connected to at least one input */
  119072. readonly hasEndpoints: boolean;
  119073. /**
  119074. * Creates a new connection point
  119075. * @param name defines the connection point name
  119076. * @param ownerBlock defines the block hosting this connection point
  119077. */
  119078. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119079. /**
  119080. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119081. * @returns the class name
  119082. */
  119083. getClassName(): string;
  119084. /**
  119085. * Gets an boolean indicating if the current point can be connected to another point
  119086. * @param connectionPoint defines the other connection point
  119087. * @returns true if the connection is possible
  119088. */
  119089. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119090. /**
  119091. * Connect this point to another connection point
  119092. * @param connectionPoint defines the other connection point
  119093. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119094. * @returns the current connection point
  119095. */
  119096. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119097. /**
  119098. * Disconnect this point from one of his endpoint
  119099. * @param endpoint defines the other connection point
  119100. * @returns the current connection point
  119101. */
  119102. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119103. /**
  119104. * Serializes this point in a JSON representation
  119105. * @returns the serialized point object
  119106. */
  119107. serialize(): any;
  119108. }
  119109. }
  119110. declare module BABYLON {
  119111. /**
  119112. * Block used to add support for vertex skinning (bones)
  119113. */
  119114. export class BonesBlock extends NodeMaterialBlock {
  119115. /**
  119116. * Creates a new BonesBlock
  119117. * @param name defines the block name
  119118. */
  119119. constructor(name: string);
  119120. /**
  119121. * Initialize the block and prepare the context for build
  119122. * @param state defines the state that will be used for the build
  119123. */
  119124. initialize(state: NodeMaterialBuildState): void;
  119125. /**
  119126. * Gets the current class name
  119127. * @returns the class name
  119128. */
  119129. getClassName(): string;
  119130. /**
  119131. * Gets the matrix indices input component
  119132. */
  119133. readonly matricesIndices: NodeMaterialConnectionPoint;
  119134. /**
  119135. * Gets the matrix weights input component
  119136. */
  119137. readonly matricesWeights: NodeMaterialConnectionPoint;
  119138. /**
  119139. * Gets the extra matrix indices input component
  119140. */
  119141. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119142. /**
  119143. * Gets the extra matrix weights input component
  119144. */
  119145. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119146. /**
  119147. * Gets the world input component
  119148. */
  119149. readonly world: NodeMaterialConnectionPoint;
  119150. /**
  119151. * Gets the output component
  119152. */
  119153. readonly output: NodeMaterialConnectionPoint;
  119154. autoConfigure(material: NodeMaterial): void;
  119155. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119158. protected _buildBlock(state: NodeMaterialBuildState): this;
  119159. }
  119160. }
  119161. declare module BABYLON {
  119162. /**
  119163. * Block used to add support for instances
  119164. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119165. */
  119166. export class InstancesBlock extends NodeMaterialBlock {
  119167. /**
  119168. * Creates a new InstancesBlock
  119169. * @param name defines the block name
  119170. */
  119171. constructor(name: string);
  119172. /**
  119173. * Gets the current class name
  119174. * @returns the class name
  119175. */
  119176. getClassName(): string;
  119177. /**
  119178. * Gets the first world row input component
  119179. */
  119180. readonly world0: NodeMaterialConnectionPoint;
  119181. /**
  119182. * Gets the second world row input component
  119183. */
  119184. readonly world1: NodeMaterialConnectionPoint;
  119185. /**
  119186. * Gets the third world row input component
  119187. */
  119188. readonly world2: NodeMaterialConnectionPoint;
  119189. /**
  119190. * Gets the forth world row input component
  119191. */
  119192. readonly world3: NodeMaterialConnectionPoint;
  119193. /**
  119194. * Gets the world input component
  119195. */
  119196. readonly world: NodeMaterialConnectionPoint;
  119197. /**
  119198. * Gets the output component
  119199. */
  119200. readonly output: NodeMaterialConnectionPoint;
  119201. autoConfigure(material: NodeMaterial): void;
  119202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119203. protected _buildBlock(state: NodeMaterialBuildState): this;
  119204. }
  119205. }
  119206. declare module BABYLON {
  119207. /**
  119208. * Block used to add morph targets support to vertex shader
  119209. */
  119210. export class MorphTargetsBlock extends NodeMaterialBlock {
  119211. private _repeatableContentAnchor;
  119212. private _repeatebleContentGenerated;
  119213. /**
  119214. * Create a new MorphTargetsBlock
  119215. * @param name defines the block name
  119216. */
  119217. constructor(name: string);
  119218. /**
  119219. * Gets the current class name
  119220. * @returns the class name
  119221. */
  119222. getClassName(): string;
  119223. /**
  119224. * Gets the position input component
  119225. */
  119226. readonly position: NodeMaterialConnectionPoint;
  119227. /**
  119228. * Gets the normal input component
  119229. */
  119230. readonly normal: NodeMaterialConnectionPoint;
  119231. /**
  119232. * Gets the tangent input component
  119233. */
  119234. readonly tangent: NodeMaterialConnectionPoint;
  119235. /**
  119236. * Gets the tangent input component
  119237. */
  119238. readonly uv: NodeMaterialConnectionPoint;
  119239. /**
  119240. * Gets the position output component
  119241. */
  119242. readonly positionOutput: NodeMaterialConnectionPoint;
  119243. /**
  119244. * Gets the normal output component
  119245. */
  119246. readonly normalOutput: NodeMaterialConnectionPoint;
  119247. /**
  119248. * Gets the tangent output component
  119249. */
  119250. readonly tangentOutput: NodeMaterialConnectionPoint;
  119251. /**
  119252. * Gets the tangent output component
  119253. */
  119254. readonly uvOutput: NodeMaterialConnectionPoint;
  119255. initialize(state: NodeMaterialBuildState): void;
  119256. autoConfigure(material: NodeMaterial): void;
  119257. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119258. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119259. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119260. protected _buildBlock(state: NodeMaterialBuildState): this;
  119261. }
  119262. }
  119263. declare module BABYLON {
  119264. /**
  119265. * Block used to get data information from a light
  119266. */
  119267. export class LightInformationBlock extends NodeMaterialBlock {
  119268. private _lightDataUniformName;
  119269. private _lightColorUniformName;
  119270. private _lightTypeDefineName;
  119271. /**
  119272. * Gets or sets the light associated with this block
  119273. */
  119274. light: Nullable<Light>;
  119275. /**
  119276. * Creates a new LightInformationBlock
  119277. * @param name defines the block name
  119278. */
  119279. constructor(name: string);
  119280. /**
  119281. * Gets the current class name
  119282. * @returns the class name
  119283. */
  119284. getClassName(): string;
  119285. /**
  119286. * Gets the world position input component
  119287. */
  119288. readonly worldPosition: NodeMaterialConnectionPoint;
  119289. /**
  119290. * Gets the direction output component
  119291. */
  119292. readonly direction: NodeMaterialConnectionPoint;
  119293. /**
  119294. * Gets the direction output component
  119295. */
  119296. readonly color: NodeMaterialConnectionPoint;
  119297. /**
  119298. * Gets the direction output component
  119299. */
  119300. readonly intensity: NodeMaterialConnectionPoint;
  119301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119302. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119303. protected _buildBlock(state: NodeMaterialBuildState): this;
  119304. serialize(): any;
  119305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119306. }
  119307. }
  119308. declare module BABYLON {
  119309. /**
  119310. * Block used to add image processing support to fragment shader
  119311. */
  119312. export class ImageProcessingBlock extends NodeMaterialBlock {
  119313. /**
  119314. * Create a new ImageProcessingBlock
  119315. * @param name defines the block name
  119316. */
  119317. constructor(name: string);
  119318. /**
  119319. * Gets the current class name
  119320. * @returns the class name
  119321. */
  119322. getClassName(): string;
  119323. /**
  119324. * Gets the color input component
  119325. */
  119326. readonly color: NodeMaterialConnectionPoint;
  119327. /**
  119328. * Gets the output component
  119329. */
  119330. readonly output: NodeMaterialConnectionPoint;
  119331. /**
  119332. * Initialize the block and prepare the context for build
  119333. * @param state defines the state that will be used for the build
  119334. */
  119335. initialize(state: NodeMaterialBuildState): void;
  119336. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119339. protected _buildBlock(state: NodeMaterialBuildState): this;
  119340. }
  119341. }
  119342. declare module BABYLON {
  119343. /**
  119344. * Block used to pertub normals based on a normal map
  119345. */
  119346. export class PerturbNormalBlock extends NodeMaterialBlock {
  119347. private _tangentSpaceParameterName;
  119348. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119349. invertX: boolean;
  119350. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119351. invertY: boolean;
  119352. /**
  119353. * Create a new PerturbNormalBlock
  119354. * @param name defines the block name
  119355. */
  119356. constructor(name: string);
  119357. /**
  119358. * Gets the current class name
  119359. * @returns the class name
  119360. */
  119361. getClassName(): string;
  119362. /**
  119363. * Gets the world position input component
  119364. */
  119365. readonly worldPosition: NodeMaterialConnectionPoint;
  119366. /**
  119367. * Gets the world normal input component
  119368. */
  119369. readonly worldNormal: NodeMaterialConnectionPoint;
  119370. /**
  119371. * Gets the uv input component
  119372. */
  119373. readonly uv: NodeMaterialConnectionPoint;
  119374. /**
  119375. * Gets the normal map color input component
  119376. */
  119377. readonly normalMapColor: NodeMaterialConnectionPoint;
  119378. /**
  119379. * Gets the strength input component
  119380. */
  119381. readonly strength: NodeMaterialConnectionPoint;
  119382. /**
  119383. * Gets the output component
  119384. */
  119385. readonly output: NodeMaterialConnectionPoint;
  119386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119388. autoConfigure(material: NodeMaterial): void;
  119389. protected _buildBlock(state: NodeMaterialBuildState): this;
  119390. protected _dumpPropertiesCode(): string;
  119391. serialize(): any;
  119392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119393. }
  119394. }
  119395. declare module BABYLON {
  119396. /**
  119397. * Block used to discard a pixel if a value is smaller than a cutoff
  119398. */
  119399. export class DiscardBlock extends NodeMaterialBlock {
  119400. /**
  119401. * Create a new DiscardBlock
  119402. * @param name defines the block name
  119403. */
  119404. constructor(name: string);
  119405. /**
  119406. * Gets the current class name
  119407. * @returns the class name
  119408. */
  119409. getClassName(): string;
  119410. /**
  119411. * Gets the color input component
  119412. */
  119413. readonly value: NodeMaterialConnectionPoint;
  119414. /**
  119415. * Gets the cutoff input component
  119416. */
  119417. readonly cutoff: NodeMaterialConnectionPoint;
  119418. protected _buildBlock(state: NodeMaterialBuildState): this;
  119419. }
  119420. }
  119421. declare module BABYLON {
  119422. /**
  119423. * Block used to add support for scene fog
  119424. */
  119425. export class FogBlock extends NodeMaterialBlock {
  119426. private _fogDistanceName;
  119427. private _fogParameters;
  119428. /**
  119429. * Create a new FogBlock
  119430. * @param name defines the block name
  119431. */
  119432. constructor(name: string);
  119433. /**
  119434. * Gets the current class name
  119435. * @returns the class name
  119436. */
  119437. getClassName(): string;
  119438. /**
  119439. * Gets the world position input component
  119440. */
  119441. readonly worldPosition: NodeMaterialConnectionPoint;
  119442. /**
  119443. * Gets the view input component
  119444. */
  119445. readonly view: NodeMaterialConnectionPoint;
  119446. /**
  119447. * Gets the color input component
  119448. */
  119449. readonly input: NodeMaterialConnectionPoint;
  119450. /**
  119451. * Gets the fog color input component
  119452. */
  119453. readonly fogColor: NodeMaterialConnectionPoint;
  119454. /**
  119455. * Gets the output component
  119456. */
  119457. readonly output: NodeMaterialConnectionPoint;
  119458. autoConfigure(material: NodeMaterial): void;
  119459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119461. protected _buildBlock(state: NodeMaterialBuildState): this;
  119462. }
  119463. }
  119464. declare module BABYLON {
  119465. /**
  119466. * Block used to add light in the fragment shader
  119467. */
  119468. export class LightBlock extends NodeMaterialBlock {
  119469. private _lightId;
  119470. /**
  119471. * Gets or sets the light associated with this block
  119472. */
  119473. light: Nullable<Light>;
  119474. /**
  119475. * Create a new LightBlock
  119476. * @param name defines the block name
  119477. */
  119478. constructor(name: string);
  119479. /**
  119480. * Gets the current class name
  119481. * @returns the class name
  119482. */
  119483. getClassName(): string;
  119484. /**
  119485. * Gets the world position input component
  119486. */
  119487. readonly worldPosition: NodeMaterialConnectionPoint;
  119488. /**
  119489. * Gets the world normal input component
  119490. */
  119491. readonly worldNormal: NodeMaterialConnectionPoint;
  119492. /**
  119493. * Gets the camera (or eye) position component
  119494. */
  119495. readonly cameraPosition: NodeMaterialConnectionPoint;
  119496. /**
  119497. * Gets the diffuse output component
  119498. */
  119499. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119500. /**
  119501. * Gets the specular output component
  119502. */
  119503. readonly specularOutput: NodeMaterialConnectionPoint;
  119504. autoConfigure(material: NodeMaterial): void;
  119505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119506. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119508. private _injectVertexCode;
  119509. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119510. serialize(): any;
  119511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119512. }
  119513. }
  119514. declare module BABYLON {
  119515. /**
  119516. * Block used to multiply 2 values
  119517. */
  119518. export class MultiplyBlock extends NodeMaterialBlock {
  119519. /**
  119520. * Creates a new MultiplyBlock
  119521. * @param name defines the block name
  119522. */
  119523. constructor(name: string);
  119524. /**
  119525. * Gets the current class name
  119526. * @returns the class name
  119527. */
  119528. getClassName(): string;
  119529. /**
  119530. * Gets the left operand input component
  119531. */
  119532. readonly left: NodeMaterialConnectionPoint;
  119533. /**
  119534. * Gets the right operand input component
  119535. */
  119536. readonly right: NodeMaterialConnectionPoint;
  119537. /**
  119538. * Gets the output component
  119539. */
  119540. readonly output: NodeMaterialConnectionPoint;
  119541. protected _buildBlock(state: NodeMaterialBuildState): this;
  119542. }
  119543. }
  119544. declare module BABYLON {
  119545. /**
  119546. * Block used to add 2 vectors
  119547. */
  119548. export class AddBlock extends NodeMaterialBlock {
  119549. /**
  119550. * Creates a new AddBlock
  119551. * @param name defines the block name
  119552. */
  119553. constructor(name: string);
  119554. /**
  119555. * Gets the current class name
  119556. * @returns the class name
  119557. */
  119558. getClassName(): string;
  119559. /**
  119560. * Gets the left operand input component
  119561. */
  119562. readonly left: NodeMaterialConnectionPoint;
  119563. /**
  119564. * Gets the right operand input component
  119565. */
  119566. readonly right: NodeMaterialConnectionPoint;
  119567. /**
  119568. * Gets the output component
  119569. */
  119570. readonly output: NodeMaterialConnectionPoint;
  119571. protected _buildBlock(state: NodeMaterialBuildState): this;
  119572. }
  119573. }
  119574. declare module BABYLON {
  119575. /**
  119576. * Block used to scale a vector by a float
  119577. */
  119578. export class ScaleBlock extends NodeMaterialBlock {
  119579. /**
  119580. * Creates a new ScaleBlock
  119581. * @param name defines the block name
  119582. */
  119583. constructor(name: string);
  119584. /**
  119585. * Gets the current class name
  119586. * @returns the class name
  119587. */
  119588. getClassName(): string;
  119589. /**
  119590. * Gets the input component
  119591. */
  119592. readonly input: NodeMaterialConnectionPoint;
  119593. /**
  119594. * Gets the factor input component
  119595. */
  119596. readonly factor: NodeMaterialConnectionPoint;
  119597. /**
  119598. * Gets the output component
  119599. */
  119600. readonly output: NodeMaterialConnectionPoint;
  119601. protected _buildBlock(state: NodeMaterialBuildState): this;
  119602. }
  119603. }
  119604. declare module BABYLON {
  119605. /**
  119606. * Block used to clamp a float
  119607. */
  119608. export class ClampBlock extends NodeMaterialBlock {
  119609. /** Gets or sets the minimum range */
  119610. minimum: number;
  119611. /** Gets or sets the maximum range */
  119612. maximum: number;
  119613. /**
  119614. * Creates a new ClampBlock
  119615. * @param name defines the block name
  119616. */
  119617. constructor(name: string);
  119618. /**
  119619. * Gets the current class name
  119620. * @returns the class name
  119621. */
  119622. getClassName(): string;
  119623. /**
  119624. * Gets the value input component
  119625. */
  119626. readonly value: NodeMaterialConnectionPoint;
  119627. /**
  119628. * Gets the output component
  119629. */
  119630. readonly output: NodeMaterialConnectionPoint;
  119631. protected _buildBlock(state: NodeMaterialBuildState): this;
  119632. protected _dumpPropertiesCode(): string;
  119633. serialize(): any;
  119634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119635. }
  119636. }
  119637. declare module BABYLON {
  119638. /**
  119639. * Block used to apply a cross product between 2 vectors
  119640. */
  119641. export class CrossBlock extends NodeMaterialBlock {
  119642. /**
  119643. * Creates a new CrossBlock
  119644. * @param name defines the block name
  119645. */
  119646. constructor(name: string);
  119647. /**
  119648. * Gets the current class name
  119649. * @returns the class name
  119650. */
  119651. getClassName(): string;
  119652. /**
  119653. * Gets the left operand input component
  119654. */
  119655. readonly left: NodeMaterialConnectionPoint;
  119656. /**
  119657. * Gets the right operand input component
  119658. */
  119659. readonly right: NodeMaterialConnectionPoint;
  119660. /**
  119661. * Gets the output component
  119662. */
  119663. readonly output: NodeMaterialConnectionPoint;
  119664. protected _buildBlock(state: NodeMaterialBuildState): this;
  119665. }
  119666. }
  119667. declare module BABYLON {
  119668. /**
  119669. * Block used to apply a dot product between 2 vectors
  119670. */
  119671. export class DotBlock extends NodeMaterialBlock {
  119672. /**
  119673. * Creates a new DotBlock
  119674. * @param name defines the block name
  119675. */
  119676. constructor(name: string);
  119677. /**
  119678. * Gets the current class name
  119679. * @returns the class name
  119680. */
  119681. getClassName(): string;
  119682. /**
  119683. * Gets the left operand input component
  119684. */
  119685. readonly left: NodeMaterialConnectionPoint;
  119686. /**
  119687. * Gets the right operand input component
  119688. */
  119689. readonly right: NodeMaterialConnectionPoint;
  119690. /**
  119691. * Gets the output component
  119692. */
  119693. readonly output: NodeMaterialConnectionPoint;
  119694. protected _buildBlock(state: NodeMaterialBuildState): this;
  119695. }
  119696. }
  119697. declare module BABYLON {
  119698. /**
  119699. * Block used to remap a float from a range to a new one
  119700. */
  119701. export class RemapBlock extends NodeMaterialBlock {
  119702. /**
  119703. * Gets or sets the source range
  119704. */
  119705. sourceRange: Vector2;
  119706. /**
  119707. * Gets or sets the target range
  119708. */
  119709. targetRange: Vector2;
  119710. /**
  119711. * Creates a new RemapBlock
  119712. * @param name defines the block name
  119713. */
  119714. constructor(name: string);
  119715. /**
  119716. * Gets the current class name
  119717. * @returns the class name
  119718. */
  119719. getClassName(): string;
  119720. /**
  119721. * Gets the input component
  119722. */
  119723. readonly input: NodeMaterialConnectionPoint;
  119724. /**
  119725. * Gets the source min input component
  119726. */
  119727. readonly sourceMin: NodeMaterialConnectionPoint;
  119728. /**
  119729. * Gets the source max input component
  119730. */
  119731. readonly sourceMax: NodeMaterialConnectionPoint;
  119732. /**
  119733. * Gets the target min input component
  119734. */
  119735. readonly targetMin: NodeMaterialConnectionPoint;
  119736. /**
  119737. * Gets the target max input component
  119738. */
  119739. readonly targetMax: NodeMaterialConnectionPoint;
  119740. /**
  119741. * Gets the output component
  119742. */
  119743. readonly output: NodeMaterialConnectionPoint;
  119744. protected _buildBlock(state: NodeMaterialBuildState): this;
  119745. protected _dumpPropertiesCode(): string;
  119746. serialize(): any;
  119747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119748. }
  119749. }
  119750. declare module BABYLON {
  119751. /**
  119752. * Block used to normalize a vector
  119753. */
  119754. export class NormalizeBlock extends NodeMaterialBlock {
  119755. /**
  119756. * Creates a new NormalizeBlock
  119757. * @param name defines the block name
  119758. */
  119759. constructor(name: string);
  119760. /**
  119761. * Gets the current class name
  119762. * @returns the class name
  119763. */
  119764. getClassName(): string;
  119765. /**
  119766. * Gets the input component
  119767. */
  119768. readonly input: NodeMaterialConnectionPoint;
  119769. /**
  119770. * Gets the output component
  119771. */
  119772. readonly output: NodeMaterialConnectionPoint;
  119773. protected _buildBlock(state: NodeMaterialBuildState): this;
  119774. }
  119775. }
  119776. declare module BABYLON {
  119777. /**
  119778. * Operations supported by the Trigonometry block
  119779. */
  119780. export enum TrigonometryBlockOperations {
  119781. /** Cos */
  119782. Cos = 0,
  119783. /** Sin */
  119784. Sin = 1,
  119785. /** Abs */
  119786. Abs = 2,
  119787. /** Exp */
  119788. Exp = 3,
  119789. /** Exp2 */
  119790. Exp2 = 4,
  119791. /** Round */
  119792. Round = 5,
  119793. /** Floor */
  119794. Floor = 6,
  119795. /** Ceiling */
  119796. Ceiling = 7,
  119797. /** Square root */
  119798. Sqrt = 8
  119799. }
  119800. /**
  119801. * Block used to apply trigonometry operation to floats
  119802. */
  119803. export class TrigonometryBlock extends NodeMaterialBlock {
  119804. /**
  119805. * Gets or sets the operation applied by the block
  119806. */
  119807. operation: TrigonometryBlockOperations;
  119808. /**
  119809. * Creates a new TrigonometryBlock
  119810. * @param name defines the block name
  119811. */
  119812. constructor(name: string);
  119813. /**
  119814. * Gets the current class name
  119815. * @returns the class name
  119816. */
  119817. getClassName(): string;
  119818. /**
  119819. * Gets the input component
  119820. */
  119821. readonly input: NodeMaterialConnectionPoint;
  119822. /**
  119823. * Gets the output component
  119824. */
  119825. readonly output: NodeMaterialConnectionPoint;
  119826. protected _buildBlock(state: NodeMaterialBuildState): this;
  119827. serialize(): any;
  119828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119829. }
  119830. }
  119831. declare module BABYLON {
  119832. /**
  119833. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119834. */
  119835. export class ColorMergerBlock extends NodeMaterialBlock {
  119836. /**
  119837. * Create a new ColorMergerBlock
  119838. * @param name defines the block name
  119839. */
  119840. constructor(name: string);
  119841. /**
  119842. * Gets the current class name
  119843. * @returns the class name
  119844. */
  119845. getClassName(): string;
  119846. /**
  119847. * Gets the r component (input)
  119848. */
  119849. readonly r: NodeMaterialConnectionPoint;
  119850. /**
  119851. * Gets the g component (input)
  119852. */
  119853. readonly g: NodeMaterialConnectionPoint;
  119854. /**
  119855. * Gets the b component (input)
  119856. */
  119857. readonly b: NodeMaterialConnectionPoint;
  119858. /**
  119859. * Gets the a component (input)
  119860. */
  119861. readonly a: NodeMaterialConnectionPoint;
  119862. /**
  119863. * Gets the rgba component (output)
  119864. */
  119865. readonly rgba: NodeMaterialConnectionPoint;
  119866. /**
  119867. * Gets the rgb component (output)
  119868. */
  119869. readonly rgb: NodeMaterialConnectionPoint;
  119870. protected _buildBlock(state: NodeMaterialBuildState): this;
  119871. }
  119872. }
  119873. declare module BABYLON {
  119874. /**
  119875. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119876. */
  119877. export class VectorMergerBlock extends NodeMaterialBlock {
  119878. /**
  119879. * Create a new VectorMergerBlock
  119880. * @param name defines the block name
  119881. */
  119882. constructor(name: string);
  119883. /**
  119884. * Gets the current class name
  119885. * @returns the class name
  119886. */
  119887. getClassName(): string;
  119888. /**
  119889. * Gets the x component (input)
  119890. */
  119891. readonly x: NodeMaterialConnectionPoint;
  119892. /**
  119893. * Gets the y component (input)
  119894. */
  119895. readonly y: NodeMaterialConnectionPoint;
  119896. /**
  119897. * Gets the z component (input)
  119898. */
  119899. readonly z: NodeMaterialConnectionPoint;
  119900. /**
  119901. * Gets the w component (input)
  119902. */
  119903. readonly w: NodeMaterialConnectionPoint;
  119904. /**
  119905. * Gets the xyzw component (output)
  119906. */
  119907. readonly xyzw: NodeMaterialConnectionPoint;
  119908. /**
  119909. * Gets the xyz component (output)
  119910. */
  119911. readonly xyz: NodeMaterialConnectionPoint;
  119912. /**
  119913. * Gets the xy component (output)
  119914. */
  119915. readonly xy: NodeMaterialConnectionPoint;
  119916. protected _buildBlock(state: NodeMaterialBuildState): this;
  119917. }
  119918. }
  119919. declare module BABYLON {
  119920. /**
  119921. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119922. */
  119923. export class ColorSplitterBlock extends NodeMaterialBlock {
  119924. /**
  119925. * Create a new ColorSplitterBlock
  119926. * @param name defines the block name
  119927. */
  119928. constructor(name: string);
  119929. /**
  119930. * Gets the current class name
  119931. * @returns the class name
  119932. */
  119933. getClassName(): string;
  119934. /**
  119935. * Gets the rgba component (input)
  119936. */
  119937. readonly rgba: NodeMaterialConnectionPoint;
  119938. /**
  119939. * Gets the rgb component (input)
  119940. */
  119941. readonly rgbIn: NodeMaterialConnectionPoint;
  119942. /**
  119943. * Gets the rgb component (output)
  119944. */
  119945. readonly rgbOut: NodeMaterialConnectionPoint;
  119946. /**
  119947. * Gets the r component (output)
  119948. */
  119949. readonly r: NodeMaterialConnectionPoint;
  119950. /**
  119951. * Gets the g component (output)
  119952. */
  119953. readonly g: NodeMaterialConnectionPoint;
  119954. /**
  119955. * Gets the b component (output)
  119956. */
  119957. readonly b: NodeMaterialConnectionPoint;
  119958. /**
  119959. * Gets the a component (output)
  119960. */
  119961. readonly a: NodeMaterialConnectionPoint;
  119962. protected _inputRename(name: string): string;
  119963. protected _outputRename(name: string): string;
  119964. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119965. }
  119966. }
  119967. declare module BABYLON {
  119968. /**
  119969. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119970. */
  119971. export class VectorSplitterBlock extends NodeMaterialBlock {
  119972. /**
  119973. * Create a new VectorSplitterBlock
  119974. * @param name defines the block name
  119975. */
  119976. constructor(name: string);
  119977. /**
  119978. * Gets the current class name
  119979. * @returns the class name
  119980. */
  119981. getClassName(): string;
  119982. /**
  119983. * Gets the xyzw component (input)
  119984. */
  119985. readonly xyzw: NodeMaterialConnectionPoint;
  119986. /**
  119987. * Gets the xyz component (input)
  119988. */
  119989. readonly xyzIn: NodeMaterialConnectionPoint;
  119990. /**
  119991. * Gets the xy component (input)
  119992. */
  119993. readonly xyIn: NodeMaterialConnectionPoint;
  119994. /**
  119995. * Gets the xyz component (output)
  119996. */
  119997. readonly xyzOut: NodeMaterialConnectionPoint;
  119998. /**
  119999. * Gets the xy component (output)
  120000. */
  120001. readonly xyOut: NodeMaterialConnectionPoint;
  120002. /**
  120003. * Gets the x component (output)
  120004. */
  120005. readonly x: NodeMaterialConnectionPoint;
  120006. /**
  120007. * Gets the y component (output)
  120008. */
  120009. readonly y: NodeMaterialConnectionPoint;
  120010. /**
  120011. * Gets the z component (output)
  120012. */
  120013. readonly z: NodeMaterialConnectionPoint;
  120014. /**
  120015. * Gets the w component (output)
  120016. */
  120017. readonly w: NodeMaterialConnectionPoint;
  120018. protected _inputRename(name: string): string;
  120019. protected _outputRename(name: string): string;
  120020. protected _buildBlock(state: NodeMaterialBuildState): this;
  120021. }
  120022. }
  120023. declare module BABYLON {
  120024. /**
  120025. * Block used to lerp 2 values
  120026. */
  120027. export class LerpBlock extends NodeMaterialBlock {
  120028. /**
  120029. * Creates a new LerpBlock
  120030. * @param name defines the block name
  120031. */
  120032. constructor(name: string);
  120033. /**
  120034. * Gets the current class name
  120035. * @returns the class name
  120036. */
  120037. getClassName(): string;
  120038. /**
  120039. * Gets the left operand input component
  120040. */
  120041. readonly left: NodeMaterialConnectionPoint;
  120042. /**
  120043. * Gets the right operand input component
  120044. */
  120045. readonly right: NodeMaterialConnectionPoint;
  120046. /**
  120047. * Gets the gradient operand input component
  120048. */
  120049. readonly gradient: NodeMaterialConnectionPoint;
  120050. /**
  120051. * Gets the output component
  120052. */
  120053. readonly output: NodeMaterialConnectionPoint;
  120054. protected _buildBlock(state: NodeMaterialBuildState): this;
  120055. }
  120056. }
  120057. declare module BABYLON {
  120058. /**
  120059. * Block used to divide 2 vectors
  120060. */
  120061. export class DivideBlock extends NodeMaterialBlock {
  120062. /**
  120063. * Creates a new DivideBlock
  120064. * @param name defines the block name
  120065. */
  120066. constructor(name: string);
  120067. /**
  120068. * Gets the current class name
  120069. * @returns the class name
  120070. */
  120071. getClassName(): string;
  120072. /**
  120073. * Gets the left operand input component
  120074. */
  120075. readonly left: NodeMaterialConnectionPoint;
  120076. /**
  120077. * Gets the right operand input component
  120078. */
  120079. readonly right: NodeMaterialConnectionPoint;
  120080. /**
  120081. * Gets the output component
  120082. */
  120083. readonly output: NodeMaterialConnectionPoint;
  120084. protected _buildBlock(state: NodeMaterialBuildState): this;
  120085. }
  120086. }
  120087. declare module BABYLON {
  120088. /**
  120089. * Block used to subtract 2 vectors
  120090. */
  120091. export class SubtractBlock extends NodeMaterialBlock {
  120092. /**
  120093. * Creates a new SubtractBlock
  120094. * @param name defines the block name
  120095. */
  120096. constructor(name: string);
  120097. /**
  120098. * Gets the current class name
  120099. * @returns the class name
  120100. */
  120101. getClassName(): string;
  120102. /**
  120103. * Gets the left operand input component
  120104. */
  120105. readonly left: NodeMaterialConnectionPoint;
  120106. /**
  120107. * Gets the right operand input component
  120108. */
  120109. readonly right: NodeMaterialConnectionPoint;
  120110. /**
  120111. * Gets the output component
  120112. */
  120113. readonly output: NodeMaterialConnectionPoint;
  120114. protected _buildBlock(state: NodeMaterialBuildState): this;
  120115. }
  120116. }
  120117. declare module BABYLON {
  120118. /**
  120119. * Block used to step a value
  120120. */
  120121. export class StepBlock extends NodeMaterialBlock {
  120122. /**
  120123. * Creates a new AddBlock
  120124. * @param name defines the block name
  120125. */
  120126. constructor(name: string);
  120127. /**
  120128. * Gets the current class name
  120129. * @returns the class name
  120130. */
  120131. getClassName(): string;
  120132. /**
  120133. * Gets the value operand input component
  120134. */
  120135. readonly value: NodeMaterialConnectionPoint;
  120136. /**
  120137. * Gets the edge operand input component
  120138. */
  120139. readonly edge: NodeMaterialConnectionPoint;
  120140. /**
  120141. * Gets the output component
  120142. */
  120143. readonly output: NodeMaterialConnectionPoint;
  120144. protected _buildBlock(state: NodeMaterialBuildState): this;
  120145. }
  120146. }
  120147. declare module BABYLON {
  120148. /**
  120149. * Block used to get the opposite (1 - x) of a value
  120150. */
  120151. export class OneMinusBlock extends NodeMaterialBlock {
  120152. /**
  120153. * Creates a new OneMinusBlock
  120154. * @param name defines the block name
  120155. */
  120156. constructor(name: string);
  120157. /**
  120158. * Gets the current class name
  120159. * @returns the class name
  120160. */
  120161. getClassName(): string;
  120162. /**
  120163. * Gets the input component
  120164. */
  120165. readonly input: NodeMaterialConnectionPoint;
  120166. /**
  120167. * Gets the output component
  120168. */
  120169. readonly output: NodeMaterialConnectionPoint;
  120170. protected _buildBlock(state: NodeMaterialBuildState): this;
  120171. }
  120172. }
  120173. declare module BABYLON {
  120174. /**
  120175. * Block used to get the view direction
  120176. */
  120177. export class ViewDirectionBlock extends NodeMaterialBlock {
  120178. /**
  120179. * Creates a new ViewDirectionBlock
  120180. * @param name defines the block name
  120181. */
  120182. constructor(name: string);
  120183. /**
  120184. * Gets the current class name
  120185. * @returns the class name
  120186. */
  120187. getClassName(): string;
  120188. /**
  120189. * Gets the world position component
  120190. */
  120191. readonly worldPosition: NodeMaterialConnectionPoint;
  120192. /**
  120193. * Gets the camera position component
  120194. */
  120195. readonly cameraPosition: NodeMaterialConnectionPoint;
  120196. /**
  120197. * Gets the output component
  120198. */
  120199. readonly output: NodeMaterialConnectionPoint;
  120200. autoConfigure(material: NodeMaterial): void;
  120201. protected _buildBlock(state: NodeMaterialBuildState): this;
  120202. }
  120203. }
  120204. declare module BABYLON {
  120205. /**
  120206. * Block used to compute fresnel value
  120207. */
  120208. export class FresnelBlock extends NodeMaterialBlock {
  120209. /**
  120210. * Create a new FresnelBlock
  120211. * @param name defines the block name
  120212. */
  120213. constructor(name: string);
  120214. /**
  120215. * Gets the current class name
  120216. * @returns the class name
  120217. */
  120218. getClassName(): string;
  120219. /**
  120220. * Gets the world normal input component
  120221. */
  120222. readonly worldNormal: NodeMaterialConnectionPoint;
  120223. /**
  120224. * Gets the view direction input component
  120225. */
  120226. readonly viewDirection: NodeMaterialConnectionPoint;
  120227. /**
  120228. * Gets the bias input component
  120229. */
  120230. readonly bias: NodeMaterialConnectionPoint;
  120231. /**
  120232. * Gets the camera (or eye) position component
  120233. */
  120234. readonly power: NodeMaterialConnectionPoint;
  120235. /**
  120236. * Gets the fresnel output component
  120237. */
  120238. readonly fresnel: NodeMaterialConnectionPoint;
  120239. autoConfigure(material: NodeMaterial): void;
  120240. protected _buildBlock(state: NodeMaterialBuildState): this;
  120241. }
  120242. }
  120243. declare module BABYLON {
  120244. /**
  120245. * Block used to get the max of 2 values
  120246. */
  120247. export class MaxBlock extends NodeMaterialBlock {
  120248. /**
  120249. * Creates a new MaxBlock
  120250. * @param name defines the block name
  120251. */
  120252. constructor(name: string);
  120253. /**
  120254. * Gets the current class name
  120255. * @returns the class name
  120256. */
  120257. getClassName(): string;
  120258. /**
  120259. * Gets the left operand input component
  120260. */
  120261. readonly left: NodeMaterialConnectionPoint;
  120262. /**
  120263. * Gets the right operand input component
  120264. */
  120265. readonly right: NodeMaterialConnectionPoint;
  120266. /**
  120267. * Gets the output component
  120268. */
  120269. readonly output: NodeMaterialConnectionPoint;
  120270. protected _buildBlock(state: NodeMaterialBuildState): this;
  120271. }
  120272. }
  120273. declare module BABYLON {
  120274. /**
  120275. * Block used to get the min of 2 values
  120276. */
  120277. export class MinBlock extends NodeMaterialBlock {
  120278. /**
  120279. * Creates a new MinBlock
  120280. * @param name defines the block name
  120281. */
  120282. constructor(name: string);
  120283. /**
  120284. * Gets the current class name
  120285. * @returns the class name
  120286. */
  120287. getClassName(): string;
  120288. /**
  120289. * Gets the left operand input component
  120290. */
  120291. readonly left: NodeMaterialConnectionPoint;
  120292. /**
  120293. * Gets the right operand input component
  120294. */
  120295. readonly right: NodeMaterialConnectionPoint;
  120296. /**
  120297. * Gets the output component
  120298. */
  120299. readonly output: NodeMaterialConnectionPoint;
  120300. protected _buildBlock(state: NodeMaterialBuildState): this;
  120301. }
  120302. }
  120303. declare module BABYLON {
  120304. /**
  120305. * Block used to get the distance between 2 values
  120306. */
  120307. export class DistanceBlock extends NodeMaterialBlock {
  120308. /**
  120309. * Creates a new DistanceBlock
  120310. * @param name defines the block name
  120311. */
  120312. constructor(name: string);
  120313. /**
  120314. * Gets the current class name
  120315. * @returns the class name
  120316. */
  120317. getClassName(): string;
  120318. /**
  120319. * Gets the left operand input component
  120320. */
  120321. readonly left: NodeMaterialConnectionPoint;
  120322. /**
  120323. * Gets the right operand input component
  120324. */
  120325. readonly right: NodeMaterialConnectionPoint;
  120326. /**
  120327. * Gets the output component
  120328. */
  120329. readonly output: NodeMaterialConnectionPoint;
  120330. protected _buildBlock(state: NodeMaterialBuildState): this;
  120331. }
  120332. }
  120333. declare module BABYLON {
  120334. /**
  120335. * Block used to get the length of a vector
  120336. */
  120337. export class LengthBlock extends NodeMaterialBlock {
  120338. /**
  120339. * Creates a new LengthBlock
  120340. * @param name defines the block name
  120341. */
  120342. constructor(name: string);
  120343. /**
  120344. * Gets the current class name
  120345. * @returns the class name
  120346. */
  120347. getClassName(): string;
  120348. /**
  120349. * Gets the value input component
  120350. */
  120351. readonly value: NodeMaterialConnectionPoint;
  120352. /**
  120353. * Gets the output component
  120354. */
  120355. readonly output: NodeMaterialConnectionPoint;
  120356. protected _buildBlock(state: NodeMaterialBuildState): this;
  120357. }
  120358. }
  120359. declare module BABYLON {
  120360. /**
  120361. * Block used to get negative version of a value (i.e. x * -1)
  120362. */
  120363. export class NegateBlock extends NodeMaterialBlock {
  120364. /**
  120365. * Creates a new NegateBlock
  120366. * @param name defines the block name
  120367. */
  120368. constructor(name: string);
  120369. /**
  120370. * Gets the current class name
  120371. * @returns the class name
  120372. */
  120373. getClassName(): string;
  120374. /**
  120375. * Gets the value input component
  120376. */
  120377. readonly value: NodeMaterialConnectionPoint;
  120378. /**
  120379. * Gets the output component
  120380. */
  120381. readonly output: NodeMaterialConnectionPoint;
  120382. protected _buildBlock(state: NodeMaterialBuildState): this;
  120383. }
  120384. }
  120385. declare module BABYLON {
  120386. /**
  120387. * Block used to get the value of the first parameter raised to the power of the second
  120388. */
  120389. export class PowBlock extends NodeMaterialBlock {
  120390. /**
  120391. * Creates a new PowBlock
  120392. * @param name defines the block name
  120393. */
  120394. constructor(name: string);
  120395. /**
  120396. * Gets the current class name
  120397. * @returns the class name
  120398. */
  120399. getClassName(): string;
  120400. /**
  120401. * Gets the value operand input component
  120402. */
  120403. readonly value: NodeMaterialConnectionPoint;
  120404. /**
  120405. * Gets the power operand input component
  120406. */
  120407. readonly power: NodeMaterialConnectionPoint;
  120408. /**
  120409. * Gets the output component
  120410. */
  120411. readonly output: NodeMaterialConnectionPoint;
  120412. protected _buildBlock(state: NodeMaterialBuildState): this;
  120413. }
  120414. }
  120415. declare module BABYLON {
  120416. /**
  120417. * Effect Render Options
  120418. */
  120419. export interface IEffectRendererOptions {
  120420. /**
  120421. * Defines the vertices positions.
  120422. */
  120423. positions?: number[];
  120424. /**
  120425. * Defines the indices.
  120426. */
  120427. indices?: number[];
  120428. }
  120429. /**
  120430. * Helper class to render one or more effects
  120431. */
  120432. export class EffectRenderer {
  120433. private engine;
  120434. private static _DefaultOptions;
  120435. private _vertexBuffers;
  120436. private _indexBuffer;
  120437. private _ringBufferIndex;
  120438. private _ringScreenBuffer;
  120439. private _fullscreenViewport;
  120440. private _getNextFrameBuffer;
  120441. /**
  120442. * Creates an effect renderer
  120443. * @param engine the engine to use for rendering
  120444. * @param options defines the options of the effect renderer
  120445. */
  120446. constructor(engine: Engine, options?: IEffectRendererOptions);
  120447. /**
  120448. * Sets the current viewport in normalized coordinates 0-1
  120449. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120450. */
  120451. setViewport(viewport?: Viewport): void;
  120452. /**
  120453. * Binds the embedded attributes buffer to the effect.
  120454. * @param effect Defines the effect to bind the attributes for
  120455. */
  120456. bindBuffers(effect: Effect): void;
  120457. /**
  120458. * Sets the current effect wrapper to use during draw.
  120459. * The effect needs to be ready before calling this api.
  120460. * This also sets the default full screen position attribute.
  120461. * @param effectWrapper Defines the effect to draw with
  120462. */
  120463. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120464. /**
  120465. * Draws a full screen quad.
  120466. */
  120467. draw(): void;
  120468. /**
  120469. * renders one or more effects to a specified texture
  120470. * @param effectWrappers list of effects to renderer
  120471. * @param outputTexture texture to draw to, if null it will render to the screen
  120472. */
  120473. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120474. /**
  120475. * Disposes of the effect renderer
  120476. */
  120477. dispose(): void;
  120478. }
  120479. /**
  120480. * Options to create an EffectWrapper
  120481. */
  120482. interface EffectWrapperCreationOptions {
  120483. /**
  120484. * Engine to use to create the effect
  120485. */
  120486. engine: Engine;
  120487. /**
  120488. * Fragment shader for the effect
  120489. */
  120490. fragmentShader: string;
  120491. /**
  120492. * Vertex shader for the effect
  120493. */
  120494. vertexShader?: string;
  120495. /**
  120496. * Attributes to use in the shader
  120497. */
  120498. attributeNames?: Array<string>;
  120499. /**
  120500. * Uniforms to use in the shader
  120501. */
  120502. uniformNames?: Array<string>;
  120503. /**
  120504. * Texture sampler names to use in the shader
  120505. */
  120506. samplerNames?: Array<string>;
  120507. /**
  120508. * The friendly name of the effect displayed in Spector.
  120509. */
  120510. name?: string;
  120511. }
  120512. /**
  120513. * Wraps an effect to be used for rendering
  120514. */
  120515. export class EffectWrapper {
  120516. /**
  120517. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120518. */
  120519. onApplyObservable: Observable<{}>;
  120520. /**
  120521. * The underlying effect
  120522. */
  120523. effect: Effect;
  120524. /**
  120525. * Creates an effect to be renderer
  120526. * @param creationOptions options to create the effect
  120527. */
  120528. constructor(creationOptions: EffectWrapperCreationOptions);
  120529. /**
  120530. * Disposes of the effect wrapper
  120531. */
  120532. dispose(): void;
  120533. }
  120534. }
  120535. declare module BABYLON {
  120536. /**
  120537. * Helper class to push actions to a pool of workers.
  120538. */
  120539. export class WorkerPool implements IDisposable {
  120540. private _workerInfos;
  120541. private _pendingActions;
  120542. /**
  120543. * Constructor
  120544. * @param workers Array of workers to use for actions
  120545. */
  120546. constructor(workers: Array<Worker>);
  120547. /**
  120548. * Terminates all workers and clears any pending actions.
  120549. */
  120550. dispose(): void;
  120551. /**
  120552. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120553. * pended until a worker has completed its action.
  120554. * @param action The action to perform. Call onComplete when the action is complete.
  120555. */
  120556. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120557. private _execute;
  120558. }
  120559. }
  120560. declare module BABYLON {
  120561. /**
  120562. * Configuration for Draco compression
  120563. */
  120564. export interface IDracoCompressionConfiguration {
  120565. /**
  120566. * Configuration for the decoder.
  120567. */
  120568. decoder: {
  120569. /**
  120570. * The url to the WebAssembly module.
  120571. */
  120572. wasmUrl?: string;
  120573. /**
  120574. * The url to the WebAssembly binary.
  120575. */
  120576. wasmBinaryUrl?: string;
  120577. /**
  120578. * The url to the fallback JavaScript module.
  120579. */
  120580. fallbackUrl?: string;
  120581. };
  120582. }
  120583. /**
  120584. * Draco compression (https://google.github.io/draco/)
  120585. *
  120586. * This class wraps the Draco module.
  120587. *
  120588. * **Encoder**
  120589. *
  120590. * The encoder is not currently implemented.
  120591. *
  120592. * **Decoder**
  120593. *
  120594. * 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.
  120595. *
  120596. * To update the configuration, use the following code:
  120597. * ```javascript
  120598. * DracoCompression.Configuration = {
  120599. * decoder: {
  120600. * wasmUrl: "<url to the WebAssembly library>",
  120601. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120602. * fallbackUrl: "<url to the fallback JavaScript library>",
  120603. * }
  120604. * };
  120605. * ```
  120606. *
  120607. * 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.
  120608. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120609. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120610. *
  120611. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120612. * ```javascript
  120613. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120614. * ```
  120615. *
  120616. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120617. */
  120618. export class DracoCompression implements IDisposable {
  120619. private _workerPoolPromise?;
  120620. private _decoderModulePromise?;
  120621. /**
  120622. * The configuration. Defaults to the following urls:
  120623. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120624. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120625. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120626. */
  120627. static Configuration: IDracoCompressionConfiguration;
  120628. /**
  120629. * Returns true if the decoder configuration is available.
  120630. */
  120631. static readonly DecoderAvailable: boolean;
  120632. /**
  120633. * Default number of workers to create when creating the draco compression object.
  120634. */
  120635. static DefaultNumWorkers: number;
  120636. private static GetDefaultNumWorkers;
  120637. private static _Default;
  120638. /**
  120639. * Default instance for the draco compression object.
  120640. */
  120641. static readonly Default: DracoCompression;
  120642. /**
  120643. * Constructor
  120644. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120645. */
  120646. constructor(numWorkers?: number);
  120647. /**
  120648. * Stop all async operations and release resources.
  120649. */
  120650. dispose(): void;
  120651. /**
  120652. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120653. * @returns a promise that resolves when ready
  120654. */
  120655. whenReadyAsync(): Promise<void>;
  120656. /**
  120657. * Decode Draco compressed mesh data to vertex data.
  120658. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120659. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120660. * @returns A promise that resolves with the decoded vertex data
  120661. */
  120662. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120663. [kind: string]: number;
  120664. }): Promise<VertexData>;
  120665. }
  120666. }
  120667. declare module BABYLON {
  120668. /**
  120669. * Class for building Constructive Solid Geometry
  120670. */
  120671. export class CSG {
  120672. private polygons;
  120673. /**
  120674. * The world matrix
  120675. */
  120676. matrix: Matrix;
  120677. /**
  120678. * Stores the position
  120679. */
  120680. position: Vector3;
  120681. /**
  120682. * Stores the rotation
  120683. */
  120684. rotation: Vector3;
  120685. /**
  120686. * Stores the rotation quaternion
  120687. */
  120688. rotationQuaternion: Nullable<Quaternion>;
  120689. /**
  120690. * Stores the scaling vector
  120691. */
  120692. scaling: Vector3;
  120693. /**
  120694. * Convert the Mesh to CSG
  120695. * @param mesh The Mesh to convert to CSG
  120696. * @returns A new CSG from the Mesh
  120697. */
  120698. static FromMesh(mesh: Mesh): CSG;
  120699. /**
  120700. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120701. * @param polygons Polygons used to construct a CSG solid
  120702. */
  120703. private static FromPolygons;
  120704. /**
  120705. * Clones, or makes a deep copy, of the CSG
  120706. * @returns A new CSG
  120707. */
  120708. clone(): CSG;
  120709. /**
  120710. * Unions this CSG with another CSG
  120711. * @param csg The CSG to union against this CSG
  120712. * @returns The unioned CSG
  120713. */
  120714. union(csg: CSG): CSG;
  120715. /**
  120716. * Unions this CSG with another CSG in place
  120717. * @param csg The CSG to union against this CSG
  120718. */
  120719. unionInPlace(csg: CSG): void;
  120720. /**
  120721. * Subtracts this CSG with another CSG
  120722. * @param csg The CSG to subtract against this CSG
  120723. * @returns A new CSG
  120724. */
  120725. subtract(csg: CSG): CSG;
  120726. /**
  120727. * Subtracts this CSG with another CSG in place
  120728. * @param csg The CSG to subtact against this CSG
  120729. */
  120730. subtractInPlace(csg: CSG): void;
  120731. /**
  120732. * Intersect this CSG with another CSG
  120733. * @param csg The CSG to intersect against this CSG
  120734. * @returns A new CSG
  120735. */
  120736. intersect(csg: CSG): CSG;
  120737. /**
  120738. * Intersects this CSG with another CSG in place
  120739. * @param csg The CSG to intersect against this CSG
  120740. */
  120741. intersectInPlace(csg: CSG): void;
  120742. /**
  120743. * Return a new CSG solid with solid and empty space switched. This solid is
  120744. * not modified.
  120745. * @returns A new CSG solid with solid and empty space switched
  120746. */
  120747. inverse(): CSG;
  120748. /**
  120749. * Inverses the CSG in place
  120750. */
  120751. inverseInPlace(): void;
  120752. /**
  120753. * This is used to keep meshes transformations so they can be restored
  120754. * when we build back a Babylon Mesh
  120755. * NB : All CSG operations are performed in world coordinates
  120756. * @param csg The CSG to copy the transform attributes from
  120757. * @returns This CSG
  120758. */
  120759. copyTransformAttributes(csg: CSG): CSG;
  120760. /**
  120761. * Build Raw mesh from CSG
  120762. * Coordinates here are in world space
  120763. * @param name The name of the mesh geometry
  120764. * @param scene The Scene
  120765. * @param keepSubMeshes Specifies if the submeshes should be kept
  120766. * @returns A new Mesh
  120767. */
  120768. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120769. /**
  120770. * Build Mesh from CSG taking material and transforms into account
  120771. * @param name The name of the Mesh
  120772. * @param material The material of the Mesh
  120773. * @param scene The Scene
  120774. * @param keepSubMeshes Specifies if submeshes should be kept
  120775. * @returns The new Mesh
  120776. */
  120777. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120778. }
  120779. }
  120780. declare module BABYLON {
  120781. /**
  120782. * Class used to create a trail following a mesh
  120783. */
  120784. export class TrailMesh extends Mesh {
  120785. private _generator;
  120786. private _autoStart;
  120787. private _running;
  120788. private _diameter;
  120789. private _length;
  120790. private _sectionPolygonPointsCount;
  120791. private _sectionVectors;
  120792. private _sectionNormalVectors;
  120793. private _beforeRenderObserver;
  120794. /**
  120795. * @constructor
  120796. * @param name The value used by scene.getMeshByName() to do a lookup.
  120797. * @param generator The mesh to generate a trail.
  120798. * @param scene The scene to add this mesh to.
  120799. * @param diameter Diameter of trailing mesh. Default is 1.
  120800. * @param length Length of trailing mesh. Default is 60.
  120801. * @param autoStart Automatically start trailing mesh. Default true.
  120802. */
  120803. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120804. /**
  120805. * "TrailMesh"
  120806. * @returns "TrailMesh"
  120807. */
  120808. getClassName(): string;
  120809. private _createMesh;
  120810. /**
  120811. * Start trailing mesh.
  120812. */
  120813. start(): void;
  120814. /**
  120815. * Stop trailing mesh.
  120816. */
  120817. stop(): void;
  120818. /**
  120819. * Update trailing mesh geometry.
  120820. */
  120821. update(): void;
  120822. /**
  120823. * Returns a new TrailMesh object.
  120824. * @param name is a string, the name given to the new mesh
  120825. * @param newGenerator use new generator object for cloned trail mesh
  120826. * @returns a new mesh
  120827. */
  120828. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120829. /**
  120830. * Serializes this trail mesh
  120831. * @param serializationObject object to write serialization to
  120832. */
  120833. serialize(serializationObject: any): void;
  120834. /**
  120835. * Parses a serialized trail mesh
  120836. * @param parsedMesh the serialized mesh
  120837. * @param scene the scene to create the trail mesh in
  120838. * @returns the created trail mesh
  120839. */
  120840. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120841. }
  120842. }
  120843. declare module BABYLON {
  120844. /**
  120845. * Class containing static functions to help procedurally build meshes
  120846. */
  120847. export class TiledBoxBuilder {
  120848. /**
  120849. * Creates a box mesh
  120850. * 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)
  120851. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120855. * @param name defines the name of the mesh
  120856. * @param options defines the options used to create the mesh
  120857. * @param scene defines the hosting scene
  120858. * @returns the box mesh
  120859. */
  120860. static CreateTiledBox(name: string, options: {
  120861. pattern?: number;
  120862. width?: number;
  120863. height?: number;
  120864. depth?: number;
  120865. tileSize?: number;
  120866. tileWidth?: number;
  120867. tileHeight?: number;
  120868. alignHorizontal?: number;
  120869. alignVertical?: number;
  120870. faceUV?: Vector4[];
  120871. faceColors?: Color4[];
  120872. sideOrientation?: number;
  120873. updatable?: boolean;
  120874. }, scene?: Nullable<Scene>): Mesh;
  120875. }
  120876. }
  120877. declare module BABYLON {
  120878. /**
  120879. * Class containing static functions to help procedurally build meshes
  120880. */
  120881. export class TorusKnotBuilder {
  120882. /**
  120883. * Creates a torus knot mesh
  120884. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120885. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120886. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120887. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120891. * @param name defines the name of the mesh
  120892. * @param options defines the options used to create the mesh
  120893. * @param scene defines the hosting scene
  120894. * @returns the torus knot mesh
  120895. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120896. */
  120897. static CreateTorusKnot(name: string, options: {
  120898. radius?: number;
  120899. tube?: number;
  120900. radialSegments?: number;
  120901. tubularSegments?: number;
  120902. p?: number;
  120903. q?: number;
  120904. updatable?: boolean;
  120905. sideOrientation?: number;
  120906. frontUVs?: Vector4;
  120907. backUVs?: Vector4;
  120908. }, scene: any): Mesh;
  120909. }
  120910. }
  120911. declare module BABYLON {
  120912. /**
  120913. * Polygon
  120914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120915. */
  120916. export class Polygon {
  120917. /**
  120918. * Creates a rectangle
  120919. * @param xmin bottom X coord
  120920. * @param ymin bottom Y coord
  120921. * @param xmax top X coord
  120922. * @param ymax top Y coord
  120923. * @returns points that make the resulting rectation
  120924. */
  120925. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120926. /**
  120927. * Creates a circle
  120928. * @param radius radius of circle
  120929. * @param cx scale in x
  120930. * @param cy scale in y
  120931. * @param numberOfSides number of sides that make up the circle
  120932. * @returns points that make the resulting circle
  120933. */
  120934. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120935. /**
  120936. * Creates a polygon from input string
  120937. * @param input Input polygon data
  120938. * @returns the parsed points
  120939. */
  120940. static Parse(input: string): Vector2[];
  120941. /**
  120942. * Starts building a polygon from x and y coordinates
  120943. * @param x x coordinate
  120944. * @param y y coordinate
  120945. * @returns the started path2
  120946. */
  120947. static StartingAt(x: number, y: number): Path2;
  120948. }
  120949. /**
  120950. * Builds a polygon
  120951. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120952. */
  120953. export class PolygonMeshBuilder {
  120954. private _points;
  120955. private _outlinepoints;
  120956. private _holes;
  120957. private _name;
  120958. private _scene;
  120959. private _epoints;
  120960. private _eholes;
  120961. private _addToepoint;
  120962. /**
  120963. * Babylon reference to the earcut plugin.
  120964. */
  120965. bjsEarcut: any;
  120966. /**
  120967. * Creates a PolygonMeshBuilder
  120968. * @param name name of the builder
  120969. * @param contours Path of the polygon
  120970. * @param scene scene to add to when creating the mesh
  120971. * @param earcutInjection can be used to inject your own earcut reference
  120972. */
  120973. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120974. /**
  120975. * Adds a whole within the polygon
  120976. * @param hole Array of points defining the hole
  120977. * @returns this
  120978. */
  120979. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120980. /**
  120981. * Creates the polygon
  120982. * @param updatable If the mesh should be updatable
  120983. * @param depth The depth of the mesh created
  120984. * @returns the created mesh
  120985. */
  120986. build(updatable?: boolean, depth?: number): Mesh;
  120987. /**
  120988. * Creates the polygon
  120989. * @param depth The depth of the mesh created
  120990. * @returns the created VertexData
  120991. */
  120992. buildVertexData(depth?: number): VertexData;
  120993. /**
  120994. * Adds a side to the polygon
  120995. * @param positions points that make the polygon
  120996. * @param normals normals of the polygon
  120997. * @param uvs uvs of the polygon
  120998. * @param indices indices of the polygon
  120999. * @param bounds bounds of the polygon
  121000. * @param points points of the polygon
  121001. * @param depth depth of the polygon
  121002. * @param flip flip of the polygon
  121003. */
  121004. private addSide;
  121005. }
  121006. }
  121007. declare module BABYLON {
  121008. /**
  121009. * Class containing static functions to help procedurally build meshes
  121010. */
  121011. export class PolygonBuilder {
  121012. /**
  121013. * Creates a polygon mesh
  121014. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121015. * * 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
  121016. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121019. * * Remember you can only change the shape positions, not their number when updating a polygon
  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 CreatePolygon(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. * Creates an extruded polygon mesh, with depth in the Y direction.
  121039. * * 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)
  121040. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121041. * @param name defines the name of the mesh
  121042. * @param options defines the options used to create the mesh
  121043. * @param scene defines the hosting scene
  121044. * @param earcutInjection can be used to inject your own earcut reference
  121045. * @returns the polygon mesh
  121046. */
  121047. static ExtrudePolygon(name: string, options: {
  121048. shape: Vector3[];
  121049. holes?: Vector3[][];
  121050. depth?: number;
  121051. faceUV?: Vector4[];
  121052. faceColors?: Color4[];
  121053. updatable?: boolean;
  121054. sideOrientation?: number;
  121055. frontUVs?: Vector4;
  121056. backUVs?: Vector4;
  121057. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121058. }
  121059. }
  121060. declare module BABYLON {
  121061. /**
  121062. * Class containing static functions to help procedurally build meshes
  121063. */
  121064. export class LatheBuilder {
  121065. /**
  121066. * Creates lathe mesh.
  121067. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121068. * * 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
  121069. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121070. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121071. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121072. * * 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
  121073. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121074. * * 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
  121075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121079. * @param name defines the name of the mesh
  121080. * @param options defines the options used to create the mesh
  121081. * @param scene defines the hosting scene
  121082. * @returns the lathe mesh
  121083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121084. */
  121085. static CreateLathe(name: string, options: {
  121086. shape: Vector3[];
  121087. radius?: number;
  121088. tessellation?: number;
  121089. clip?: number;
  121090. arc?: number;
  121091. closed?: boolean;
  121092. updatable?: boolean;
  121093. sideOrientation?: number;
  121094. frontUVs?: Vector4;
  121095. backUVs?: Vector4;
  121096. cap?: number;
  121097. invertUV?: boolean;
  121098. }, scene?: Nullable<Scene>): Mesh;
  121099. }
  121100. }
  121101. declare module BABYLON {
  121102. /**
  121103. * Class containing static functions to help procedurally build meshes
  121104. */
  121105. export class TiledPlaneBuilder {
  121106. /**
  121107. * Creates a tiled plane mesh
  121108. * * The parameter `pattern` will, depending on value, do nothing or
  121109. * * * flip (reflect about central vertical) alternate tiles across and up
  121110. * * * flip every tile on alternate rows
  121111. * * * rotate (180 degs) alternate tiles across and up
  121112. * * * rotate every tile on alternate rows
  121113. * * * flip and rotate alternate tiles across and up
  121114. * * * flip and rotate every tile on alternate rows
  121115. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121116. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121119. * * 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)
  121120. * * 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)
  121121. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121122. * @param name defines the name of the mesh
  121123. * @param options defines the options used to create the mesh
  121124. * @param scene defines the hosting scene
  121125. * @returns the box mesh
  121126. */
  121127. static CreateTiledPlane(name: string, options: {
  121128. pattern?: number;
  121129. tileSize?: number;
  121130. tileWidth?: number;
  121131. tileHeight?: number;
  121132. size?: number;
  121133. width?: number;
  121134. height?: number;
  121135. alignHorizontal?: number;
  121136. alignVertical?: number;
  121137. sideOrientation?: number;
  121138. frontUVs?: Vector4;
  121139. backUVs?: Vector4;
  121140. updatable?: boolean;
  121141. }, scene?: Nullable<Scene>): Mesh;
  121142. }
  121143. }
  121144. declare module BABYLON {
  121145. /**
  121146. * Class containing static functions to help procedurally build meshes
  121147. */
  121148. export class TubeBuilder {
  121149. /**
  121150. * Creates a tube mesh.
  121151. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121152. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121153. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121154. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121155. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121156. * * 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)
  121157. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121158. * * 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
  121159. * * 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
  121160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121164. * @param name defines the name of the mesh
  121165. * @param options defines the options used to create the mesh
  121166. * @param scene defines the hosting scene
  121167. * @returns the tube mesh
  121168. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121169. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121170. */
  121171. static CreateTube(name: string, options: {
  121172. path: Vector3[];
  121173. radius?: number;
  121174. tessellation?: number;
  121175. radiusFunction?: {
  121176. (i: number, distance: number): number;
  121177. };
  121178. cap?: number;
  121179. arc?: number;
  121180. updatable?: boolean;
  121181. sideOrientation?: number;
  121182. frontUVs?: Vector4;
  121183. backUVs?: Vector4;
  121184. instance?: Mesh;
  121185. invertUV?: boolean;
  121186. }, scene?: Nullable<Scene>): Mesh;
  121187. }
  121188. }
  121189. declare module BABYLON {
  121190. /**
  121191. * Class containing static functions to help procedurally build meshes
  121192. */
  121193. export class IcoSphereBuilder {
  121194. /**
  121195. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121196. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121197. * * 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`)
  121198. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121199. * * 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
  121200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121203. * @param name defines the name of the mesh
  121204. * @param options defines the options used to create the mesh
  121205. * @param scene defines the hosting scene
  121206. * @returns the icosahedron mesh
  121207. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121208. */
  121209. static CreateIcoSphere(name: string, options: {
  121210. radius?: number;
  121211. radiusX?: number;
  121212. radiusY?: number;
  121213. radiusZ?: number;
  121214. flat?: boolean;
  121215. subdivisions?: number;
  121216. sideOrientation?: number;
  121217. frontUVs?: Vector4;
  121218. backUVs?: Vector4;
  121219. updatable?: boolean;
  121220. }, scene?: Nullable<Scene>): Mesh;
  121221. }
  121222. }
  121223. declare module BABYLON {
  121224. /**
  121225. * Class containing static functions to help procedurally build meshes
  121226. */
  121227. export class DecalBuilder {
  121228. /**
  121229. * Creates a decal mesh.
  121230. * 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
  121231. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121232. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121233. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121234. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121235. * @param name defines the name of the mesh
  121236. * @param sourceMesh defines the mesh where the decal must be applied
  121237. * @param options defines the options used to create the mesh
  121238. * @param scene defines the hosting scene
  121239. * @returns the decal mesh
  121240. * @see https://doc.babylonjs.com/how_to/decals
  121241. */
  121242. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121243. position?: Vector3;
  121244. normal?: Vector3;
  121245. size?: Vector3;
  121246. angle?: number;
  121247. }): Mesh;
  121248. }
  121249. }
  121250. declare module BABYLON {
  121251. /**
  121252. * Class containing static functions to help procedurally build meshes
  121253. */
  121254. export class MeshBuilder {
  121255. /**
  121256. * Creates a box mesh
  121257. * * The parameter `size` sets the size (float) of each box side (default 1)
  121258. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121259. * * 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)
  121260. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121264. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  121269. */
  121270. static CreateBox(name: string, options: {
  121271. size?: number;
  121272. width?: number;
  121273. height?: number;
  121274. depth?: number;
  121275. faceUV?: Vector4[];
  121276. faceColors?: Color4[];
  121277. sideOrientation?: number;
  121278. frontUVs?: Vector4;
  121279. backUVs?: Vector4;
  121280. updatable?: boolean;
  121281. }, scene?: Nullable<Scene>): Mesh;
  121282. /**
  121283. * Creates a tiled box mesh
  121284. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121286. * @param name defines the name of the mesh
  121287. * @param options defines the options used to create the mesh
  121288. * @param scene defines the hosting scene
  121289. * @returns the tiled box mesh
  121290. */
  121291. static CreateTiledBox(name: string, options: {
  121292. pattern?: number;
  121293. size?: number;
  121294. width?: number;
  121295. height?: number;
  121296. depth: number;
  121297. tileSize?: number;
  121298. tileWidth?: number;
  121299. tileHeight?: number;
  121300. faceUV?: Vector4[];
  121301. faceColors?: Color4[];
  121302. alignHorizontal?: number;
  121303. alignVertical?: number;
  121304. sideOrientation?: number;
  121305. updatable?: boolean;
  121306. }, scene?: Nullable<Scene>): Mesh;
  121307. /**
  121308. * Creates a sphere mesh
  121309. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121310. * * 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`)
  121311. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121312. * * 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
  121313. * * 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)
  121314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121317. * @param name defines the name of the mesh
  121318. * @param options defines the options used to create the mesh
  121319. * @param scene defines the hosting scene
  121320. * @returns the sphere mesh
  121321. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121322. */
  121323. static CreateSphere(name: string, options: {
  121324. segments?: number;
  121325. diameter?: number;
  121326. diameterX?: number;
  121327. diameterY?: number;
  121328. diameterZ?: number;
  121329. arc?: number;
  121330. slice?: number;
  121331. sideOrientation?: number;
  121332. frontUVs?: Vector4;
  121333. backUVs?: Vector4;
  121334. updatable?: boolean;
  121335. }, scene?: Nullable<Scene>): Mesh;
  121336. /**
  121337. * Creates a plane polygonal mesh. By default, this is a disc
  121338. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121339. * * 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
  121340. * * 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
  121341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121344. * @param name defines the name of the mesh
  121345. * @param options defines the options used to create the mesh
  121346. * @param scene defines the hosting scene
  121347. * @returns the plane polygonal mesh
  121348. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121349. */
  121350. static CreateDisc(name: string, options: {
  121351. radius?: number;
  121352. tessellation?: number;
  121353. arc?: number;
  121354. updatable?: boolean;
  121355. sideOrientation?: number;
  121356. frontUVs?: Vector4;
  121357. backUVs?: Vector4;
  121358. }, scene?: Nullable<Scene>): Mesh;
  121359. /**
  121360. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121361. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121362. * * 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`)
  121363. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121364. * * 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
  121365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121368. * @param name defines the name of the mesh
  121369. * @param options defines the options used to create the mesh
  121370. * @param scene defines the hosting scene
  121371. * @returns the icosahedron mesh
  121372. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121373. */
  121374. static CreateIcoSphere(name: string, options: {
  121375. radius?: number;
  121376. radiusX?: number;
  121377. radiusY?: number;
  121378. radiusZ?: number;
  121379. flat?: boolean;
  121380. subdivisions?: number;
  121381. sideOrientation?: number;
  121382. frontUVs?: Vector4;
  121383. backUVs?: Vector4;
  121384. updatable?: boolean;
  121385. }, scene?: Nullable<Scene>): Mesh;
  121386. /**
  121387. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121388. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121389. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121390. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121391. * * 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
  121392. * * 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
  121393. * * 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
  121394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121397. * * 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
  121398. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121399. * * 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
  121400. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121402. * @param name defines the name of the mesh
  121403. * @param options defines the options used to create the mesh
  121404. * @param scene defines the hosting scene
  121405. * @returns the ribbon mesh
  121406. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121408. */
  121409. static CreateRibbon(name: string, options: {
  121410. pathArray: Vector3[][];
  121411. closeArray?: boolean;
  121412. closePath?: boolean;
  121413. offset?: number;
  121414. updatable?: boolean;
  121415. sideOrientation?: number;
  121416. frontUVs?: Vector4;
  121417. backUVs?: Vector4;
  121418. instance?: Mesh;
  121419. invertUV?: boolean;
  121420. uvs?: Vector2[];
  121421. colors?: Color4[];
  121422. }, scene?: Nullable<Scene>): Mesh;
  121423. /**
  121424. * Creates a cylinder or a cone mesh
  121425. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121426. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121427. * * 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.
  121428. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121429. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121430. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121431. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121432. * * 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).
  121433. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121434. * * 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).
  121435. * * 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
  121436. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121437. * * 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
  121438. * * 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.
  121439. * * If `enclose` is false, a ring surface is one element.
  121440. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121441. * * 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
  121442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121445. * @param name defines the name of the mesh
  121446. * @param options defines the options used to create the mesh
  121447. * @param scene defines the hosting scene
  121448. * @returns the cylinder mesh
  121449. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121450. */
  121451. static CreateCylinder(name: string, options: {
  121452. height?: number;
  121453. diameterTop?: number;
  121454. diameterBottom?: number;
  121455. diameter?: number;
  121456. tessellation?: number;
  121457. subdivisions?: number;
  121458. arc?: number;
  121459. faceColors?: Color4[];
  121460. faceUV?: Vector4[];
  121461. updatable?: boolean;
  121462. hasRings?: boolean;
  121463. enclose?: boolean;
  121464. cap?: number;
  121465. sideOrientation?: number;
  121466. frontUVs?: Vector4;
  121467. backUVs?: Vector4;
  121468. }, scene?: Nullable<Scene>): Mesh;
  121469. /**
  121470. * Creates a torus mesh
  121471. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121472. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121473. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121477. * @param name defines the name of the mesh
  121478. * @param options defines the options used to create the mesh
  121479. * @param scene defines the hosting scene
  121480. * @returns the torus mesh
  121481. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121482. */
  121483. static CreateTorus(name: string, options: {
  121484. diameter?: number;
  121485. thickness?: number;
  121486. tessellation?: number;
  121487. updatable?: boolean;
  121488. sideOrientation?: number;
  121489. frontUVs?: Vector4;
  121490. backUVs?: Vector4;
  121491. }, scene?: Nullable<Scene>): Mesh;
  121492. /**
  121493. * Creates a torus knot mesh
  121494. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121495. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121496. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121497. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121501. * @param name defines the name of the mesh
  121502. * @param options defines the options used to create the mesh
  121503. * @param scene defines the hosting scene
  121504. * @returns the torus knot mesh
  121505. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121506. */
  121507. static CreateTorusKnot(name: string, options: {
  121508. radius?: number;
  121509. tube?: number;
  121510. radialSegments?: number;
  121511. tubularSegments?: number;
  121512. p?: number;
  121513. q?: number;
  121514. updatable?: boolean;
  121515. sideOrientation?: number;
  121516. frontUVs?: Vector4;
  121517. backUVs?: Vector4;
  121518. }, scene?: Nullable<Scene>): Mesh;
  121519. /**
  121520. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121521. * * 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
  121522. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121523. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121524. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121525. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121526. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121527. * * 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
  121528. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121531. * @param name defines the name of the new line system
  121532. * @param options defines the options used to create the line system
  121533. * @param scene defines the hosting scene
  121534. * @returns a new line system mesh
  121535. */
  121536. static CreateLineSystem(name: string, options: {
  121537. lines: Vector3[][];
  121538. updatable?: boolean;
  121539. instance?: Nullable<LinesMesh>;
  121540. colors?: Nullable<Color4[][]>;
  121541. useVertexAlpha?: boolean;
  121542. }, scene: Nullable<Scene>): LinesMesh;
  121543. /**
  121544. * Creates a line mesh
  121545. * 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
  121546. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121547. * * The parameter `points` is an array successive Vector3
  121548. * * 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
  121549. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121550. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121551. * * When updating an instance, remember that only point positions can change, not the number of points
  121552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121554. * @param name defines the name of the new line system
  121555. * @param options defines the options used to create the line system
  121556. * @param scene defines the hosting scene
  121557. * @returns a new line mesh
  121558. */
  121559. static CreateLines(name: string, options: {
  121560. points: Vector3[];
  121561. updatable?: boolean;
  121562. instance?: Nullable<LinesMesh>;
  121563. colors?: Color4[];
  121564. useVertexAlpha?: boolean;
  121565. }, scene?: Nullable<Scene>): LinesMesh;
  121566. /**
  121567. * Creates a dashed line mesh
  121568. * * 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
  121569. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121570. * * The parameter `points` is an array successive Vector3
  121571. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121572. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121573. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121574. * * 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
  121575. * * When updating an instance, remember that only point positions can change, not the number of points
  121576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121577. * @param name defines the name of the mesh
  121578. * @param options defines the options used to create the mesh
  121579. * @param scene defines the hosting scene
  121580. * @returns the dashed line mesh
  121581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121582. */
  121583. static CreateDashedLines(name: string, options: {
  121584. points: Vector3[];
  121585. dashSize?: number;
  121586. gapSize?: number;
  121587. dashNb?: number;
  121588. updatable?: boolean;
  121589. instance?: LinesMesh;
  121590. }, scene?: Nullable<Scene>): LinesMesh;
  121591. /**
  121592. * 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.
  121593. * * 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.
  121594. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121595. * * 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.
  121596. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121597. * * 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
  121598. * * 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
  121599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121604. * @param name defines the name of the mesh
  121605. * @param options defines the options used to create the mesh
  121606. * @param scene defines the hosting scene
  121607. * @returns the extruded shape mesh
  121608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121610. */
  121611. static ExtrudeShape(name: string, options: {
  121612. shape: Vector3[];
  121613. path: Vector3[];
  121614. scale?: number;
  121615. rotation?: number;
  121616. cap?: number;
  121617. updatable?: boolean;
  121618. sideOrientation?: number;
  121619. frontUVs?: Vector4;
  121620. backUVs?: Vector4;
  121621. instance?: Mesh;
  121622. invertUV?: boolean;
  121623. }, scene?: Nullable<Scene>): Mesh;
  121624. /**
  121625. * Creates an custom extruded shape mesh.
  121626. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121627. * * 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.
  121628. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121629. * * 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
  121630. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121631. * * 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
  121632. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121633. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121634. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121635. * * 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
  121636. * * 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
  121637. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121642. * @param name defines the name of the mesh
  121643. * @param options defines the options used to create the mesh
  121644. * @param scene defines the hosting scene
  121645. * @returns the custom extruded shape mesh
  121646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121649. */
  121650. static ExtrudeShapeCustom(name: string, options: {
  121651. shape: Vector3[];
  121652. path: Vector3[];
  121653. scaleFunction?: any;
  121654. rotationFunction?: any;
  121655. ribbonCloseArray?: boolean;
  121656. ribbonClosePath?: boolean;
  121657. cap?: number;
  121658. updatable?: boolean;
  121659. sideOrientation?: number;
  121660. frontUVs?: Vector4;
  121661. backUVs?: Vector4;
  121662. instance?: Mesh;
  121663. invertUV?: boolean;
  121664. }, scene?: Nullable<Scene>): Mesh;
  121665. /**
  121666. * Creates lathe mesh.
  121667. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121668. * * 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
  121669. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121670. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121671. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121672. * * 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
  121673. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121674. * * 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
  121675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121679. * @param name defines the name of the mesh
  121680. * @param options defines the options used to create the mesh
  121681. * @param scene defines the hosting scene
  121682. * @returns the lathe mesh
  121683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121684. */
  121685. static CreateLathe(name: string, options: {
  121686. shape: Vector3[];
  121687. radius?: number;
  121688. tessellation?: number;
  121689. clip?: number;
  121690. arc?: number;
  121691. closed?: boolean;
  121692. updatable?: boolean;
  121693. sideOrientation?: number;
  121694. frontUVs?: Vector4;
  121695. backUVs?: Vector4;
  121696. cap?: number;
  121697. invertUV?: boolean;
  121698. }, scene?: Nullable<Scene>): Mesh;
  121699. /**
  121700. * Creates a tiled plane mesh
  121701. * * You can set a limited pattern arrangement with the tiles
  121702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121705. * @param name defines the name of the mesh
  121706. * @param options defines the options used to create the mesh
  121707. * @param scene defines the hosting scene
  121708. * @returns the plane mesh
  121709. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121710. */
  121711. static CreateTiledPlane(name: string, options: {
  121712. pattern?: number;
  121713. tileSize?: number;
  121714. tileWidth?: number;
  121715. tileHeight?: number;
  121716. size?: number;
  121717. width?: number;
  121718. height?: number;
  121719. alignHorizontal?: number;
  121720. alignVertical?: number;
  121721. sideOrientation?: number;
  121722. frontUVs?: Vector4;
  121723. backUVs?: Vector4;
  121724. updatable?: boolean;
  121725. }, scene?: Nullable<Scene>): Mesh;
  121726. /**
  121727. * Creates a plane mesh
  121728. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121729. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121730. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  121738. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121739. */
  121740. static CreatePlane(name: string, options: {
  121741. size?: number;
  121742. width?: number;
  121743. height?: number;
  121744. sideOrientation?: number;
  121745. frontUVs?: Vector4;
  121746. backUVs?: Vector4;
  121747. updatable?: boolean;
  121748. sourcePlane?: Plane;
  121749. }, scene?: Nullable<Scene>): Mesh;
  121750. /**
  121751. * Creates a ground mesh
  121752. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121753. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  121759. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121760. */
  121761. static CreateGround(name: string, options: {
  121762. width?: number;
  121763. height?: number;
  121764. subdivisions?: number;
  121765. subdivisionsX?: number;
  121766. subdivisionsY?: number;
  121767. updatable?: boolean;
  121768. }, scene?: Nullable<Scene>): Mesh;
  121769. /**
  121770. * Creates a tiled ground mesh
  121771. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121772. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121773. * * 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
  121774. * * 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
  121775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121776. * @param name defines the name of the mesh
  121777. * @param options defines the options used to create the mesh
  121778. * @param scene defines the hosting scene
  121779. * @returns the tiled ground mesh
  121780. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121781. */
  121782. static CreateTiledGround(name: string, options: {
  121783. xmin: number;
  121784. zmin: number;
  121785. xmax: number;
  121786. zmax: number;
  121787. subdivisions?: {
  121788. w: number;
  121789. h: number;
  121790. };
  121791. precision?: {
  121792. w: number;
  121793. h: number;
  121794. };
  121795. updatable?: boolean;
  121796. }, scene?: Nullable<Scene>): Mesh;
  121797. /**
  121798. * Creates a ground mesh from a height map
  121799. * * The parameter `url` sets the URL of the height map image resource.
  121800. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121801. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121802. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121803. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121804. * * 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.
  121805. * * 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).
  121806. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121808. * @param name defines the name of the mesh
  121809. * @param url defines the url to the height map
  121810. * @param options defines the options used to create the mesh
  121811. * @param scene defines the hosting scene
  121812. * @returns the ground mesh
  121813. * @see https://doc.babylonjs.com/babylon101/height_map
  121814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121815. */
  121816. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121817. width?: number;
  121818. height?: number;
  121819. subdivisions?: number;
  121820. minHeight?: number;
  121821. maxHeight?: number;
  121822. colorFilter?: Color3;
  121823. alphaFilter?: number;
  121824. updatable?: boolean;
  121825. onReady?: (mesh: GroundMesh) => void;
  121826. }, scene?: Nullable<Scene>): GroundMesh;
  121827. /**
  121828. * Creates a polygon mesh
  121829. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121830. * * 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
  121831. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121834. * * Remember you can only change the shape positions, not their number when updating a polygon
  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 CreatePolygon(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 an extruded polygon mesh, with depth in the Y direction.
  121854. * * 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)
  121855. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121856. * @param name defines the name of the mesh
  121857. * @param options defines the options used to create the mesh
  121858. * @param scene defines the hosting scene
  121859. * @param earcutInjection can be used to inject your own earcut reference
  121860. * @returns the polygon mesh
  121861. */
  121862. static ExtrudePolygon(name: string, options: {
  121863. shape: Vector3[];
  121864. holes?: Vector3[][];
  121865. depth?: number;
  121866. faceUV?: Vector4[];
  121867. faceColors?: Color4[];
  121868. updatable?: boolean;
  121869. sideOrientation?: number;
  121870. frontUVs?: Vector4;
  121871. backUVs?: Vector4;
  121872. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121873. /**
  121874. * Creates a tube mesh.
  121875. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121876. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121877. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121878. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121879. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121880. * * 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)
  121881. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121882. * * 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
  121883. * * 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
  121884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121888. * @param name defines the name of the mesh
  121889. * @param options defines the options used to create the mesh
  121890. * @param scene defines the hosting scene
  121891. * @returns the tube mesh
  121892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121893. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121894. */
  121895. static CreateTube(name: string, options: {
  121896. path: Vector3[];
  121897. radius?: number;
  121898. tessellation?: number;
  121899. radiusFunction?: {
  121900. (i: number, distance: number): number;
  121901. };
  121902. cap?: number;
  121903. arc?: number;
  121904. updatable?: boolean;
  121905. sideOrientation?: number;
  121906. frontUVs?: Vector4;
  121907. backUVs?: Vector4;
  121908. instance?: Mesh;
  121909. invertUV?: boolean;
  121910. }, scene?: Nullable<Scene>): Mesh;
  121911. /**
  121912. * Creates a polyhedron mesh
  121913. * * 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
  121914. * * The parameter `size` (positive float, default 1) sets the polygon size
  121915. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121916. * * 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`
  121917. * * 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
  121918. * * 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)`)
  121919. * * 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
  121920. * * 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
  121921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121924. * @param name defines the name of the mesh
  121925. * @param options defines the options used to create the mesh
  121926. * @param scene defines the hosting scene
  121927. * @returns the polyhedron mesh
  121928. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121929. */
  121930. static CreatePolyhedron(name: string, options: {
  121931. type?: number;
  121932. size?: number;
  121933. sizeX?: number;
  121934. sizeY?: number;
  121935. sizeZ?: number;
  121936. custom?: any;
  121937. faceUV?: Vector4[];
  121938. faceColors?: Color4[];
  121939. flat?: boolean;
  121940. updatable?: boolean;
  121941. sideOrientation?: number;
  121942. frontUVs?: Vector4;
  121943. backUVs?: Vector4;
  121944. }, scene?: Nullable<Scene>): Mesh;
  121945. /**
  121946. * Creates a decal mesh.
  121947. * 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
  121948. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121949. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121950. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121951. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121952. * @param name defines the name of the mesh
  121953. * @param sourceMesh defines the mesh where the decal must be applied
  121954. * @param options defines the options used to create the mesh
  121955. * @param scene defines the hosting scene
  121956. * @returns the decal mesh
  121957. * @see https://doc.babylonjs.com/how_to/decals
  121958. */
  121959. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121960. position?: Vector3;
  121961. normal?: Vector3;
  121962. size?: Vector3;
  121963. angle?: number;
  121964. }): Mesh;
  121965. }
  121966. }
  121967. declare module BABYLON {
  121968. /**
  121969. * A simplifier interface for future simplification implementations
  121970. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121971. */
  121972. export interface ISimplifier {
  121973. /**
  121974. * Simplification of a given mesh according to the given settings.
  121975. * Since this requires computation, it is assumed that the function runs async.
  121976. * @param settings The settings of the simplification, including quality and distance
  121977. * @param successCallback A callback that will be called after the mesh was simplified.
  121978. * @param errorCallback in case of an error, this callback will be called. optional.
  121979. */
  121980. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121981. }
  121982. /**
  121983. * Expected simplification settings.
  121984. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121985. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121986. */
  121987. export interface ISimplificationSettings {
  121988. /**
  121989. * Gets or sets the expected quality
  121990. */
  121991. quality: number;
  121992. /**
  121993. * Gets or sets the distance when this optimized version should be used
  121994. */
  121995. distance: number;
  121996. /**
  121997. * Gets an already optimized mesh
  121998. */
  121999. optimizeMesh?: boolean;
  122000. }
  122001. /**
  122002. * Class used to specify simplification options
  122003. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122004. */
  122005. export class SimplificationSettings implements ISimplificationSettings {
  122006. /** expected quality */
  122007. quality: number;
  122008. /** distance when this optimized version should be used */
  122009. distance: number;
  122010. /** already optimized mesh */
  122011. optimizeMesh?: boolean | undefined;
  122012. /**
  122013. * Creates a SimplificationSettings
  122014. * @param quality expected quality
  122015. * @param distance distance when this optimized version should be used
  122016. * @param optimizeMesh already optimized mesh
  122017. */
  122018. constructor(
  122019. /** expected quality */
  122020. quality: number,
  122021. /** distance when this optimized version should be used */
  122022. distance: number,
  122023. /** already optimized mesh */
  122024. optimizeMesh?: boolean | undefined);
  122025. }
  122026. /**
  122027. * Interface used to define a simplification task
  122028. */
  122029. export interface ISimplificationTask {
  122030. /**
  122031. * Array of settings
  122032. */
  122033. settings: Array<ISimplificationSettings>;
  122034. /**
  122035. * Simplification type
  122036. */
  122037. simplificationType: SimplificationType;
  122038. /**
  122039. * Mesh to simplify
  122040. */
  122041. mesh: Mesh;
  122042. /**
  122043. * Callback called on success
  122044. */
  122045. successCallback?: () => void;
  122046. /**
  122047. * Defines if parallel processing can be used
  122048. */
  122049. parallelProcessing: boolean;
  122050. }
  122051. /**
  122052. * Queue used to order the simplification tasks
  122053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122054. */
  122055. export class SimplificationQueue {
  122056. private _simplificationArray;
  122057. /**
  122058. * Gets a boolean indicating that the process is still running
  122059. */
  122060. running: boolean;
  122061. /**
  122062. * Creates a new queue
  122063. */
  122064. constructor();
  122065. /**
  122066. * Adds a new simplification task
  122067. * @param task defines a task to add
  122068. */
  122069. addTask(task: ISimplificationTask): void;
  122070. /**
  122071. * Execute next task
  122072. */
  122073. executeNext(): void;
  122074. /**
  122075. * Execute a simplification task
  122076. * @param task defines the task to run
  122077. */
  122078. runSimplification(task: ISimplificationTask): void;
  122079. private getSimplifier;
  122080. }
  122081. /**
  122082. * The implemented types of simplification
  122083. * At the moment only Quadratic Error Decimation is implemented
  122084. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122085. */
  122086. export enum SimplificationType {
  122087. /** Quadratic error decimation */
  122088. QUADRATIC = 0
  122089. }
  122090. }
  122091. declare module BABYLON {
  122092. interface Scene {
  122093. /** @hidden (Backing field) */
  122094. _simplificationQueue: SimplificationQueue;
  122095. /**
  122096. * Gets or sets the simplification queue attached to the scene
  122097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122098. */
  122099. simplificationQueue: SimplificationQueue;
  122100. }
  122101. interface Mesh {
  122102. /**
  122103. * Simplify the mesh according to the given array of settings.
  122104. * Function will return immediately and will simplify async
  122105. * @param settings a collection of simplification settings
  122106. * @param parallelProcessing should all levels calculate parallel or one after the other
  122107. * @param simplificationType the type of simplification to run
  122108. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122109. * @returns the current mesh
  122110. */
  122111. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122112. }
  122113. /**
  122114. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122115. * created in a scene
  122116. */
  122117. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122118. /**
  122119. * The component name helpfull to identify the component in the list of scene components.
  122120. */
  122121. readonly name: string;
  122122. /**
  122123. * The scene the component belongs to.
  122124. */
  122125. scene: Scene;
  122126. /**
  122127. * Creates a new instance of the component for the given scene
  122128. * @param scene Defines the scene to register the component in
  122129. */
  122130. constructor(scene: Scene);
  122131. /**
  122132. * Registers the component in a given scene
  122133. */
  122134. register(): void;
  122135. /**
  122136. * Rebuilds the elements related to this component in case of
  122137. * context lost for instance.
  122138. */
  122139. rebuild(): void;
  122140. /**
  122141. * Disposes the component and the associated ressources
  122142. */
  122143. dispose(): void;
  122144. private _beforeCameraUpdate;
  122145. }
  122146. }
  122147. declare module BABYLON {
  122148. /**
  122149. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122150. */
  122151. export interface INavigationEnginePlugin {
  122152. /**
  122153. * plugin name
  122154. */
  122155. name: string;
  122156. /**
  122157. * Creates a navigation mesh
  122158. * @param meshes array of all the geometry used to compute the navigatio mesh
  122159. * @param parameters bunch of parameters used to filter geometry
  122160. */
  122161. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122162. /**
  122163. * Create a navigation mesh debug mesh
  122164. * @param scene is where the mesh will be added
  122165. * @returns debug display mesh
  122166. */
  122167. createDebugNavMesh(scene: Scene): Mesh;
  122168. /**
  122169. * Get a navigation mesh constrained position, closest to the parameter position
  122170. * @param position world position
  122171. * @returns the closest point to position constrained by the navigation mesh
  122172. */
  122173. getClosestPoint(position: Vector3): Vector3;
  122174. /**
  122175. * Get a navigation mesh constrained position, within a particular radius
  122176. * @param position world position
  122177. * @param maxRadius the maximum distance to the constrained world position
  122178. * @returns the closest point to position constrained by the navigation mesh
  122179. */
  122180. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122181. /**
  122182. * Compute the final position from a segment made of destination-position
  122183. * @param position world position
  122184. * @param destination world position
  122185. * @returns the resulting point along the navmesh
  122186. */
  122187. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122188. /**
  122189. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122190. * @param start world position
  122191. * @param end world position
  122192. * @returns array containing world position composing the path
  122193. */
  122194. computePath(start: Vector3, end: Vector3): Vector3[];
  122195. /**
  122196. * If this plugin is supported
  122197. * @returns true if plugin is supported
  122198. */
  122199. isSupported(): boolean;
  122200. /**
  122201. * Create a new Crowd so you can add agents
  122202. * @param maxAgents the maximum agent count in the crowd
  122203. * @param maxAgentRadius the maximum radius an agent can have
  122204. * @param scene to attach the crowd to
  122205. * @returns the crowd you can add agents to
  122206. */
  122207. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122208. /**
  122209. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122210. * The queries will try to find a solution within those bounds
  122211. * default is (1,1,1)
  122212. * @param extent x,y,z value that define the extent around the queries point of reference
  122213. */
  122214. setDefaultQueryExtent(extent: Vector3): void;
  122215. /**
  122216. * Get the Bounding box extent specified by setDefaultQueryExtent
  122217. * @returns the box extent values
  122218. */
  122219. getDefaultQueryExtent(): Vector3;
  122220. /**
  122221. * Release all resources
  122222. */
  122223. dispose(): void;
  122224. }
  122225. /**
  122226. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122227. */
  122228. export interface ICrowd {
  122229. /**
  122230. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122231. * You can attach anything to that node. The node position is updated in the scene update tick.
  122232. * @param pos world position that will be constrained by the navigation mesh
  122233. * @param parameters agent parameters
  122234. * @param transform hooked to the agent that will be update by the scene
  122235. * @returns agent index
  122236. */
  122237. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122238. /**
  122239. * Returns the agent position in world space
  122240. * @param index agent index returned by addAgent
  122241. * @returns world space position
  122242. */
  122243. getAgentPosition(index: number): Vector3;
  122244. /**
  122245. * Gets the agent velocity in world space
  122246. * @param index agent index returned by addAgent
  122247. * @returns world space velocity
  122248. */
  122249. getAgentVelocity(index: number): Vector3;
  122250. /**
  122251. * remove a particular agent previously created
  122252. * @param index agent index returned by addAgent
  122253. */
  122254. removeAgent(index: number): void;
  122255. /**
  122256. * get the list of all agents attached to this crowd
  122257. * @returns list of agent indices
  122258. */
  122259. getAgents(): number[];
  122260. /**
  122261. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122262. * @param deltaTime in seconds
  122263. */
  122264. update(deltaTime: number): void;
  122265. /**
  122266. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122267. * @param index agent index returned by addAgent
  122268. * @param destination targeted world position
  122269. */
  122270. agentGoto(index: number, destination: Vector3): void;
  122271. /**
  122272. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122273. * The queries will try to find a solution within those bounds
  122274. * default is (1,1,1)
  122275. * @param extent x,y,z value that define the extent around the queries point of reference
  122276. */
  122277. setDefaultQueryExtent(extent: Vector3): void;
  122278. /**
  122279. * Get the Bounding box extent specified by setDefaultQueryExtent
  122280. * @returns the box extent values
  122281. */
  122282. getDefaultQueryExtent(): Vector3;
  122283. /**
  122284. * Release all resources
  122285. */
  122286. dispose(): void;
  122287. }
  122288. /**
  122289. * Configures an agent
  122290. */
  122291. export interface IAgentParameters {
  122292. /**
  122293. * Agent radius. [Limit: >= 0]
  122294. */
  122295. radius: number;
  122296. /**
  122297. * Agent height. [Limit: > 0]
  122298. */
  122299. height: number;
  122300. /**
  122301. * Maximum allowed acceleration. [Limit: >= 0]
  122302. */
  122303. maxAcceleration: number;
  122304. /**
  122305. * Maximum allowed speed. [Limit: >= 0]
  122306. */
  122307. maxSpeed: number;
  122308. /**
  122309. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122310. */
  122311. collisionQueryRange: number;
  122312. /**
  122313. * The path visibility optimization range. [Limit: > 0]
  122314. */
  122315. pathOptimizationRange: number;
  122316. /**
  122317. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122318. */
  122319. separationWeight: number;
  122320. }
  122321. /**
  122322. * Configures the navigation mesh creation
  122323. */
  122324. export interface INavMeshParameters {
  122325. /**
  122326. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122327. */
  122328. cs: number;
  122329. /**
  122330. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122331. */
  122332. ch: number;
  122333. /**
  122334. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122335. */
  122336. walkableSlopeAngle: number;
  122337. /**
  122338. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122339. * be considered walkable. [Limit: >= 3] [Units: vx]
  122340. */
  122341. walkableHeight: number;
  122342. /**
  122343. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122344. */
  122345. walkableClimb: number;
  122346. /**
  122347. * The distance to erode/shrink the walkable area of the heightfield away from
  122348. * obstructions. [Limit: >=0] [Units: vx]
  122349. */
  122350. walkableRadius: number;
  122351. /**
  122352. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122353. */
  122354. maxEdgeLen: number;
  122355. /**
  122356. * The maximum distance a simplfied contour's border edges should deviate
  122357. * the original raw contour. [Limit: >=0] [Units: vx]
  122358. */
  122359. maxSimplificationError: number;
  122360. /**
  122361. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122362. */
  122363. minRegionArea: number;
  122364. /**
  122365. * Any regions with a span count smaller than this value will, if possible,
  122366. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122367. */
  122368. mergeRegionArea: number;
  122369. /**
  122370. * The maximum number of vertices allowed for polygons generated during the
  122371. * contour to polygon conversion process. [Limit: >= 3]
  122372. */
  122373. maxVertsPerPoly: number;
  122374. /**
  122375. * Sets the sampling distance to use when generating the detail mesh.
  122376. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122377. */
  122378. detailSampleDist: number;
  122379. /**
  122380. * The maximum distance the detail mesh surface should deviate from heightfield
  122381. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122382. */
  122383. detailSampleMaxError: number;
  122384. }
  122385. }
  122386. declare module BABYLON {
  122387. /**
  122388. * RecastJS navigation plugin
  122389. */
  122390. export class RecastJSPlugin implements INavigationEnginePlugin {
  122391. /**
  122392. * Reference to the Recast library
  122393. */
  122394. bjsRECAST: any;
  122395. /**
  122396. * plugin name
  122397. */
  122398. name: string;
  122399. /**
  122400. * the first navmesh created. We might extend this to support multiple navmeshes
  122401. */
  122402. navMesh: any;
  122403. /**
  122404. * Initializes the recastJS plugin
  122405. * @param recastInjection can be used to inject your own recast reference
  122406. */
  122407. constructor(recastInjection?: any);
  122408. /**
  122409. * Creates a navigation mesh
  122410. * @param meshes array of all the geometry used to compute the navigatio mesh
  122411. * @param parameters bunch of parameters used to filter geometry
  122412. */
  122413. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122414. /**
  122415. * Create a navigation mesh debug mesh
  122416. * @param scene is where the mesh will be added
  122417. * @returns debug display mesh
  122418. */
  122419. createDebugNavMesh(scene: Scene): Mesh;
  122420. /**
  122421. * Get a navigation mesh constrained position, closest to the parameter position
  122422. * @param position world position
  122423. * @returns the closest point to position constrained by the navigation mesh
  122424. */
  122425. getClosestPoint(position: Vector3): Vector3;
  122426. /**
  122427. * Get a navigation mesh constrained position, within a particular radius
  122428. * @param position world position
  122429. * @param maxRadius the maximum distance to the constrained world position
  122430. * @returns the closest point to position constrained by the navigation mesh
  122431. */
  122432. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122433. /**
  122434. * Compute the final position from a segment made of destination-position
  122435. * @param position world position
  122436. * @param destination world position
  122437. * @returns the resulting point along the navmesh
  122438. */
  122439. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122440. /**
  122441. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122442. * @param start world position
  122443. * @param end world position
  122444. * @returns array containing world position composing the path
  122445. */
  122446. computePath(start: Vector3, end: Vector3): Vector3[];
  122447. /**
  122448. * Create a new Crowd so you can add agents
  122449. * @param maxAgents the maximum agent count in the crowd
  122450. * @param maxAgentRadius the maximum radius an agent can have
  122451. * @param scene to attach the crowd to
  122452. * @returns the crowd you can add agents to
  122453. */
  122454. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122455. /**
  122456. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122457. * The queries will try to find a solution within those bounds
  122458. * default is (1,1,1)
  122459. * @param extent x,y,z value that define the extent around the queries point of reference
  122460. */
  122461. setDefaultQueryExtent(extent: Vector3): void;
  122462. /**
  122463. * Get the Bounding box extent specified by setDefaultQueryExtent
  122464. * @returns the box extent values
  122465. */
  122466. getDefaultQueryExtent(): Vector3;
  122467. /**
  122468. * Disposes
  122469. */
  122470. dispose(): void;
  122471. /**
  122472. * If this plugin is supported
  122473. * @returns true if plugin is supported
  122474. */
  122475. isSupported(): boolean;
  122476. }
  122477. /**
  122478. * Recast detour crowd implementation
  122479. */
  122480. export class RecastJSCrowd implements ICrowd {
  122481. /**
  122482. * Recast/detour plugin
  122483. */
  122484. bjsRECASTPlugin: RecastJSPlugin;
  122485. /**
  122486. * Link to the detour crowd
  122487. */
  122488. recastCrowd: any;
  122489. /**
  122490. * One transform per agent
  122491. */
  122492. transforms: TransformNode[];
  122493. /**
  122494. * All agents created
  122495. */
  122496. agents: number[];
  122497. /**
  122498. * Link to the scene is kept to unregister the crowd from the scene
  122499. */
  122500. private _scene;
  122501. /**
  122502. * Observer for crowd updates
  122503. */
  122504. private _onBeforeAnimationsObserver;
  122505. /**
  122506. * Constructor
  122507. * @param plugin recastJS plugin
  122508. * @param maxAgents the maximum agent count in the crowd
  122509. * @param maxAgentRadius the maximum radius an agent can have
  122510. * @param scene to attach the crowd to
  122511. * @returns the crowd you can add agents to
  122512. */
  122513. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122514. /**
  122515. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122516. * You can attach anything to that node. The node position is updated in the scene update tick.
  122517. * @param pos world position that will be constrained by the navigation mesh
  122518. * @param parameters agent parameters
  122519. * @param transform hooked to the agent that will be update by the scene
  122520. * @returns agent index
  122521. */
  122522. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122523. /**
  122524. * Returns the agent position in world space
  122525. * @param index agent index returned by addAgent
  122526. * @returns world space position
  122527. */
  122528. getAgentPosition(index: number): Vector3;
  122529. /**
  122530. * Returns the agent velocity in world space
  122531. * @param index agent index returned by addAgent
  122532. * @returns world space velocity
  122533. */
  122534. getAgentVelocity(index: number): Vector3;
  122535. /**
  122536. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122537. * @param index agent index returned by addAgent
  122538. * @param destination targeted world position
  122539. */
  122540. agentGoto(index: number, destination: Vector3): void;
  122541. /**
  122542. * remove a particular agent previously created
  122543. * @param index agent index returned by addAgent
  122544. */
  122545. removeAgent(index: number): void;
  122546. /**
  122547. * get the list of all agents attached to this crowd
  122548. * @returns list of agent indices
  122549. */
  122550. getAgents(): number[];
  122551. /**
  122552. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122553. * @param deltaTime in seconds
  122554. */
  122555. update(deltaTime: number): void;
  122556. /**
  122557. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122558. * The queries will try to find a solution within those bounds
  122559. * default is (1,1,1)
  122560. * @param extent x,y,z value that define the extent around the queries point of reference
  122561. */
  122562. setDefaultQueryExtent(extent: Vector3): void;
  122563. /**
  122564. * Get the Bounding box extent specified by setDefaultQueryExtent
  122565. * @returns the box extent values
  122566. */
  122567. getDefaultQueryExtent(): Vector3;
  122568. /**
  122569. * Release all resources
  122570. */
  122571. dispose(): void;
  122572. }
  122573. }
  122574. declare module BABYLON {
  122575. /**
  122576. * Class used to enable access to IndexedDB
  122577. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122578. */
  122579. export class Database implements IOfflineProvider {
  122580. private _callbackManifestChecked;
  122581. private _currentSceneUrl;
  122582. private _db;
  122583. private _enableSceneOffline;
  122584. private _enableTexturesOffline;
  122585. private _manifestVersionFound;
  122586. private _mustUpdateRessources;
  122587. private _hasReachedQuota;
  122588. private _isSupported;
  122589. private _idbFactory;
  122590. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122591. private static IsUASupportingBlobStorage;
  122592. /**
  122593. * Gets a boolean indicating if Database storate is enabled (off by default)
  122594. */
  122595. static IDBStorageEnabled: boolean;
  122596. /**
  122597. * Gets a boolean indicating if scene must be saved in the database
  122598. */
  122599. readonly enableSceneOffline: boolean;
  122600. /**
  122601. * Gets a boolean indicating if textures must be saved in the database
  122602. */
  122603. readonly enableTexturesOffline: boolean;
  122604. /**
  122605. * Creates a new Database
  122606. * @param urlToScene defines the url to load the scene
  122607. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122608. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122609. */
  122610. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122611. private static _ParseURL;
  122612. private static _ReturnFullUrlLocation;
  122613. private _checkManifestFile;
  122614. /**
  122615. * Open the database and make it available
  122616. * @param successCallback defines the callback to call on success
  122617. * @param errorCallback defines the callback to call on error
  122618. */
  122619. open(successCallback: () => void, errorCallback: () => void): void;
  122620. /**
  122621. * Loads an image from the database
  122622. * @param url defines the url to load from
  122623. * @param image defines the target DOM image
  122624. */
  122625. loadImage(url: string, image: HTMLImageElement): void;
  122626. private _loadImageFromDBAsync;
  122627. private _saveImageIntoDBAsync;
  122628. private _checkVersionFromDB;
  122629. private _loadVersionFromDBAsync;
  122630. private _saveVersionIntoDBAsync;
  122631. /**
  122632. * Loads a file from database
  122633. * @param url defines the URL to load from
  122634. * @param sceneLoaded defines a callback to call on success
  122635. * @param progressCallBack defines a callback to call when progress changed
  122636. * @param errorCallback defines a callback to call on error
  122637. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122638. */
  122639. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122640. private _loadFileAsync;
  122641. private _saveFileAsync;
  122642. /**
  122643. * Validates if xhr data is correct
  122644. * @param xhr defines the request to validate
  122645. * @param dataType defines the expected data type
  122646. * @returns true if data is correct
  122647. */
  122648. private static _ValidateXHRData;
  122649. }
  122650. }
  122651. declare module BABYLON {
  122652. /** @hidden */
  122653. export var gpuUpdateParticlesPixelShader: {
  122654. name: string;
  122655. shader: string;
  122656. };
  122657. }
  122658. declare module BABYLON {
  122659. /** @hidden */
  122660. export var gpuUpdateParticlesVertexShader: {
  122661. name: string;
  122662. shader: string;
  122663. };
  122664. }
  122665. declare module BABYLON {
  122666. /** @hidden */
  122667. export var clipPlaneFragmentDeclaration2: {
  122668. name: string;
  122669. shader: string;
  122670. };
  122671. }
  122672. declare module BABYLON {
  122673. /** @hidden */
  122674. export var gpuRenderParticlesPixelShader: {
  122675. name: string;
  122676. shader: string;
  122677. };
  122678. }
  122679. declare module BABYLON {
  122680. /** @hidden */
  122681. export var clipPlaneVertexDeclaration2: {
  122682. name: string;
  122683. shader: string;
  122684. };
  122685. }
  122686. declare module BABYLON {
  122687. /** @hidden */
  122688. export var gpuRenderParticlesVertexShader: {
  122689. name: string;
  122690. shader: string;
  122691. };
  122692. }
  122693. declare module BABYLON {
  122694. /**
  122695. * This represents a GPU particle system in Babylon
  122696. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122697. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122698. */
  122699. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122700. /**
  122701. * The layer mask we are rendering the particles through.
  122702. */
  122703. layerMask: number;
  122704. private _capacity;
  122705. private _activeCount;
  122706. private _currentActiveCount;
  122707. private _accumulatedCount;
  122708. private _renderEffect;
  122709. private _updateEffect;
  122710. private _buffer0;
  122711. private _buffer1;
  122712. private _spriteBuffer;
  122713. private _updateVAO;
  122714. private _renderVAO;
  122715. private _targetIndex;
  122716. private _sourceBuffer;
  122717. private _targetBuffer;
  122718. private _engine;
  122719. private _currentRenderId;
  122720. private _started;
  122721. private _stopped;
  122722. private _timeDelta;
  122723. private _randomTexture;
  122724. private _randomTexture2;
  122725. private _attributesStrideSize;
  122726. private _updateEffectOptions;
  122727. private _randomTextureSize;
  122728. private _actualFrame;
  122729. private readonly _rawTextureWidth;
  122730. /**
  122731. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122732. */
  122733. static readonly IsSupported: boolean;
  122734. /**
  122735. * An event triggered when the system is disposed.
  122736. */
  122737. onDisposeObservable: Observable<GPUParticleSystem>;
  122738. /**
  122739. * Gets the maximum number of particles active at the same time.
  122740. * @returns The max number of active particles.
  122741. */
  122742. getCapacity(): number;
  122743. /**
  122744. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122745. * to override the particles.
  122746. */
  122747. forceDepthWrite: boolean;
  122748. /**
  122749. * Gets or set the number of active particles
  122750. */
  122751. activeParticleCount: number;
  122752. private _preWarmDone;
  122753. /**
  122754. * Is this system ready to be used/rendered
  122755. * @return true if the system is ready
  122756. */
  122757. isReady(): boolean;
  122758. /**
  122759. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122760. * @returns True if it has been started, otherwise false.
  122761. */
  122762. isStarted(): boolean;
  122763. /**
  122764. * Starts the particle system and begins to emit
  122765. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122766. */
  122767. start(delay?: number): void;
  122768. /**
  122769. * Stops the particle system.
  122770. */
  122771. stop(): void;
  122772. /**
  122773. * Remove all active particles
  122774. */
  122775. reset(): void;
  122776. /**
  122777. * Returns the string "GPUParticleSystem"
  122778. * @returns a string containing the class name
  122779. */
  122780. getClassName(): string;
  122781. private _colorGradientsTexture;
  122782. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122783. /**
  122784. * Adds a new color gradient
  122785. * @param gradient defines the gradient to use (between 0 and 1)
  122786. * @param color1 defines the color to affect to the specified gradient
  122787. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122788. * @returns the current particle system
  122789. */
  122790. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122791. /**
  122792. * Remove a specific color gradient
  122793. * @param gradient defines the gradient to remove
  122794. * @returns the current particle system
  122795. */
  122796. removeColorGradient(gradient: number): GPUParticleSystem;
  122797. private _angularSpeedGradientsTexture;
  122798. private _sizeGradientsTexture;
  122799. private _velocityGradientsTexture;
  122800. private _limitVelocityGradientsTexture;
  122801. private _dragGradientsTexture;
  122802. private _addFactorGradient;
  122803. /**
  122804. * Adds a new size gradient
  122805. * @param gradient defines the gradient to use (between 0 and 1)
  122806. * @param factor defines the size factor to affect to the specified gradient
  122807. * @returns the current particle system
  122808. */
  122809. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122810. /**
  122811. * Remove a specific size gradient
  122812. * @param gradient defines the gradient to remove
  122813. * @returns the current particle system
  122814. */
  122815. removeSizeGradient(gradient: number): GPUParticleSystem;
  122816. /**
  122817. * Adds a new angular speed gradient
  122818. * @param gradient defines the gradient to use (between 0 and 1)
  122819. * @param factor defines the angular speed to affect to the specified gradient
  122820. * @returns the current particle system
  122821. */
  122822. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122823. /**
  122824. * Remove a specific angular speed gradient
  122825. * @param gradient defines the gradient to remove
  122826. * @returns the current particle system
  122827. */
  122828. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122829. /**
  122830. * Adds a new velocity gradient
  122831. * @param gradient defines the gradient to use (between 0 and 1)
  122832. * @param factor defines the velocity to affect to the specified gradient
  122833. * @returns the current particle system
  122834. */
  122835. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122836. /**
  122837. * Remove a specific velocity gradient
  122838. * @param gradient defines the gradient to remove
  122839. * @returns the current particle system
  122840. */
  122841. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122842. /**
  122843. * Adds a new limit velocity gradient
  122844. * @param gradient defines the gradient to use (between 0 and 1)
  122845. * @param factor defines the limit velocity value to affect to the specified gradient
  122846. * @returns the current particle system
  122847. */
  122848. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122849. /**
  122850. * Remove a specific limit velocity gradient
  122851. * @param gradient defines the gradient to remove
  122852. * @returns the current particle system
  122853. */
  122854. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122855. /**
  122856. * Adds a new drag gradient
  122857. * @param gradient defines the gradient to use (between 0 and 1)
  122858. * @param factor defines the drag value to affect to the specified gradient
  122859. * @returns the current particle system
  122860. */
  122861. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122862. /**
  122863. * Remove a specific drag gradient
  122864. * @param gradient defines the gradient to remove
  122865. * @returns the current particle system
  122866. */
  122867. removeDragGradient(gradient: number): GPUParticleSystem;
  122868. /**
  122869. * Not supported by GPUParticleSystem
  122870. * @param gradient defines the gradient to use (between 0 and 1)
  122871. * @param factor defines the emit rate value to affect to the specified gradient
  122872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122873. * @returns the current particle system
  122874. */
  122875. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122876. /**
  122877. * Not supported by GPUParticleSystem
  122878. * @param gradient defines the gradient to remove
  122879. * @returns the current particle system
  122880. */
  122881. removeEmitRateGradient(gradient: number): IParticleSystem;
  122882. /**
  122883. * Not supported by GPUParticleSystem
  122884. * @param gradient defines the gradient to use (between 0 and 1)
  122885. * @param factor defines the start size value to affect to the specified gradient
  122886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122887. * @returns the current particle system
  122888. */
  122889. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122890. /**
  122891. * Not supported by GPUParticleSystem
  122892. * @param gradient defines the gradient to remove
  122893. * @returns the current particle system
  122894. */
  122895. removeStartSizeGradient(gradient: number): IParticleSystem;
  122896. /**
  122897. * Not supported by GPUParticleSystem
  122898. * @param gradient defines the gradient to use (between 0 and 1)
  122899. * @param min defines the color remap minimal range
  122900. * @param max defines the color remap maximal range
  122901. * @returns the current particle system
  122902. */
  122903. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122904. /**
  122905. * Not supported by GPUParticleSystem
  122906. * @param gradient defines the gradient to remove
  122907. * @returns the current particle system
  122908. */
  122909. removeColorRemapGradient(): IParticleSystem;
  122910. /**
  122911. * Not supported by GPUParticleSystem
  122912. * @param gradient defines the gradient to use (between 0 and 1)
  122913. * @param min defines the alpha remap minimal range
  122914. * @param max defines the alpha remap maximal range
  122915. * @returns the current particle system
  122916. */
  122917. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122918. /**
  122919. * Not supported by GPUParticleSystem
  122920. * @param gradient defines the gradient to remove
  122921. * @returns the current particle system
  122922. */
  122923. removeAlphaRemapGradient(): IParticleSystem;
  122924. /**
  122925. * Not supported by GPUParticleSystem
  122926. * @param gradient defines the gradient to use (between 0 and 1)
  122927. * @param color defines the color to affect to the specified gradient
  122928. * @returns the current particle system
  122929. */
  122930. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122931. /**
  122932. * Not supported by GPUParticleSystem
  122933. * @param gradient defines the gradient to remove
  122934. * @returns the current particle system
  122935. */
  122936. removeRampGradient(): IParticleSystem;
  122937. /**
  122938. * Not supported by GPUParticleSystem
  122939. * @returns the list of ramp gradients
  122940. */
  122941. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122942. /**
  122943. * Not supported by GPUParticleSystem
  122944. * Gets or sets a boolean indicating that ramp gradients must be used
  122945. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122946. */
  122947. useRampGradients: boolean;
  122948. /**
  122949. * Not supported by GPUParticleSystem
  122950. * @param gradient defines the gradient to use (between 0 and 1)
  122951. * @param factor defines the life time factor to affect to the specified gradient
  122952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122953. * @returns the current particle system
  122954. */
  122955. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122956. /**
  122957. * Not supported by GPUParticleSystem
  122958. * @param gradient defines the gradient to remove
  122959. * @returns the current particle system
  122960. */
  122961. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122962. /**
  122963. * Instantiates a GPU particle system.
  122964. * 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.
  122965. * @param name The name of the particle system
  122966. * @param options The options used to create the system
  122967. * @param scene The scene the particle system belongs to
  122968. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122969. */
  122970. constructor(name: string, options: Partial<{
  122971. capacity: number;
  122972. randomTextureSize: number;
  122973. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122974. protected _reset(): void;
  122975. private _createUpdateVAO;
  122976. private _createRenderVAO;
  122977. private _initialize;
  122978. /** @hidden */
  122979. _recreateUpdateEffect(): void;
  122980. /** @hidden */
  122981. _recreateRenderEffect(): void;
  122982. /**
  122983. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122984. * @param preWarm defines if we are in the pre-warmimg phase
  122985. */
  122986. animate(preWarm?: boolean): void;
  122987. private _createFactorGradientTexture;
  122988. private _createSizeGradientTexture;
  122989. private _createAngularSpeedGradientTexture;
  122990. private _createVelocityGradientTexture;
  122991. private _createLimitVelocityGradientTexture;
  122992. private _createDragGradientTexture;
  122993. private _createColorGradientTexture;
  122994. /**
  122995. * Renders the particle system in its current state
  122996. * @param preWarm defines if the system should only update the particles but not render them
  122997. * @returns the current number of particles
  122998. */
  122999. render(preWarm?: boolean): number;
  123000. /**
  123001. * Rebuilds the particle system
  123002. */
  123003. rebuild(): void;
  123004. private _releaseBuffers;
  123005. private _releaseVAOs;
  123006. /**
  123007. * Disposes the particle system and free the associated resources
  123008. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123009. */
  123010. dispose(disposeTexture?: boolean): void;
  123011. /**
  123012. * Clones the particle system.
  123013. * @param name The name of the cloned object
  123014. * @param newEmitter The new emitter to use
  123015. * @returns the cloned particle system
  123016. */
  123017. clone(name: string, newEmitter: any): GPUParticleSystem;
  123018. /**
  123019. * Serializes the particle system to a JSON object.
  123020. * @returns the JSON object
  123021. */
  123022. serialize(): any;
  123023. /**
  123024. * Parses a JSON object to create a GPU particle system.
  123025. * @param parsedParticleSystem The JSON object to parse
  123026. * @param scene The scene to create the particle system in
  123027. * @param rootUrl The root url to use to load external dependencies like texture
  123028. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123029. * @returns the parsed GPU particle system
  123030. */
  123031. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123032. }
  123033. }
  123034. declare module BABYLON {
  123035. /**
  123036. * Represents a set of particle systems working together to create a specific effect
  123037. */
  123038. export class ParticleSystemSet implements IDisposable {
  123039. private _emitterCreationOptions;
  123040. private _emitterNode;
  123041. /**
  123042. * Gets the particle system list
  123043. */
  123044. systems: IParticleSystem[];
  123045. /**
  123046. * Gets the emitter node used with this set
  123047. */
  123048. readonly emitterNode: Nullable<TransformNode>;
  123049. /**
  123050. * Creates a new emitter mesh as a sphere
  123051. * @param options defines the options used to create the sphere
  123052. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123053. * @param scene defines the hosting scene
  123054. */
  123055. setEmitterAsSphere(options: {
  123056. diameter: number;
  123057. segments: number;
  123058. color: Color3;
  123059. }, renderingGroupId: number, scene: Scene): void;
  123060. /**
  123061. * Starts all particle systems of the set
  123062. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123063. */
  123064. start(emitter?: AbstractMesh): void;
  123065. /**
  123066. * Release all associated resources
  123067. */
  123068. dispose(): void;
  123069. /**
  123070. * Serialize the set into a JSON compatible object
  123071. * @returns a JSON compatible representation of the set
  123072. */
  123073. serialize(): any;
  123074. /**
  123075. * Parse a new ParticleSystemSet from a serialized source
  123076. * @param data defines a JSON compatible representation of the set
  123077. * @param scene defines the hosting scene
  123078. * @param gpu defines if we want GPU particles or CPU particles
  123079. * @returns a new ParticleSystemSet
  123080. */
  123081. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123082. }
  123083. }
  123084. declare module BABYLON {
  123085. /**
  123086. * This class is made for on one-liner static method to help creating particle system set.
  123087. */
  123088. export class ParticleHelper {
  123089. /**
  123090. * Gets or sets base Assets URL
  123091. */
  123092. static BaseAssetsUrl: string;
  123093. /**
  123094. * Create a default particle system that you can tweak
  123095. * @param emitter defines the emitter to use
  123096. * @param capacity defines the system capacity (default is 500 particles)
  123097. * @param scene defines the hosting scene
  123098. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123099. * @returns the new Particle system
  123100. */
  123101. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123102. /**
  123103. * This is the main static method (one-liner) of this helper to create different particle systems
  123104. * @param type This string represents the type to the particle system to create
  123105. * @param scene The scene where the particle system should live
  123106. * @param gpu If the system will use gpu
  123107. * @returns the ParticleSystemSet created
  123108. */
  123109. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123110. /**
  123111. * Static function used to export a particle system to a ParticleSystemSet variable.
  123112. * Please note that the emitter shape is not exported
  123113. * @param systems defines the particle systems to export
  123114. * @returns the created particle system set
  123115. */
  123116. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123117. }
  123118. }
  123119. declare module BABYLON {
  123120. interface Engine {
  123121. /**
  123122. * Create an effect to use with particle systems.
  123123. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123124. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123125. * @param uniformsNames defines a list of attribute names
  123126. * @param samplers defines an array of string used to represent textures
  123127. * @param defines defines the string containing the defines to use to compile the shaders
  123128. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123129. * @param onCompiled defines a function to call when the effect creation is successful
  123130. * @param onError defines a function to call when the effect creation has failed
  123131. * @returns the new Effect
  123132. */
  123133. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123134. }
  123135. interface Mesh {
  123136. /**
  123137. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123138. * @returns an array of IParticleSystem
  123139. */
  123140. getEmittedParticleSystems(): IParticleSystem[];
  123141. /**
  123142. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123143. * @returns an array of IParticleSystem
  123144. */
  123145. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123146. }
  123147. /**
  123148. * @hidden
  123149. */
  123150. export var _IDoNeedToBeInTheBuild: number;
  123151. }
  123152. declare module BABYLON {
  123153. interface Scene {
  123154. /** @hidden (Backing field) */
  123155. _physicsEngine: Nullable<IPhysicsEngine>;
  123156. /**
  123157. * Gets the current physics engine
  123158. * @returns a IPhysicsEngine or null if none attached
  123159. */
  123160. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123161. /**
  123162. * Enables physics to the current scene
  123163. * @param gravity defines the scene's gravity for the physics engine
  123164. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123165. * @return a boolean indicating if the physics engine was initialized
  123166. */
  123167. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123168. /**
  123169. * Disables and disposes the physics engine associated with the scene
  123170. */
  123171. disablePhysicsEngine(): void;
  123172. /**
  123173. * Gets a boolean indicating if there is an active physics engine
  123174. * @returns a boolean indicating if there is an active physics engine
  123175. */
  123176. isPhysicsEnabled(): boolean;
  123177. /**
  123178. * Deletes a physics compound impostor
  123179. * @param compound defines the compound to delete
  123180. */
  123181. deleteCompoundImpostor(compound: any): void;
  123182. /**
  123183. * An event triggered when physic simulation is about to be run
  123184. */
  123185. onBeforePhysicsObservable: Observable<Scene>;
  123186. /**
  123187. * An event triggered when physic simulation has been done
  123188. */
  123189. onAfterPhysicsObservable: Observable<Scene>;
  123190. }
  123191. interface AbstractMesh {
  123192. /** @hidden */
  123193. _physicsImpostor: Nullable<PhysicsImpostor>;
  123194. /**
  123195. * Gets or sets impostor used for physic simulation
  123196. * @see http://doc.babylonjs.com/features/physics_engine
  123197. */
  123198. physicsImpostor: Nullable<PhysicsImpostor>;
  123199. /**
  123200. * Gets the current physics impostor
  123201. * @see http://doc.babylonjs.com/features/physics_engine
  123202. * @returns a physics impostor or null
  123203. */
  123204. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123205. /** Apply a physic impulse to the mesh
  123206. * @param force defines the force to apply
  123207. * @param contactPoint defines where to apply the force
  123208. * @returns the current mesh
  123209. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123210. */
  123211. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123212. /**
  123213. * Creates a physic joint between two meshes
  123214. * @param otherMesh defines the other mesh to use
  123215. * @param pivot1 defines the pivot to use on this mesh
  123216. * @param pivot2 defines the pivot to use on the other mesh
  123217. * @param options defines additional options (can be plugin dependent)
  123218. * @returns the current mesh
  123219. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123220. */
  123221. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123222. /** @hidden */
  123223. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123224. }
  123225. /**
  123226. * Defines the physics engine scene component responsible to manage a physics engine
  123227. */
  123228. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123229. /**
  123230. * The component name helpful to identify the component in the list of scene components.
  123231. */
  123232. readonly name: string;
  123233. /**
  123234. * The scene the component belongs to.
  123235. */
  123236. scene: Scene;
  123237. /**
  123238. * Creates a new instance of the component for the given scene
  123239. * @param scene Defines the scene to register the component in
  123240. */
  123241. constructor(scene: Scene);
  123242. /**
  123243. * Registers the component in a given scene
  123244. */
  123245. register(): void;
  123246. /**
  123247. * Rebuilds the elements related to this component in case of
  123248. * context lost for instance.
  123249. */
  123250. rebuild(): void;
  123251. /**
  123252. * Disposes the component and the associated ressources
  123253. */
  123254. dispose(): void;
  123255. }
  123256. }
  123257. declare module BABYLON {
  123258. /**
  123259. * A helper for physics simulations
  123260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123261. */
  123262. export class PhysicsHelper {
  123263. private _scene;
  123264. private _physicsEngine;
  123265. /**
  123266. * Initializes the Physics helper
  123267. * @param scene Babylon.js scene
  123268. */
  123269. constructor(scene: Scene);
  123270. /**
  123271. * Applies a radial explosion impulse
  123272. * @param origin the origin of the explosion
  123273. * @param radiusOrEventOptions the radius or the options of radial explosion
  123274. * @param strength the explosion strength
  123275. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123276. * @returns A physics radial explosion event, or null
  123277. */
  123278. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123279. /**
  123280. * Applies a radial explosion force
  123281. * @param origin the origin of the explosion
  123282. * @param radiusOrEventOptions the radius or the options of radial explosion
  123283. * @param strength the explosion strength
  123284. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123285. * @returns A physics radial explosion event, or null
  123286. */
  123287. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123288. /**
  123289. * Creates a gravitational field
  123290. * @param origin the origin of the explosion
  123291. * @param radiusOrEventOptions the radius or the options of radial explosion
  123292. * @param strength the explosion strength
  123293. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123294. * @returns A physics gravitational field event, or null
  123295. */
  123296. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123297. /**
  123298. * Creates a physics updraft event
  123299. * @param origin the origin of the updraft
  123300. * @param radiusOrEventOptions the radius or the options of the updraft
  123301. * @param strength the strength of the updraft
  123302. * @param height the height of the updraft
  123303. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123304. * @returns A physics updraft event, or null
  123305. */
  123306. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123307. /**
  123308. * Creates a physics vortex event
  123309. * @param origin the of the vortex
  123310. * @param radiusOrEventOptions the radius or the options of the vortex
  123311. * @param strength the strength of the vortex
  123312. * @param height the height of the vortex
  123313. * @returns a Physics vortex event, or null
  123314. * A physics vortex event or null
  123315. */
  123316. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123317. }
  123318. /**
  123319. * Represents a physics radial explosion event
  123320. */
  123321. class PhysicsRadialExplosionEvent {
  123322. private _scene;
  123323. private _options;
  123324. private _sphere;
  123325. private _dataFetched;
  123326. /**
  123327. * Initializes a radial explosioin event
  123328. * @param _scene BabylonJS scene
  123329. * @param _options The options for the vortex event
  123330. */
  123331. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123332. /**
  123333. * Returns the data related to the radial explosion event (sphere).
  123334. * @returns The radial explosion event data
  123335. */
  123336. getData(): PhysicsRadialExplosionEventData;
  123337. /**
  123338. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123339. * @param impostor A physics imposter
  123340. * @param origin the origin of the explosion
  123341. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123342. */
  123343. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123344. /**
  123345. * Triggers affecterd impostors callbacks
  123346. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123347. */
  123348. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123349. /**
  123350. * Disposes the sphere.
  123351. * @param force Specifies if the sphere should be disposed by force
  123352. */
  123353. dispose(force?: boolean): void;
  123354. /*** Helpers ***/
  123355. private _prepareSphere;
  123356. private _intersectsWithSphere;
  123357. }
  123358. /**
  123359. * Represents a gravitational field event
  123360. */
  123361. class PhysicsGravitationalFieldEvent {
  123362. private _physicsHelper;
  123363. private _scene;
  123364. private _origin;
  123365. private _options;
  123366. private _tickCallback;
  123367. private _sphere;
  123368. private _dataFetched;
  123369. /**
  123370. * Initializes the physics gravitational field event
  123371. * @param _physicsHelper A physics helper
  123372. * @param _scene BabylonJS scene
  123373. * @param _origin The origin position of the gravitational field event
  123374. * @param _options The options for the vortex event
  123375. */
  123376. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123377. /**
  123378. * Returns the data related to the gravitational field event (sphere).
  123379. * @returns A gravitational field event
  123380. */
  123381. getData(): PhysicsGravitationalFieldEventData;
  123382. /**
  123383. * Enables the gravitational field.
  123384. */
  123385. enable(): void;
  123386. /**
  123387. * Disables the gravitational field.
  123388. */
  123389. disable(): void;
  123390. /**
  123391. * Disposes the sphere.
  123392. * @param force The force to dispose from the gravitational field event
  123393. */
  123394. dispose(force?: boolean): void;
  123395. private _tick;
  123396. }
  123397. /**
  123398. * Represents a physics updraft event
  123399. */
  123400. class PhysicsUpdraftEvent {
  123401. private _scene;
  123402. private _origin;
  123403. private _options;
  123404. private _physicsEngine;
  123405. private _originTop;
  123406. private _originDirection;
  123407. private _tickCallback;
  123408. private _cylinder;
  123409. private _cylinderPosition;
  123410. private _dataFetched;
  123411. /**
  123412. * Initializes the physics updraft event
  123413. * @param _scene BabylonJS scene
  123414. * @param _origin The origin position of the updraft
  123415. * @param _options The options for the updraft event
  123416. */
  123417. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123418. /**
  123419. * Returns the data related to the updraft event (cylinder).
  123420. * @returns A physics updraft event
  123421. */
  123422. getData(): PhysicsUpdraftEventData;
  123423. /**
  123424. * Enables the updraft.
  123425. */
  123426. enable(): void;
  123427. /**
  123428. * Disables the updraft.
  123429. */
  123430. disable(): void;
  123431. /**
  123432. * Disposes the cylinder.
  123433. * @param force Specifies if the updraft should be disposed by force
  123434. */
  123435. dispose(force?: boolean): void;
  123436. private getImpostorHitData;
  123437. private _tick;
  123438. /*** Helpers ***/
  123439. private _prepareCylinder;
  123440. private _intersectsWithCylinder;
  123441. }
  123442. /**
  123443. * Represents a physics vortex event
  123444. */
  123445. class PhysicsVortexEvent {
  123446. private _scene;
  123447. private _origin;
  123448. private _options;
  123449. private _physicsEngine;
  123450. private _originTop;
  123451. private _tickCallback;
  123452. private _cylinder;
  123453. private _cylinderPosition;
  123454. private _dataFetched;
  123455. /**
  123456. * Initializes the physics vortex event
  123457. * @param _scene The BabylonJS scene
  123458. * @param _origin The origin position of the vortex
  123459. * @param _options The options for the vortex event
  123460. */
  123461. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123462. /**
  123463. * Returns the data related to the vortex event (cylinder).
  123464. * @returns The physics vortex event data
  123465. */
  123466. getData(): PhysicsVortexEventData;
  123467. /**
  123468. * Enables the vortex.
  123469. */
  123470. enable(): void;
  123471. /**
  123472. * Disables the cortex.
  123473. */
  123474. disable(): void;
  123475. /**
  123476. * Disposes the sphere.
  123477. * @param force
  123478. */
  123479. dispose(force?: boolean): void;
  123480. private getImpostorHitData;
  123481. private _tick;
  123482. /*** Helpers ***/
  123483. private _prepareCylinder;
  123484. private _intersectsWithCylinder;
  123485. }
  123486. /**
  123487. * Options fot the radial explosion event
  123488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123489. */
  123490. export class PhysicsRadialExplosionEventOptions {
  123491. /**
  123492. * The radius of the sphere for the radial explosion.
  123493. */
  123494. radius: number;
  123495. /**
  123496. * The strenth of the explosion.
  123497. */
  123498. strength: number;
  123499. /**
  123500. * The strenght of the force in correspondence to the distance of the affected object
  123501. */
  123502. falloff: PhysicsRadialImpulseFalloff;
  123503. /**
  123504. * Sphere options for the radial explosion.
  123505. */
  123506. sphere: {
  123507. segments: number;
  123508. diameter: number;
  123509. };
  123510. /**
  123511. * Sphere options for the radial explosion.
  123512. */
  123513. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123514. }
  123515. /**
  123516. * Options fot the updraft event
  123517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123518. */
  123519. export class PhysicsUpdraftEventOptions {
  123520. /**
  123521. * The radius of the cylinder for the vortex
  123522. */
  123523. radius: number;
  123524. /**
  123525. * The strenth of the updraft.
  123526. */
  123527. strength: number;
  123528. /**
  123529. * The height of the cylinder for the updraft.
  123530. */
  123531. height: number;
  123532. /**
  123533. * The mode for the the updraft.
  123534. */
  123535. updraftMode: PhysicsUpdraftMode;
  123536. }
  123537. /**
  123538. * Options fot the vortex event
  123539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123540. */
  123541. export class PhysicsVortexEventOptions {
  123542. /**
  123543. * The radius of the cylinder for the vortex
  123544. */
  123545. radius: number;
  123546. /**
  123547. * The strenth of the vortex.
  123548. */
  123549. strength: number;
  123550. /**
  123551. * The height of the cylinder for the vortex.
  123552. */
  123553. height: number;
  123554. /**
  123555. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123556. */
  123557. centripetalForceThreshold: number;
  123558. /**
  123559. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123560. */
  123561. centripetalForceMultiplier: number;
  123562. /**
  123563. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123564. */
  123565. centrifugalForceMultiplier: number;
  123566. /**
  123567. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123568. */
  123569. updraftForceMultiplier: number;
  123570. }
  123571. /**
  123572. * The strenght of the force in correspondence to the distance of the affected object
  123573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123574. */
  123575. export enum PhysicsRadialImpulseFalloff {
  123576. /** Defines that impulse is constant in strength across it's whole radius */
  123577. Constant = 0,
  123578. /** Defines that impulse gets weaker if it's further from the origin */
  123579. Linear = 1
  123580. }
  123581. /**
  123582. * The strength of the force in correspondence to the distance of the affected object
  123583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123584. */
  123585. export enum PhysicsUpdraftMode {
  123586. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123587. Center = 0,
  123588. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123589. Perpendicular = 1
  123590. }
  123591. /**
  123592. * Interface for a physics hit data
  123593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123594. */
  123595. export interface PhysicsHitData {
  123596. /**
  123597. * The force applied at the contact point
  123598. */
  123599. force: Vector3;
  123600. /**
  123601. * The contact point
  123602. */
  123603. contactPoint: Vector3;
  123604. /**
  123605. * The distance from the origin to the contact point
  123606. */
  123607. distanceFromOrigin: number;
  123608. }
  123609. /**
  123610. * Interface for radial explosion event data
  123611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123612. */
  123613. export interface PhysicsRadialExplosionEventData {
  123614. /**
  123615. * A sphere used for the radial explosion event
  123616. */
  123617. sphere: Mesh;
  123618. }
  123619. /**
  123620. * Interface for gravitational field event data
  123621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123622. */
  123623. export interface PhysicsGravitationalFieldEventData {
  123624. /**
  123625. * A sphere mesh used for the gravitational field event
  123626. */
  123627. sphere: Mesh;
  123628. }
  123629. /**
  123630. * Interface for updraft event data
  123631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123632. */
  123633. export interface PhysicsUpdraftEventData {
  123634. /**
  123635. * A cylinder used for the updraft event
  123636. */
  123637. cylinder: Mesh;
  123638. }
  123639. /**
  123640. * Interface for vortex event data
  123641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123642. */
  123643. export interface PhysicsVortexEventData {
  123644. /**
  123645. * A cylinder used for the vortex event
  123646. */
  123647. cylinder: Mesh;
  123648. }
  123649. /**
  123650. * Interface for an affected physics impostor
  123651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123652. */
  123653. export interface PhysicsAffectedImpostorWithData {
  123654. /**
  123655. * The impostor affected by the effect
  123656. */
  123657. impostor: PhysicsImpostor;
  123658. /**
  123659. * The data about the hit/horce from the explosion
  123660. */
  123661. hitData: PhysicsHitData;
  123662. }
  123663. }
  123664. declare module BABYLON {
  123665. /** @hidden */
  123666. export var blackAndWhitePixelShader: {
  123667. name: string;
  123668. shader: string;
  123669. };
  123670. }
  123671. declare module BABYLON {
  123672. /**
  123673. * Post process used to render in black and white
  123674. */
  123675. export class BlackAndWhitePostProcess extends PostProcess {
  123676. /**
  123677. * Linear about to convert he result to black and white (default: 1)
  123678. */
  123679. degree: number;
  123680. /**
  123681. * Creates a black and white post process
  123682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123683. * @param name The name of the effect.
  123684. * @param options The required width/height ratio to downsize to before computing the render pass.
  123685. * @param camera The camera to apply the render pass to.
  123686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123687. * @param engine The engine which the post process will be applied. (default: current engine)
  123688. * @param reusable If the post process can be reused on the same frame. (default: false)
  123689. */
  123690. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123691. }
  123692. }
  123693. declare module BABYLON {
  123694. /**
  123695. * This represents a set of one or more post processes in Babylon.
  123696. * A post process can be used to apply a shader to a texture after it is rendered.
  123697. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123698. */
  123699. export class PostProcessRenderEffect {
  123700. private _postProcesses;
  123701. private _getPostProcesses;
  123702. private _singleInstance;
  123703. private _cameras;
  123704. private _indicesForCamera;
  123705. /**
  123706. * Name of the effect
  123707. * @hidden
  123708. */
  123709. _name: string;
  123710. /**
  123711. * Instantiates a post process render effect.
  123712. * A post process can be used to apply a shader to a texture after it is rendered.
  123713. * @param engine The engine the effect is tied to
  123714. * @param name The name of the effect
  123715. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123716. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123717. */
  123718. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123719. /**
  123720. * Checks if all the post processes in the effect are supported.
  123721. */
  123722. readonly isSupported: boolean;
  123723. /**
  123724. * Updates the current state of the effect
  123725. * @hidden
  123726. */
  123727. _update(): void;
  123728. /**
  123729. * Attaches the effect on cameras
  123730. * @param cameras The camera to attach to.
  123731. * @hidden
  123732. */
  123733. _attachCameras(cameras: Camera): void;
  123734. /**
  123735. * Attaches the effect on cameras
  123736. * @param cameras The camera to attach to.
  123737. * @hidden
  123738. */
  123739. _attachCameras(cameras: Camera[]): void;
  123740. /**
  123741. * Detaches the effect on cameras
  123742. * @param cameras The camera to detatch from.
  123743. * @hidden
  123744. */
  123745. _detachCameras(cameras: Camera): void;
  123746. /**
  123747. * Detatches the effect on cameras
  123748. * @param cameras The camera to detatch from.
  123749. * @hidden
  123750. */
  123751. _detachCameras(cameras: Camera[]): void;
  123752. /**
  123753. * Enables the effect on given cameras
  123754. * @param cameras The camera to enable.
  123755. * @hidden
  123756. */
  123757. _enable(cameras: Camera): void;
  123758. /**
  123759. * Enables the effect on given cameras
  123760. * @param cameras The camera to enable.
  123761. * @hidden
  123762. */
  123763. _enable(cameras: Nullable<Camera[]>): void;
  123764. /**
  123765. * Disables the effect on the given cameras
  123766. * @param cameras The camera to disable.
  123767. * @hidden
  123768. */
  123769. _disable(cameras: Camera): void;
  123770. /**
  123771. * Disables the effect on the given cameras
  123772. * @param cameras The camera to disable.
  123773. * @hidden
  123774. */
  123775. _disable(cameras: Nullable<Camera[]>): void;
  123776. /**
  123777. * Gets a list of the post processes contained in the effect.
  123778. * @param camera The camera to get the post processes on.
  123779. * @returns The list of the post processes in the effect.
  123780. */
  123781. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123782. }
  123783. }
  123784. declare module BABYLON {
  123785. /** @hidden */
  123786. export var extractHighlightsPixelShader: {
  123787. name: string;
  123788. shader: string;
  123789. };
  123790. }
  123791. declare module BABYLON {
  123792. /**
  123793. * 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.
  123794. */
  123795. export class ExtractHighlightsPostProcess extends PostProcess {
  123796. /**
  123797. * The luminance threshold, pixels below this value will be set to black.
  123798. */
  123799. threshold: number;
  123800. /** @hidden */
  123801. _exposure: number;
  123802. /**
  123803. * Post process which has the input texture to be used when performing highlight extraction
  123804. * @hidden
  123805. */
  123806. _inputPostProcess: Nullable<PostProcess>;
  123807. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123808. }
  123809. }
  123810. declare module BABYLON {
  123811. /** @hidden */
  123812. export var bloomMergePixelShader: {
  123813. name: string;
  123814. shader: string;
  123815. };
  123816. }
  123817. declare module BABYLON {
  123818. /**
  123819. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123820. */
  123821. export class BloomMergePostProcess extends PostProcess {
  123822. /** Weight of the bloom to be added to the original input. */
  123823. weight: number;
  123824. /**
  123825. * Creates a new instance of @see BloomMergePostProcess
  123826. * @param name The name of the effect.
  123827. * @param originalFromInput Post process which's input will be used for the merge.
  123828. * @param blurred Blurred highlights post process which's output will be used.
  123829. * @param weight Weight of the bloom to be added to the original input.
  123830. * @param options The required width/height ratio to downsize to before computing the render pass.
  123831. * @param camera The camera to apply the render pass to.
  123832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123833. * @param engine The engine which the post process will be applied. (default: current engine)
  123834. * @param reusable If the post process can be reused on the same frame. (default: false)
  123835. * @param textureType Type of textures used when performing the post process. (default: 0)
  123836. * @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)
  123837. */
  123838. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123839. /** Weight of the bloom to be added to the original input. */
  123840. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123841. }
  123842. }
  123843. declare module BABYLON {
  123844. /**
  123845. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123846. */
  123847. export class BloomEffect extends PostProcessRenderEffect {
  123848. private bloomScale;
  123849. /**
  123850. * @hidden Internal
  123851. */
  123852. _effects: Array<PostProcess>;
  123853. /**
  123854. * @hidden Internal
  123855. */
  123856. _downscale: ExtractHighlightsPostProcess;
  123857. private _blurX;
  123858. private _blurY;
  123859. private _merge;
  123860. /**
  123861. * The luminance threshold to find bright areas of the image to bloom.
  123862. */
  123863. threshold: number;
  123864. /**
  123865. * The strength of the bloom.
  123866. */
  123867. weight: number;
  123868. /**
  123869. * Specifies the size of the bloom blur kernel, relative to the final output size
  123870. */
  123871. kernel: number;
  123872. /**
  123873. * Creates a new instance of @see BloomEffect
  123874. * @param scene The scene the effect belongs to.
  123875. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123876. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123877. * @param bloomWeight The the strength of bloom.
  123878. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123879. * @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)
  123880. */
  123881. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123882. /**
  123883. * Disposes each of the internal effects for a given camera.
  123884. * @param camera The camera to dispose the effect on.
  123885. */
  123886. disposeEffects(camera: Camera): void;
  123887. /**
  123888. * @hidden Internal
  123889. */
  123890. _updateEffects(): void;
  123891. /**
  123892. * Internal
  123893. * @returns if all the contained post processes are ready.
  123894. * @hidden
  123895. */
  123896. _isReady(): boolean;
  123897. }
  123898. }
  123899. declare module BABYLON {
  123900. /** @hidden */
  123901. export var chromaticAberrationPixelShader: {
  123902. name: string;
  123903. shader: string;
  123904. };
  123905. }
  123906. declare module BABYLON {
  123907. /**
  123908. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123909. */
  123910. export class ChromaticAberrationPostProcess extends PostProcess {
  123911. /**
  123912. * The amount of seperation of rgb channels (default: 30)
  123913. */
  123914. aberrationAmount: number;
  123915. /**
  123916. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123917. */
  123918. radialIntensity: number;
  123919. /**
  123920. * 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))
  123921. */
  123922. direction: Vector2;
  123923. /**
  123924. * 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))
  123925. */
  123926. centerPosition: Vector2;
  123927. /**
  123928. * Creates a new instance ChromaticAberrationPostProcess
  123929. * @param name The name of the effect.
  123930. * @param screenWidth The width of the screen to apply the effect on.
  123931. * @param screenHeight The height of the screen to apply the effect on.
  123932. * @param options The required width/height ratio to downsize to before computing the render pass.
  123933. * @param camera The camera to apply the render pass to.
  123934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123935. * @param engine The engine which the post process will be applied. (default: current engine)
  123936. * @param reusable If the post process can be reused on the same frame. (default: false)
  123937. * @param textureType Type of textures used when performing the post process. (default: 0)
  123938. * @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)
  123939. */
  123940. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123941. }
  123942. }
  123943. declare module BABYLON {
  123944. /** @hidden */
  123945. export var circleOfConfusionPixelShader: {
  123946. name: string;
  123947. shader: string;
  123948. };
  123949. }
  123950. declare module BABYLON {
  123951. /**
  123952. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123953. */
  123954. export class CircleOfConfusionPostProcess extends PostProcess {
  123955. /**
  123956. * 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.
  123957. */
  123958. lensSize: number;
  123959. /**
  123960. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123961. */
  123962. fStop: number;
  123963. /**
  123964. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123965. */
  123966. focusDistance: number;
  123967. /**
  123968. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123969. */
  123970. focalLength: number;
  123971. private _depthTexture;
  123972. /**
  123973. * Creates a new instance CircleOfConfusionPostProcess
  123974. * @param name The name of the effect.
  123975. * @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.
  123976. * @param options The required width/height ratio to downsize to before computing the render pass.
  123977. * @param camera The camera to apply the render pass to.
  123978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123979. * @param engine The engine which the post process will be applied. (default: current engine)
  123980. * @param reusable If the post process can be reused on the same frame. (default: false)
  123981. * @param textureType Type of textures used when performing the post process. (default: 0)
  123982. * @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)
  123983. */
  123984. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123985. /**
  123986. * 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.
  123987. */
  123988. depthTexture: RenderTargetTexture;
  123989. }
  123990. }
  123991. declare module BABYLON {
  123992. /** @hidden */
  123993. export var colorCorrectionPixelShader: {
  123994. name: string;
  123995. shader: string;
  123996. };
  123997. }
  123998. declare module BABYLON {
  123999. /**
  124000. *
  124001. * This post-process allows the modification of rendered colors by using
  124002. * a 'look-up table' (LUT). This effect is also called Color Grading.
  124003. *
  124004. * The object needs to be provided an url to a texture containing the color
  124005. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  124006. * Use an image editing software to tweak the LUT to match your needs.
  124007. *
  124008. * For an example of a color LUT, see here:
  124009. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  124010. * For explanations on color grading, see here:
  124011. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124012. *
  124013. */
  124014. export class ColorCorrectionPostProcess extends PostProcess {
  124015. private _colorTableTexture;
  124016. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124017. }
  124018. }
  124019. declare module BABYLON {
  124020. /** @hidden */
  124021. export var convolutionPixelShader: {
  124022. name: string;
  124023. shader: string;
  124024. };
  124025. }
  124026. declare module BABYLON {
  124027. /**
  124028. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124029. * input texture to perform effects such as edge detection or sharpening
  124030. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124031. */
  124032. export class ConvolutionPostProcess extends PostProcess {
  124033. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124034. kernel: number[];
  124035. /**
  124036. * Creates a new instance ConvolutionPostProcess
  124037. * @param name The name of the effect.
  124038. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124039. * @param options The required width/height ratio to downsize to before computing the render pass.
  124040. * @param camera The camera to apply the render pass to.
  124041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124042. * @param engine The engine which the post process will be applied. (default: current engine)
  124043. * @param reusable If the post process can be reused on the same frame. (default: false)
  124044. * @param textureType Type of textures used when performing the post process. (default: 0)
  124045. */
  124046. constructor(name: string,
  124047. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124048. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124049. /**
  124050. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124051. */
  124052. static EdgeDetect0Kernel: number[];
  124053. /**
  124054. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124055. */
  124056. static EdgeDetect1Kernel: number[];
  124057. /**
  124058. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124059. */
  124060. static EdgeDetect2Kernel: number[];
  124061. /**
  124062. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124063. */
  124064. static SharpenKernel: number[];
  124065. /**
  124066. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124067. */
  124068. static EmbossKernel: number[];
  124069. /**
  124070. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124071. */
  124072. static GaussianKernel: number[];
  124073. }
  124074. }
  124075. declare module BABYLON {
  124076. /**
  124077. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124078. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124079. * based on samples that have a large difference in distance than the center pixel.
  124080. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124081. */
  124082. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124083. direction: Vector2;
  124084. /**
  124085. * Creates a new instance CircleOfConfusionPostProcess
  124086. * @param name The name of the effect.
  124087. * @param scene The scene the effect belongs to.
  124088. * @param direction The direction the blur should be applied.
  124089. * @param kernel The size of the kernel used to blur.
  124090. * @param options The required width/height ratio to downsize to before computing the render pass.
  124091. * @param camera The camera to apply the render pass to.
  124092. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124093. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124095. * @param engine The engine which the post process will be applied. (default: current engine)
  124096. * @param reusable If the post process can be reused on the same frame. (default: false)
  124097. * @param textureType Type of textures used when performing the post process. (default: 0)
  124098. * @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)
  124099. */
  124100. 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);
  124101. }
  124102. }
  124103. declare module BABYLON {
  124104. /** @hidden */
  124105. export var depthOfFieldMergePixelShader: {
  124106. name: string;
  124107. shader: string;
  124108. };
  124109. }
  124110. declare module BABYLON {
  124111. /**
  124112. * Options to be set when merging outputs from the default pipeline.
  124113. */
  124114. export class DepthOfFieldMergePostProcessOptions {
  124115. /**
  124116. * The original image to merge on top of
  124117. */
  124118. originalFromInput: PostProcess;
  124119. /**
  124120. * Parameters to perform the merge of the depth of field effect
  124121. */
  124122. depthOfField?: {
  124123. circleOfConfusion: PostProcess;
  124124. blurSteps: Array<PostProcess>;
  124125. };
  124126. /**
  124127. * Parameters to perform the merge of bloom effect
  124128. */
  124129. bloom?: {
  124130. blurred: PostProcess;
  124131. weight: number;
  124132. };
  124133. }
  124134. /**
  124135. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124136. */
  124137. export class DepthOfFieldMergePostProcess extends PostProcess {
  124138. private blurSteps;
  124139. /**
  124140. * Creates a new instance of DepthOfFieldMergePostProcess
  124141. * @param name The name of the effect.
  124142. * @param originalFromInput Post process which's input will be used for the merge.
  124143. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124144. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124145. * @param options The required width/height ratio to downsize to before computing the render pass.
  124146. * @param camera The camera to apply the render pass to.
  124147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124148. * @param engine The engine which the post process will be applied. (default: current engine)
  124149. * @param reusable If the post process can be reused on the same frame. (default: false)
  124150. * @param textureType Type of textures used when performing the post process. (default: 0)
  124151. * @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)
  124152. */
  124153. 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);
  124154. /**
  124155. * Updates the effect with the current post process compile time values and recompiles the shader.
  124156. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124157. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124158. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124159. * @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
  124160. * @param onCompiled Called when the shader has been compiled.
  124161. * @param onError Called if there is an error when compiling a shader.
  124162. */
  124163. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124164. }
  124165. }
  124166. declare module BABYLON {
  124167. /**
  124168. * Specifies the level of max blur that should be applied when using the depth of field effect
  124169. */
  124170. export enum DepthOfFieldEffectBlurLevel {
  124171. /**
  124172. * Subtle blur
  124173. */
  124174. Low = 0,
  124175. /**
  124176. * Medium blur
  124177. */
  124178. Medium = 1,
  124179. /**
  124180. * Large blur
  124181. */
  124182. High = 2
  124183. }
  124184. /**
  124185. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124186. */
  124187. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124188. private _circleOfConfusion;
  124189. /**
  124190. * @hidden Internal, blurs from high to low
  124191. */
  124192. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124193. private _depthOfFieldBlurY;
  124194. private _dofMerge;
  124195. /**
  124196. * @hidden Internal post processes in depth of field effect
  124197. */
  124198. _effects: Array<PostProcess>;
  124199. /**
  124200. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124201. */
  124202. focalLength: number;
  124203. /**
  124204. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124205. */
  124206. fStop: number;
  124207. /**
  124208. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124209. */
  124210. focusDistance: number;
  124211. /**
  124212. * 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.
  124213. */
  124214. lensSize: number;
  124215. /**
  124216. * Creates a new instance DepthOfFieldEffect
  124217. * @param scene The scene the effect belongs to.
  124218. * @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.
  124219. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124220. * @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)
  124221. */
  124222. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124223. /**
  124224. * Get the current class name of the current effet
  124225. * @returns "DepthOfFieldEffect"
  124226. */
  124227. getClassName(): string;
  124228. /**
  124229. * 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.
  124230. */
  124231. depthTexture: RenderTargetTexture;
  124232. /**
  124233. * Disposes each of the internal effects for a given camera.
  124234. * @param camera The camera to dispose the effect on.
  124235. */
  124236. disposeEffects(camera: Camera): void;
  124237. /**
  124238. * @hidden Internal
  124239. */
  124240. _updateEffects(): void;
  124241. /**
  124242. * Internal
  124243. * @returns if all the contained post processes are ready.
  124244. * @hidden
  124245. */
  124246. _isReady(): boolean;
  124247. }
  124248. }
  124249. declare module BABYLON {
  124250. /** @hidden */
  124251. export var displayPassPixelShader: {
  124252. name: string;
  124253. shader: string;
  124254. };
  124255. }
  124256. declare module BABYLON {
  124257. /**
  124258. * DisplayPassPostProcess which produces an output the same as it's input
  124259. */
  124260. export class DisplayPassPostProcess extends PostProcess {
  124261. /**
  124262. * Creates the DisplayPassPostProcess
  124263. * @param name The name of the effect.
  124264. * @param options The required width/height ratio to downsize to before computing the render pass.
  124265. * @param camera The camera to apply the render pass to.
  124266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124267. * @param engine The engine which the post process will be applied. (default: current engine)
  124268. * @param reusable If the post process can be reused on the same frame. (default: false)
  124269. */
  124270. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124271. }
  124272. }
  124273. declare module BABYLON {
  124274. /** @hidden */
  124275. export var filterPixelShader: {
  124276. name: string;
  124277. shader: string;
  124278. };
  124279. }
  124280. declare module BABYLON {
  124281. /**
  124282. * Applies a kernel filter to the image
  124283. */
  124284. export class FilterPostProcess extends PostProcess {
  124285. /** The matrix to be applied to the image */
  124286. kernelMatrix: Matrix;
  124287. /**
  124288. *
  124289. * @param name The name of the effect.
  124290. * @param kernelMatrix The matrix to be applied to the image
  124291. * @param options The required width/height ratio to downsize to before computing the render pass.
  124292. * @param camera The camera to apply the render pass to.
  124293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124294. * @param engine The engine which the post process will be applied. (default: current engine)
  124295. * @param reusable If the post process can be reused on the same frame. (default: false)
  124296. */
  124297. constructor(name: string,
  124298. /** The matrix to be applied to the image */
  124299. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124300. }
  124301. }
  124302. declare module BABYLON {
  124303. /** @hidden */
  124304. export var fxaaPixelShader: {
  124305. name: string;
  124306. shader: string;
  124307. };
  124308. }
  124309. declare module BABYLON {
  124310. /** @hidden */
  124311. export var fxaaVertexShader: {
  124312. name: string;
  124313. shader: string;
  124314. };
  124315. }
  124316. declare module BABYLON {
  124317. /**
  124318. * Fxaa post process
  124319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124320. */
  124321. export class FxaaPostProcess extends PostProcess {
  124322. /** @hidden */
  124323. texelWidth: number;
  124324. /** @hidden */
  124325. texelHeight: number;
  124326. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124327. private _getDefines;
  124328. }
  124329. }
  124330. declare module BABYLON {
  124331. /** @hidden */
  124332. export var grainPixelShader: {
  124333. name: string;
  124334. shader: string;
  124335. };
  124336. }
  124337. declare module BABYLON {
  124338. /**
  124339. * The GrainPostProcess adds noise to the image at mid luminance levels
  124340. */
  124341. export class GrainPostProcess extends PostProcess {
  124342. /**
  124343. * The intensity of the grain added (default: 30)
  124344. */
  124345. intensity: number;
  124346. /**
  124347. * If the grain should be randomized on every frame
  124348. */
  124349. animated: boolean;
  124350. /**
  124351. * Creates a new instance of @see GrainPostProcess
  124352. * @param name The name of the effect.
  124353. * @param options The required width/height ratio to downsize to before computing the render pass.
  124354. * @param camera The camera to apply the render pass to.
  124355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124356. * @param engine The engine which the post process will be applied. (default: current engine)
  124357. * @param reusable If the post process can be reused on the same frame. (default: false)
  124358. * @param textureType Type of textures used when performing the post process. (default: 0)
  124359. * @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)
  124360. */
  124361. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124362. }
  124363. }
  124364. declare module BABYLON {
  124365. /** @hidden */
  124366. export var highlightsPixelShader: {
  124367. name: string;
  124368. shader: string;
  124369. };
  124370. }
  124371. declare module BABYLON {
  124372. /**
  124373. * Extracts highlights from the image
  124374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124375. */
  124376. export class HighlightsPostProcess extends PostProcess {
  124377. /**
  124378. * Extracts highlights from the image
  124379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124380. * @param name The name of the effect.
  124381. * @param options The required width/height ratio to downsize to before computing the render pass.
  124382. * @param camera The camera to apply the render pass to.
  124383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124384. * @param engine The engine which the post process will be applied. (default: current engine)
  124385. * @param reusable If the post process can be reused on the same frame. (default: false)
  124386. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124387. */
  124388. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124389. }
  124390. }
  124391. declare module BABYLON {
  124392. /** @hidden */
  124393. export var mrtFragmentDeclaration: {
  124394. name: string;
  124395. shader: string;
  124396. };
  124397. }
  124398. declare module BABYLON {
  124399. /** @hidden */
  124400. export var geometryPixelShader: {
  124401. name: string;
  124402. shader: string;
  124403. };
  124404. }
  124405. declare module BABYLON {
  124406. /** @hidden */
  124407. export var geometryVertexShader: {
  124408. name: string;
  124409. shader: string;
  124410. };
  124411. }
  124412. declare module BABYLON {
  124413. /** @hidden */
  124414. interface ISavedTransformationMatrix {
  124415. world: Matrix;
  124416. viewProjection: Matrix;
  124417. }
  124418. /**
  124419. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124420. */
  124421. export class GeometryBufferRenderer {
  124422. /**
  124423. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124424. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124425. */
  124426. static readonly POSITION_TEXTURE_TYPE: number;
  124427. /**
  124428. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124429. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124430. */
  124431. static readonly VELOCITY_TEXTURE_TYPE: number;
  124432. /**
  124433. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124434. * in order to compute objects velocities when enableVelocity is set to "true"
  124435. * @hidden
  124436. */
  124437. _previousTransformationMatrices: {
  124438. [index: number]: ISavedTransformationMatrix;
  124439. };
  124440. /**
  124441. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124442. * in order to compute objects velocities when enableVelocity is set to "true"
  124443. * @hidden
  124444. */
  124445. _previousBonesTransformationMatrices: {
  124446. [index: number]: Float32Array;
  124447. };
  124448. /**
  124449. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124450. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124451. */
  124452. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124453. private _scene;
  124454. private _multiRenderTarget;
  124455. private _ratio;
  124456. private _enablePosition;
  124457. private _enableVelocity;
  124458. private _positionIndex;
  124459. private _velocityIndex;
  124460. protected _effect: Effect;
  124461. protected _cachedDefines: string;
  124462. /**
  124463. * Set the render list (meshes to be rendered) used in the G buffer.
  124464. */
  124465. renderList: Mesh[];
  124466. /**
  124467. * Gets wether or not G buffer are supported by the running hardware.
  124468. * This requires draw buffer supports
  124469. */
  124470. readonly isSupported: boolean;
  124471. /**
  124472. * Returns the index of the given texture type in the G-Buffer textures array
  124473. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124474. * @returns the index of the given texture type in the G-Buffer textures array
  124475. */
  124476. getTextureIndex(textureType: number): number;
  124477. /**
  124478. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124479. */
  124480. /**
  124481. * Sets whether or not objects positions are enabled for the G buffer.
  124482. */
  124483. enablePosition: boolean;
  124484. /**
  124485. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124486. */
  124487. /**
  124488. * Sets wether or not objects velocities are enabled for the G buffer.
  124489. */
  124490. enableVelocity: boolean;
  124491. /**
  124492. * Gets the scene associated with the buffer.
  124493. */
  124494. readonly scene: Scene;
  124495. /**
  124496. * Gets the ratio used by the buffer during its creation.
  124497. * How big is the buffer related to the main canvas.
  124498. */
  124499. readonly ratio: number;
  124500. /** @hidden */
  124501. static _SceneComponentInitialization: (scene: Scene) => void;
  124502. /**
  124503. * Creates a new G Buffer for the scene
  124504. * @param scene The scene the buffer belongs to
  124505. * @param ratio How big is the buffer related to the main canvas.
  124506. */
  124507. constructor(scene: Scene, ratio?: number);
  124508. /**
  124509. * Checks wether everything is ready to render a submesh to the G buffer.
  124510. * @param subMesh the submesh to check readiness for
  124511. * @param useInstances is the mesh drawn using instance or not
  124512. * @returns true if ready otherwise false
  124513. */
  124514. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124515. /**
  124516. * Gets the current underlying G Buffer.
  124517. * @returns the buffer
  124518. */
  124519. getGBuffer(): MultiRenderTarget;
  124520. /**
  124521. * Gets the number of samples used to render the buffer (anti aliasing).
  124522. */
  124523. /**
  124524. * Sets the number of samples used to render the buffer (anti aliasing).
  124525. */
  124526. samples: number;
  124527. /**
  124528. * Disposes the renderer and frees up associated resources.
  124529. */
  124530. dispose(): void;
  124531. protected _createRenderTargets(): void;
  124532. private _copyBonesTransformationMatrices;
  124533. }
  124534. }
  124535. declare module BABYLON {
  124536. interface Scene {
  124537. /** @hidden (Backing field) */
  124538. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124539. /**
  124540. * Gets or Sets the current geometry buffer associated to the scene.
  124541. */
  124542. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124543. /**
  124544. * Enables a GeometryBufferRender and associates it with the scene
  124545. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124546. * @returns the GeometryBufferRenderer
  124547. */
  124548. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124549. /**
  124550. * Disables the GeometryBufferRender associated with the scene
  124551. */
  124552. disableGeometryBufferRenderer(): void;
  124553. }
  124554. /**
  124555. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124556. * in several rendering techniques.
  124557. */
  124558. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124559. /**
  124560. * The component name helpful to identify the component in the list of scene components.
  124561. */
  124562. readonly name: string;
  124563. /**
  124564. * The scene the component belongs to.
  124565. */
  124566. scene: Scene;
  124567. /**
  124568. * Creates a new instance of the component for the given scene
  124569. * @param scene Defines the scene to register the component in
  124570. */
  124571. constructor(scene: Scene);
  124572. /**
  124573. * Registers the component in a given scene
  124574. */
  124575. register(): void;
  124576. /**
  124577. * Rebuilds the elements related to this component in case of
  124578. * context lost for instance.
  124579. */
  124580. rebuild(): void;
  124581. /**
  124582. * Disposes the component and the associated ressources
  124583. */
  124584. dispose(): void;
  124585. private _gatherRenderTargets;
  124586. }
  124587. }
  124588. declare module BABYLON {
  124589. /** @hidden */
  124590. export var motionBlurPixelShader: {
  124591. name: string;
  124592. shader: string;
  124593. };
  124594. }
  124595. declare module BABYLON {
  124596. /**
  124597. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124598. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124599. * As an example, all you have to do is to create the post-process:
  124600. * var mb = new BABYLON.MotionBlurPostProcess(
  124601. * 'mb', // The name of the effect.
  124602. * scene, // The scene containing the objects to blur according to their velocity.
  124603. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124604. * camera // The camera to apply the render pass to.
  124605. * );
  124606. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124607. */
  124608. export class MotionBlurPostProcess extends PostProcess {
  124609. /**
  124610. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124611. */
  124612. motionStrength: number;
  124613. /**
  124614. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124615. */
  124616. /**
  124617. * Sets the number of iterations to be used for motion blur quality
  124618. */
  124619. motionBlurSamples: number;
  124620. private _motionBlurSamples;
  124621. private _geometryBufferRenderer;
  124622. /**
  124623. * Creates a new instance MotionBlurPostProcess
  124624. * @param name The name of the effect.
  124625. * @param scene The scene containing the objects to blur according to their velocity.
  124626. * @param options The required width/height ratio to downsize to before computing the render pass.
  124627. * @param camera The camera to apply the render pass to.
  124628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124629. * @param engine The engine which the post process will be applied. (default: current engine)
  124630. * @param reusable If the post process can be reused on the same frame. (default: false)
  124631. * @param textureType Type of textures used when performing the post process. (default: 0)
  124632. * @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)
  124633. */
  124634. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124635. /**
  124636. * Excludes the given skinned mesh from computing bones velocities.
  124637. * 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.
  124638. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124639. */
  124640. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124641. /**
  124642. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124643. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124644. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124645. */
  124646. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124647. /**
  124648. * Disposes the post process.
  124649. * @param camera The camera to dispose the post process on.
  124650. */
  124651. dispose(camera?: Camera): void;
  124652. }
  124653. }
  124654. declare module BABYLON {
  124655. /** @hidden */
  124656. export var refractionPixelShader: {
  124657. name: string;
  124658. shader: string;
  124659. };
  124660. }
  124661. declare module BABYLON {
  124662. /**
  124663. * Post process which applies a refractin texture
  124664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124665. */
  124666. export class RefractionPostProcess extends PostProcess {
  124667. /** the base color of the refraction (used to taint the rendering) */
  124668. color: Color3;
  124669. /** simulated refraction depth */
  124670. depth: number;
  124671. /** the coefficient of the base color (0 to remove base color tainting) */
  124672. colorLevel: number;
  124673. private _refTexture;
  124674. private _ownRefractionTexture;
  124675. /**
  124676. * Gets or sets the refraction texture
  124677. * Please note that you are responsible for disposing the texture if you set it manually
  124678. */
  124679. refractionTexture: Texture;
  124680. /**
  124681. * Initializes the RefractionPostProcess
  124682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124683. * @param name The name of the effect.
  124684. * @param refractionTextureUrl Url of the refraction texture to use
  124685. * @param color the base color of the refraction (used to taint the rendering)
  124686. * @param depth simulated refraction depth
  124687. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124688. * @param camera The camera to apply the render pass to.
  124689. * @param options The required width/height ratio to downsize to before computing the render pass.
  124690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124691. * @param engine The engine which the post process will be applied. (default: current engine)
  124692. * @param reusable If the post process can be reused on the same frame. (default: false)
  124693. */
  124694. constructor(name: string, refractionTextureUrl: string,
  124695. /** the base color of the refraction (used to taint the rendering) */
  124696. color: Color3,
  124697. /** simulated refraction depth */
  124698. depth: number,
  124699. /** the coefficient of the base color (0 to remove base color tainting) */
  124700. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124701. /**
  124702. * Disposes of the post process
  124703. * @param camera Camera to dispose post process on
  124704. */
  124705. dispose(camera: Camera): void;
  124706. }
  124707. }
  124708. declare module BABYLON {
  124709. /** @hidden */
  124710. export var sharpenPixelShader: {
  124711. name: string;
  124712. shader: string;
  124713. };
  124714. }
  124715. declare module BABYLON {
  124716. /**
  124717. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124718. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124719. */
  124720. export class SharpenPostProcess extends PostProcess {
  124721. /**
  124722. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124723. */
  124724. colorAmount: number;
  124725. /**
  124726. * How much sharpness should be applied (default: 0.3)
  124727. */
  124728. edgeAmount: number;
  124729. /**
  124730. * Creates a new instance ConvolutionPostProcess
  124731. * @param name The name of the effect.
  124732. * @param options The required width/height ratio to downsize to before computing the render pass.
  124733. * @param camera The camera to apply the render pass to.
  124734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124735. * @param engine The engine which the post process will be applied. (default: current engine)
  124736. * @param reusable If the post process can be reused on the same frame. (default: false)
  124737. * @param textureType Type of textures used when performing the post process. (default: 0)
  124738. * @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)
  124739. */
  124740. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124741. }
  124742. }
  124743. declare module BABYLON {
  124744. /**
  124745. * PostProcessRenderPipeline
  124746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124747. */
  124748. export class PostProcessRenderPipeline {
  124749. private engine;
  124750. private _renderEffects;
  124751. private _renderEffectsForIsolatedPass;
  124752. /**
  124753. * List of inspectable custom properties (used by the Inspector)
  124754. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124755. */
  124756. inspectableCustomProperties: IInspectable[];
  124757. /**
  124758. * @hidden
  124759. */
  124760. protected _cameras: Camera[];
  124761. /** @hidden */
  124762. _name: string;
  124763. /**
  124764. * Gets pipeline name
  124765. */
  124766. readonly name: string;
  124767. /**
  124768. * Initializes a PostProcessRenderPipeline
  124769. * @param engine engine to add the pipeline to
  124770. * @param name name of the pipeline
  124771. */
  124772. constructor(engine: Engine, name: string);
  124773. /**
  124774. * Gets the class name
  124775. * @returns "PostProcessRenderPipeline"
  124776. */
  124777. getClassName(): string;
  124778. /**
  124779. * If all the render effects in the pipeline are supported
  124780. */
  124781. readonly isSupported: boolean;
  124782. /**
  124783. * Adds an effect to the pipeline
  124784. * @param renderEffect the effect to add
  124785. */
  124786. addEffect(renderEffect: PostProcessRenderEffect): void;
  124787. /** @hidden */
  124788. _rebuild(): void;
  124789. /** @hidden */
  124790. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124791. /** @hidden */
  124792. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124793. /** @hidden */
  124794. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124795. /** @hidden */
  124796. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124797. /** @hidden */
  124798. _attachCameras(cameras: Camera, unique: boolean): void;
  124799. /** @hidden */
  124800. _attachCameras(cameras: Camera[], unique: boolean): void;
  124801. /** @hidden */
  124802. _detachCameras(cameras: Camera): void;
  124803. /** @hidden */
  124804. _detachCameras(cameras: Nullable<Camera[]>): void;
  124805. /** @hidden */
  124806. _update(): void;
  124807. /** @hidden */
  124808. _reset(): void;
  124809. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124810. /**
  124811. * Disposes of the pipeline
  124812. */
  124813. dispose(): void;
  124814. }
  124815. }
  124816. declare module BABYLON {
  124817. /**
  124818. * PostProcessRenderPipelineManager class
  124819. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124820. */
  124821. export class PostProcessRenderPipelineManager {
  124822. private _renderPipelines;
  124823. /**
  124824. * Initializes a PostProcessRenderPipelineManager
  124825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124826. */
  124827. constructor();
  124828. /**
  124829. * Gets the list of supported render pipelines
  124830. */
  124831. readonly supportedPipelines: PostProcessRenderPipeline[];
  124832. /**
  124833. * Adds a pipeline to the manager
  124834. * @param renderPipeline The pipeline to add
  124835. */
  124836. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124837. /**
  124838. * Attaches a camera to the pipeline
  124839. * @param renderPipelineName The name of the pipeline to attach to
  124840. * @param cameras the camera to attach
  124841. * @param unique if the camera can be attached multiple times to the pipeline
  124842. */
  124843. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124844. /**
  124845. * Detaches a camera from the pipeline
  124846. * @param renderPipelineName The name of the pipeline to detach from
  124847. * @param cameras the camera to detach
  124848. */
  124849. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124850. /**
  124851. * Enables an effect by name on a pipeline
  124852. * @param renderPipelineName the name of the pipeline to enable the effect in
  124853. * @param renderEffectName the name of the effect to enable
  124854. * @param cameras the cameras that the effect should be enabled on
  124855. */
  124856. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124857. /**
  124858. * Disables an effect by name on a pipeline
  124859. * @param renderPipelineName the name of the pipeline to disable the effect in
  124860. * @param renderEffectName the name of the effect to disable
  124861. * @param cameras the cameras that the effect should be disabled on
  124862. */
  124863. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124864. /**
  124865. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124866. */
  124867. update(): void;
  124868. /** @hidden */
  124869. _rebuild(): void;
  124870. /**
  124871. * Disposes of the manager and pipelines
  124872. */
  124873. dispose(): void;
  124874. }
  124875. }
  124876. declare module BABYLON {
  124877. interface Scene {
  124878. /** @hidden (Backing field) */
  124879. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124880. /**
  124881. * Gets the postprocess render pipeline manager
  124882. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124883. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124884. */
  124885. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124886. }
  124887. /**
  124888. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124889. */
  124890. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124891. /**
  124892. * The component name helpfull to identify the component in the list of scene components.
  124893. */
  124894. readonly name: string;
  124895. /**
  124896. * The scene the component belongs to.
  124897. */
  124898. scene: Scene;
  124899. /**
  124900. * Creates a new instance of the component for the given scene
  124901. * @param scene Defines the scene to register the component in
  124902. */
  124903. constructor(scene: Scene);
  124904. /**
  124905. * Registers the component in a given scene
  124906. */
  124907. register(): void;
  124908. /**
  124909. * Rebuilds the elements related to this component in case of
  124910. * context lost for instance.
  124911. */
  124912. rebuild(): void;
  124913. /**
  124914. * Disposes the component and the associated ressources
  124915. */
  124916. dispose(): void;
  124917. private _gatherRenderTargets;
  124918. }
  124919. }
  124920. declare module BABYLON {
  124921. /**
  124922. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124923. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124924. */
  124925. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124926. private _scene;
  124927. private _camerasToBeAttached;
  124928. /**
  124929. * ID of the sharpen post process,
  124930. */
  124931. private readonly SharpenPostProcessId;
  124932. /**
  124933. * @ignore
  124934. * ID of the image processing post process;
  124935. */
  124936. readonly ImageProcessingPostProcessId: string;
  124937. /**
  124938. * @ignore
  124939. * ID of the Fast Approximate Anti-Aliasing post process;
  124940. */
  124941. readonly FxaaPostProcessId: string;
  124942. /**
  124943. * ID of the chromatic aberration post process,
  124944. */
  124945. private readonly ChromaticAberrationPostProcessId;
  124946. /**
  124947. * ID of the grain post process
  124948. */
  124949. private readonly GrainPostProcessId;
  124950. /**
  124951. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124952. */
  124953. sharpen: SharpenPostProcess;
  124954. private _sharpenEffect;
  124955. private bloom;
  124956. /**
  124957. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124958. */
  124959. depthOfField: DepthOfFieldEffect;
  124960. /**
  124961. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124962. */
  124963. fxaa: FxaaPostProcess;
  124964. /**
  124965. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124966. */
  124967. imageProcessing: ImageProcessingPostProcess;
  124968. /**
  124969. * Chromatic aberration post process which will shift rgb colors in the image
  124970. */
  124971. chromaticAberration: ChromaticAberrationPostProcess;
  124972. private _chromaticAberrationEffect;
  124973. /**
  124974. * Grain post process which add noise to the image
  124975. */
  124976. grain: GrainPostProcess;
  124977. private _grainEffect;
  124978. /**
  124979. * Glow post process which adds a glow to emissive areas of the image
  124980. */
  124981. private _glowLayer;
  124982. /**
  124983. * Animations which can be used to tweak settings over a period of time
  124984. */
  124985. animations: Animation[];
  124986. private _imageProcessingConfigurationObserver;
  124987. private _sharpenEnabled;
  124988. private _bloomEnabled;
  124989. private _depthOfFieldEnabled;
  124990. private _depthOfFieldBlurLevel;
  124991. private _fxaaEnabled;
  124992. private _imageProcessingEnabled;
  124993. private _defaultPipelineTextureType;
  124994. private _bloomScale;
  124995. private _chromaticAberrationEnabled;
  124996. private _grainEnabled;
  124997. private _buildAllowed;
  124998. /**
  124999. * Gets active scene
  125000. */
  125001. readonly scene: Scene;
  125002. /**
  125003. * Enable or disable the sharpen process from the pipeline
  125004. */
  125005. sharpenEnabled: boolean;
  125006. private _resizeObserver;
  125007. private _hardwareScaleLevel;
  125008. private _bloomKernel;
  125009. /**
  125010. * Specifies the size of the bloom blur kernel, relative to the final output size
  125011. */
  125012. bloomKernel: number;
  125013. /**
  125014. * Specifies the weight of the bloom in the final rendering
  125015. */
  125016. private _bloomWeight;
  125017. /**
  125018. * Specifies the luma threshold for the area that will be blurred by the bloom
  125019. */
  125020. private _bloomThreshold;
  125021. private _hdr;
  125022. /**
  125023. * The strength of the bloom.
  125024. */
  125025. bloomWeight: number;
  125026. /**
  125027. * The strength of the bloom.
  125028. */
  125029. bloomThreshold: number;
  125030. /**
  125031. * The scale of the bloom, lower value will provide better performance.
  125032. */
  125033. bloomScale: number;
  125034. /**
  125035. * Enable or disable the bloom from the pipeline
  125036. */
  125037. bloomEnabled: boolean;
  125038. private _rebuildBloom;
  125039. /**
  125040. * If the depth of field is enabled.
  125041. */
  125042. depthOfFieldEnabled: boolean;
  125043. /**
  125044. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125045. */
  125046. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125047. /**
  125048. * If the anti aliasing is enabled.
  125049. */
  125050. fxaaEnabled: boolean;
  125051. private _samples;
  125052. /**
  125053. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125054. */
  125055. samples: number;
  125056. /**
  125057. * If image processing is enabled.
  125058. */
  125059. imageProcessingEnabled: boolean;
  125060. /**
  125061. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125062. */
  125063. glowLayerEnabled: boolean;
  125064. /**
  125065. * Gets the glow layer (or null if not defined)
  125066. */
  125067. readonly glowLayer: Nullable<GlowLayer>;
  125068. /**
  125069. * Enable or disable the chromaticAberration process from the pipeline
  125070. */
  125071. chromaticAberrationEnabled: boolean;
  125072. /**
  125073. * Enable or disable the grain process from the pipeline
  125074. */
  125075. grainEnabled: boolean;
  125076. /**
  125077. * @constructor
  125078. * @param name - The rendering pipeline name (default: "")
  125079. * @param hdr - If high dynamic range textures should be used (default: true)
  125080. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125081. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125082. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125083. */
  125084. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125085. /**
  125086. * Get the class name
  125087. * @returns "DefaultRenderingPipeline"
  125088. */
  125089. getClassName(): string;
  125090. /**
  125091. * Force the compilation of the entire pipeline.
  125092. */
  125093. prepare(): void;
  125094. private _hasCleared;
  125095. private _prevPostProcess;
  125096. private _prevPrevPostProcess;
  125097. private _setAutoClearAndTextureSharing;
  125098. private _depthOfFieldSceneObserver;
  125099. private _buildPipeline;
  125100. private _disposePostProcesses;
  125101. /**
  125102. * Adds a camera to the pipeline
  125103. * @param camera the camera to be added
  125104. */
  125105. addCamera(camera: Camera): void;
  125106. /**
  125107. * Removes a camera from the pipeline
  125108. * @param camera the camera to remove
  125109. */
  125110. removeCamera(camera: Camera): void;
  125111. /**
  125112. * Dispose of the pipeline and stop all post processes
  125113. */
  125114. dispose(): void;
  125115. /**
  125116. * Serialize the rendering pipeline (Used when exporting)
  125117. * @returns the serialized object
  125118. */
  125119. serialize(): any;
  125120. /**
  125121. * Parse the serialized pipeline
  125122. * @param source Source pipeline.
  125123. * @param scene The scene to load the pipeline to.
  125124. * @param rootUrl The URL of the serialized pipeline.
  125125. * @returns An instantiated pipeline from the serialized object.
  125126. */
  125127. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125128. }
  125129. }
  125130. declare module BABYLON {
  125131. /** @hidden */
  125132. export var lensHighlightsPixelShader: {
  125133. name: string;
  125134. shader: string;
  125135. };
  125136. }
  125137. declare module BABYLON {
  125138. /** @hidden */
  125139. export var depthOfFieldPixelShader: {
  125140. name: string;
  125141. shader: string;
  125142. };
  125143. }
  125144. declare module BABYLON {
  125145. /**
  125146. * BABYLON.JS Chromatic Aberration GLSL Shader
  125147. * Author: Olivier Guyot
  125148. * Separates very slightly R, G and B colors on the edges of the screen
  125149. * Inspired by Francois Tarlier & Martins Upitis
  125150. */
  125151. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125152. /**
  125153. * @ignore
  125154. * The chromatic aberration PostProcess id in the pipeline
  125155. */
  125156. LensChromaticAberrationEffect: string;
  125157. /**
  125158. * @ignore
  125159. * The highlights enhancing PostProcess id in the pipeline
  125160. */
  125161. HighlightsEnhancingEffect: string;
  125162. /**
  125163. * @ignore
  125164. * The depth-of-field PostProcess id in the pipeline
  125165. */
  125166. LensDepthOfFieldEffect: string;
  125167. private _scene;
  125168. private _depthTexture;
  125169. private _grainTexture;
  125170. private _chromaticAberrationPostProcess;
  125171. private _highlightsPostProcess;
  125172. private _depthOfFieldPostProcess;
  125173. private _edgeBlur;
  125174. private _grainAmount;
  125175. private _chromaticAberration;
  125176. private _distortion;
  125177. private _highlightsGain;
  125178. private _highlightsThreshold;
  125179. private _dofDistance;
  125180. private _dofAperture;
  125181. private _dofDarken;
  125182. private _dofPentagon;
  125183. private _blurNoise;
  125184. /**
  125185. * @constructor
  125186. *
  125187. * Effect parameters are as follow:
  125188. * {
  125189. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125190. * edge_blur: number; // from 0 to x (1 for realism)
  125191. * distortion: number; // from 0 to x (1 for realism)
  125192. * grain_amount: number; // from 0 to 1
  125193. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125194. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125195. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125196. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125197. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125198. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125199. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125200. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125201. * }
  125202. * Note: if an effect parameter is unset, effect is disabled
  125203. *
  125204. * @param name The rendering pipeline name
  125205. * @param parameters - An object containing all parameters (see above)
  125206. * @param scene The scene linked to this pipeline
  125207. * @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)
  125208. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125209. */
  125210. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125211. /**
  125212. * Get the class name
  125213. * @returns "LensRenderingPipeline"
  125214. */
  125215. getClassName(): string;
  125216. /**
  125217. * Gets associated scene
  125218. */
  125219. readonly scene: Scene;
  125220. /**
  125221. * Gets or sets the edge blur
  125222. */
  125223. edgeBlur: number;
  125224. /**
  125225. * Gets or sets the grain amount
  125226. */
  125227. grainAmount: number;
  125228. /**
  125229. * Gets or sets the chromatic aberration amount
  125230. */
  125231. chromaticAberration: number;
  125232. /**
  125233. * Gets or sets the depth of field aperture
  125234. */
  125235. dofAperture: number;
  125236. /**
  125237. * Gets or sets the edge distortion
  125238. */
  125239. edgeDistortion: number;
  125240. /**
  125241. * Gets or sets the depth of field distortion
  125242. */
  125243. dofDistortion: number;
  125244. /**
  125245. * Gets or sets the darken out of focus amount
  125246. */
  125247. darkenOutOfFocus: number;
  125248. /**
  125249. * Gets or sets a boolean indicating if blur noise is enabled
  125250. */
  125251. blurNoise: boolean;
  125252. /**
  125253. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125254. */
  125255. pentagonBokeh: boolean;
  125256. /**
  125257. * Gets or sets the highlight grain amount
  125258. */
  125259. highlightsGain: number;
  125260. /**
  125261. * Gets or sets the highlight threshold
  125262. */
  125263. highlightsThreshold: number;
  125264. /**
  125265. * Sets the amount of blur at the edges
  125266. * @param amount blur amount
  125267. */
  125268. setEdgeBlur(amount: number): void;
  125269. /**
  125270. * Sets edge blur to 0
  125271. */
  125272. disableEdgeBlur(): void;
  125273. /**
  125274. * Sets the amout of grain
  125275. * @param amount Amount of grain
  125276. */
  125277. setGrainAmount(amount: number): void;
  125278. /**
  125279. * Set grain amount to 0
  125280. */
  125281. disableGrain(): void;
  125282. /**
  125283. * Sets the chromatic aberration amount
  125284. * @param amount amount of chromatic aberration
  125285. */
  125286. setChromaticAberration(amount: number): void;
  125287. /**
  125288. * Sets chromatic aberration amount to 0
  125289. */
  125290. disableChromaticAberration(): void;
  125291. /**
  125292. * Sets the EdgeDistortion amount
  125293. * @param amount amount of EdgeDistortion
  125294. */
  125295. setEdgeDistortion(amount: number): void;
  125296. /**
  125297. * Sets edge distortion to 0
  125298. */
  125299. disableEdgeDistortion(): void;
  125300. /**
  125301. * Sets the FocusDistance amount
  125302. * @param amount amount of FocusDistance
  125303. */
  125304. setFocusDistance(amount: number): void;
  125305. /**
  125306. * Disables depth of field
  125307. */
  125308. disableDepthOfField(): void;
  125309. /**
  125310. * Sets the Aperture amount
  125311. * @param amount amount of Aperture
  125312. */
  125313. setAperture(amount: number): void;
  125314. /**
  125315. * Sets the DarkenOutOfFocus amount
  125316. * @param amount amount of DarkenOutOfFocus
  125317. */
  125318. setDarkenOutOfFocus(amount: number): void;
  125319. private _pentagonBokehIsEnabled;
  125320. /**
  125321. * Creates a pentagon bokeh effect
  125322. */
  125323. enablePentagonBokeh(): void;
  125324. /**
  125325. * Disables the pentagon bokeh effect
  125326. */
  125327. disablePentagonBokeh(): void;
  125328. /**
  125329. * Enables noise blur
  125330. */
  125331. enableNoiseBlur(): void;
  125332. /**
  125333. * Disables noise blur
  125334. */
  125335. disableNoiseBlur(): void;
  125336. /**
  125337. * Sets the HighlightsGain amount
  125338. * @param amount amount of HighlightsGain
  125339. */
  125340. setHighlightsGain(amount: number): void;
  125341. /**
  125342. * Sets the HighlightsThreshold amount
  125343. * @param amount amount of HighlightsThreshold
  125344. */
  125345. setHighlightsThreshold(amount: number): void;
  125346. /**
  125347. * Disables highlights
  125348. */
  125349. disableHighlights(): void;
  125350. /**
  125351. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125352. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125353. */
  125354. dispose(disableDepthRender?: boolean): void;
  125355. private _createChromaticAberrationPostProcess;
  125356. private _createHighlightsPostProcess;
  125357. private _createDepthOfFieldPostProcess;
  125358. private _createGrainTexture;
  125359. }
  125360. }
  125361. declare module BABYLON {
  125362. /** @hidden */
  125363. export var ssao2PixelShader: {
  125364. name: string;
  125365. shader: string;
  125366. };
  125367. }
  125368. declare module BABYLON {
  125369. /** @hidden */
  125370. export var ssaoCombinePixelShader: {
  125371. name: string;
  125372. shader: string;
  125373. };
  125374. }
  125375. declare module BABYLON {
  125376. /**
  125377. * Render pipeline to produce ssao effect
  125378. */
  125379. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125380. /**
  125381. * @ignore
  125382. * The PassPostProcess id in the pipeline that contains the original scene color
  125383. */
  125384. SSAOOriginalSceneColorEffect: string;
  125385. /**
  125386. * @ignore
  125387. * The SSAO PostProcess id in the pipeline
  125388. */
  125389. SSAORenderEffect: string;
  125390. /**
  125391. * @ignore
  125392. * The horizontal blur PostProcess id in the pipeline
  125393. */
  125394. SSAOBlurHRenderEffect: string;
  125395. /**
  125396. * @ignore
  125397. * The vertical blur PostProcess id in the pipeline
  125398. */
  125399. SSAOBlurVRenderEffect: string;
  125400. /**
  125401. * @ignore
  125402. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125403. */
  125404. SSAOCombineRenderEffect: string;
  125405. /**
  125406. * The output strength of the SSAO post-process. Default value is 1.0.
  125407. */
  125408. totalStrength: number;
  125409. /**
  125410. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125411. */
  125412. maxZ: number;
  125413. /**
  125414. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125415. */
  125416. minZAspect: number;
  125417. private _samples;
  125418. /**
  125419. * Number of samples used for the SSAO calculations. Default value is 8
  125420. */
  125421. samples: number;
  125422. private _textureSamples;
  125423. /**
  125424. * Number of samples to use for antialiasing
  125425. */
  125426. textureSamples: number;
  125427. /**
  125428. * Ratio object used for SSAO ratio and blur ratio
  125429. */
  125430. private _ratio;
  125431. /**
  125432. * Dynamically generated sphere sampler.
  125433. */
  125434. private _sampleSphere;
  125435. /**
  125436. * Blur filter offsets
  125437. */
  125438. private _samplerOffsets;
  125439. private _expensiveBlur;
  125440. /**
  125441. * If bilateral blur should be used
  125442. */
  125443. expensiveBlur: boolean;
  125444. /**
  125445. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125446. */
  125447. radius: number;
  125448. /**
  125449. * The base color of the SSAO post-process
  125450. * The final result is "base + ssao" between [0, 1]
  125451. */
  125452. base: number;
  125453. /**
  125454. * Support test.
  125455. */
  125456. static readonly IsSupported: boolean;
  125457. private _scene;
  125458. private _depthTexture;
  125459. private _normalTexture;
  125460. private _randomTexture;
  125461. private _originalColorPostProcess;
  125462. private _ssaoPostProcess;
  125463. private _blurHPostProcess;
  125464. private _blurVPostProcess;
  125465. private _ssaoCombinePostProcess;
  125466. private _firstUpdate;
  125467. /**
  125468. * Gets active scene
  125469. */
  125470. readonly scene: Scene;
  125471. /**
  125472. * @constructor
  125473. * @param name The rendering pipeline name
  125474. * @param scene The scene linked to this pipeline
  125475. * @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 }
  125476. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125477. */
  125478. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125479. /**
  125480. * Get the class name
  125481. * @returns "SSAO2RenderingPipeline"
  125482. */
  125483. getClassName(): string;
  125484. /**
  125485. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125486. */
  125487. dispose(disableGeometryBufferRenderer?: boolean): void;
  125488. private _createBlurPostProcess;
  125489. /** @hidden */
  125490. _rebuild(): void;
  125491. private _bits;
  125492. private _radicalInverse_VdC;
  125493. private _hammersley;
  125494. private _hemisphereSample_uniform;
  125495. private _generateHemisphere;
  125496. private _createSSAOPostProcess;
  125497. private _createSSAOCombinePostProcess;
  125498. private _createRandomTexture;
  125499. /**
  125500. * Serialize the rendering pipeline (Used when exporting)
  125501. * @returns the serialized object
  125502. */
  125503. serialize(): any;
  125504. /**
  125505. * Parse the serialized pipeline
  125506. * @param source Source pipeline.
  125507. * @param scene The scene to load the pipeline to.
  125508. * @param rootUrl The URL of the serialized pipeline.
  125509. * @returns An instantiated pipeline from the serialized object.
  125510. */
  125511. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125512. }
  125513. }
  125514. declare module BABYLON {
  125515. /** @hidden */
  125516. export var ssaoPixelShader: {
  125517. name: string;
  125518. shader: string;
  125519. };
  125520. }
  125521. declare module BABYLON {
  125522. /**
  125523. * Render pipeline to produce ssao effect
  125524. */
  125525. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125526. /**
  125527. * @ignore
  125528. * The PassPostProcess id in the pipeline that contains the original scene color
  125529. */
  125530. SSAOOriginalSceneColorEffect: string;
  125531. /**
  125532. * @ignore
  125533. * The SSAO PostProcess id in the pipeline
  125534. */
  125535. SSAORenderEffect: string;
  125536. /**
  125537. * @ignore
  125538. * The horizontal blur PostProcess id in the pipeline
  125539. */
  125540. SSAOBlurHRenderEffect: string;
  125541. /**
  125542. * @ignore
  125543. * The vertical blur PostProcess id in the pipeline
  125544. */
  125545. SSAOBlurVRenderEffect: string;
  125546. /**
  125547. * @ignore
  125548. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125549. */
  125550. SSAOCombineRenderEffect: string;
  125551. /**
  125552. * The output strength of the SSAO post-process. Default value is 1.0.
  125553. */
  125554. totalStrength: number;
  125555. /**
  125556. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125557. */
  125558. radius: number;
  125559. /**
  125560. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125561. * Must not be equal to fallOff and superior to fallOff.
  125562. * Default value is 0.0075
  125563. */
  125564. area: number;
  125565. /**
  125566. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125567. * Must not be equal to area and inferior to area.
  125568. * Default value is 0.000001
  125569. */
  125570. fallOff: number;
  125571. /**
  125572. * The base color of the SSAO post-process
  125573. * The final result is "base + ssao" between [0, 1]
  125574. */
  125575. base: number;
  125576. private _scene;
  125577. private _depthTexture;
  125578. private _randomTexture;
  125579. private _originalColorPostProcess;
  125580. private _ssaoPostProcess;
  125581. private _blurHPostProcess;
  125582. private _blurVPostProcess;
  125583. private _ssaoCombinePostProcess;
  125584. private _firstUpdate;
  125585. /**
  125586. * Gets active scene
  125587. */
  125588. readonly scene: Scene;
  125589. /**
  125590. * @constructor
  125591. * @param name - The rendering pipeline name
  125592. * @param scene - The scene linked to this pipeline
  125593. * @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 }
  125594. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125595. */
  125596. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125597. /**
  125598. * Get the class name
  125599. * @returns "SSAORenderingPipeline"
  125600. */
  125601. getClassName(): string;
  125602. /**
  125603. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125604. */
  125605. dispose(disableDepthRender?: boolean): void;
  125606. private _createBlurPostProcess;
  125607. /** @hidden */
  125608. _rebuild(): void;
  125609. private _createSSAOPostProcess;
  125610. private _createSSAOCombinePostProcess;
  125611. private _createRandomTexture;
  125612. }
  125613. }
  125614. declare module BABYLON {
  125615. /** @hidden */
  125616. export var standardPixelShader: {
  125617. name: string;
  125618. shader: string;
  125619. };
  125620. }
  125621. declare module BABYLON {
  125622. /**
  125623. * Standard rendering pipeline
  125624. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125625. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125626. */
  125627. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125628. /**
  125629. * Public members
  125630. */
  125631. /**
  125632. * Post-process which contains the original scene color before the pipeline applies all the effects
  125633. */
  125634. originalPostProcess: Nullable<PostProcess>;
  125635. /**
  125636. * Post-process used to down scale an image x4
  125637. */
  125638. downSampleX4PostProcess: Nullable<PostProcess>;
  125639. /**
  125640. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125641. */
  125642. brightPassPostProcess: Nullable<PostProcess>;
  125643. /**
  125644. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125645. */
  125646. blurHPostProcesses: PostProcess[];
  125647. /**
  125648. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125649. */
  125650. blurVPostProcesses: PostProcess[];
  125651. /**
  125652. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125653. */
  125654. textureAdderPostProcess: Nullable<PostProcess>;
  125655. /**
  125656. * Post-process used to create volumetric lighting effect
  125657. */
  125658. volumetricLightPostProcess: Nullable<PostProcess>;
  125659. /**
  125660. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125661. */
  125662. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125663. /**
  125664. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125665. */
  125666. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125667. /**
  125668. * Post-process used to merge the volumetric light effect and the real scene color
  125669. */
  125670. volumetricLightMergePostProces: Nullable<PostProcess>;
  125671. /**
  125672. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125673. */
  125674. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125675. /**
  125676. * Base post-process used to calculate the average luminance of the final image for HDR
  125677. */
  125678. luminancePostProcess: Nullable<PostProcess>;
  125679. /**
  125680. * Post-processes used to create down sample post-processes in order to get
  125681. * the average luminance of the final image for HDR
  125682. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125683. */
  125684. luminanceDownSamplePostProcesses: PostProcess[];
  125685. /**
  125686. * Post-process used to create a HDR effect (light adaptation)
  125687. */
  125688. hdrPostProcess: Nullable<PostProcess>;
  125689. /**
  125690. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125691. */
  125692. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125693. /**
  125694. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125695. */
  125696. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125697. /**
  125698. * Post-process used to merge the final HDR post-process and the real scene color
  125699. */
  125700. hdrFinalPostProcess: Nullable<PostProcess>;
  125701. /**
  125702. * Post-process used to create a lens flare effect
  125703. */
  125704. lensFlarePostProcess: Nullable<PostProcess>;
  125705. /**
  125706. * Post-process that merges the result of the lens flare post-process and the real scene color
  125707. */
  125708. lensFlareComposePostProcess: Nullable<PostProcess>;
  125709. /**
  125710. * Post-process used to create a motion blur effect
  125711. */
  125712. motionBlurPostProcess: Nullable<PostProcess>;
  125713. /**
  125714. * Post-process used to create a depth of field effect
  125715. */
  125716. depthOfFieldPostProcess: Nullable<PostProcess>;
  125717. /**
  125718. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125719. */
  125720. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125721. /**
  125722. * Represents the brightness threshold in order to configure the illuminated surfaces
  125723. */
  125724. brightThreshold: number;
  125725. /**
  125726. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125727. */
  125728. blurWidth: number;
  125729. /**
  125730. * Sets if the blur for highlighted surfaces must be only horizontal
  125731. */
  125732. horizontalBlur: boolean;
  125733. /**
  125734. * Gets the overall exposure used by the pipeline
  125735. */
  125736. /**
  125737. * Sets the overall exposure used by the pipeline
  125738. */
  125739. exposure: number;
  125740. /**
  125741. * Texture used typically to simulate "dirty" on camera lens
  125742. */
  125743. lensTexture: Nullable<Texture>;
  125744. /**
  125745. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125746. */
  125747. volumetricLightCoefficient: number;
  125748. /**
  125749. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125750. */
  125751. volumetricLightPower: number;
  125752. /**
  125753. * Used the set the blur intensity to smooth the volumetric lights
  125754. */
  125755. volumetricLightBlurScale: number;
  125756. /**
  125757. * Light (spot or directional) used to generate the volumetric lights rays
  125758. * The source light must have a shadow generate so the pipeline can get its
  125759. * depth map
  125760. */
  125761. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125762. /**
  125763. * For eye adaptation, represents the minimum luminance the eye can see
  125764. */
  125765. hdrMinimumLuminance: number;
  125766. /**
  125767. * For eye adaptation, represents the decrease luminance speed
  125768. */
  125769. hdrDecreaseRate: number;
  125770. /**
  125771. * For eye adaptation, represents the increase luminance speed
  125772. */
  125773. hdrIncreaseRate: number;
  125774. /**
  125775. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125776. */
  125777. /**
  125778. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125779. */
  125780. hdrAutoExposure: boolean;
  125781. /**
  125782. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125783. */
  125784. lensColorTexture: Nullable<Texture>;
  125785. /**
  125786. * The overall strengh for the lens flare effect
  125787. */
  125788. lensFlareStrength: number;
  125789. /**
  125790. * Dispersion coefficient for lens flare ghosts
  125791. */
  125792. lensFlareGhostDispersal: number;
  125793. /**
  125794. * Main lens flare halo width
  125795. */
  125796. lensFlareHaloWidth: number;
  125797. /**
  125798. * Based on the lens distortion effect, defines how much the lens flare result
  125799. * is distorted
  125800. */
  125801. lensFlareDistortionStrength: number;
  125802. /**
  125803. * Configures the blur intensity used for for lens flare (halo)
  125804. */
  125805. lensFlareBlurWidth: number;
  125806. /**
  125807. * Lens star texture must be used to simulate rays on the flares and is available
  125808. * in the documentation
  125809. */
  125810. lensStarTexture: Nullable<Texture>;
  125811. /**
  125812. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125813. * flare effect by taking account of the dirt texture
  125814. */
  125815. lensFlareDirtTexture: Nullable<Texture>;
  125816. /**
  125817. * Represents the focal length for the depth of field effect
  125818. */
  125819. depthOfFieldDistance: number;
  125820. /**
  125821. * Represents the blur intensity for the blurred part of the depth of field effect
  125822. */
  125823. depthOfFieldBlurWidth: number;
  125824. /**
  125825. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125826. */
  125827. /**
  125828. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125829. */
  125830. motionStrength: number;
  125831. /**
  125832. * Gets wether or not the motion blur post-process is object based or screen based.
  125833. */
  125834. /**
  125835. * Sets wether or not the motion blur post-process should be object based or screen based
  125836. */
  125837. objectBasedMotionBlur: boolean;
  125838. /**
  125839. * List of animations for the pipeline (IAnimatable implementation)
  125840. */
  125841. animations: Animation[];
  125842. /**
  125843. * Private members
  125844. */
  125845. private _scene;
  125846. private _currentDepthOfFieldSource;
  125847. private _basePostProcess;
  125848. private _fixedExposure;
  125849. private _currentExposure;
  125850. private _hdrAutoExposure;
  125851. private _hdrCurrentLuminance;
  125852. private _motionStrength;
  125853. private _isObjectBasedMotionBlur;
  125854. private _floatTextureType;
  125855. private _camerasToBeAttached;
  125856. private _ratio;
  125857. private _bloomEnabled;
  125858. private _depthOfFieldEnabled;
  125859. private _vlsEnabled;
  125860. private _lensFlareEnabled;
  125861. private _hdrEnabled;
  125862. private _motionBlurEnabled;
  125863. private _fxaaEnabled;
  125864. private _motionBlurSamples;
  125865. private _volumetricLightStepsCount;
  125866. private _samples;
  125867. /**
  125868. * @ignore
  125869. * Specifies if the bloom pipeline is enabled
  125870. */
  125871. BloomEnabled: boolean;
  125872. /**
  125873. * @ignore
  125874. * Specifies if the depth of field pipeline is enabed
  125875. */
  125876. DepthOfFieldEnabled: boolean;
  125877. /**
  125878. * @ignore
  125879. * Specifies if the lens flare pipeline is enabed
  125880. */
  125881. LensFlareEnabled: boolean;
  125882. /**
  125883. * @ignore
  125884. * Specifies if the HDR pipeline is enabled
  125885. */
  125886. HDREnabled: boolean;
  125887. /**
  125888. * @ignore
  125889. * Specifies if the volumetric lights scattering effect is enabled
  125890. */
  125891. VLSEnabled: boolean;
  125892. /**
  125893. * @ignore
  125894. * Specifies if the motion blur effect is enabled
  125895. */
  125896. MotionBlurEnabled: boolean;
  125897. /**
  125898. * Specifies if anti-aliasing is enabled
  125899. */
  125900. fxaaEnabled: boolean;
  125901. /**
  125902. * Specifies the number of steps used to calculate the volumetric lights
  125903. * Typically in interval [50, 200]
  125904. */
  125905. volumetricLightStepsCount: number;
  125906. /**
  125907. * Specifies the number of samples used for the motion blur effect
  125908. * Typically in interval [16, 64]
  125909. */
  125910. motionBlurSamples: number;
  125911. /**
  125912. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125913. */
  125914. samples: number;
  125915. /**
  125916. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125917. * @constructor
  125918. * @param name The rendering pipeline name
  125919. * @param scene The scene linked to this pipeline
  125920. * @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)
  125921. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125922. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125923. */
  125924. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125925. private _buildPipeline;
  125926. private _createDownSampleX4PostProcess;
  125927. private _createBrightPassPostProcess;
  125928. private _createBlurPostProcesses;
  125929. private _createTextureAdderPostProcess;
  125930. private _createVolumetricLightPostProcess;
  125931. private _createLuminancePostProcesses;
  125932. private _createHdrPostProcess;
  125933. private _createLensFlarePostProcess;
  125934. private _createDepthOfFieldPostProcess;
  125935. private _createMotionBlurPostProcess;
  125936. private _getDepthTexture;
  125937. private _disposePostProcesses;
  125938. /**
  125939. * Dispose of the pipeline and stop all post processes
  125940. */
  125941. dispose(): void;
  125942. /**
  125943. * Serialize the rendering pipeline (Used when exporting)
  125944. * @returns the serialized object
  125945. */
  125946. serialize(): any;
  125947. /**
  125948. * Parse the serialized pipeline
  125949. * @param source Source pipeline.
  125950. * @param scene The scene to load the pipeline to.
  125951. * @param rootUrl The URL of the serialized pipeline.
  125952. * @returns An instantiated pipeline from the serialized object.
  125953. */
  125954. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125955. /**
  125956. * Luminance steps
  125957. */
  125958. static LuminanceSteps: number;
  125959. }
  125960. }
  125961. declare module BABYLON {
  125962. /** @hidden */
  125963. export var tonemapPixelShader: {
  125964. name: string;
  125965. shader: string;
  125966. };
  125967. }
  125968. declare module BABYLON {
  125969. /** Defines operator used for tonemapping */
  125970. export enum TonemappingOperator {
  125971. /** Hable */
  125972. Hable = 0,
  125973. /** Reinhard */
  125974. Reinhard = 1,
  125975. /** HejiDawson */
  125976. HejiDawson = 2,
  125977. /** Photographic */
  125978. Photographic = 3
  125979. }
  125980. /**
  125981. * Defines a post process to apply tone mapping
  125982. */
  125983. export class TonemapPostProcess extends PostProcess {
  125984. private _operator;
  125985. /** Defines the required exposure adjustement */
  125986. exposureAdjustment: number;
  125987. /**
  125988. * Creates a new TonemapPostProcess
  125989. * @param name defines the name of the postprocess
  125990. * @param _operator defines the operator to use
  125991. * @param exposureAdjustment defines the required exposure adjustement
  125992. * @param camera defines the camera to use (can be null)
  125993. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125994. * @param engine defines the hosting engine (can be ignore if camera is set)
  125995. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125996. */
  125997. constructor(name: string, _operator: TonemappingOperator,
  125998. /** Defines the required exposure adjustement */
  125999. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  126000. }
  126001. }
  126002. declare module BABYLON {
  126003. /** @hidden */
  126004. export var depthVertexShader: {
  126005. name: string;
  126006. shader: string;
  126007. };
  126008. }
  126009. declare module BABYLON {
  126010. /** @hidden */
  126011. export var volumetricLightScatteringPixelShader: {
  126012. name: string;
  126013. shader: string;
  126014. };
  126015. }
  126016. declare module BABYLON {
  126017. /** @hidden */
  126018. export var volumetricLightScatteringPassVertexShader: {
  126019. name: string;
  126020. shader: string;
  126021. };
  126022. }
  126023. declare module BABYLON {
  126024. /** @hidden */
  126025. export var volumetricLightScatteringPassPixelShader: {
  126026. name: string;
  126027. shader: string;
  126028. };
  126029. }
  126030. declare module BABYLON {
  126031. /**
  126032. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126033. */
  126034. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126035. private _volumetricLightScatteringPass;
  126036. private _volumetricLightScatteringRTT;
  126037. private _viewPort;
  126038. private _screenCoordinates;
  126039. private _cachedDefines;
  126040. /**
  126041. * If not undefined, the mesh position is computed from the attached node position
  126042. */
  126043. attachedNode: {
  126044. position: Vector3;
  126045. };
  126046. /**
  126047. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126048. */
  126049. customMeshPosition: Vector3;
  126050. /**
  126051. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126052. */
  126053. useCustomMeshPosition: boolean;
  126054. /**
  126055. * If the post-process should inverse the light scattering direction
  126056. */
  126057. invert: boolean;
  126058. /**
  126059. * The internal mesh used by the post-process
  126060. */
  126061. mesh: Mesh;
  126062. /**
  126063. * @hidden
  126064. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126065. */
  126066. useDiffuseColor: boolean;
  126067. /**
  126068. * Array containing the excluded meshes not rendered in the internal pass
  126069. */
  126070. excludedMeshes: AbstractMesh[];
  126071. /**
  126072. * Controls the overall intensity of the post-process
  126073. */
  126074. exposure: number;
  126075. /**
  126076. * Dissipates each sample's contribution in range [0, 1]
  126077. */
  126078. decay: number;
  126079. /**
  126080. * Controls the overall intensity of each sample
  126081. */
  126082. weight: number;
  126083. /**
  126084. * Controls the density of each sample
  126085. */
  126086. density: number;
  126087. /**
  126088. * @constructor
  126089. * @param name The post-process name
  126090. * @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)
  126091. * @param camera The camera that the post-process will be attached to
  126092. * @param mesh The mesh used to create the light scattering
  126093. * @param samples The post-process quality, default 100
  126094. * @param samplingModeThe post-process filtering mode
  126095. * @param engine The babylon engine
  126096. * @param reusable If the post-process is reusable
  126097. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126098. */
  126099. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126100. /**
  126101. * Returns the string "VolumetricLightScatteringPostProcess"
  126102. * @returns "VolumetricLightScatteringPostProcess"
  126103. */
  126104. getClassName(): string;
  126105. private _isReady;
  126106. /**
  126107. * Sets the new light position for light scattering effect
  126108. * @param position The new custom light position
  126109. */
  126110. setCustomMeshPosition(position: Vector3): void;
  126111. /**
  126112. * Returns the light position for light scattering effect
  126113. * @return Vector3 The custom light position
  126114. */
  126115. getCustomMeshPosition(): Vector3;
  126116. /**
  126117. * Disposes the internal assets and detaches the post-process from the camera
  126118. */
  126119. dispose(camera: Camera): void;
  126120. /**
  126121. * Returns the render target texture used by the post-process
  126122. * @return the render target texture used by the post-process
  126123. */
  126124. getPass(): RenderTargetTexture;
  126125. private _meshExcluded;
  126126. private _createPass;
  126127. private _updateMeshScreenCoordinates;
  126128. /**
  126129. * Creates a default mesh for the Volumeric Light Scattering post-process
  126130. * @param name The mesh name
  126131. * @param scene The scene where to create the mesh
  126132. * @return the default mesh
  126133. */
  126134. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126135. }
  126136. }
  126137. declare module BABYLON {
  126138. interface Scene {
  126139. /** @hidden (Backing field) */
  126140. _boundingBoxRenderer: BoundingBoxRenderer;
  126141. /** @hidden (Backing field) */
  126142. _forceShowBoundingBoxes: boolean;
  126143. /**
  126144. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126145. */
  126146. forceShowBoundingBoxes: boolean;
  126147. /**
  126148. * Gets the bounding box renderer associated with the scene
  126149. * @returns a BoundingBoxRenderer
  126150. */
  126151. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126152. }
  126153. interface AbstractMesh {
  126154. /** @hidden (Backing field) */
  126155. _showBoundingBox: boolean;
  126156. /**
  126157. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126158. */
  126159. showBoundingBox: boolean;
  126160. }
  126161. /**
  126162. * Component responsible of rendering the bounding box of the meshes in a scene.
  126163. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126164. */
  126165. export class BoundingBoxRenderer implements ISceneComponent {
  126166. /**
  126167. * The component name helpfull to identify the component in the list of scene components.
  126168. */
  126169. readonly name: string;
  126170. /**
  126171. * The scene the component belongs to.
  126172. */
  126173. scene: Scene;
  126174. /**
  126175. * Color of the bounding box lines placed in front of an object
  126176. */
  126177. frontColor: Color3;
  126178. /**
  126179. * Color of the bounding box lines placed behind an object
  126180. */
  126181. backColor: Color3;
  126182. /**
  126183. * Defines if the renderer should show the back lines or not
  126184. */
  126185. showBackLines: boolean;
  126186. /**
  126187. * @hidden
  126188. */
  126189. renderList: SmartArray<BoundingBox>;
  126190. private _colorShader;
  126191. private _vertexBuffers;
  126192. private _indexBuffer;
  126193. private _fillIndexBuffer;
  126194. private _fillIndexData;
  126195. /**
  126196. * Instantiates a new bounding box renderer in a scene.
  126197. * @param scene the scene the renderer renders in
  126198. */
  126199. constructor(scene: Scene);
  126200. /**
  126201. * Registers the component in a given scene
  126202. */
  126203. register(): void;
  126204. private _evaluateSubMesh;
  126205. private _activeMesh;
  126206. private _prepareRessources;
  126207. private _createIndexBuffer;
  126208. /**
  126209. * Rebuilds the elements related to this component in case of
  126210. * context lost for instance.
  126211. */
  126212. rebuild(): void;
  126213. /**
  126214. * @hidden
  126215. */
  126216. reset(): void;
  126217. /**
  126218. * Render the bounding boxes of a specific rendering group
  126219. * @param renderingGroupId defines the rendering group to render
  126220. */
  126221. render(renderingGroupId: number): void;
  126222. /**
  126223. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126224. * @param mesh Define the mesh to render the occlusion bounding box for
  126225. */
  126226. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126227. /**
  126228. * Dispose and release the resources attached to this renderer.
  126229. */
  126230. dispose(): void;
  126231. }
  126232. }
  126233. declare module BABYLON {
  126234. /** @hidden */
  126235. export var depthPixelShader: {
  126236. name: string;
  126237. shader: string;
  126238. };
  126239. }
  126240. declare module BABYLON {
  126241. /**
  126242. * This represents a depth renderer in Babylon.
  126243. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126244. */
  126245. export class DepthRenderer {
  126246. private _scene;
  126247. private _depthMap;
  126248. private _effect;
  126249. private readonly _storeNonLinearDepth;
  126250. private readonly _clearColor;
  126251. /** Get if the depth renderer is using packed depth or not */
  126252. readonly isPacked: boolean;
  126253. private _cachedDefines;
  126254. private _camera;
  126255. /**
  126256. * Specifiess that the depth renderer will only be used within
  126257. * the camera it is created for.
  126258. * This can help forcing its rendering during the camera processing.
  126259. */
  126260. useOnlyInActiveCamera: boolean;
  126261. /** @hidden */
  126262. static _SceneComponentInitialization: (scene: Scene) => void;
  126263. /**
  126264. * Instantiates a depth renderer
  126265. * @param scene The scene the renderer belongs to
  126266. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126267. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126268. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126269. */
  126270. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126271. /**
  126272. * Creates the depth rendering effect and checks if the effect is ready.
  126273. * @param subMesh The submesh to be used to render the depth map of
  126274. * @param useInstances If multiple world instances should be used
  126275. * @returns if the depth renderer is ready to render the depth map
  126276. */
  126277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126278. /**
  126279. * Gets the texture which the depth map will be written to.
  126280. * @returns The depth map texture
  126281. */
  126282. getDepthMap(): RenderTargetTexture;
  126283. /**
  126284. * Disposes of the depth renderer.
  126285. */
  126286. dispose(): void;
  126287. }
  126288. }
  126289. declare module BABYLON {
  126290. interface Scene {
  126291. /** @hidden (Backing field) */
  126292. _depthRenderer: {
  126293. [id: string]: DepthRenderer;
  126294. };
  126295. /**
  126296. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126297. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126298. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126299. * @returns the created depth renderer
  126300. */
  126301. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126302. /**
  126303. * Disables a depth renderer for a given camera
  126304. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126305. */
  126306. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126307. }
  126308. /**
  126309. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126310. * in several rendering techniques.
  126311. */
  126312. export class DepthRendererSceneComponent implements ISceneComponent {
  126313. /**
  126314. * The component name helpfull to identify the component in the list of scene components.
  126315. */
  126316. readonly name: string;
  126317. /**
  126318. * The scene the component belongs to.
  126319. */
  126320. scene: Scene;
  126321. /**
  126322. * Creates a new instance of the component for the given scene
  126323. * @param scene Defines the scene to register the component in
  126324. */
  126325. constructor(scene: Scene);
  126326. /**
  126327. * Registers the component in a given scene
  126328. */
  126329. register(): void;
  126330. /**
  126331. * Rebuilds the elements related to this component in case of
  126332. * context lost for instance.
  126333. */
  126334. rebuild(): void;
  126335. /**
  126336. * Disposes the component and the associated ressources
  126337. */
  126338. dispose(): void;
  126339. private _gatherRenderTargets;
  126340. private _gatherActiveCameraRenderTargets;
  126341. }
  126342. }
  126343. declare module BABYLON {
  126344. /** @hidden */
  126345. export var outlinePixelShader: {
  126346. name: string;
  126347. shader: string;
  126348. };
  126349. }
  126350. declare module BABYLON {
  126351. /** @hidden */
  126352. export var outlineVertexShader: {
  126353. name: string;
  126354. shader: string;
  126355. };
  126356. }
  126357. declare module BABYLON {
  126358. interface Scene {
  126359. /** @hidden */
  126360. _outlineRenderer: OutlineRenderer;
  126361. /**
  126362. * Gets the outline renderer associated with the scene
  126363. * @returns a OutlineRenderer
  126364. */
  126365. getOutlineRenderer(): OutlineRenderer;
  126366. }
  126367. interface AbstractMesh {
  126368. /** @hidden (Backing field) */
  126369. _renderOutline: boolean;
  126370. /**
  126371. * Gets or sets a boolean indicating if the outline must be rendered as well
  126372. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126373. */
  126374. renderOutline: boolean;
  126375. /** @hidden (Backing field) */
  126376. _renderOverlay: boolean;
  126377. /**
  126378. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126379. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126380. */
  126381. renderOverlay: boolean;
  126382. }
  126383. /**
  126384. * This class is responsible to draw bothe outline/overlay of meshes.
  126385. * It should not be used directly but through the available method on mesh.
  126386. */
  126387. export class OutlineRenderer implements ISceneComponent {
  126388. /**
  126389. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126390. */
  126391. private static _StencilReference;
  126392. /**
  126393. * The name of the component. Each component must have a unique name.
  126394. */
  126395. name: string;
  126396. /**
  126397. * The scene the component belongs to.
  126398. */
  126399. scene: Scene;
  126400. /**
  126401. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126402. */
  126403. zOffset: number;
  126404. private _engine;
  126405. private _effect;
  126406. private _cachedDefines;
  126407. private _savedDepthWrite;
  126408. /**
  126409. * Instantiates a new outline renderer. (There could be only one per scene).
  126410. * @param scene Defines the scene it belongs to
  126411. */
  126412. constructor(scene: Scene);
  126413. /**
  126414. * Register the component to one instance of a scene.
  126415. */
  126416. register(): void;
  126417. /**
  126418. * Rebuilds the elements related to this component in case of
  126419. * context lost for instance.
  126420. */
  126421. rebuild(): void;
  126422. /**
  126423. * Disposes the component and the associated ressources.
  126424. */
  126425. dispose(): void;
  126426. /**
  126427. * Renders the outline in the canvas.
  126428. * @param subMesh Defines the sumesh to render
  126429. * @param batch Defines the batch of meshes in case of instances
  126430. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126431. */
  126432. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126433. /**
  126434. * Returns whether or not the outline renderer is ready for a given submesh.
  126435. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126436. * @param subMesh Defines the submesh to check readyness for
  126437. * @param useInstances Defines wheter wee are trying to render instances or not
  126438. * @returns true if ready otherwise false
  126439. */
  126440. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126441. private _beforeRenderingMesh;
  126442. private _afterRenderingMesh;
  126443. }
  126444. }
  126445. declare module BABYLON {
  126446. /**
  126447. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126448. * @see http://doc.babylonjs.com/babylon101/sprites
  126449. */
  126450. export class SpritePackedManager extends SpriteManager {
  126451. /** defines the packed manager's name */
  126452. name: string;
  126453. /**
  126454. * Creates a new sprite manager from a packed sprite sheet
  126455. * @param name defines the manager's name
  126456. * @param imgUrl defines the sprite sheet url
  126457. * @param capacity defines the maximum allowed number of sprites
  126458. * @param scene defines the hosting scene
  126459. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126460. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126461. * @param samplingMode defines the smapling mode to use with spritesheet
  126462. * @param fromPacked set to true; do not alter
  126463. */
  126464. constructor(
  126465. /** defines the packed manager's name */
  126466. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126467. }
  126468. }
  126469. declare module BABYLON {
  126470. /**
  126471. * Defines the list of states available for a task inside a AssetsManager
  126472. */
  126473. export enum AssetTaskState {
  126474. /**
  126475. * Initialization
  126476. */
  126477. INIT = 0,
  126478. /**
  126479. * Running
  126480. */
  126481. RUNNING = 1,
  126482. /**
  126483. * Done
  126484. */
  126485. DONE = 2,
  126486. /**
  126487. * Error
  126488. */
  126489. ERROR = 3
  126490. }
  126491. /**
  126492. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126493. */
  126494. export abstract class AbstractAssetTask {
  126495. /**
  126496. * Task name
  126497. */ name: string;
  126498. /**
  126499. * Callback called when the task is successful
  126500. */
  126501. onSuccess: (task: any) => void;
  126502. /**
  126503. * Callback called when the task is not successful
  126504. */
  126505. onError: (task: any, message?: string, exception?: any) => void;
  126506. /**
  126507. * Creates a new AssetsManager
  126508. * @param name defines the name of the task
  126509. */
  126510. constructor(
  126511. /**
  126512. * Task name
  126513. */ name: string);
  126514. private _isCompleted;
  126515. private _taskState;
  126516. private _errorObject;
  126517. /**
  126518. * Get if the task is completed
  126519. */
  126520. readonly isCompleted: boolean;
  126521. /**
  126522. * Gets the current state of the task
  126523. */
  126524. readonly taskState: AssetTaskState;
  126525. /**
  126526. * Gets the current error object (if task is in error)
  126527. */
  126528. readonly errorObject: {
  126529. message?: string;
  126530. exception?: any;
  126531. };
  126532. /**
  126533. * Internal only
  126534. * @hidden
  126535. */
  126536. _setErrorObject(message?: string, exception?: any): void;
  126537. /**
  126538. * Execute the current task
  126539. * @param scene defines the scene where you want your assets to be loaded
  126540. * @param onSuccess is a callback called when the task is successfully executed
  126541. * @param onError is a callback called if an error occurs
  126542. */
  126543. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126544. /**
  126545. * Execute the current task
  126546. * @param scene defines the scene where you want your assets to be loaded
  126547. * @param onSuccess is a callback called when the task is successfully executed
  126548. * @param onError is a callback called if an error occurs
  126549. */
  126550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126551. /**
  126552. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126553. * This can be used with failed tasks that have the reason for failure fixed.
  126554. */
  126555. reset(): void;
  126556. private onErrorCallback;
  126557. private onDoneCallback;
  126558. }
  126559. /**
  126560. * Define the interface used by progress events raised during assets loading
  126561. */
  126562. export interface IAssetsProgressEvent {
  126563. /**
  126564. * Defines the number of remaining tasks to process
  126565. */
  126566. remainingCount: number;
  126567. /**
  126568. * Defines the total number of tasks
  126569. */
  126570. totalCount: number;
  126571. /**
  126572. * Defines the task that was just processed
  126573. */
  126574. task: AbstractAssetTask;
  126575. }
  126576. /**
  126577. * Class used to share progress information about assets loading
  126578. */
  126579. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126580. /**
  126581. * Defines the number of remaining tasks to process
  126582. */
  126583. remainingCount: number;
  126584. /**
  126585. * Defines the total number of tasks
  126586. */
  126587. totalCount: number;
  126588. /**
  126589. * Defines the task that was just processed
  126590. */
  126591. task: AbstractAssetTask;
  126592. /**
  126593. * Creates a AssetsProgressEvent
  126594. * @param remainingCount defines the number of remaining tasks to process
  126595. * @param totalCount defines the total number of tasks
  126596. * @param task defines the task that was just processed
  126597. */
  126598. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126599. }
  126600. /**
  126601. * Define a task used by AssetsManager to load meshes
  126602. */
  126603. export class MeshAssetTask extends AbstractAssetTask {
  126604. /**
  126605. * Defines the name of the task
  126606. */
  126607. name: string;
  126608. /**
  126609. * Defines the list of mesh's names you want to load
  126610. */
  126611. meshesNames: any;
  126612. /**
  126613. * Defines the root url to use as a base to load your meshes and associated resources
  126614. */
  126615. rootUrl: string;
  126616. /**
  126617. * Defines the filename of the scene to load from
  126618. */
  126619. sceneFilename: string;
  126620. /**
  126621. * Gets the list of loaded meshes
  126622. */
  126623. loadedMeshes: Array<AbstractMesh>;
  126624. /**
  126625. * Gets the list of loaded particle systems
  126626. */
  126627. loadedParticleSystems: Array<IParticleSystem>;
  126628. /**
  126629. * Gets the list of loaded skeletons
  126630. */
  126631. loadedSkeletons: Array<Skeleton>;
  126632. /**
  126633. * Gets the list of loaded animation groups
  126634. */
  126635. loadedAnimationGroups: Array<AnimationGroup>;
  126636. /**
  126637. * Callback called when the task is successful
  126638. */
  126639. onSuccess: (task: MeshAssetTask) => void;
  126640. /**
  126641. * Callback called when the task is successful
  126642. */
  126643. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126644. /**
  126645. * Creates a new MeshAssetTask
  126646. * @param name defines the name of the task
  126647. * @param meshesNames defines the list of mesh's names you want to load
  126648. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126649. * @param sceneFilename defines the filename of the scene to load from
  126650. */
  126651. constructor(
  126652. /**
  126653. * Defines the name of the task
  126654. */
  126655. name: string,
  126656. /**
  126657. * Defines the list of mesh's names you want to load
  126658. */
  126659. meshesNames: any,
  126660. /**
  126661. * Defines the root url to use as a base to load your meshes and associated resources
  126662. */
  126663. rootUrl: string,
  126664. /**
  126665. * Defines the filename of the scene to load from
  126666. */
  126667. sceneFilename: string);
  126668. /**
  126669. * Execute the current task
  126670. * @param scene defines the scene where you want your assets to be loaded
  126671. * @param onSuccess is a callback called when the task is successfully executed
  126672. * @param onError is a callback called if an error occurs
  126673. */
  126674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126675. }
  126676. /**
  126677. * Define a task used by AssetsManager to load text content
  126678. */
  126679. export class TextFileAssetTask extends AbstractAssetTask {
  126680. /**
  126681. * Defines the name of the task
  126682. */
  126683. name: string;
  126684. /**
  126685. * Defines the location of the file to load
  126686. */
  126687. url: string;
  126688. /**
  126689. * Gets the loaded text string
  126690. */
  126691. text: string;
  126692. /**
  126693. * Callback called when the task is successful
  126694. */
  126695. onSuccess: (task: TextFileAssetTask) => void;
  126696. /**
  126697. * Callback called when the task is successful
  126698. */
  126699. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126700. /**
  126701. * Creates a new TextFileAssetTask object
  126702. * @param name defines the name of the task
  126703. * @param url defines the location of the file to load
  126704. */
  126705. constructor(
  126706. /**
  126707. * Defines the name of the task
  126708. */
  126709. name: string,
  126710. /**
  126711. * Defines the location of the file to load
  126712. */
  126713. url: string);
  126714. /**
  126715. * Execute the current task
  126716. * @param scene defines the scene where you want your assets to be loaded
  126717. * @param onSuccess is a callback called when the task is successfully executed
  126718. * @param onError is a callback called if an error occurs
  126719. */
  126720. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126721. }
  126722. /**
  126723. * Define a task used by AssetsManager to load binary data
  126724. */
  126725. export class BinaryFileAssetTask extends AbstractAssetTask {
  126726. /**
  126727. * Defines the name of the task
  126728. */
  126729. name: string;
  126730. /**
  126731. * Defines the location of the file to load
  126732. */
  126733. url: string;
  126734. /**
  126735. * Gets the lodaded data (as an array buffer)
  126736. */
  126737. data: ArrayBuffer;
  126738. /**
  126739. * Callback called when the task is successful
  126740. */
  126741. onSuccess: (task: BinaryFileAssetTask) => void;
  126742. /**
  126743. * Callback called when the task is successful
  126744. */
  126745. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126746. /**
  126747. * Creates a new BinaryFileAssetTask object
  126748. * @param name defines the name of the new task
  126749. * @param url defines the location of the file to load
  126750. */
  126751. constructor(
  126752. /**
  126753. * Defines the name of the task
  126754. */
  126755. name: string,
  126756. /**
  126757. * Defines the location of the file to load
  126758. */
  126759. url: string);
  126760. /**
  126761. * Execute the current task
  126762. * @param scene defines the scene where you want your assets to be loaded
  126763. * @param onSuccess is a callback called when the task is successfully executed
  126764. * @param onError is a callback called if an error occurs
  126765. */
  126766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126767. }
  126768. /**
  126769. * Define a task used by AssetsManager to load images
  126770. */
  126771. export class ImageAssetTask extends AbstractAssetTask {
  126772. /**
  126773. * Defines the name of the task
  126774. */
  126775. name: string;
  126776. /**
  126777. * Defines the location of the image to load
  126778. */
  126779. url: string;
  126780. /**
  126781. * Gets the loaded images
  126782. */
  126783. image: HTMLImageElement;
  126784. /**
  126785. * Callback called when the task is successful
  126786. */
  126787. onSuccess: (task: ImageAssetTask) => void;
  126788. /**
  126789. * Callback called when the task is successful
  126790. */
  126791. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126792. /**
  126793. * Creates a new ImageAssetTask
  126794. * @param name defines the name of the task
  126795. * @param url defines the location of the image to load
  126796. */
  126797. constructor(
  126798. /**
  126799. * Defines the name of the task
  126800. */
  126801. name: string,
  126802. /**
  126803. * Defines the location of the image to load
  126804. */
  126805. url: string);
  126806. /**
  126807. * Execute the current task
  126808. * @param scene defines the scene where you want your assets to be loaded
  126809. * @param onSuccess is a callback called when the task is successfully executed
  126810. * @param onError is a callback called if an error occurs
  126811. */
  126812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126813. }
  126814. /**
  126815. * Defines the interface used by texture loading tasks
  126816. */
  126817. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126818. /**
  126819. * Gets the loaded texture
  126820. */
  126821. texture: TEX;
  126822. }
  126823. /**
  126824. * Define a task used by AssetsManager to load 2D textures
  126825. */
  126826. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126827. /**
  126828. * Defines the name of the task
  126829. */
  126830. name: string;
  126831. /**
  126832. * Defines the location of the file to load
  126833. */
  126834. url: string;
  126835. /**
  126836. * Defines if mipmap should not be generated (default is false)
  126837. */
  126838. noMipmap?: boolean | undefined;
  126839. /**
  126840. * Defines if texture must be inverted on Y axis (default is false)
  126841. */
  126842. invertY?: boolean | undefined;
  126843. /**
  126844. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126845. */
  126846. samplingMode: number;
  126847. /**
  126848. * Gets the loaded texture
  126849. */
  126850. texture: Texture;
  126851. /**
  126852. * Callback called when the task is successful
  126853. */
  126854. onSuccess: (task: TextureAssetTask) => void;
  126855. /**
  126856. * Callback called when the task is successful
  126857. */
  126858. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126859. /**
  126860. * Creates a new TextureAssetTask object
  126861. * @param name defines the name of the task
  126862. * @param url defines the location of the file to load
  126863. * @param noMipmap defines if mipmap should not be generated (default is false)
  126864. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126865. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126866. */
  126867. constructor(
  126868. /**
  126869. * Defines the name of the task
  126870. */
  126871. name: string,
  126872. /**
  126873. * Defines the location of the file to load
  126874. */
  126875. url: string,
  126876. /**
  126877. * Defines if mipmap should not be generated (default is false)
  126878. */
  126879. noMipmap?: boolean | undefined,
  126880. /**
  126881. * Defines if texture must be inverted on Y axis (default is false)
  126882. */
  126883. invertY?: boolean | undefined,
  126884. /**
  126885. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126886. */
  126887. samplingMode?: number);
  126888. /**
  126889. * Execute the current task
  126890. * @param scene defines the scene where you want your assets to be loaded
  126891. * @param onSuccess is a callback called when the task is successfully executed
  126892. * @param onError is a callback called if an error occurs
  126893. */
  126894. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126895. }
  126896. /**
  126897. * Define a task used by AssetsManager to load cube textures
  126898. */
  126899. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126900. /**
  126901. * Defines the name of the task
  126902. */
  126903. name: string;
  126904. /**
  126905. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126906. */
  126907. url: string;
  126908. /**
  126909. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126910. */
  126911. extensions?: string[] | undefined;
  126912. /**
  126913. * Defines if mipmaps should not be generated (default is false)
  126914. */
  126915. noMipmap?: boolean | undefined;
  126916. /**
  126917. * Defines the explicit list of files (undefined by default)
  126918. */
  126919. files?: string[] | undefined;
  126920. /**
  126921. * Gets the loaded texture
  126922. */
  126923. texture: CubeTexture;
  126924. /**
  126925. * Callback called when the task is successful
  126926. */
  126927. onSuccess: (task: CubeTextureAssetTask) => void;
  126928. /**
  126929. * Callback called when the task is successful
  126930. */
  126931. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126932. /**
  126933. * Creates a new CubeTextureAssetTask
  126934. * @param name defines the name of the task
  126935. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126936. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126937. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126938. * @param files defines the explicit list of files (undefined by default)
  126939. */
  126940. constructor(
  126941. /**
  126942. * Defines the name of the task
  126943. */
  126944. name: string,
  126945. /**
  126946. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126947. */
  126948. url: string,
  126949. /**
  126950. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126951. */
  126952. extensions?: string[] | undefined,
  126953. /**
  126954. * Defines if mipmaps should not be generated (default is false)
  126955. */
  126956. noMipmap?: boolean | undefined,
  126957. /**
  126958. * Defines the explicit list of files (undefined by default)
  126959. */
  126960. files?: string[] | undefined);
  126961. /**
  126962. * Execute the current task
  126963. * @param scene defines the scene where you want your assets to be loaded
  126964. * @param onSuccess is a callback called when the task is successfully executed
  126965. * @param onError is a callback called if an error occurs
  126966. */
  126967. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126968. }
  126969. /**
  126970. * Define a task used by AssetsManager to load HDR cube textures
  126971. */
  126972. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126973. /**
  126974. * Defines the name of the task
  126975. */
  126976. name: string;
  126977. /**
  126978. * Defines the location of the file to load
  126979. */
  126980. url: string;
  126981. /**
  126982. * Defines the desired size (the more it increases the longer the generation will be)
  126983. */
  126984. size: number;
  126985. /**
  126986. * Defines if mipmaps should not be generated (default is false)
  126987. */
  126988. noMipmap: boolean;
  126989. /**
  126990. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126991. */
  126992. generateHarmonics: boolean;
  126993. /**
  126994. * 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)
  126995. */
  126996. gammaSpace: boolean;
  126997. /**
  126998. * Internal Use Only
  126999. */
  127000. reserved: boolean;
  127001. /**
  127002. * Gets the loaded texture
  127003. */
  127004. texture: HDRCubeTexture;
  127005. /**
  127006. * Callback called when the task is successful
  127007. */
  127008. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  127009. /**
  127010. * Callback called when the task is successful
  127011. */
  127012. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127013. /**
  127014. * Creates a new HDRCubeTextureAssetTask object
  127015. * @param name defines the name of the task
  127016. * @param url defines the location of the file to load
  127017. * @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.
  127018. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127019. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127020. * @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)
  127021. * @param reserved Internal use only
  127022. */
  127023. constructor(
  127024. /**
  127025. * Defines the name of the task
  127026. */
  127027. name: string,
  127028. /**
  127029. * Defines the location of the file to load
  127030. */
  127031. url: string,
  127032. /**
  127033. * Defines the desired size (the more it increases the longer the generation will be)
  127034. */
  127035. size: number,
  127036. /**
  127037. * Defines if mipmaps should not be generated (default is false)
  127038. */
  127039. noMipmap?: boolean,
  127040. /**
  127041. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127042. */
  127043. generateHarmonics?: boolean,
  127044. /**
  127045. * 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)
  127046. */
  127047. gammaSpace?: boolean,
  127048. /**
  127049. * Internal Use Only
  127050. */
  127051. reserved?: boolean);
  127052. /**
  127053. * Execute the current task
  127054. * @param scene defines the scene where you want your assets to be loaded
  127055. * @param onSuccess is a callback called when the task is successfully executed
  127056. * @param onError is a callback called if an error occurs
  127057. */
  127058. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127059. }
  127060. /**
  127061. * Define a task used by AssetsManager to load Equirectangular cube textures
  127062. */
  127063. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127064. /**
  127065. * Defines the name of the task
  127066. */
  127067. name: string;
  127068. /**
  127069. * Defines the location of the file to load
  127070. */
  127071. url: string;
  127072. /**
  127073. * Defines the desired size (the more it increases the longer the generation will be)
  127074. */
  127075. size: number;
  127076. /**
  127077. * Defines if mipmaps should not be generated (default is false)
  127078. */
  127079. noMipmap: boolean;
  127080. /**
  127081. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127082. * but the standard material would require them in Gamma space) (default is true)
  127083. */
  127084. gammaSpace: boolean;
  127085. /**
  127086. * Gets the loaded texture
  127087. */
  127088. texture: EquiRectangularCubeTexture;
  127089. /**
  127090. * Callback called when the task is successful
  127091. */
  127092. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127093. /**
  127094. * Callback called when the task is successful
  127095. */
  127096. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127097. /**
  127098. * Creates a new EquiRectangularCubeTextureAssetTask object
  127099. * @param name defines the name of the task
  127100. * @param url defines the location of the file to load
  127101. * @param size defines the desired size (the more it increases the longer the generation will be)
  127102. * If the size is omitted this implies you are using a preprocessed cubemap.
  127103. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127104. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127105. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127106. * (default is true)
  127107. */
  127108. constructor(
  127109. /**
  127110. * Defines the name of the task
  127111. */
  127112. name: string,
  127113. /**
  127114. * Defines the location of the file to load
  127115. */
  127116. url: string,
  127117. /**
  127118. * Defines the desired size (the more it increases the longer the generation will be)
  127119. */
  127120. size: number,
  127121. /**
  127122. * Defines if mipmaps should not be generated (default is false)
  127123. */
  127124. noMipmap?: boolean,
  127125. /**
  127126. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127127. * but the standard material would require them in Gamma space) (default is true)
  127128. */
  127129. gammaSpace?: boolean);
  127130. /**
  127131. * Execute the current task
  127132. * @param scene defines the scene where you want your assets to be loaded
  127133. * @param onSuccess is a callback called when the task is successfully executed
  127134. * @param onError is a callback called if an error occurs
  127135. */
  127136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127137. }
  127138. /**
  127139. * This class can be used to easily import assets into a scene
  127140. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127141. */
  127142. export class AssetsManager {
  127143. private _scene;
  127144. private _isLoading;
  127145. protected _tasks: AbstractAssetTask[];
  127146. protected _waitingTasksCount: number;
  127147. protected _totalTasksCount: number;
  127148. /**
  127149. * Callback called when all tasks are processed
  127150. */
  127151. onFinish: (tasks: AbstractAssetTask[]) => void;
  127152. /**
  127153. * Callback called when a task is successful
  127154. */
  127155. onTaskSuccess: (task: AbstractAssetTask) => void;
  127156. /**
  127157. * Callback called when a task had an error
  127158. */
  127159. onTaskError: (task: AbstractAssetTask) => void;
  127160. /**
  127161. * Callback called when a task is done (whatever the result is)
  127162. */
  127163. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127164. /**
  127165. * Observable called when all tasks are processed
  127166. */
  127167. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127168. /**
  127169. * Observable called when a task had an error
  127170. */
  127171. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127172. /**
  127173. * Observable called when all tasks were executed
  127174. */
  127175. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127176. /**
  127177. * Observable called when a task is done (whatever the result is)
  127178. */
  127179. onProgressObservable: Observable<IAssetsProgressEvent>;
  127180. /**
  127181. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127183. */
  127184. useDefaultLoadingScreen: boolean;
  127185. /**
  127186. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127187. * when all assets have been downloaded.
  127188. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127189. */
  127190. autoHideLoadingUI: boolean;
  127191. /**
  127192. * Creates a new AssetsManager
  127193. * @param scene defines the scene to work on
  127194. */
  127195. constructor(scene: Scene);
  127196. /**
  127197. * Add a MeshAssetTask to the list of active tasks
  127198. * @param taskName defines the name of the new task
  127199. * @param meshesNames defines the name of meshes to load
  127200. * @param rootUrl defines the root url to use to locate files
  127201. * @param sceneFilename defines the filename of the scene file
  127202. * @returns a new MeshAssetTask object
  127203. */
  127204. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127205. /**
  127206. * Add a TextFileAssetTask 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. * @returns a new TextFileAssetTask object
  127210. */
  127211. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127212. /**
  127213. * Add a BinaryFileAssetTask to the list of active tasks
  127214. * @param taskName defines the name of the new task
  127215. * @param url defines the url of the file to load
  127216. * @returns a new BinaryFileAssetTask object
  127217. */
  127218. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127219. /**
  127220. * Add a ImageAssetTask to the list of active tasks
  127221. * @param taskName defines the name of the new task
  127222. * @param url defines the url of the file to load
  127223. * @returns a new ImageAssetTask object
  127224. */
  127225. addImageTask(taskName: string, url: string): ImageAssetTask;
  127226. /**
  127227. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  127231. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127232. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127233. * @returns a new TextureAssetTask object
  127234. */
  127235. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127236. /**
  127237. * Add a CubeTextureAssetTask to the list of active tasks
  127238. * @param taskName defines the name of the new task
  127239. * @param url defines the url of the file to load
  127240. * @param extensions defines the extension to use to load the cube map (can be null)
  127241. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127242. * @param files defines the list of files to load (can be null)
  127243. * @returns a new CubeTextureAssetTask object
  127244. */
  127245. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127246. /**
  127247. *
  127248. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127249. * @param taskName defines the name of the new task
  127250. * @param url defines the url of the file to load
  127251. * @param size defines the size you want for the cubemap (can be null)
  127252. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127253. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127254. * @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)
  127255. * @param reserved Internal use only
  127256. * @returns a new HDRCubeTextureAssetTask object
  127257. */
  127258. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127259. /**
  127260. *
  127261. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127262. * @param taskName defines the name of the new task
  127263. * @param url defines the url of the file to load
  127264. * @param size defines the size you want for the cubemap (can be null)
  127265. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127266. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127267. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127268. * @returns a new EquiRectangularCubeTextureAssetTask object
  127269. */
  127270. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127271. /**
  127272. * Remove a task from the assets manager.
  127273. * @param task the task to remove
  127274. */
  127275. removeTask(task: AbstractAssetTask): void;
  127276. private _decreaseWaitingTasksCount;
  127277. private _runTask;
  127278. /**
  127279. * Reset the AssetsManager and remove all tasks
  127280. * @return the current instance of the AssetsManager
  127281. */
  127282. reset(): AssetsManager;
  127283. /**
  127284. * Start the loading process
  127285. * @return the current instance of the AssetsManager
  127286. */
  127287. load(): AssetsManager;
  127288. /**
  127289. * Start the loading process as an async operation
  127290. * @return a promise returning the list of failed tasks
  127291. */
  127292. loadAsync(): Promise<void>;
  127293. }
  127294. }
  127295. declare module BABYLON {
  127296. /**
  127297. * Wrapper class for promise with external resolve and reject.
  127298. */
  127299. export class Deferred<T> {
  127300. /**
  127301. * The promise associated with this deferred object.
  127302. */
  127303. readonly promise: Promise<T>;
  127304. private _resolve;
  127305. private _reject;
  127306. /**
  127307. * The resolve method of the promise associated with this deferred object.
  127308. */
  127309. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127310. /**
  127311. * The reject method of the promise associated with this deferred object.
  127312. */
  127313. readonly reject: (reason?: any) => void;
  127314. /**
  127315. * Constructor for this deferred object.
  127316. */
  127317. constructor();
  127318. }
  127319. }
  127320. declare module BABYLON {
  127321. /**
  127322. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127323. */
  127324. export class MeshExploder {
  127325. private _centerMesh;
  127326. private _meshes;
  127327. private _meshesOrigins;
  127328. private _toCenterVectors;
  127329. private _scaledDirection;
  127330. private _newPosition;
  127331. private _centerPosition;
  127332. /**
  127333. * Explodes meshes from a center mesh.
  127334. * @param meshes The meshes to explode.
  127335. * @param centerMesh The mesh to be center of explosion.
  127336. */
  127337. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127338. private _setCenterMesh;
  127339. /**
  127340. * Get class name
  127341. * @returns "MeshExploder"
  127342. */
  127343. getClassName(): string;
  127344. /**
  127345. * "Exploded meshes"
  127346. * @returns Array of meshes with the centerMesh at index 0.
  127347. */
  127348. getMeshes(): Array<Mesh>;
  127349. /**
  127350. * Explodes meshes giving a specific direction
  127351. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127352. */
  127353. explode(direction?: number): void;
  127354. }
  127355. }
  127356. declare module BABYLON {
  127357. /**
  127358. * Class used to help managing file picking and drag'n'drop
  127359. */
  127360. export class FilesInput {
  127361. /**
  127362. * List of files ready to be loaded
  127363. */
  127364. static readonly FilesToLoad: {
  127365. [key: string]: File;
  127366. };
  127367. /**
  127368. * Callback called when a file is processed
  127369. */
  127370. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127371. private _engine;
  127372. private _currentScene;
  127373. private _sceneLoadedCallback;
  127374. private _progressCallback;
  127375. private _additionalRenderLoopLogicCallback;
  127376. private _textureLoadingCallback;
  127377. private _startingProcessingFilesCallback;
  127378. private _onReloadCallback;
  127379. private _errorCallback;
  127380. private _elementToMonitor;
  127381. private _sceneFileToLoad;
  127382. private _filesToLoad;
  127383. /**
  127384. * Creates a new FilesInput
  127385. * @param engine defines the rendering engine
  127386. * @param scene defines the hosting scene
  127387. * @param sceneLoadedCallback callback called when scene is loaded
  127388. * @param progressCallback callback called to track progress
  127389. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127390. * @param textureLoadingCallback callback called when a texture is loading
  127391. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127392. * @param onReloadCallback callback called when a reload is requested
  127393. * @param errorCallback callback call if an error occurs
  127394. */
  127395. 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);
  127396. private _dragEnterHandler;
  127397. private _dragOverHandler;
  127398. private _dropHandler;
  127399. /**
  127400. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127401. * @param elementToMonitor defines the DOM element to track
  127402. */
  127403. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127404. /**
  127405. * Release all associated resources
  127406. */
  127407. dispose(): void;
  127408. private renderFunction;
  127409. private drag;
  127410. private drop;
  127411. private _traverseFolder;
  127412. private _processFiles;
  127413. /**
  127414. * Load files from a drop event
  127415. * @param event defines the drop event to use as source
  127416. */
  127417. loadFiles(event: any): void;
  127418. private _processReload;
  127419. /**
  127420. * Reload the current scene from the loaded files
  127421. */
  127422. reload(): void;
  127423. }
  127424. }
  127425. declare module BABYLON {
  127426. /**
  127427. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127428. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127429. */
  127430. export class SceneOptimization {
  127431. /**
  127432. * Defines the priority of this optimization (0 by default which means first in the list)
  127433. */
  127434. priority: number;
  127435. /**
  127436. * Gets a string describing the action executed by the current optimization
  127437. * @returns description string
  127438. */
  127439. getDescription(): string;
  127440. /**
  127441. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127442. * @param scene defines the current scene where to apply this optimization
  127443. * @param optimizer defines the current optimizer
  127444. * @returns true if everything that can be done was applied
  127445. */
  127446. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127447. /**
  127448. * Creates the SceneOptimization object
  127449. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127450. * @param desc defines the description associated with the optimization
  127451. */
  127452. constructor(
  127453. /**
  127454. * Defines the priority of this optimization (0 by default which means first in the list)
  127455. */
  127456. priority?: number);
  127457. }
  127458. /**
  127459. * Defines an optimization used to reduce the size of render target textures
  127460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127461. */
  127462. export class TextureOptimization extends SceneOptimization {
  127463. /**
  127464. * Defines the priority of this optimization (0 by default which means first in the list)
  127465. */
  127466. priority: number;
  127467. /**
  127468. * 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
  127469. */
  127470. maximumSize: number;
  127471. /**
  127472. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127473. */
  127474. step: number;
  127475. /**
  127476. * Gets a string describing the action executed by the current optimization
  127477. * @returns description string
  127478. */
  127479. getDescription(): string;
  127480. /**
  127481. * Creates the TextureOptimization object
  127482. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127483. * @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
  127484. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127485. */
  127486. constructor(
  127487. /**
  127488. * Defines the priority of this optimization (0 by default which means first in the list)
  127489. */
  127490. priority?: number,
  127491. /**
  127492. * 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
  127493. */
  127494. maximumSize?: number,
  127495. /**
  127496. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127497. */
  127498. step?: number);
  127499. /**
  127500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127501. * @param scene defines the current scene where to apply this optimization
  127502. * @param optimizer defines the current optimizer
  127503. * @returns true if everything that can be done was applied
  127504. */
  127505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127506. }
  127507. /**
  127508. * Defines an optimization used to increase or decrease the rendering resolution
  127509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127510. */
  127511. export class HardwareScalingOptimization extends SceneOptimization {
  127512. /**
  127513. * Defines the priority of this optimization (0 by default which means first in the list)
  127514. */
  127515. priority: number;
  127516. /**
  127517. * Defines the maximum scale to use (2 by default)
  127518. */
  127519. maximumScale: number;
  127520. /**
  127521. * Defines the step to use between two passes (0.5 by default)
  127522. */
  127523. step: number;
  127524. private _currentScale;
  127525. private _directionOffset;
  127526. /**
  127527. * Gets a string describing the action executed by the current optimization
  127528. * @return description string
  127529. */
  127530. getDescription(): string;
  127531. /**
  127532. * Creates the HardwareScalingOptimization object
  127533. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127534. * @param maximumScale defines the maximum scale to use (2 by default)
  127535. * @param step defines the step to use between two passes (0.5 by default)
  127536. */
  127537. constructor(
  127538. /**
  127539. * Defines the priority of this optimization (0 by default which means first in the list)
  127540. */
  127541. priority?: number,
  127542. /**
  127543. * Defines the maximum scale to use (2 by default)
  127544. */
  127545. maximumScale?: number,
  127546. /**
  127547. * Defines the step to use between two passes (0.5 by default)
  127548. */
  127549. step?: number);
  127550. /**
  127551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127552. * @param scene defines the current scene where to apply this optimization
  127553. * @param optimizer defines the current optimizer
  127554. * @returns true if everything that can be done was applied
  127555. */
  127556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127557. }
  127558. /**
  127559. * Defines an optimization used to remove shadows
  127560. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127561. */
  127562. export class ShadowsOptimization extends SceneOptimization {
  127563. /**
  127564. * Gets a string describing the action executed by the current optimization
  127565. * @return description string
  127566. */
  127567. getDescription(): string;
  127568. /**
  127569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127570. * @param scene defines the current scene where to apply this optimization
  127571. * @param optimizer defines the current optimizer
  127572. * @returns true if everything that can be done was applied
  127573. */
  127574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127575. }
  127576. /**
  127577. * Defines an optimization used to turn post-processes off
  127578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127579. */
  127580. export class PostProcessesOptimization extends SceneOptimization {
  127581. /**
  127582. * Gets a string describing the action executed by the current optimization
  127583. * @return description string
  127584. */
  127585. getDescription(): string;
  127586. /**
  127587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127588. * @param scene defines the current scene where to apply this optimization
  127589. * @param optimizer defines the current optimizer
  127590. * @returns true if everything that can be done was applied
  127591. */
  127592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127593. }
  127594. /**
  127595. * Defines an optimization used to turn lens flares off
  127596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127597. */
  127598. export class LensFlaresOptimization extends SceneOptimization {
  127599. /**
  127600. * Gets a string describing the action executed by the current optimization
  127601. * @return description string
  127602. */
  127603. getDescription(): string;
  127604. /**
  127605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127606. * @param scene defines the current scene where to apply this optimization
  127607. * @param optimizer defines the current optimizer
  127608. * @returns true if everything that can be done was applied
  127609. */
  127610. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127611. }
  127612. /**
  127613. * Defines an optimization based on user defined callback.
  127614. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127615. */
  127616. export class CustomOptimization extends SceneOptimization {
  127617. /**
  127618. * Callback called to apply the custom optimization.
  127619. */
  127620. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127621. /**
  127622. * Callback called to get custom description
  127623. */
  127624. onGetDescription: () => string;
  127625. /**
  127626. * Gets a string describing the action executed by the current optimization
  127627. * @returns description string
  127628. */
  127629. getDescription(): string;
  127630. /**
  127631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127632. * @param scene defines the current scene where to apply this optimization
  127633. * @param optimizer defines the current optimizer
  127634. * @returns true if everything that can be done was applied
  127635. */
  127636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127637. }
  127638. /**
  127639. * Defines an optimization used to turn particles off
  127640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127641. */
  127642. export class ParticlesOptimization extends SceneOptimization {
  127643. /**
  127644. * Gets a string describing the action executed by the current optimization
  127645. * @return description string
  127646. */
  127647. getDescription(): string;
  127648. /**
  127649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127650. * @param scene defines the current scene where to apply this optimization
  127651. * @param optimizer defines the current optimizer
  127652. * @returns true if everything that can be done was applied
  127653. */
  127654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127655. }
  127656. /**
  127657. * Defines an optimization used to turn render targets off
  127658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127659. */
  127660. export class RenderTargetsOptimization extends SceneOptimization {
  127661. /**
  127662. * Gets a string describing the action executed by the current optimization
  127663. * @return description string
  127664. */
  127665. getDescription(): string;
  127666. /**
  127667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127668. * @param scene defines the current scene where to apply this optimization
  127669. * @param optimizer defines the current optimizer
  127670. * @returns true if everything that can be done was applied
  127671. */
  127672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127673. }
  127674. /**
  127675. * Defines an optimization used to merge meshes with compatible materials
  127676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127677. */
  127678. export class MergeMeshesOptimization extends SceneOptimization {
  127679. private static _UpdateSelectionTree;
  127680. /**
  127681. * Gets or sets a boolean which defines if optimization octree has to be updated
  127682. */
  127683. /**
  127684. * Gets or sets a boolean which defines if optimization octree has to be updated
  127685. */
  127686. static UpdateSelectionTree: boolean;
  127687. /**
  127688. * Gets a string describing the action executed by the current optimization
  127689. * @return description string
  127690. */
  127691. getDescription(): string;
  127692. private _canBeMerged;
  127693. /**
  127694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127695. * @param scene defines the current scene where to apply this optimization
  127696. * @param optimizer defines the current optimizer
  127697. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127698. * @returns true if everything that can be done was applied
  127699. */
  127700. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127701. }
  127702. /**
  127703. * Defines a list of options used by SceneOptimizer
  127704. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127705. */
  127706. export class SceneOptimizerOptions {
  127707. /**
  127708. * Defines the target frame rate to reach (60 by default)
  127709. */
  127710. targetFrameRate: number;
  127711. /**
  127712. * Defines the interval between two checkes (2000ms by default)
  127713. */
  127714. trackerDuration: number;
  127715. /**
  127716. * Gets the list of optimizations to apply
  127717. */
  127718. optimizations: SceneOptimization[];
  127719. /**
  127720. * Creates a new list of options used by SceneOptimizer
  127721. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127722. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127723. */
  127724. constructor(
  127725. /**
  127726. * Defines the target frame rate to reach (60 by default)
  127727. */
  127728. targetFrameRate?: number,
  127729. /**
  127730. * Defines the interval between two checkes (2000ms by default)
  127731. */
  127732. trackerDuration?: number);
  127733. /**
  127734. * Add a new optimization
  127735. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127736. * @returns the current SceneOptimizerOptions
  127737. */
  127738. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127739. /**
  127740. * Add a new custom optimization
  127741. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127742. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127743. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127744. * @returns the current SceneOptimizerOptions
  127745. */
  127746. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127747. /**
  127748. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127749. * @param targetFrameRate defines the target frame rate (60 by default)
  127750. * @returns a SceneOptimizerOptions object
  127751. */
  127752. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127753. /**
  127754. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127755. * @param targetFrameRate defines the target frame rate (60 by default)
  127756. * @returns a SceneOptimizerOptions object
  127757. */
  127758. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127759. /**
  127760. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127761. * @param targetFrameRate defines the target frame rate (60 by default)
  127762. * @returns a SceneOptimizerOptions object
  127763. */
  127764. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127765. }
  127766. /**
  127767. * Class used to run optimizations in order to reach a target frame rate
  127768. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127769. */
  127770. export class SceneOptimizer implements IDisposable {
  127771. private _isRunning;
  127772. private _options;
  127773. private _scene;
  127774. private _currentPriorityLevel;
  127775. private _targetFrameRate;
  127776. private _trackerDuration;
  127777. private _currentFrameRate;
  127778. private _sceneDisposeObserver;
  127779. private _improvementMode;
  127780. /**
  127781. * Defines an observable called when the optimizer reaches the target frame rate
  127782. */
  127783. onSuccessObservable: Observable<SceneOptimizer>;
  127784. /**
  127785. * Defines an observable called when the optimizer enables an optimization
  127786. */
  127787. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127788. /**
  127789. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127790. */
  127791. onFailureObservable: Observable<SceneOptimizer>;
  127792. /**
  127793. * Gets a boolean indicating if the optimizer is in improvement mode
  127794. */
  127795. readonly isInImprovementMode: boolean;
  127796. /**
  127797. * Gets the current priority level (0 at start)
  127798. */
  127799. readonly currentPriorityLevel: number;
  127800. /**
  127801. * Gets the current frame rate checked by the SceneOptimizer
  127802. */
  127803. readonly currentFrameRate: number;
  127804. /**
  127805. * Gets or sets the current target frame rate (60 by default)
  127806. */
  127807. /**
  127808. * Gets or sets the current target frame rate (60 by default)
  127809. */
  127810. targetFrameRate: number;
  127811. /**
  127812. * Gets or sets the current interval between two checks (every 2000ms by default)
  127813. */
  127814. /**
  127815. * Gets or sets the current interval between two checks (every 2000ms by default)
  127816. */
  127817. trackerDuration: number;
  127818. /**
  127819. * Gets the list of active optimizations
  127820. */
  127821. readonly optimizations: SceneOptimization[];
  127822. /**
  127823. * Creates a new SceneOptimizer
  127824. * @param scene defines the scene to work on
  127825. * @param options defines the options to use with the SceneOptimizer
  127826. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127827. * @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)
  127828. */
  127829. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127830. /**
  127831. * Stops the current optimizer
  127832. */
  127833. stop(): void;
  127834. /**
  127835. * Reset the optimizer to initial step (current priority level = 0)
  127836. */
  127837. reset(): void;
  127838. /**
  127839. * Start the optimizer. By default it will try to reach a specific framerate
  127840. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127841. */
  127842. start(): void;
  127843. private _checkCurrentState;
  127844. /**
  127845. * Release all resources
  127846. */
  127847. dispose(): void;
  127848. /**
  127849. * Helper function to create a SceneOptimizer with one single line of code
  127850. * @param scene defines the scene to work on
  127851. * @param options defines the options to use with the SceneOptimizer
  127852. * @param onSuccess defines a callback to call on success
  127853. * @param onFailure defines a callback to call on failure
  127854. * @returns the new SceneOptimizer object
  127855. */
  127856. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127857. }
  127858. }
  127859. declare module BABYLON {
  127860. /**
  127861. * Class used to serialize a scene into a string
  127862. */
  127863. export class SceneSerializer {
  127864. /**
  127865. * Clear cache used by a previous serialization
  127866. */
  127867. static ClearCache(): void;
  127868. /**
  127869. * Serialize a scene into a JSON compatible object
  127870. * @param scene defines the scene to serialize
  127871. * @returns a JSON compatible object
  127872. */
  127873. static Serialize(scene: Scene): any;
  127874. /**
  127875. * Serialize a mesh into a JSON compatible object
  127876. * @param toSerialize defines the mesh to serialize
  127877. * @param withParents defines if parents must be serialized as well
  127878. * @param withChildren defines if children must be serialized as well
  127879. * @returns a JSON compatible object
  127880. */
  127881. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127882. }
  127883. }
  127884. declare module BABYLON {
  127885. /**
  127886. * Class used to host texture specific utilities
  127887. */
  127888. export class TextureTools {
  127889. /**
  127890. * Uses the GPU to create a copy texture rescaled at a given size
  127891. * @param texture Texture to copy from
  127892. * @param width defines the desired width
  127893. * @param height defines the desired height
  127894. * @param useBilinearMode defines if bilinear mode has to be used
  127895. * @return the generated texture
  127896. */
  127897. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127898. }
  127899. }
  127900. declare module BABYLON {
  127901. /**
  127902. * This represents the different options available for the video capture.
  127903. */
  127904. export interface VideoRecorderOptions {
  127905. /** Defines the mime type of the video. */
  127906. mimeType: string;
  127907. /** Defines the FPS the video should be recorded at. */
  127908. fps: number;
  127909. /** Defines the chunk size for the recording data. */
  127910. recordChunckSize: number;
  127911. /** The audio tracks to attach to the recording. */
  127912. audioTracks?: MediaStreamTrack[];
  127913. }
  127914. /**
  127915. * This can help with recording videos from BabylonJS.
  127916. * This is based on the available WebRTC functionalities of the browser.
  127917. *
  127918. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127919. */
  127920. export class VideoRecorder {
  127921. private static readonly _defaultOptions;
  127922. /**
  127923. * Returns whether or not the VideoRecorder is available in your browser.
  127924. * @param engine Defines the Babylon Engine.
  127925. * @returns true if supported otherwise false.
  127926. */
  127927. static IsSupported(engine: Engine): boolean;
  127928. private readonly _options;
  127929. private _canvas;
  127930. private _mediaRecorder;
  127931. private _recordedChunks;
  127932. private _fileName;
  127933. private _resolve;
  127934. private _reject;
  127935. /**
  127936. * True when a recording is already in progress.
  127937. */
  127938. readonly isRecording: boolean;
  127939. /**
  127940. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127941. * @param engine Defines the BabylonJS Engine you wish to record.
  127942. * @param options Defines options that can be used to customize the capture.
  127943. */
  127944. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127945. /**
  127946. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127947. */
  127948. stopRecording(): void;
  127949. /**
  127950. * Starts recording the canvas for a max duration specified in parameters.
  127951. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127952. * If null no automatic download will start and you can rely on the promise to get the data back.
  127953. * @param maxDuration Defines the maximum recording time in seconds.
  127954. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127955. * @return A promise callback at the end of the recording with the video data in Blob.
  127956. */
  127957. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127958. /**
  127959. * Releases internal resources used during the recording.
  127960. */
  127961. dispose(): void;
  127962. private _handleDataAvailable;
  127963. private _handleError;
  127964. private _handleStop;
  127965. }
  127966. }
  127967. declare module BABYLON {
  127968. /**
  127969. * Class containing a set of static utilities functions for screenshots
  127970. */
  127971. export class ScreenshotTools {
  127972. /**
  127973. * Captures a screenshot of the current rendering
  127974. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127975. * @param engine defines the rendering engine
  127976. * @param camera defines the source camera
  127977. * @param size This parameter can be set to a single number or to an object with the
  127978. * following (optional) properties: precision, width, height. If a single number is passed,
  127979. * it will be used for both width and height. If an object is passed, the screenshot size
  127980. * will be derived from the parameters. The precision property is a multiplier allowing
  127981. * rendering at a higher or lower resolution
  127982. * @param successCallback defines the callback receives a single parameter which contains the
  127983. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127984. * src parameter of an <img> to display it
  127985. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127986. * Check your browser for supported MIME types
  127987. */
  127988. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127989. /**
  127990. * Captures a screenshot of the current rendering
  127991. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127992. * @param engine defines the rendering engine
  127993. * @param camera defines the source camera
  127994. * @param size This parameter can be set to a single number or to an object with the
  127995. * following (optional) properties: precision, width, height. If a single number is passed,
  127996. * it will be used for both width and height. If an object is passed, the screenshot size
  127997. * will be derived from the parameters. The precision property is a multiplier allowing
  127998. * rendering at a higher or lower resolution
  127999. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128000. * Check your browser for supported MIME types
  128001. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128002. * to the src parameter of an <img> to display it
  128003. */
  128004. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  128005. /**
  128006. * Generates an image screenshot from the specified camera.
  128007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128008. * @param engine The engine to use for rendering
  128009. * @param camera The camera to use for rendering
  128010. * @param size This parameter can be set to a single number or to an object with the
  128011. * following (optional) properties: precision, width, height. If a single number is passed,
  128012. * it will be used for both width and height. If an object is passed, the screenshot size
  128013. * will be derived from the parameters. The precision property is a multiplier allowing
  128014. * rendering at a higher or lower resolution
  128015. * @param successCallback The callback receives a single parameter which contains the
  128016. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128017. * src parameter of an <img> to display it
  128018. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128019. * Check your browser for supported MIME types
  128020. * @param samples Texture samples (default: 1)
  128021. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128022. * @param fileName A name for for the downloaded file.
  128023. */
  128024. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128025. /**
  128026. * Generates an image screenshot from the specified camera.
  128027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128028. * @param engine The engine to use for rendering
  128029. * @param camera The camera to use for rendering
  128030. * @param size This parameter can be set to a single number or to an object with the
  128031. * following (optional) properties: precision, width, height. If a single number is passed,
  128032. * it will be used for both width and height. If an object is passed, the screenshot size
  128033. * will be derived from the parameters. The precision property is a multiplier allowing
  128034. * rendering at a higher or lower resolution
  128035. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128036. * Check your browser for supported MIME types
  128037. * @param samples Texture samples (default: 1)
  128038. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128039. * @param fileName A name for for the downloaded file.
  128040. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128041. * to the src parameter of an <img> to display it
  128042. */
  128043. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128044. /**
  128045. * Gets height and width for screenshot size
  128046. * @private
  128047. */
  128048. private static _getScreenshotSize;
  128049. }
  128050. }
  128051. declare module BABYLON {
  128052. /**
  128053. * A cursor which tracks a point on a path
  128054. */
  128055. export class PathCursor {
  128056. private path;
  128057. /**
  128058. * Stores path cursor callbacks for when an onchange event is triggered
  128059. */
  128060. private _onchange;
  128061. /**
  128062. * The value of the path cursor
  128063. */
  128064. value: number;
  128065. /**
  128066. * The animation array of the path cursor
  128067. */
  128068. animations: Animation[];
  128069. /**
  128070. * Initializes the path cursor
  128071. * @param path The path to track
  128072. */
  128073. constructor(path: Path2);
  128074. /**
  128075. * Gets the cursor point on the path
  128076. * @returns A point on the path cursor at the cursor location
  128077. */
  128078. getPoint(): Vector3;
  128079. /**
  128080. * Moves the cursor ahead by the step amount
  128081. * @param step The amount to move the cursor forward
  128082. * @returns This path cursor
  128083. */
  128084. moveAhead(step?: number): PathCursor;
  128085. /**
  128086. * Moves the cursor behind by the step amount
  128087. * @param step The amount to move the cursor back
  128088. * @returns This path cursor
  128089. */
  128090. moveBack(step?: number): PathCursor;
  128091. /**
  128092. * Moves the cursor by the step amount
  128093. * If the step amount is greater than one, an exception is thrown
  128094. * @param step The amount to move the cursor
  128095. * @returns This path cursor
  128096. */
  128097. move(step: number): PathCursor;
  128098. /**
  128099. * Ensures that the value is limited between zero and one
  128100. * @returns This path cursor
  128101. */
  128102. private ensureLimits;
  128103. /**
  128104. * Runs onchange callbacks on change (used by the animation engine)
  128105. * @returns This path cursor
  128106. */
  128107. private raiseOnChange;
  128108. /**
  128109. * Executes a function on change
  128110. * @param f A path cursor onchange callback
  128111. * @returns This path cursor
  128112. */
  128113. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128114. }
  128115. }
  128116. declare module BABYLON {
  128117. /** @hidden */
  128118. export var blurPixelShader: {
  128119. name: string;
  128120. shader: string;
  128121. };
  128122. }
  128123. declare module BABYLON {
  128124. /** @hidden */
  128125. export var pointCloudVertexDeclaration: {
  128126. name: string;
  128127. shader: string;
  128128. };
  128129. }
  128130. // Mixins
  128131. interface Window {
  128132. mozIndexedDB: IDBFactory;
  128133. webkitIndexedDB: IDBFactory;
  128134. msIndexedDB: IDBFactory;
  128135. webkitURL: typeof URL;
  128136. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128137. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128138. WebGLRenderingContext: WebGLRenderingContext;
  128139. MSGesture: MSGesture;
  128140. CANNON: any;
  128141. AudioContext: AudioContext;
  128142. webkitAudioContext: AudioContext;
  128143. PointerEvent: any;
  128144. Math: Math;
  128145. Uint8Array: Uint8ArrayConstructor;
  128146. Float32Array: Float32ArrayConstructor;
  128147. mozURL: typeof URL;
  128148. msURL: typeof URL;
  128149. VRFrameData: any; // WebVR, from specs 1.1
  128150. DracoDecoderModule: any;
  128151. setImmediate(handler: (...args: any[]) => void): number;
  128152. }
  128153. interface HTMLCanvasElement {
  128154. requestPointerLock(): void;
  128155. msRequestPointerLock?(): void;
  128156. mozRequestPointerLock?(): void;
  128157. webkitRequestPointerLock?(): void;
  128158. /** Track wether a record is in progress */
  128159. isRecording: boolean;
  128160. /** Capture Stream method defined by some browsers */
  128161. captureStream(fps?: number): MediaStream;
  128162. }
  128163. interface CanvasRenderingContext2D {
  128164. msImageSmoothingEnabled: boolean;
  128165. }
  128166. interface MouseEvent {
  128167. mozMovementX: number;
  128168. mozMovementY: number;
  128169. webkitMovementX: number;
  128170. webkitMovementY: number;
  128171. msMovementX: number;
  128172. msMovementY: number;
  128173. }
  128174. interface Navigator {
  128175. mozGetVRDevices: (any: any) => any;
  128176. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128177. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128178. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128179. webkitGetGamepads(): Gamepad[];
  128180. msGetGamepads(): Gamepad[];
  128181. webkitGamepads(): Gamepad[];
  128182. }
  128183. interface HTMLVideoElement {
  128184. mozSrcObject: any;
  128185. }
  128186. interface Math {
  128187. fround(x: number): number;
  128188. imul(a: number, b: number): number;
  128189. }
  128190. interface WebGLRenderingContext {
  128191. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128192. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128193. vertexAttribDivisor(index: number, divisor: number): void;
  128194. createVertexArray(): any;
  128195. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128196. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128197. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128198. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128199. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128200. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128201. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128202. // Queries
  128203. createQuery(): WebGLQuery;
  128204. deleteQuery(query: WebGLQuery): void;
  128205. beginQuery(target: number, query: WebGLQuery): void;
  128206. endQuery(target: number): void;
  128207. getQueryParameter(query: WebGLQuery, pname: number): any;
  128208. getQuery(target: number, pname: number): any;
  128209. MAX_SAMPLES: number;
  128210. RGBA8: number;
  128211. READ_FRAMEBUFFER: number;
  128212. DRAW_FRAMEBUFFER: number;
  128213. UNIFORM_BUFFER: number;
  128214. HALF_FLOAT_OES: number;
  128215. RGBA16F: number;
  128216. RGBA32F: number;
  128217. R32F: number;
  128218. RG32F: number;
  128219. RGB32F: number;
  128220. R16F: number;
  128221. RG16F: number;
  128222. RGB16F: number;
  128223. RED: number;
  128224. RG: number;
  128225. R8: number;
  128226. RG8: number;
  128227. UNSIGNED_INT_24_8: number;
  128228. DEPTH24_STENCIL8: number;
  128229. /* Multiple Render Targets */
  128230. drawBuffers(buffers: number[]): void;
  128231. readBuffer(src: number): void;
  128232. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128233. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128234. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128235. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128236. // Occlusion Query
  128237. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128238. ANY_SAMPLES_PASSED: number;
  128239. QUERY_RESULT_AVAILABLE: number;
  128240. QUERY_RESULT: number;
  128241. }
  128242. interface WebGLProgram {
  128243. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128244. }
  128245. interface EXT_disjoint_timer_query {
  128246. QUERY_COUNTER_BITS_EXT: number;
  128247. TIME_ELAPSED_EXT: number;
  128248. TIMESTAMP_EXT: number;
  128249. GPU_DISJOINT_EXT: number;
  128250. QUERY_RESULT_EXT: number;
  128251. QUERY_RESULT_AVAILABLE_EXT: number;
  128252. queryCounterEXT(query: WebGLQuery, target: number): void;
  128253. createQueryEXT(): WebGLQuery;
  128254. beginQueryEXT(target: number, query: WebGLQuery): void;
  128255. endQueryEXT(target: number): void;
  128256. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128257. deleteQueryEXT(query: WebGLQuery): void;
  128258. }
  128259. interface WebGLUniformLocation {
  128260. _currentState: any;
  128261. }
  128262. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128263. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128264. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128265. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128266. interface WebGLRenderingContext {
  128267. readonly RASTERIZER_DISCARD: number;
  128268. readonly DEPTH_COMPONENT24: number;
  128269. readonly TEXTURE_3D: number;
  128270. readonly TEXTURE_2D_ARRAY: number;
  128271. readonly TEXTURE_COMPARE_FUNC: number;
  128272. readonly TEXTURE_COMPARE_MODE: number;
  128273. readonly COMPARE_REF_TO_TEXTURE: number;
  128274. readonly TEXTURE_WRAP_R: number;
  128275. readonly HALF_FLOAT: number;
  128276. readonly RGB8: number;
  128277. readonly RED_INTEGER: number;
  128278. readonly RG_INTEGER: number;
  128279. readonly RGB_INTEGER: number;
  128280. readonly RGBA_INTEGER: number;
  128281. readonly R8_SNORM: number;
  128282. readonly RG8_SNORM: number;
  128283. readonly RGB8_SNORM: number;
  128284. readonly RGBA8_SNORM: number;
  128285. readonly R8I: number;
  128286. readonly RG8I: number;
  128287. readonly RGB8I: number;
  128288. readonly RGBA8I: number;
  128289. readonly R8UI: number;
  128290. readonly RG8UI: number;
  128291. readonly RGB8UI: number;
  128292. readonly RGBA8UI: number;
  128293. readonly R16I: number;
  128294. readonly RG16I: number;
  128295. readonly RGB16I: number;
  128296. readonly RGBA16I: number;
  128297. readonly R16UI: number;
  128298. readonly RG16UI: number;
  128299. readonly RGB16UI: number;
  128300. readonly RGBA16UI: number;
  128301. readonly R32I: number;
  128302. readonly RG32I: number;
  128303. readonly RGB32I: number;
  128304. readonly RGBA32I: number;
  128305. readonly R32UI: number;
  128306. readonly RG32UI: number;
  128307. readonly RGB32UI: number;
  128308. readonly RGBA32UI: number;
  128309. readonly RGB10_A2UI: number;
  128310. readonly R11F_G11F_B10F: number;
  128311. readonly RGB9_E5: number;
  128312. readonly RGB10_A2: number;
  128313. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128314. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128315. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128316. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128317. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128318. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128319. 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;
  128320. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128321. readonly TRANSFORM_FEEDBACK: number;
  128322. readonly INTERLEAVED_ATTRIBS: number;
  128323. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128324. createTransformFeedback(): WebGLTransformFeedback;
  128325. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128326. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128327. beginTransformFeedback(primitiveMode: number): void;
  128328. endTransformFeedback(): void;
  128329. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128330. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128331. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128332. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128333. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128334. }
  128335. interface ImageBitmap {
  128336. readonly width: number;
  128337. readonly height: number;
  128338. close(): void;
  128339. }
  128340. interface WebGLQuery extends WebGLObject {
  128341. }
  128342. declare var WebGLQuery: {
  128343. prototype: WebGLQuery;
  128344. new(): WebGLQuery;
  128345. };
  128346. interface WebGLSampler extends WebGLObject {
  128347. }
  128348. declare var WebGLSampler: {
  128349. prototype: WebGLSampler;
  128350. new(): WebGLSampler;
  128351. };
  128352. interface WebGLSync extends WebGLObject {
  128353. }
  128354. declare var WebGLSync: {
  128355. prototype: WebGLSync;
  128356. new(): WebGLSync;
  128357. };
  128358. interface WebGLTransformFeedback extends WebGLObject {
  128359. }
  128360. declare var WebGLTransformFeedback: {
  128361. prototype: WebGLTransformFeedback;
  128362. new(): WebGLTransformFeedback;
  128363. };
  128364. interface WebGLVertexArrayObject extends WebGLObject {
  128365. }
  128366. declare var WebGLVertexArrayObject: {
  128367. prototype: WebGLVertexArrayObject;
  128368. new(): WebGLVertexArrayObject;
  128369. };
  128370. // Type definitions for WebVR API
  128371. // Project: https://w3c.github.io/webvr/
  128372. // Definitions by: six a <https://github.com/lostfictions>
  128373. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128374. interface VRDisplay extends EventTarget {
  128375. /**
  128376. * Dictionary of capabilities describing the VRDisplay.
  128377. */
  128378. readonly capabilities: VRDisplayCapabilities;
  128379. /**
  128380. * z-depth defining the far plane of the eye view frustum
  128381. * enables mapping of values in the render target depth
  128382. * attachment to scene coordinates. Initially set to 10000.0.
  128383. */
  128384. depthFar: number;
  128385. /**
  128386. * z-depth defining the near plane of the eye view frustum
  128387. * enables mapping of values in the render target depth
  128388. * attachment to scene coordinates. Initially set to 0.01.
  128389. */
  128390. depthNear: number;
  128391. /**
  128392. * An identifier for this distinct VRDisplay. Used as an
  128393. * association point in the Gamepad API.
  128394. */
  128395. readonly displayId: number;
  128396. /**
  128397. * A display name, a user-readable name identifying it.
  128398. */
  128399. readonly displayName: string;
  128400. readonly isConnected: boolean;
  128401. readonly isPresenting: boolean;
  128402. /**
  128403. * If this VRDisplay supports room-scale experiences, the optional
  128404. * stage attribute contains details on the room-scale parameters.
  128405. */
  128406. readonly stageParameters: VRStageParameters | null;
  128407. /**
  128408. * Passing the value returned by `requestAnimationFrame` to
  128409. * `cancelAnimationFrame` will unregister the callback.
  128410. * @param handle Define the hanle of the request to cancel
  128411. */
  128412. cancelAnimationFrame(handle: number): void;
  128413. /**
  128414. * Stops presenting to the VRDisplay.
  128415. * @returns a promise to know when it stopped
  128416. */
  128417. exitPresent(): Promise<void>;
  128418. /**
  128419. * Return the current VREyeParameters for the given eye.
  128420. * @param whichEye Define the eye we want the parameter for
  128421. * @returns the eye parameters
  128422. */
  128423. getEyeParameters(whichEye: string): VREyeParameters;
  128424. /**
  128425. * Populates the passed VRFrameData with the information required to render
  128426. * the current frame.
  128427. * @param frameData Define the data structure to populate
  128428. * @returns true if ok otherwise false
  128429. */
  128430. getFrameData(frameData: VRFrameData): boolean;
  128431. /**
  128432. * Get the layers currently being presented.
  128433. * @returns the list of VR layers
  128434. */
  128435. getLayers(): VRLayer[];
  128436. /**
  128437. * Return a VRPose containing the future predicted pose of the VRDisplay
  128438. * when the current frame will be presented. The value returned will not
  128439. * change until JavaScript has returned control to the browser.
  128440. *
  128441. * The VRPose will contain the position, orientation, velocity,
  128442. * and acceleration of each of these properties.
  128443. * @returns the pose object
  128444. */
  128445. getPose(): VRPose;
  128446. /**
  128447. * Return the current instantaneous pose of the VRDisplay, with no
  128448. * prediction applied.
  128449. * @returns the current instantaneous pose
  128450. */
  128451. getImmediatePose(): VRPose;
  128452. /**
  128453. * The callback passed to `requestAnimationFrame` will be called
  128454. * any time a new frame should be rendered. When the VRDisplay is
  128455. * presenting the callback will be called at the native refresh
  128456. * rate of the HMD. When not presenting this function acts
  128457. * identically to how window.requestAnimationFrame acts. Content should
  128458. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128459. * asynchronously from other displays and at differing refresh rates.
  128460. * @param callback Define the eaction to run next frame
  128461. * @returns the request handle it
  128462. */
  128463. requestAnimationFrame(callback: FrameRequestCallback): number;
  128464. /**
  128465. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128466. * Repeat calls while already presenting will update the VRLayers being displayed.
  128467. * @param layers Define the list of layer to present
  128468. * @returns a promise to know when the request has been fulfilled
  128469. */
  128470. requestPresent(layers: VRLayer[]): Promise<void>;
  128471. /**
  128472. * Reset the pose for this display, treating its current position and
  128473. * orientation as the "origin/zero" values. VRPose.position,
  128474. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128475. * updated when calling resetPose(). This should be called in only
  128476. * sitting-space experiences.
  128477. */
  128478. resetPose(): void;
  128479. /**
  128480. * The VRLayer provided to the VRDisplay will be captured and presented
  128481. * in the HMD. Calling this function has the same effect on the source
  128482. * canvas as any other operation that uses its source image, and canvases
  128483. * created without preserveDrawingBuffer set to true will be cleared.
  128484. * @param pose Define the pose to submit
  128485. */
  128486. submitFrame(pose?: VRPose): void;
  128487. }
  128488. declare var VRDisplay: {
  128489. prototype: VRDisplay;
  128490. new(): VRDisplay;
  128491. };
  128492. interface VRLayer {
  128493. leftBounds?: number[] | Float32Array | null;
  128494. rightBounds?: number[] | Float32Array | null;
  128495. source?: HTMLCanvasElement | null;
  128496. }
  128497. interface VRDisplayCapabilities {
  128498. readonly canPresent: boolean;
  128499. readonly hasExternalDisplay: boolean;
  128500. readonly hasOrientation: boolean;
  128501. readonly hasPosition: boolean;
  128502. readonly maxLayers: number;
  128503. }
  128504. interface VREyeParameters {
  128505. /** @deprecated */
  128506. readonly fieldOfView: VRFieldOfView;
  128507. readonly offset: Float32Array;
  128508. readonly renderHeight: number;
  128509. readonly renderWidth: number;
  128510. }
  128511. interface VRFieldOfView {
  128512. readonly downDegrees: number;
  128513. readonly leftDegrees: number;
  128514. readonly rightDegrees: number;
  128515. readonly upDegrees: number;
  128516. }
  128517. interface VRFrameData {
  128518. readonly leftProjectionMatrix: Float32Array;
  128519. readonly leftViewMatrix: Float32Array;
  128520. readonly pose: VRPose;
  128521. readonly rightProjectionMatrix: Float32Array;
  128522. readonly rightViewMatrix: Float32Array;
  128523. readonly timestamp: number;
  128524. }
  128525. interface VRPose {
  128526. readonly angularAcceleration: Float32Array | null;
  128527. readonly angularVelocity: Float32Array | null;
  128528. readonly linearAcceleration: Float32Array | null;
  128529. readonly linearVelocity: Float32Array | null;
  128530. readonly orientation: Float32Array | null;
  128531. readonly position: Float32Array | null;
  128532. readonly timestamp: number;
  128533. }
  128534. interface VRStageParameters {
  128535. sittingToStandingTransform?: Float32Array;
  128536. sizeX?: number;
  128537. sizeY?: number;
  128538. }
  128539. interface Navigator {
  128540. getVRDisplays(): Promise<VRDisplay[]>;
  128541. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128542. }
  128543. interface Window {
  128544. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128545. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128546. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128547. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128548. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128549. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128550. }
  128551. interface Gamepad {
  128552. readonly displayId: number;
  128553. }
  128554. type XRSessionMode =
  128555. | "inline"
  128556. | "immersive-vr"
  128557. | "immersive-ar";
  128558. type XRReferenceSpaceType =
  128559. | "viewer"
  128560. | "local"
  128561. | "local-floor"
  128562. | "bounded-floor"
  128563. | "unbounded";
  128564. type XREnvironmentBlendMode =
  128565. | "opaque"
  128566. | "additive"
  128567. | "alpha-blend";
  128568. type XRVisibilityState =
  128569. | "visible"
  128570. | "visible-blurred"
  128571. | "hidden";
  128572. type XRHandedness =
  128573. | "none"
  128574. | "left"
  128575. | "right";
  128576. type XRTargetRayMode =
  128577. | "gaze"
  128578. | "tracked-pointer"
  128579. | "screen";
  128580. type XREye =
  128581. | "none"
  128582. | "left"
  128583. | "right";
  128584. interface XRSpace extends EventTarget {
  128585. }
  128586. interface XRRenderState {
  128587. depthNear?: number;
  128588. depthFar?: number;
  128589. inlineVerticalFieldOfView?: number;
  128590. baseLayer?: XRWebGLLayer;
  128591. }
  128592. interface XRInputSource {
  128593. handedness: XRHandedness;
  128594. targetRayMode: XRTargetRayMode;
  128595. targetRaySpace: XRSpace;
  128596. gripSpace: XRSpace | undefined;
  128597. gamepad: Gamepad | undefined;
  128598. profiles: Array<string>;
  128599. }
  128600. interface XRSession {
  128601. addEventListener: Function;
  128602. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128603. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128604. requestAnimationFrame: Function;
  128605. end(): Promise<void>;
  128606. renderState: XRRenderState;
  128607. inputSources: Array<XRInputSource>;
  128608. }
  128609. interface XRReferenceSpace extends XRSpace {
  128610. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128611. onreset: any;
  128612. }
  128613. interface XRFrame {
  128614. session: XRSession;
  128615. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128616. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128617. }
  128618. interface XRViewerPose extends XRPose {
  128619. views: Array<XRView>;
  128620. }
  128621. interface XRPose {
  128622. transform: XRRigidTransform;
  128623. emulatedPosition: boolean;
  128624. }
  128625. declare var XRWebGLLayer: {
  128626. prototype: XRWebGLLayer;
  128627. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128628. };
  128629. interface XRWebGLLayer {
  128630. framebuffer: WebGLFramebuffer;
  128631. framebufferWidth: number;
  128632. framebufferHeight: number;
  128633. getViewport: Function;
  128634. }
  128635. interface XRRigidTransform {
  128636. position: DOMPointReadOnly;
  128637. orientation: DOMPointReadOnly;
  128638. matrix: Float32Array;
  128639. inverse: XRRigidTransform;
  128640. }
  128641. interface XRView {
  128642. eye: XREye;
  128643. projectionMatrix: Float32Array;
  128644. transform: XRRigidTransform;
  128645. }
  128646. interface XRInputSourceChangeEvent {
  128647. session: XRSession;
  128648. removed: Array<XRInputSource>;
  128649. added: Array<XRInputSource>;
  128650. }